lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject [47/47] lucene-solr:jira/solr-11000: SOLR-11000 Fix other bugs due to API changes on parent branch.
Date Thu, 13 Jul 2017 15:38:44 GMT
SOLR-11000 Fix other bugs due to API changes on parent branch.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/e95534d2
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/e95534d2
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/e95534d2

Branch: refs/heads/jira/solr-11000
Commit: e95534d28d5dd758c79c288ef9b176278d45820b
Parents: 5aaaa491
Author: Andrzej Bialecki <ab@apache.org>
Authored: Thu Jul 13 17:09:21 2017 +0200
Committer: Andrzej Bialecki <ab@apache.org>
Committed: Thu Jul 13 17:09:21 2017 +0200

----------------------------------------------------------------------
 .../apache/solr/cloud/CreateCollectionCmd.java  |   4 +-
 .../apache/solr/cloud/DeleteCollectionCmd.java  |   3 +-
 .../cloud/autoscaling/AutoScalingHandler.java   | 107 +++++++++----------
 ...verseerCollectionConfigSetProcessorTest.java |   3 +
 4 files changed, 60 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e95534d2/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
index 6f1b42c..d859170 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
@@ -188,9 +188,9 @@ public class CreateCollectionCmd implements Cmd {
             Map newPolicy = Utils.makeMap(REPLICA, "<" + (maxShardsPerNode + 1), SHARD,
Policy.EACH, "node", Policy.ANY);
             SolrQueryResponse rsp = new SolrQueryResponse();
             policy = "COLL_POLICY_" + collectionName;
-            ash.handleSetPolicies(null, rsp, new CommandOperation(AutoScalingParams.CMD_SET_POLICY,
singletonMap(
+            ash.processOps(null, rsp, Collections.singletonList(new CommandOperation(AutoScalingParams.CMD_SET_POLICY,
singletonMap(
                 policy
-                , Collections.singletonList(newPolicy))));
+                , Collections.singletonList(newPolicy)))));
             if (!"success".equals(rsp.getValues().get("result"))) {
               throw new SolrException(ErrorCode.SERVER_ERROR, "unable to create new policy");
             }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e95534d2/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java b/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
index f0ee458..f7b2fce 100644
--- a/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
@@ -19,6 +19,7 @@
 package org.apache.solr.cloud;
 
 import java.lang.invoke.MethodHandles;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -129,7 +130,7 @@ public class DeleteCollectionCmd implements OverseerCollectionMessageHandler.Cmd
             .getRequestHandler(AutoScalingHandler.HANDLER_PATH);
         SolrQueryResponse rsp = new SolrQueryResponse();
         try {
-          ash.handleRemovePolicy(null, rsp, new CommandOperation(AutoScalingParams.CMD_REMOVE_POLICY,
collectionSpecificPolicy));
+          ash.processOps(null, rsp, Collections.singletonList(new CommandOperation(AutoScalingParams.CMD_REMOVE_POLICY,
collectionSpecificPolicy)));
         } catch (SolrException e) {
           if (e.getMessage().contains("No policy exists with name")) {
             log.warn("The policy: " + collectionSpecificPolicy + " does not exist to be removed");

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e95534d2/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
index 34717d1..83d8663 100644
--- a/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
+++ b/solr/core/src/java/org/apache/solr/cloud/autoscaling/AutoScalingHandler.java
@@ -138,25 +138,7 @@ public class AutoScalingHandler extends RequestHandlerBase implements
Permission
           // errors have already been added to the response so there's nothing left to do
           return;
         }
-        while (true) {
-          AutoScalingConfig initialConfig = container.getZkController().zkStateReader.getAutoScalingConfig();
-          AutoScalingConfig currentConfig = initialConfig;
-          currentConfig = processOps(req, rsp, ops, currentConfig);
-          if (!currentConfig.equals(initialConfig)) {
-            // update in ZK
-            if (zkSetAutoScalingConfig(container.getZkController().getZkStateReader(), currentConfig))
{
-              break;
-            } else {
-              // someone else updated the config, get the latest one and re-apply our ops
-              rsp.getValues().add("retry", "initialVersion=" + initialConfig.getZkVersion());
-              continue;
-            }
-          } else {
-            // no changes
-            break;
-          }
-        }
-        rsp.getValues().add("result", "success");
+        processOps(req, rsp, ops);
       }
     } catch (Exception e) {
       rsp.getValues().add("result", "failure");
@@ -166,44 +148,61 @@ public class AutoScalingHandler extends RequestHandlerBase implements
Permission
     }
   }
 
-  private AutoScalingConfig processOps(SolrQueryRequest req, SolrQueryResponse rsp, List<CommandOperation>
ops, AutoScalingConfig currentConfig) throws KeeperException, InterruptedException, IOException
{
-    for (CommandOperation op : ops) {
-      switch (op.name) {
-        case CMD_SET_TRIGGER:
-          currentConfig = handleSetTrigger(req, rsp, op, currentConfig);
-          break;
-        case CMD_REMOVE_TRIGGER:
-          currentConfig = handleRemoveTrigger(req, rsp, op, currentConfig);
-          break;
-        case CMD_SET_LISTENER:
-          currentConfig = handleSetListener(req, rsp, op, currentConfig);
-          break;
-        case CMD_REMOVE_LISTENER:
-          currentConfig = handleRemoveListener(req, rsp, op, currentConfig);
-          break;
-        case CMD_SUSPEND_TRIGGER:
-          currentConfig = handleSuspendTrigger(req, rsp, op, currentConfig);
-          break;
-        case CMD_RESUME_TRIGGER:
-          currentConfig = handleResumeTrigger(req, rsp, op, currentConfig);
-          break;
-        case CMD_SET_POLICY:
-          currentConfig = handleSetPolicies(req, rsp, op, currentConfig);
-          break;
-        case CMD_REMOVE_POLICY:
-          currentConfig = handleRemovePolicy(req, rsp, op, currentConfig);
-          break;
-        case CMD_SET_CLUSTER_PREFERENCES:
-          currentConfig = handleSetClusterPreferences(req, rsp, op, currentConfig);
-          break;
-        case CMD_SET_CLUSTER_POLICY:
-          currentConfig = handleSetClusterPolicy(req, rsp, op, currentConfig);
+  public void processOps(SolrQueryRequest req, SolrQueryResponse rsp, List<CommandOperation>
ops) throws KeeperException, InterruptedException, IOException {
+    while (true) {
+      AutoScalingConfig initialConfig = container.getZkController().zkStateReader.getAutoScalingConfig();
+      AutoScalingConfig currentConfig = initialConfig;
+      for (CommandOperation op : ops) {
+        switch (op.name) {
+          case CMD_SET_TRIGGER:
+            currentConfig = handleSetTrigger(req, rsp, op, currentConfig);
+            break;
+          case CMD_REMOVE_TRIGGER:
+            currentConfig = handleRemoveTrigger(req, rsp, op, currentConfig);
+            break;
+          case CMD_SET_LISTENER:
+            currentConfig = handleSetListener(req, rsp, op, currentConfig);
+            break;
+          case CMD_REMOVE_LISTENER:
+            currentConfig = handleRemoveListener(req, rsp, op, currentConfig);
+            break;
+          case CMD_SUSPEND_TRIGGER:
+            currentConfig = handleSuspendTrigger(req, rsp, op, currentConfig);
+            break;
+          case CMD_RESUME_TRIGGER:
+            currentConfig = handleResumeTrigger(req, rsp, op, currentConfig);
+            break;
+          case CMD_SET_POLICY:
+            currentConfig = handleSetPolicies(req, rsp, op, currentConfig);
+            break;
+          case CMD_REMOVE_POLICY:
+            currentConfig = handleRemovePolicy(req, rsp, op, currentConfig);
+            break;
+          case CMD_SET_CLUSTER_PREFERENCES:
+            currentConfig = handleSetClusterPreferences(req, rsp, op, currentConfig);
+            break;
+          case CMD_SET_CLUSTER_POLICY:
+            currentConfig = handleSetClusterPolicy(req, rsp, op, currentConfig);
+            break;
+          default:
+            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown command:
" + op.name);
+        }
+      }
+      if (!currentConfig.equals(initialConfig)) {
+        // update in ZK
+        if (zkSetAutoScalingConfig(container.getZkController().getZkStateReader(), currentConfig))
{
           break;
-        default:
-          throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unknown command:
" + op.name);
+        } else {
+          // someone else updated the config, get the latest one and re-apply our ops
+          rsp.getValues().add("retry", "initialVersion=" + initialConfig.getZkVersion());
+          continue;
+        }
+      } else {
+        // no changes
+        break;
       }
     }
-    return currentConfig;
+    rsp.getValues().add("result", "success");
   }
 
   private void handleDiagnostics(SolrQueryResponse rsp, AutoScalingConfig autoScalingConf)
throws IOException {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/e95534d2/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
index 7f831df..e67912f 100644
--- a/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/OverseerCollectionConfigSetProcessorTest.java
@@ -24,6 +24,7 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrResponse;
+import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
 import org.apache.solr.cloud.Overseer.LeaderStatus;
 import org.apache.solr.cloud.OverseerTaskQueue.QueueEvent;
 import org.apache.solr.common.cloud.ClusterState;
@@ -72,6 +73,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
   private static ZkStateReader zkStateReaderMock;
   private static ClusterState clusterStateMock;
   private static SolrZkClient solrZkClientMock;
+  private static AutoScalingConfig autoScalingConfig = new AutoScalingConfig(Collections.emptyMap());
   private final Map zkMap = new HashMap();
   private final Map<String, ClusterState.CollectionRef> collectionsSet = new HashMap<>();
   private final List<ZkNodeProps> replicas = new ArrayList<>();
@@ -197,6 +199,7 @@ public class OverseerCollectionConfigSetProcessorTest extends SolrTestCaseJ4
{
 
     when(zkStateReaderMock.getZkClient()).thenReturn(solrZkClientMock);
     when(zkStateReaderMock.getClusterState()).thenReturn(clusterStateMock);
+    when(zkStateReaderMock.getAutoScalingConfig()).thenReturn(autoScalingConfig);
 
     when(clusterStateMock.getCollection(anyString())).thenAnswer(invocation -> {
       String key = invocation.getArgument(0);


Mime
View raw message