You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by an...@apache.org on 2015/11/24 18:56:26 UTC

svn commit: r1716223 - in /lucene/dev/trunk/solr: CHANGES.txt core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java

Author: anshum
Date: Tue Nov 24 17:56:25 2015
New Revision: 1716223

URL: http://svn.apache.org/viewvc?rev=1716223&view=rev
Log:
SOLR-8299: ConfigSet DELETE operation no longer allows deletion of config sets that are currently in use by other collections

Added:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java   (with props)
Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1716223&r1=1716222&r2=1716223&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Tue Nov 24 17:56:25 2015
@@ -574,6 +574,9 @@ Other Changes
 
 * SOLR-8277: (Search|Top)GroupsFieldCommand tweaks (Christine Poerschke)
 
+* SOLR-8299: ConfigSet DELETE operation no longer allows deletion of config sets that
+  are currently in use by other collections (Anshum Gupta)
+
 ==================  5.3.1 ==================
 
 Bug Fixes

Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java?rev=1716223&r1=1716222&r2=1716223&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/cloud/OverseerConfigSetMessageHandler.java Tue Nov 24 17:56:25 2015
@@ -46,9 +46,8 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.OverseerMessageHandler.ExclusiveMarking.NONEXCLUSIVE;
 import static org.apache.solr.cloud.OverseerMessageHandler.ExclusiveMarking.NOTDETERMINED;
-import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
-import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.DELETE;
 import static org.apache.solr.common.params.CommonParams.NAME;
+import static org.apache.solr.common.params.ConfigSetParams.ConfigSetAction.CREATE;
 
 /**
  * A {@link OverseerMessageHandler} that handles ConfigSets API related
@@ -351,6 +350,12 @@ public class OverseerConfigSetMessageHan
       throw new SolrException(ErrorCode.BAD_REQUEST, "ConfigSet does not exist to delete: " + configSetName);
     }
 
+    for (String s : zkStateReader.getClusterState().getCollections()) {
+      if (configSetName.equals(zkStateReader.readConfigName(s)))
+        throw new SolrException(ErrorCode.BAD_REQUEST,
+            "Can not delete ConfigSet as it is currently being used by collection [" + s + "]");
+    }
+
     String propertyPath = ConfigSetProperties.DEFAULT_FILENAME;
     NamedList properties = getConfigSetProperties(getPropertyPath(configSetName, propertyPath));
     if (properties != null) {

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java?rev=1716223&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ConfigSetsAPITest.java Tue Nov 24 17:56:25 2015
@@ -0,0 +1,57 @@
+package org.apache.solr.cloud;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
+import org.apache.solr.common.SolrException;
+import org.junit.Test;
+
+@LuceneTestCase.Slow
+public class ConfigSetsAPITest extends AbstractFullDistribZkTestBase {
+  public ConfigSetsAPITest() {
+    super();
+    sliceCount = 1;
+  }
+
+  @Test
+  public void testConfigSetDeleteWhenInUse() throws Exception {
+    CollectionAdminRequest.Create create = new CollectionAdminRequest.Create();
+    create.setConfigName("conf1");
+    create.setCollectionName("test_configset_delete");
+    create.setNumShards(1);
+    create.process(cloudClient);
+    waitForCollection(cloudClient.getZkStateReader(), "test_configset_delete", 1);
+
+    ConfigSetAdminRequest.Delete deleteConfigRequest = new ConfigSetAdminRequest.Delete();
+    deleteConfigRequest.setConfigSetName("conf1");
+    try {
+      deleteConfigRequest.process(cloudClient);
+      fail("The config deletion should cause an exception as it's currently being used by a collection.");
+    } catch (SolrException e) {
+      // Do nothing
+    }
+
+    // Clean up the collection
+    CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete();
+    deleteCollectionRequest.setCollectionName("test_configset_delete");
+    deleteCollectionRequest.process(cloudClient);
+  }
+
+}