mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 19:15:06 +00:00
SOLR-6069: The 'clusterstatus' API should return 'roles' information
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1606034 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd0f5fc9c1
commit
70709b224a
@ -94,6 +94,8 @@ New Features
|
|||||||
* SOLR-6196: The overseerstatus collection API instruments amILeader and ZK state update calls.
|
* SOLR-6196: The overseerstatus collection API instruments amILeader and ZK state update calls.
|
||||||
(shalin)
|
(shalin)
|
||||||
|
|
||||||
|
* SOLR-6069: The 'clusterstatus' API should return 'roles' information. (shalin)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
@ -668,7 +668,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
String collection = message.getStr(ZkStateReader.COLLECTION_PROP);
|
||||||
|
|
||||||
// read aliases
|
// read aliases
|
||||||
@ -692,6 +692,11 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
// convert cluster state into a map of writable types
|
||||||
byte[] bytes = ZkStateReader.toJSON(clusterState);
|
byte[] bytes = ZkStateReader.toJSON(clusterState);
|
||||||
Map<String, Object> stateMap = (Map<String, Object>) ZkStateReader.fromJSON(bytes);
|
Map<String, Object> stateMap = (Map<String, Object>) ZkStateReader.fromJSON(bytes);
|
||||||
@ -753,6 +758,11 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
|||||||
clusterStatus.add("aliases", aliasVsCollections);
|
clusterStatus.add("aliases", aliasVsCollections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add the roles map
|
||||||
|
if (roles != null) {
|
||||||
|
clusterStatus.add("roles", roles);
|
||||||
|
}
|
||||||
|
|
||||||
results.add("cluster", clusterStatus);
|
results.add("cluster", clusterStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import org.apache.solr.client.solrj.SolrServerException;
|
|||||||
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
import org.apache.solr.client.solrj.impl.CloudSolrServer;
|
||||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||||
import org.apache.solr.common.SolrInputDocument;
|
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.CollectionParams;
|
||||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||||
import org.apache.solr.common.params.ShardParams;
|
import org.apache.solr.common.params.ShardParams;
|
||||||
@ -74,6 +75,7 @@ public class TestCollectionAPI extends AbstractFullDistribZkTestBase {
|
|||||||
clusterStatusWithCollectionAndShard();
|
clusterStatusWithCollectionAndShard();
|
||||||
clusterStatusWithRouteKey();
|
clusterStatusWithRouteKey();
|
||||||
clusterStatusAliasTest();
|
clusterStatusAliasTest();
|
||||||
|
clusterStatusRolesTest();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clusterStatusWithCollectionAndShard() throws IOException, SolrServerException {
|
private void clusterStatusWithCollectionAndShard() throws IOException, SolrServerException {
|
||||||
@ -239,7 +241,40 @@ public class TestCollectionAPI extends AbstractFullDistribZkTestBase {
|
|||||||
List<String> collAlias = (List<String>) collection.get("aliases");
|
List<String> collAlias = (List<String>) collection.get("aliases");
|
||||||
assertEquals("Aliases not found", Lists.newArrayList("myalias"), collAlias);
|
assertEquals("Aliases not found", Lists.newArrayList("myalias"), collAlias);
|
||||||
} finally {
|
} 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();
|
client.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user