Skip to content

Commit

Permalink
SOLR-15311: MODIFYCOLLECTION now supports async (#152)
Browse files Browse the repository at this point in the history
Co-authored-by: Nazerke Seidan <[email protected]>
Co-authored-by: David Smiley <[email protected]>
  • Loading branch information
3 people committed Jun 3, 2021
1 parent bf549a0 commit ec3e445
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
3 changes: 2 additions & 1 deletion solr/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ Optimizations

Bug Fixes
---------------------
(No changes)
* SOLR-15311: Support async parameter in MODIFYCOLLECTION
(Nazerke Seidan, Christine Poerschke, David Smiley)

Other Changes
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.CollectionAdminParams;
import org.apache.solr.common.params.CollectionParams.CollectionAction;
import org.apache.solr.common.params.CommonAdminParams;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
import org.apache.solr.common.params.ModifiableSolrParams;
Expand Down Expand Up @@ -654,6 +655,7 @@ void modifyCollection(ClusterState clusterState, ZkNodeProps message, @SuppressW

if (!updateKey.equals(ZkStateReader.COLLECTION_PROP)
&& !updateKey.equals(Overseer.QUEUE_OPERATION)
&& !updateKey.equals(CommonAdminParams.ASYNC)
&& updateEntry.getValue() != null // handled below in a separate conditional
&& !updateEntry.getValue().equals(collection.get(updateKey))) {
areChangesVisible = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@

package org.apache.solr.cloud;

import java.util.Collections;
import java.util.Map;

import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.GenericSolrRequest;
import org.apache.solr.client.solrj.response.RequestStatusState;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.Utils;
import org.apache.zookeeper.KeeperException;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.apache.solr.client.solrj.SolrRequest.METHOD.POST;
import static org.apache.solr.common.params.CommonParams.COLLECTIONS_HANDLER_PATH;

public class OverseerModifyCollectionTest extends SolrCloudTestCase {

@BeforeClass
Expand All @@ -49,22 +46,19 @@ public void testModifyColl() throws Exception {
CollectionAdminRequest.createCollection(collName, "conf1", 1, 2)
.process(cluster.getSolrClient());

// TODO create a modifyCollection() method on CollectionAdminRequest
ModifiableSolrParams p1 = new ModifiableSolrParams();
p1.add("collection", collName);
p1.add("action", "MODIFYCOLLECTION");
p1.add("collection.configName", "conf2");
cluster.getSolrClient().request(new GenericSolrRequest(POST, COLLECTIONS_HANDLER_PATH, p1));
// Modify configSet
RequestStatusState requestStatusState = CollectionAdminRequest.modifyCollection(collName,
Collections.singletonMap("collection.configName", "conf2"))
.processAndWait(cluster.getSolrClient(), DEFAULT_TIMEOUT);
assertEquals(requestStatusState, RequestStatusState.COMPLETED);

assertEquals("conf2", getConfigNameFromZk(collName));

//Try an invalid config name
ModifiableSolrParams p2 = new ModifiableSolrParams();
p2.add("collection", collName);
p2.add("action", "MODIFYCOLLECTION");
p2.add("collection.configName", "notARealConfigName");
Exception e = expectThrows(Exception.class, () -> {
cluster.getSolrClient().request(new GenericSolrRequest(POST, COLLECTIONS_HANDLER_PATH, p2));
CollectionAdminRequest.modifyCollection(collName,
Collections.singletonMap("collection.configName", "notARealConfigName")
).process(cluster.getSolrClient());
});

assertTrue(e.getMessage(), e.getMessage().contains("Can not find the specified config set"));
Expand Down
1 change: 1 addition & 0 deletions solr/solr-ref-guide/src/collection-management.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ The attributes that can be modified are:
* policy
* withCollection
* readOnly
* async
* other custom properties that use a `property.` prefix

See the <<create,CREATE action>> section above for details on these attributes.
Expand Down

0 comments on commit ec3e445

Please sign in to comment.