SOLR-6104: The 'addreplica' Collection API does not support 'async' parameter

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596822 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-05-22 11:58:07 +00:00
parent 988df83885
commit 2af3939769
4 changed files with 23 additions and 7 deletions

View File

@ -125,6 +125,9 @@ Bug Fixes
rollback as well as how SolrIndexWriter manages it's ref counted directory
instance. (Mark Miller, Gregory Chanan)
* SOLR-6104: The 'addreplica' Collection API does not support 'async' parameter.
(shalin)
Other Changes
---------------------

View File

@ -2234,7 +2234,7 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
String node = message.getStr("node");
String shard = message.getStr(SHARD_ID_PROP);
String coreName = message.getStr(CoreAdminParams.NAME);
String asyncId = message.getStr("async");
DocCollection coll = clusterState.getCollection(collection);
if (coll == null) {
@ -2246,9 +2246,9 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
}
ShardHandler shardHandler = shardHandlerFactory.getShardHandler();
if(node== null){
node = getNodesForNewShard(clusterState,collection, coll.getSlices().size() , coll.getInt(MAX_SHARDS_PER_NODE, 1),coll.getInt(REPLICATION_FACTOR, 1),null).get(0).nodeName;
log.info("node not provided , Identified {} for creating new replica",node);
if (node == null) {
node = getNodesForNewShard(clusterState, collection, coll.getSlices().size(), coll.getInt(MAX_SHARDS_PER_NODE, 1), coll.getInt(REPLICATION_FACTOR, 1), null).get(0).nodeName;
log.info("Node not provided, Identified {} for creating new replica", node);
}
@ -2317,10 +2317,15 @@ public class OverseerCollectionProcessor implements Runnable, ClosableThread {
}
addPropertyParams(message, params);
// For tracking async calls.
HashMap<String, String> requestMap = new HashMap<>();
setupAsyncRequest(asyncId, requestMap, params, node);
sendShardRequest(node, params, shardHandler);
collectShardResponses(results, true,
"ADDREPLICA failed to create replica", shardHandler);
completeAsyncRequest(asyncId, requestMap, results);
}
private void processResponses(NamedList results, ShardHandler shardHandler) {

View File

@ -610,7 +610,7 @@ public class CollectionsHandler extends RequestHandlerBase {
Map<String,Object> props = new HashMap<>();
props.put(Overseer.QUEUE_OPERATION, CollectionAction.ADDREPLICA.toString());
copyIfNotNull(req.getParams(), props, COLLECTION_PROP, "node", SHARD_ID_PROP, ShardParams._ROUTE_,
CoreAdminParams.NAME, CoreAdminParams.INSTANCE_DIR, CoreAdminParams.DATA_DIR);
CoreAdminParams.NAME, CoreAdminParams.INSTANCE_DIR, CoreAdminParams.DATA_DIR, ASYNC);
ZkNodeProps m = new ZkNodeProps(props);
handleResponse(CollectionAction.ADDREPLICA.toString(), m, rsp);
}

View File

@ -80,9 +80,17 @@ public class CollectionsAPIAsyncDistributedZkTest extends AbstractFullDistribZkT
assertEquals("Recreating a collection with the same name didn't fail, should have.", "failed", state);
CollectionAdminRequest.splitShard("testasynccollectioncreation", "shard1", server, "1003");
CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica();
addReplica.setCollectionName("testasynccollectioncreation");
addReplica.setShardName("shard1");
addReplica.setAsyncId("1003");
server.request(addReplica);
state = getRequestStateAfterCompletion("1003", 60, server);
assertEquals("Add replica did not complete", "completed", state);
CollectionAdminRequest.splitShard("testasynccollectioncreation", "shard1", server, "1004");
state = getRequestStateAfterCompletion("1004", 60, server);
assertEquals("Shard split did not complete. Last recorded state: " + state, "completed", state);
}