SOLR-7638: Fix new (Angular-based) admin UI Cloud pane

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1684553 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2015-06-10 02:33:36 +00:00
parent e07ca21126
commit 12369fa890
5 changed files with 186 additions and 88 deletions

View File

@ -178,6 +178,8 @@ Bug Fixes
* SOLR-7512: SolrOutputFormat creates an invalid solr.xml in the solr home zip for MapReduceIndexerTool.
(Mark Miller, Adam McElwee)
* SOLR-7638: Fix new (Angular-based) admin UI Cloud pane (Upayavira via ehatcher)
Other Changes
----------------------

View File

@ -389,3 +389,10 @@ limitations under the License.
{
stroke: #fff;
}
#cloudGraphPaging
{
display: inline-block;
padding-top: 15px;
padding-bottom: 15px;
}

View File

@ -337,7 +337,7 @@ solrAdminApp.controller('MainController', function($scope, $route, $rootScope, $
}
});
System.get(function(data) {
$scope.isCloudEnabledCloud = data.mode.match( /solrcloud/i )
$scope.isCloudEnabled = data.mode.match( /solrcloud/i )
});
};
$scope.refresh();

View File

@ -67,7 +67,6 @@ var treeSubController = function($scope, Zookeeper) {
$scope.initTree = function() {
Zookeeper.simple(function(data) {
$scope.tree = data.tree;
//$scope.jstree.json_data.data = data.tree;
});
};
@ -78,6 +77,8 @@ var graphSubController = function ($scope, Zookeeper, isRadial) {
$scope.showTree = false;
$scope.showGraph = true;
$scope.filterType = "status";
$scope.helperData = {
protocol: [],
host: [],
@ -86,98 +87,158 @@ var graphSubController = function ($scope, Zookeeper, isRadial) {
pathname: []
};
$scope.next = function() {
$scope.pos += $scope.rows;
$scope.initGraph();
}
Zookeeper.liveNodes(function (data) {
var live_nodes = {};
for (var c in data.tree[0].children) {
live_nodes[data.tree[0].children[c].data.title] = true;
}
Zookeeper.clusterState(function (data) {
eval("var state=" + data.znode.data); // @todo fix horrid means to parse JSON
$scope.previous = function() {
$scope.pos = Math.max(0, $scope.pos - $scope.rows);
$scope.initGraph();
}
var leaf_count = 0;
var graph_data = {
name: null,
children: []
};
$scope.resetGraph = function() {
$scope.pos = 0;
$scope.initGraph();
}
for (var c in state) {
var shards = [];
for (var s in state[c].shards) {
var nodes = [];
for (var n in state[c].shards[s].replicas) {
leaf_count++;
var replica = state[c].shards[s].replicas[n]
var uri = replica.base_url;
var parts = uri.match(/^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/);
var uri_parts = {
protocol: parts[1],
host: parts[2],
hostname: parts[3],
port: parseInt(parts[5] || 80, 10),
pathname: parts[6]
};
$scope.helperData.protocol.push(uri_parts.protocol);
$scope.helperData.host.push(uri_parts.host);
$scope.helperData.hostname.push(uri_parts.hostname);
$scope.helperData.port.push(uri_parts.port);
$scope.helperData.pathname.push(uri_parts.pathname);
var status = replica.state;
if (!live_nodes[replica.node_name]) {
status = 'gone';
}
var node = {
name: uri,
data: {
type: 'node',
state: status,
leader: 'true' === replica.leader,
uri: uri_parts
}
};
nodes.push(node);
}
var shard = {
name: s,
data: {
type: 'shard'
},
children: nodes
};
shards.push(shard);
}
var collection = {
name: c,
data: {
type: 'collection'
},
children: shards
};
graph_data.children.push(collection);
$scope.initGraph = function() {
Zookeeper.liveNodes(function (data) {
var live_nodes = {};
for (var c in data.tree[0].children) {
live_nodes[data.tree[0].children[c].data.title] = true;
}
$scope.helperData.protocol = $.unique($scope.helperData.protocol);
$scope.helperData.host = $.unique($scope.helperData.host);
$scope.helperData.hostname = $.unique($scope.helperData.hostname);
$scope.helperData.port = $.unique($scope.helperData.port);
$scope.helperData.pathname = $.unique($scope.helperData.pathname);
var params = {view: "graph"};
if ($scope.rows) {
params.start = $scope.pos;
params.rows = $scope.rows;
}
var filter = ($scope.filterType=='status') ? $scope.pagingStatusFilter : $scope.pagingFilter;
$scope.graphData = graph_data;
$scope.leafCount = leaf_count;
$scope.isRadial = isRadial;
console.log("AFTER PREPARE GRAPH:");
console.dir(data);
console.log("LEAF COUNT: " + leaf_count);
if (filter) {
params.filterType = $scope.filterType;
params.filter = filter;
}
Zookeeper.clusterState(params, function (data) {
eval("var state=" + data.znode.data); // @todo fix horrid means to parse JSON
var leaf_count = 0;
var graph_data = {
name: null,
children: []
};
for (var c in state) {
var shards = [];
for (var s in state[c].shards) {
var nodes = [];
for (var n in state[c].shards[s].replicas) {
leaf_count++;
var replica = state[c].shards[s].replicas[n]
var uri = replica.base_url;
var parts = uri.match(/^(\w+:)\/\/(([\w\d\.-]+)(:(\d+))?)(.+)$/);
var uri_parts = {
protocol: parts[1],
host: parts[2],
hostname: parts[3],
port: parseInt(parts[5] || 80, 10),
pathname: parts[6]
};
$scope.helperData.protocol.push(uri_parts.protocol);
$scope.helperData.host.push(uri_parts.host);
$scope.helperData.hostname.push(uri_parts.hostname);
$scope.helperData.port.push(uri_parts.port);
$scope.helperData.pathname.push(uri_parts.pathname);
var status = replica.state;
if (!live_nodes[replica.node_name]) {
status = 'gone';
}
var node = {
name: uri,
data: {
type: 'node',
state: status,
leader: 'true' === replica.leader,
uri: uri_parts
}
};
nodes.push(node);
}
var shard = {
name: s,
data: {
type: 'shard'
},
children: nodes
};
shards.push(shard);
}
var collection = {
name: c,
data: {
type: 'collection'
},
children: shards
};
graph_data.children.push(collection);
}
$scope.helperData.protocol = $.unique($scope.helperData.protocol);
$scope.helperData.host = $.unique($scope.helperData.host);
$scope.helperData.hostname = $.unique($scope.helperData.hostname);
$scope.helperData.port = $.unique($scope.helperData.port);
$scope.helperData.pathname = $.unique($scope.helperData.pathname);
if (!isRadial && data.znode && data.znode.paging) {
$scope.showPaging = true;
var parr = data.znode.paging.split('|');
if (parr.length < 3) {
$scope.showPaging = false;
} else {
$scope.start = Math.max(parseInt(parr[0]), 0);
$scope.prevEnabled = ($scope.start > 0);
$scope.rows = parseInt(parr[1]);
$scope.total = parseInt(parr[2]);
if ($scope.rows == -1) {
$scope.showPaging = false;
} else {
var filterType = parr.length > 3 ? parr[3] : '';
if (filterType == '' || filterType == 'none') filterType = 'status';
+$('#cloudGraphPagingFilterType').val(filterType);
var filter = parr.length > 4 ? parr[4] : '';
var page = Math.floor($scope.start / $scope.rows) + 1;
var pages = Math.ceil($scope.total / $scope.rows);
$scope.last = Math.min($scope.start + $scope.rows, $scope.total);
$scope.nextEnabled = ($scope.last < $scope.total);
}
}
}
else {
$scope.showPaging = false;
}
$scope.graphData = graph_data;
$scope.leafCount = leaf_count;
$scope.isRadial = isRadial;
});
});
});
};
$scope.initGraph();
};
solrAdminApp.directive('graph', function() {
@ -244,7 +305,6 @@ solrAdminApp.directive('graph', function() {
scope.$watch("data", function(newValue, oldValue) {
if (newValue) {
console.log("NEW VALUE");
if (scope.isRadial) {
radialGraph(element, scope.data, scope.leafCount);
} else {
@ -263,6 +323,7 @@ solrAdminApp.directive('graph', function() {
return [d.y, d.x];
});
d3.select('#canvas', element).html('');
var vis = d3.select('#canvas', element).append('svg')
.attr('width', w)
.attr('height', h)
@ -319,6 +380,7 @@ solrAdminApp.directive('graph', function() {
return [d.y, d.x / 180 * Math.PI];
});
d3.select('#canvas', element).html('');
var vis = d3.select('#canvas').append('svg')
.attr('width', r * 2)
.attr('height', r * 2)

View File

@ -19,7 +19,7 @@ limitations under the License.
<div id="frame">
<div id="tree-content" class="content clearfix" ng-show="showTree">
<jstree class="tree" on-select="showTreeLink(url)" id="tree"></jstree>
<jstree class="tree" on-select="showTreeLink(url)" id="tree" data="tree"></jstree>
<div id="file-content" class="clearfix">
@ -61,6 +61,33 @@ limitations under the License.
<li class="gone"><svg width="15" height="15"><g transform="translate(5,2)"><g transform="translate(0,5)"><circle r="4.5"></circle></g></g></svg> Gone</li>
</ul>
</div>
<div style="width: 100%; text-align: center;" ng-show="showPaging">
<div id="cloudGraphPaging">
<button ng-show="prevEnabled" ng-click="previous()" id="cloudGraphPagingPrev">&lt; Previous</button>
<span ng-show="total==0">No collections found.</span>
<span ng-hide="total==0">Collections {{start}} - {{last}} of {{total}}.</span>&nbsp;
Filter by:&nbsp;<select ng-model="filterType" ng-change="initGraph()" id="cloudGraphPagingFilterType">
<option value="status">Status</option>
<option value="name">Name</option>
</select>&nbsp;T:{{filterType}}
<span ng-show="filterType=='status'">
<select ng-model="pagingStatusFilter" id="cloudGraphPagingStatusFilter" ng-change="resetGraph()">
<option value=""> - Any - </option>
<option value="healthy">Healthy</option>
<option value="degraded">Degraded</option>
<option value="downed_shard">Downed Shard</option>
<option value="recovering">Replica in Recovery</option>
</select>
</span>
<span ng-show="filterType=='name'">
<input ng-model="pagingFilter" type="text" size="10" name="filter" ng-change="resetGraph()"/>&nbsp;
</span>
Show <input ng-model="rows" ng-change="resetGraph()" type="text" size="2" name="rows" /> per page.
<button ng-show="nextEnabled" ng-click="next()">Next &gt;</button>
</div>
</div>
</div>