From 988df838852d09a1d5f9f1b4c9fda8d93a8c91b0 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Thu, 22 May 2014 11:50:31 +0000 Subject: [PATCH] SOLR-6108: Add support for 'addreplica' Collection API in SolrJ git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1596819 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 2 + .../CollectionsAPIDistributedZkTest.java | 43 +++++------- .../solrj/request/CollectionAdminRequest.java | 67 +++++++++++++++++++ 3 files changed, 87 insertions(+), 25 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 5f3d5cee074..3c9bd97a216 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -116,6 +116,8 @@ New Features * SOLR-5973: Pluggable Ranking Collectors and Merge Strategies (Joel Bernstein) +* SOLR-6108: Add support for 'addreplica' Collection API in SolrJ. (shalin) + Bug Fixes ---------------------- diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java index 24153bdbf3f..5568b9ae0ee 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java @@ -1210,53 +1210,46 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa } } - private void addReplicaTest()throws Exception{ + + private void addReplicaTest() throws Exception { String collectionName = "addReplicaColl"; CloudSolrServer client = createCloudClient(null); try { - createCollection(collectionName, client,2,2); - String newReplicaName = Assign.assignNode(collectionName , client.getZkStateReader().getClusterState() ); + createCollection(collectionName, client, 2, 2); + String newReplicaName = Assign.assignNode(collectionName, client.getZkStateReader().getClusterState()); ArrayList nodeList = new ArrayList<>(client.getZkStateReader().getClusterState().getLiveNodes()); Collections.shuffle(nodeList); - Map m = makeMap( - "action", CollectionAction.ADDREPLICA.toString(), - ZkStateReader.COLLECTION_PROP, collectionName, - ZkStateReader.SHARD_ID_PROP, "shard1", - "node", nodeList.get(0)); - - SolrRequest request = new QueryRequest(new MapSolrParams(m)); - request.setPath("/admin/collections"); - client.request(request); + CollectionAdminRequest.AddReplica addReplica = new CollectionAdminRequest.AddReplica(); + addReplica.setCollectionName(collectionName); + addReplica.setShardName("shard1"); + addReplica.setNode(nodeList.get(0)); + client.request(addReplica); long timeout = System.currentTimeMillis() + 3000; Replica newReplica = null; - for(; System.currentTimeMillis()