Skip to content

Apache Lucene open-source search software

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

Erik Hatcher12369fa890f9
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 3cf68086a88..13604654d8c 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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
----------------------
diff --git a/solr/webapp/web/css/angular/cloud.css b/solr/webapp/web/css/angular/cloud.css
index 69d8fa3890b..bbb66ae6a59 100644
--- a/solr/webapp/web/css/angular/cloud.css
+++ b/solr/webapp/web/css/angular/cloud.css
@@ -389,3 +389,10 @@ limitations under the License.
{
stroke: #fff;
}
+
+#cloudGraphPaging
+{
+ display: inline-block;
+ padding-top: 15px;
+ padding-bottom: 15px;
+}
diff --git a/solr/webapp/web/js/angular/app.js b/solr/webapp/web/js/angular/app.js
index d4bf3755133..c77067df1fe 100644
--- a/solr/webapp/web/js/angular/app.js
+++ b/solr/webapp/web/js/angular/app.js
@@ -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();
diff --git a/solr/webapp/web/js/angular/controllers/cloud.js b/solr/webapp/web/js/angular/controllers/cloud.js
index 738371442d0..ef8e9c1c31c 100644
--- a/solr/webapp/web/js/angular/controllers/cloud.js
+++ b/solr/webapp/web/js/angular/controllers/cloud.js
@@ -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.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.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 params = {view: "graph"};
+ if ($scope.rows) {
+ params.start = $scope.pos;
+ params.rows = $scope.rows;
+ }
- var status = replica.state;
+ var filter = ($scope.filterType=='status') ? $scope.pagingStatusFilter : $scope.pagingFilter;
- if (!live_nodes[replica.node_name]) {
- status = 'gone';
- }
+ if (filter) {
+ params.filterType = $scope.filterType;
+ params.filter = filter;
+ }
- var node = {
- name: uri,
- data: {
- type: 'node',
- state: status,
- leader: 'true' === replica.leader,
- uri: uri_parts
- }
- };
- nodes.push(node);
- }
+ Zookeeper.clusterState(params, function (data) {
+ eval("var state=" + data.znode.data); // @todo fix horrid means to parse JSON
- var shard = {
- name: s,
- data: {
- type: 'shard'
- },
- children: nodes
+ var leaf_count = 0;
+ var graph_data = {
+ name: null,
+ children: []
};
- shards.push(shard);
- }
- var collection = {
- name: c,
- data: {
- type: 'collection'
- },
- children: shards
- };
- graph_data.children.push(collection);
- }
+ 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);
+ }
- $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 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.graphData = graph_data;
- $scope.leafCount = leaf_count;
- $scope.isRadial = isRadial;
- console.log("AFTER PREPARE GRAPH:");
- console.dir(data);
- console.log("LEAF COUNT: " + leaf_count);
+ $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)
diff --git a/solr/webapp/web/partials/cloud.html b/solr/webapp/web/partials/cloud.html
index 7a6e77694a4..ef39bb302c1 100644
--- a/solr/webapp/web/partials/cloud.html
+++ b/solr/webapp/web/partials/cloud.html
@@ -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>