Commit cbdbed1d by Venkatesh Seetharam

Add Quick Start Example and minor cleanup

parent 73748b46
var DgcApp = angular.module('DgcApp', [
'ngRoute',
'DgcControllers',
'ui.bootstrap'
]);
DgcApp.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/Search', {
templateUrl: 'partials/search.html',
controller: 'ListController'
}).
when('/Search/:Id', {
templateUrl: 'partials/wiki.html',
controller: 'DefinitionController'
}).
otherwise({
redirectTo: '/Search'
});
}]);
<h4>{{key}}:</h4>
<p>{{val}}</p>
var DgcControllers = angular.module("DgcControllers", []);
DgcControllers.controller("ListController", ['$scope','$http', function($scope, $http)
{
$scope.executeSearch = function executeSearch() {
$scope.SearchQuery=$scope.query;
$scope.iswiki=false;
//$http.get('http://162.249.6.76:21000/api/metadata/entities/list/'+$scope.query)
var searchQry=$scope.query.split(",");
$http.get('http://162.249.6.76:21000/api/metadata/discovery/search/fulltext?depth=1&'+searchQry[0]+'&'+searchQry[1])
.success(function (data) {
$scope.iserror=false;
$scope.entities=angular.fromJson(data.vertices);
var count=0;
angular.forEach(data.vertices, function(v, index) {
count++;
});
$scope.matchingResults=count;
})
.error(function (e) {
$scope.iserror=true;
$scope.error=e;
$scope.matchingResults=0;
});
}
}]
);
DgcControllers.controller("DefinitionController", ['$scope','$http','$routeParams', function($scope, $http, $routeParams)
{
$scope.isString=function isString(value){
return typeof value === 'string';
}
$scope.Guid=$routeParams.Id;
$scope.iswiki=true;
$scope.selectedDefination={
"path":"wiki.html"
};
$http.get('http://162.249.6.76:21000/api/metadata/entities/definition/'+$routeParams.Id)
.success(function (data) {
$scope.iserror1=false;
$scope.details=angular.fromJson(data.definition);
})
.error(function (e) {
$scope.iserror1=true;
$scope.error1=e;
});
}]
);
DgcControllers.controller("LineageController", ['$scope','$http','$routeParams', function($scope, $http, $routeParams)
{
$scope.width = 1110;
$scope.height = 400;
//Initialize a default force layout, using the nodes and edges in dataset
$http.get('http://162.249.6.76:21000/api/metadata/discovery/search/relationships/'+$routeParams.Id+'?depth=3&&edgesToFollow=HiveLineage.sourceTables.0,HiveLineage.sourceTables.1,HiveLineage.tableName')
.success(function (data) {
$scope.iserror1=false;
$scope.lineage=angular.fromJson(data);
$scope.vertices = data.vertices; // response data
$scope.vts = [];
$scope.egs = [];
$scope.ids = [];
angular.forEach(data.vertices, function(v, index) {
if(v["hive_table.name"]==undefined){
$scope.vts.push({"name" :index,"values":v["HiveLineage.query"],"guid":v["guid"],"hasChild":"True"});
$scope.ids.push({"Id" :index,"Name":index,"values":v["HiveLineage.query"],"guid":v["guid"],"hasChild":"True"});
}else{
$scope.vts.push({"name" :v["hive_table.name"],"values":v["hive_table.description"],"guid":v["guid"],"hasChild":"False"});
$scope.ids.push({"Id" :index,"Name":v["hive_table.name"],"values":v["hive_table.description"],"guid":v["guid"],"hasChild":"False"});
}
});
angular.forEach(data.edges, function(e, index) {
$scope.egs.push({"source" :e["head"],"target":e["tail"]});
});
var edges2 = [];
$scope.egs.forEach(function(e) {
var sourceNode = $scope.ids.filter(function(n) { return n.Id === e.source; })[0],
targetNode = $scope.ids.filter(function(n) { return n.Id === e.target; })[0];
if(sourceNode==undefined){
sourceNode=e.source;
$scope.vts.push({"name" :e.source+", Missing Node","values":e.source+", Missing Node","guid":$scope.ids["guid"],"hasChild":"False"});
$scope.ids.push({"Id" :e.source,"Name":e.source+", Missing Node","values":e.source+", Missing Node","guid":$scope.ids["guid"],"hasChild":"False"});
}
if(targetNode==undefined){
targetNode=e.target;
$scope.vts.push({"name" :e.target+", Missing Node","values":e.target+", Missing Node","guid":$scope.ids["guid"],"hasChild":"False"});
$scope.ids.push({"Id" :e.target,"Name":e.target+", Missing Node","values":e.target+", Missing Node","guid":$scope.ids["guid"],"hasChild":"False"});
}
edges2.push({source: sourceNode, target: targetNode});
});
var edges1 = [];
$scope.egs.forEach(function(e) {
var sourceNode = $scope.ids.filter(function(n) { return n.Id === e.source; })[0],
targetNode = $scope.ids.filter(function(n) { return n.Id === e.target; })[0];
edges1.push({source: sourceNode, target: targetNode});
});
//Width and height
var w = 1110;
var h = 400;
var force = d3.layout.force()
.nodes($scope.ids)
.links(edges1)
.size([w, h])
.linkDistance([180])
.charge([-250])
.start();
var colors = d3.scale.category10();
//Create SVG element
var svg = d3.select("svg")
.attr("width", w)
.attr("height", h);
var tip = d3.tip()
.attr('class', 'd3-tip')
.offset([-10, 0])
.html(function(d) {
return "<pre class='alert alert-success' style='max-width:400px;'>" + d.values + "</pre>";
});
svg.call(tip);
//Create edges as lines
var edges = svg.selectAll("line")
.data(edges1)
.enter()
.append("line")
.style("stroke", "#23A410")
.style("stroke-width", 3);
var node = svg.selectAll(".node")
.data($scope.ids)
.enter().append("g")
.attr("class", "node")
.on("mouseover", tip.show)
.on("mouseout", tip.hide)
.on("click", function(d){
tip.hide();
if(d.guid==undefined){
}
else
{
location.href="#/Search/"+d.guid;
}
})
.call(force.drag);
svg.append("svg:pattern").attr("id","processICO").attr("width",1).attr("height",1)
.append("svg:image").attr("xlink:href","img/process.png").attr("x",-5.5).attr("y",-4).attr("width",41).attr("height",42);
svg.append("svg:pattern").attr("id","textICO").attr("width",1).attr("height",1)
.append("svg:image").attr("xlink:href","img/text.ico").attr("x",2).attr("y",2).attr("width",25).attr("height",25);
// define arrow markers for graph links
svg.append('svg:defs').append('svg:marker')
.attr('id', 'end-arrow')
.attr('viewBox', '0 -5 10 10')
.attr('refX', 10)
.attr('markerWidth', 5)
.attr('markerHeight', 5)
.attr('orient', 'auto')
.append('svg:path')
.attr('d', 'M0,-5L10,0L0,5')
.attr('fill', '#7B7A7A');
svg.append('svg:defs').append('svg:marker')
.attr('id', 'start-arrow')
.attr('viewBox', '0 -5 10 10')
.attr('refX', 4)
.attr('markerWidth', 3)
.attr('markerHeight', 3)
.attr('orient', 'auto')
.append('svg:path')
.attr('d', 'M10,-5L0,0L10,5')
.attr('fill', '#000');
// handles to link and node element groups
var path = svg.append('svg:g').selectAll('path')
.data(force.links())
.enter().append("svg:path")
.attr("class", "link")
.attr('marker-end','url(#end-arrow)');
//Create nodes as circles
//var nodes = svg.selectAll("circle")
//.data(dataset.nodes)
// .enter()
node.append("circle")
.attr("r", function(d, i) {
if(d.hasChild=="True"){
return 15;
}else{
return 15;
}
return 10;
})
.attr("cursor","pointer")
.style("fill", function(d, i) {
if(d.hasChild=="True"){
return "url('#processICO')";
}else{
return "url('#textICO')";
}
return colors(i);
})
.attr("class","circle");
//.call(force.drag);
//Add text
node.append("text")
.attr("x", 12)
.attr("dy", ".35em")
.text(function(d) { return d.Name; });
//Every time the simulation "ticks", this will be called
force.on("tick", function() {
edges.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
path.attr('d', function(d) {
var deltaX = d.target.x - d.source.x,
deltaY = d.target.y - d.source.y,
dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
normX = deltaX / dist,
normY = deltaY / dist,
sourcePadding = d.left ? 17 : 12,
targetPadding = d.right ? 17 : 12,
sourceX = d.source.x + (sourcePadding * normX),
sourceY = d.source.y + (sourcePadding * normY),
targetX = d.target.x - (targetPadding * normX),
targetY = d.target.y - (targetPadding * normY);
return 'M' + sourceX + ',' + sourceY + 'L' + targetX + ',' + targetY;
});
//node.attr("cx", function(d) { return d.x; })
//.attr("cy", function(d) { return d.y; });
node
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
})
function mouseover(d) {
d3.select(this).select("circle").transition()
.duration(750)
.attr("r", 16);
}
function mouseout() {
d3.select(this).select("circle").transition()
.duration(750)
.attr("r", 10);
}
});
}]
);
<h4 class="titletxt2">{{key}}:</h4>
<p class="sm-txt2">{{value | date:'medium'}}</p>
<div class="container" ng-controller="LineageController">
<div class="lineage"></div>
<svg ng-attr-width="{{width}}"
ng-attr-height="{{height}}">
</svg>
</div>
<!-- Page Content -->
<div style="margin-top:-20px;padding-top:20px; background-color:#eeeded;padding-bottom:10px;border-bottom:solid 1px #d9d9d8;">
<form name=form" class="container">
<div class="col-lg-7">
<div class="row input-group">
<input type="text" ng-model="query" ng-keyup="$event.keyCode == 13 && executeSearch()" class="form-control search_table" placeholder="Search">
<span class="input-group-btn">
<button class="btn btn-success" ng-click="executeSearch()" type="submit"><i class="glyphicon glyphicon-search white "></i></button>
</span>
</div>
<div class="row">
<small style="color:#999999; margin-top:2px;">property=HiveLineage.executionEngine&text=tez</small><br/>
<small style="color:#999999; margin-top:2px;">property=type&text=HiveLineage</small><br/>
<small style="color:#999999; margin-top:2px;">property=type&text=hive_table</small>
</div>
</div>
</form>
</div>
<div class="container" style="min-height:330px;">
<div class="row">
<div class="col-lg-11">
<div ng-hide="iswiki">
<input type="hidden" ng-model="iserror">
<h4 class="txt1" ng-hide="!matchingResults">{{matchingResults}} results matching your query "{{SearchQuery}}" were found"</h4>
<ul class="list-unstyled">
<li ng-hide="iserror" class="sm-txt1" ng-repeat="entity in entities"><u><a href="#Search/{{entity.guid}}" ng-click="StoreJson(entity)" style="line-height: 2.5;">{{ entity.guid}}</a></u>
</li>
<li ng-show="iserror" class="sm-txt1"></li>
</ul>
</ul>
</div>
<div ng-show="iswiki" data-ng-include="selectedDefination.path"></div>
</div>
</div>
</div>
<div class="content">
<div class="container">
<div class="col-lg-12">
<h4 class="txt1">{{Guid}}</h4>
<br/>
<div ng-controller="LineageController" style="border-bottom: 2px solid #060;margin-bottom: 30px;">
<div class="lineage"></div>
<svg ng-attr-width="{{width}}"
ng-attr-height="{{height}}">
</svg>
</div>
<div ng-repeat="(key,value) in details" ng-if="isString(value)" ng-include="'partials/attribute.html'"></div>
<!--<tab heading="Raw"><pre>{{details}}</pre></tab>-->
</div>
</div>
</div>
#!/bin/bash
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License. See accompanying LICENSE file.
#
# resolve links - $0 may be a softlink
PRG="${0}"
while [ -h "${PRG}" ]; do
ls=`ls -ld "${PRG}"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "${PRG}"`/"$link"
fi
done
BASEDIR=`dirname ${PRG}`
BASEDIR=`cd ${BASEDIR}/..;pwd`
if [ -z "$METADATA_CONF" ]; then
METADATA_CONF=${BASEDIR}/conf
fi
export METADATA_CONF
if [ -f "${METADATA_CONF}/metadata-env.sh" ]; then
. "${METADATA_CONF}/metadata-env.sh"
fi
if test -z ${JAVA_HOME}
then
JAVA_BIN=`which java`
JAR_BIN=`which jar`
else
JAVA_BIN=${JAVA_HOME}/bin/java
JAR_BIN=${JAVA_HOME}/bin/jar
fi
export JAVA_BIN
if [ ! -e $JAVA_BIN ] || [ ! -e $JAR_BIN ]; then
echo "$JAVA_BIN and/or $JAR_BIN not found on the system. Please make sure java and jar commands are available."
exit 1
fi
# default the heap size to 1GB
DEFAULT_JAVA_HEAP_MAX=-Xmx1024m
METADATA_OPTS="$DEFAULT_JAVA_HEAP_MAX $METADATA_OPTS"
METADATACPPATH="$METADATA_CONF"
METADATA_EXPANDED_WEBAPP_DIR=${METADATA_EXPANDED_WEBAPP_DIR:-${BASEDIR}/server/webapp}
export METADATA_EXPANDED_WEBAPP_DIR
METADATACPPATH="${METADATACPPATH}:${METADATA_EXPANDED_WEBAPP_DIR}/metadata/WEB-INF/classes"
METADATACPPATH="${METADATACPPATH}:${METADATA_EXPANDED_WEBAPP_DIR}/metadata/WEB-INF/lib/*:${BASEDIR}/libext/*"
# log and pid dirs for applications
METADATA_LOG_DIR="${METADATA_LOG_DIR:-$BASEDIR/logs}"
export METADATA_LOG_DIR
METADATA_HOME_DIR="${METADATA_HOME_DIR:-$BASEDIR}"
export METADATA_HOME_DIR
JAVA_PROPERTIES="$METADATA_OPTS $METADATA_PROPERTIES -Dmetadata.log.dir=$METADATA_LOG_DIR -Dmetadata.home=${METADATA_HOME_DIR}"
${JAVA_BIN} ${JAVA_PROPERTIES} -cp ${METADATACPPATH} org.apache.hadoop.metadata.DemoDataDriver
echo Test data added to Metadata Server!!!
...@@ -74,6 +74,6 @@ export METADATA_HOME_DIR ...@@ -74,6 +74,6 @@ export METADATA_HOME_DIR
JAVA_PROPERTIES="$METADATA_OPTS $METADATA_PROPERTIES -Dmetadata.log.dir=$METADATA_LOG_DIR -Dmetadata.home=${METADATA_HOME_DIR}" JAVA_PROPERTIES="$METADATA_OPTS $METADATA_PROPERTIES -Dmetadata.log.dir=$METADATA_LOG_DIR -Dmetadata.home=${METADATA_HOME_DIR}"
${JAVA_BIN} ${JAVA_PROPERTIES} -cp ${METADATACPPATH} org.apache.hadoop.metadata.TestDataDriver ${JAVA_BIN} ${JAVA_PROPERTIES} -cp ${METADATACPPATH} org.apache.hadoop.metadata.examples.QuickStart
echo Test data added to Metadata Server!!! echo Example data added to Metadata Server!!!
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment