You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/06/27 13:32:24 UTC
svn commit: r1606035 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
Author: shalin
Date: Fri Jun 27 11:32:24 2014
New Revision: 1606035
URL: http://svn.apache.org/r1606035
Log:
SOLR-6069: The 'clusterstatus' API should return 'roles' information
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1606035&r1=1606034&r2=1606035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Fri Jun 27 11:32:24 2014
@@ -30,6 +30,8 @@ New Features
* SOLR-6196: The overseerstatus collection API instruments amILeader and ZK state update calls.
(shalin)
+* SOLR-6069: The 'clusterstatus' API should return 'roles' information. (shalin)
+
Bug Fixes
----------------------
Modified: lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java?rev=1606035&r1=1606034&r2=1606035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/java/org/apache/solr/cloud/OverseerCollectionProcessor.java Fri Jun 27 11:32:24 2014
@@ -672,7 +672,7 @@ public class OverseerCollectionProcessor
}
- private void getClusterStatus(ClusterState clusterState, ZkNodeProps message, NamedList results) {
+ private void getClusterStatus(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
// read aliases
@@ -696,6 +696,11 @@ public class OverseerCollectionProcessor
}
}
+ Map roles = null;
+ if(zkStateReader.getZkClient().exists(ZkStateReader.ROLES, true)){
+ roles = (Map) ZkStateReader.fromJSON(zkStateReader.getZkClient().getData(ZkStateReader.ROLES, null, null, true));
+ }
+
// convert cluster state into a map of writable types
byte[] bytes = ZkStateReader.toJSON(clusterState);
Map<String, Object> stateMap = (Map<String, Object>) ZkStateReader.fromJSON(bytes);
@@ -753,6 +758,11 @@ public class OverseerCollectionProcessor
clusterStatus.add("aliases", aliasVsCollections);
}
+ // add the roles map
+ if (roles != null) {
+ clusterStatus.add("roles", roles);
+ }
+
results.add("cluster", clusterStatus);
}
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java?rev=1606035&r1=1606034&r2=1606035&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/TestCollectionAPI.java Fri Jun 27 11:32:24 2014
@@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.Solr
import org.apache.solr.client.solrj.impl.CloudSolrServer;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.params.CollectionParams;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.params.ShardParams;
@@ -69,6 +70,7 @@ public class TestCollectionAPI extends A
clusterStatusWithCollectionAndShard();
clusterStatusWithRouteKey();
clusterStatusAliasTest();
+ clusterStatusRolesTest();
}
private void clusterStatusWithCollectionAndShard() throws IOException, SolrServerException {
@@ -234,7 +236,40 @@ public class TestCollectionAPI extends A
List<String> collAlias = (List<String>) collection.get("aliases");
assertEquals("Aliases not found", Lists.newArrayList("myalias"), collAlias);
} finally {
- //remove collections
+ client.shutdown();
+ }
+ }
+
+ private void clusterStatusRolesTest() throws Exception {
+ CloudSolrServer client = createCloudClient(null);
+ try {
+ client.connect();
+ Replica replica = client.getZkStateReader().getLeaderRetry(DEFAULT_COLLECTION, SHARD1);
+
+ ModifiableSolrParams params = new ModifiableSolrParams();
+ params.set("action", CollectionParams.CollectionAction.ADDROLE.toString());
+ params.set("node", replica.getNodeName());
+ params.set("role", "overseer");
+ SolrRequest request = new QueryRequest(params);
+ request.setPath("/admin/collections");
+ client.request(request);
+
+ params = new ModifiableSolrParams();
+ params.set("action", CollectionParams.CollectionAction.CLUSTERSTATUS.toString());
+ params.set("collection", DEFAULT_COLLECTION);
+ request = new QueryRequest(params);
+ request.setPath("/admin/collections");
+
+ NamedList<Object> rsp = client.request(request);
+ NamedList<Object> cluster = (NamedList<Object>) rsp.get("cluster");
+ assertNotNull("Cluster state should not be null", cluster);
+ Map<String, Object> roles = (Map<String, Object>) cluster.get("roles");
+ assertNotNull("Role information should not be null", roles);
+ List<String> overseer = (List<String>) roles.get("overseer");
+ assertNotNull(overseer);
+ assertEquals(1, overseer.size());
+ assertTrue(overseer.contains(replica.getNodeName()));
+ } finally {
client.shutdown();
}
}