mirror of https://github.com/apache/lucene.git
SOLR-2592: more DocCollection refactoring in tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1418507 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
330a570fc6
commit
113437054c
|
@ -46,6 +46,7 @@ import org.apache.solr.common.SolrDocumentList;
|
|||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.ZkCoreNodeProps;
|
||||
|
@ -375,30 +376,24 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
shardToJetty.clear();
|
||||
|
||||
ClusterState clusterState = zkStateReader.getClusterState();
|
||||
Map<String,Slice> slices = clusterState.getSlicesMap(DEFAULT_COLLECTION);
|
||||
|
||||
if (slices == null) {
|
||||
throw new RuntimeException("No slices found for collection "
|
||||
+ DEFAULT_COLLECTION + " in " + clusterState.getCollections());
|
||||
}
|
||||
|
||||
DocCollection coll = clusterState.getCollection(DEFAULT_COLLECTION);
|
||||
|
||||
List<CloudSolrServerClient> theClients = new ArrayList<CloudSolrServerClient>();
|
||||
for (SolrServer client : clients) {
|
||||
// find info for this client in zk
|
||||
nextClient:
|
||||
// we find ou state by simply matching ports...
|
||||
for (Map.Entry<String,Slice> slice : slices.entrySet()) {
|
||||
Map<String,Replica> theShards = slice.getValue().getReplicasMap();
|
||||
for (Map.Entry<String,Replica> shard : theShards.entrySet()) {
|
||||
// we find out state by simply matching ports...
|
||||
for (Slice slice : coll.getSlices()) {
|
||||
for (Replica replica : slice.getReplicas()) {
|
||||
int port = new URI(((HttpSolrServer) client).getBaseURL())
|
||||
.getPort();
|
||||
|
||||
if (shard.getKey().contains(":" + port + "_")) {
|
||||
if (replica.getName().contains(":" + port + "_")) {
|
||||
CloudSolrServerClient csc = new CloudSolrServerClient();
|
||||
csc.solrClient = client;
|
||||
csc.port = port;
|
||||
csc.shardName = shard.getValue().getStr(ZkStateReader.NODE_NAME_PROP);
|
||||
csc.info = shard.getValue();
|
||||
csc.shardName = replica.getStr(ZkStateReader.NODE_NAME_PROP);
|
||||
csc.info = replica;
|
||||
|
||||
theClients .add(csc);
|
||||
|
||||
|
@ -415,27 +410,25 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
}
|
||||
|
||||
nextJetty:
|
||||
for (Map.Entry<String,Slice> slice : slices.entrySet()) {
|
||||
Map<String,Replica> theShards = slice.getValue().getReplicasMap();
|
||||
for (Map.Entry<String,Replica> shard : theShards.entrySet()) {
|
||||
if (shard.getKey().contains(":" + port + "_")) {
|
||||
List<CloudJettyRunner> list = shardToJetty.get(slice.getKey());
|
||||
for (Slice slice : coll.getSlices()) {
|
||||
for (Replica replica : slice.getReplicas()) {
|
||||
if (replica.getName().contains(":" + port + "_")) {
|
||||
List<CloudJettyRunner> list = shardToJetty.get(slice.getName());
|
||||
if (list == null) {
|
||||
list = new ArrayList<CloudJettyRunner>();
|
||||
shardToJetty.put(slice.getKey(), list);
|
||||
shardToJetty.put(slice.getName(), list);
|
||||
}
|
||||
boolean isLeader = shard.getValue().containsKey(
|
||||
ZkStateReader.LEADER_PROP);
|
||||
boolean isLeader = slice.getLeader() == replica;
|
||||
CloudJettyRunner cjr = new CloudJettyRunner();
|
||||
cjr.jetty = jetty;
|
||||
cjr.info = shard.getValue();
|
||||
cjr.nodeName = shard.getValue().getStr(ZkStateReader.NODE_NAME_PROP);
|
||||
cjr.coreNodeName = shard.getKey();
|
||||
cjr.url = shard.getValue().getStr(ZkStateReader.BASE_URL_PROP) + "/" + shard.getValue().getStr(ZkStateReader.CORE_NAME_PROP);
|
||||
cjr.info = replica;
|
||||
cjr.nodeName = replica.getStr(ZkStateReader.NODE_NAME_PROP);
|
||||
cjr.coreNodeName = replica.getName();
|
||||
cjr.url = replica.getStr(ZkStateReader.BASE_URL_PROP) + "/" + replica.getStr(ZkStateReader.CORE_NAME_PROP);
|
||||
cjr.client = findClientByPort(port, theClients);
|
||||
list.add(cjr);
|
||||
if (isLeader) {
|
||||
shardToLeaderJetty.put(slice.getKey(), cjr);
|
||||
shardToLeaderJetty.put(slice.getName(), cjr);
|
||||
}
|
||||
cloudJettys.add(cjr);
|
||||
break nextJetty;
|
||||
|
@ -447,12 +440,12 @@ public abstract class AbstractFullDistribZkTestBase extends AbstractDistribZkTes
|
|||
// # of jetties may not match replicas in shard here, because we don't map
|
||||
// jetties that are not running - every shard should have at least one
|
||||
// running jetty though
|
||||
for (Map.Entry<String,Slice> slice : slices.entrySet()) {
|
||||
for (Slice slice : coll.getSlices()) {
|
||||
// check that things look right
|
||||
List<CloudJettyRunner> jetties = shardToJetty.get(slice.getKey());
|
||||
assertNotNull("Test setup problem: We found no jetties for shard: " + slice.getKey()
|
||||
List<CloudJettyRunner> jetties = shardToJetty.get(slice.getName());
|
||||
assertNotNull("Test setup problem: We found no jetties for shard: " + slice.getName()
|
||||
+ " just:" + shardToJetty.keySet(), jetties);
|
||||
assertEquals(slice.getValue().getReplicasMap().size(), jetties.size());
|
||||
assertEquals(slice.getReplicas().size(), jetties.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue