mirror of https://github.com/apache/lucene.git
SOLR-5525 use hasCollection()
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1553095 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d9d344501
commit
97d3e2d546
|
@ -262,7 +262,7 @@ public class Overseer {
|
||||||
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
|
private ClusterState buildCollection(ClusterState clusterState, ZkNodeProps message) {
|
||||||
String collection = message.getStr("name");
|
String collection = message.getStr("name");
|
||||||
log.info("building a new collection: " + collection);
|
log.info("building a new collection: " + collection);
|
||||||
if(clusterState.getCollections().contains(collection) ){
|
if(clusterState.hasCollection(collection) ){
|
||||||
log.warn("Collection {} already exists. exit" ,collection);
|
log.warn("Collection {} already exists. exit" ,collection);
|
||||||
return clusterState;
|
return clusterState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,8 +366,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
||||||
boolean removed = false;
|
boolean removed = false;
|
||||||
while (System.currentTimeMillis() < timeout) {
|
while (System.currentTimeMillis() < timeout) {
|
||||||
Thread.sleep(100);
|
Thread.sleep(100);
|
||||||
removed = !zkStateReader.getClusterState().getCollections()
|
removed = !zkStateReader.getClusterState().hasCollection(message.getStr(collection));
|
||||||
.contains(message.getStr("name"));
|
|
||||||
if (removed) {
|
if (removed) {
|
||||||
Thread.sleep(100); // just a bit of time so it's more likely other
|
Thread.sleep(100); // just a bit of time so it's more likely other
|
||||||
// readers see on return
|
// readers see on return
|
||||||
|
@ -609,7 +608,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parentSlice == null) {
|
if (parentSlice == null) {
|
||||||
if(clusterState.getCollections().contains(collectionName)) {
|
if(clusterState.hasCollection(collectionName)) {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "No shard with the specified name exists: " + slice);
|
throw new SolrException(ErrorCode.BAD_REQUEST, "No shard with the specified name exists: " + slice);
|
||||||
} else {
|
} else {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "No collection with the specified name exists: " + collectionName);
|
throw new SolrException(ErrorCode.BAD_REQUEST, "No collection with the specified name exists: " + collectionName);
|
||||||
|
@ -1003,7 +1002,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
||||||
Slice slice = clusterState.getSlice(collection, sliceId);
|
Slice slice = clusterState.getSlice(collection, sliceId);
|
||||||
|
|
||||||
if (slice == null) {
|
if (slice == null) {
|
||||||
if(clusterState.getCollections().contains(collection)) {
|
if(clusterState.hasCollection(collection)) {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST,
|
throw new SolrException(ErrorCode.BAD_REQUEST,
|
||||||
"No shard with the specified name exists: " + slice);
|
"No shard with the specified name exists: " + slice);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1316,7 +1315,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
|
||||||
}
|
}
|
||||||
private void createCollection(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
|
private void createCollection(ClusterState clusterState, ZkNodeProps message, NamedList results) throws KeeperException, InterruptedException {
|
||||||
String collectionName = message.getStr("name");
|
String collectionName = message.getStr("name");
|
||||||
if (clusterState.getCollections().contains(collectionName)) {
|
if (clusterState.hasCollection(collectionName)) {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
|
throw new SolrException(ErrorCode.BAD_REQUEST, "collection already exists: " + collectionName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -387,8 +387,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
|
||||||
createNewSolrServer("", baseUrl).request(request);
|
createNewSolrServer("", baseUrl).request(request);
|
||||||
|
|
||||||
cloudClient.getZkStateReader().updateClusterState(true);
|
cloudClient.getZkStateReader().updateClusterState(true);
|
||||||
assertFalse(cloudClient.getZkStateReader().getClusterState()
|
assertFalse(cloudClient.getZkStateReader().getClusterState().hasCollection("halfdeletedcollection2"));
|
||||||
.getCollections().contains("halfdeletedcollection2"));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,7 +138,7 @@ public class UnloadDistributedZkTest extends BasicDistributedZkTest {
|
||||||
//printLayout();
|
//printLayout();
|
||||||
// the collection should be gone
|
// the collection should be gone
|
||||||
timeoutAt = System.currentTimeMillis() + 30000;
|
timeoutAt = System.currentTimeMillis() + 30000;
|
||||||
while (getCommonCloudSolrServer().getZkStateReader().getClusterState().getCollections().contains(collection)) {
|
while (getCommonCloudSolrServer().getZkStateReader().getClusterState().hasCollection(collection)) {
|
||||||
if (System.currentTimeMillis() > timeoutAt) {
|
if (System.currentTimeMillis() > timeoutAt) {
|
||||||
printLayout();
|
printLayout();
|
||||||
fail("Still found collection");
|
fail("Still found collection");
|
||||||
|
|
|
@ -146,4 +146,9 @@ public class ZkNodeProps implements JSONWriter.Writable {
|
||||||
return propMap.containsKey(key);
|
return propMap.containsKey(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getBool(String key, boolean b) {
|
||||||
|
Object o = propMap.get(key);
|
||||||
|
if(o==null) return b;
|
||||||
|
return Boolean.parseBoolean(o.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue