lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From no...@apache.org
Subject [04/50] [abbrv] lucene-solr:master: SOLR-11005: reverted the changes
Date Wed, 04 Oct 2017 08:24:56 GMT
SOLR-11005: reverted the changes


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

Branch: refs/heads/master
Commit: eb49230e371d0ba984d06c6e2cedc181755d79a1
Parents: 91446f7
Author: Noble Paul <noble@apache.org>
Authored: Thu Aug 17 13:21:19 2017 +0930
Committer: Noble Paul <noble@apache.org>
Committed: Thu Aug 17 13:21:19 2017 +0930

----------------------------------------------------------------------
 .../apache/solr/cloud/CreateCollectionCmd.java  | 36 ++++-------------
 .../apache/solr/cloud/DeleteCollectionCmd.java  | 31 ---------------
 .../solr/cloud/autoscaling/TestPolicyCloud.java | 42 --------------------
 3 files changed, 7 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb49230e/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 87f9bca..664cea8 100644
--- a/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/CreateCollectionCmd.java
@@ -32,32 +32,28 @@ import java.util.concurrent.TimeUnit;
 import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
 import org.apache.solr.client.solrj.cloud.autoscaling.PolicyHelper;
 import org.apache.solr.cloud.OverseerCollectionMessageHandler.Cmd;
-import org.apache.solr.cloud.autoscaling.AutoScalingHandler;
 import org.apache.solr.cloud.overseer.ClusterStateMutator;
-import org.apache.solr.common.cloud.ReplicaPosition;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.SolrException.ErrorCode;
 import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.DocRouter;
 import org.apache.solr.common.cloud.ImplicitDocRouter;
 import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.ReplicaPosition;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkConfigManager;
 import org.apache.solr.common.cloud.ZkNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.cloud.ZooKeeperException;
-import org.apache.solr.common.params.AutoScalingParams;
 import org.apache.solr.common.params.CollectionAdminParams;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.CommandOperation;
 import org.apache.solr.common.util.NamedList;
 import org.apache.solr.common.util.SimpleOrderedMap;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.handler.admin.ConfigSetsHandlerApi;
 import org.apache.solr.handler.component.ShardHandler;
 import org.apache.solr.handler.component.ShardRequest;
-import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.util.TimeOut;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
@@ -65,17 +61,19 @@ import org.apache.zookeeper.KeeperException.NoNodeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import static java.util.Collections.singletonMap;
 import static org.apache.solr.cloud.OverseerCollectionMessageHandler.COLL_CONF;
 import static org.apache.solr.cloud.OverseerCollectionMessageHandler.CREATE_NODE_SET;
 import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
 import static org.apache.solr.cloud.OverseerCollectionMessageHandler.RANDOM;
-import static org.apache.solr.common.cloud.ZkStateReader.*;
+import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
+import static org.apache.solr.common.cloud.ZkStateReader.NRT_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.PULL_REPLICAS;
+import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
+import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_PATH;
+import static org.apache.solr.common.cloud.ZkStateReader.TLOG_REPLICAS;
 import static org.apache.solr.common.params.CollectionParams.CollectionAction.ADDREPLICA;
 import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
 import static org.apache.solr.common.params.CommonParams.NAME;
-import static org.apache.solr.common.params.CoreAdminParams.REPLICA;
-import static org.apache.solr.common.params.CoreAdminParams.SHARD;
 import static org.apache.solr.common.util.StrUtils.formatString;
 
 public class CreateCollectionCmd implements Cmd {
@@ -177,26 +175,6 @@ public class CreateCollectionCmd implements Cmd {
               + ". This requires " + requestedShardsToCreate
               + " shards to be created (higher than the allowed number)");
         }
-        if (usePolicyFramework && maxShardsPerNode > 0) {
-          if (policy == null) {
-            //this means we should create a policy for this collection
-            AutoScalingHandler ash = (AutoScalingHandler) ocmh.overseer.getZkController().getCoreContainer().getRequestHandler(AutoScalingHandler.HANDLER_PATH);
-            Map newPolicy = Utils.makeMap(REPLICA, "<" + (maxShardsPerNode + 1), SHARD,
Policy.EACH, "node", Policy.ANY);
-            SolrQueryResponse rsp = new SolrQueryResponse();
-            policy = "COLL_POLICY_" + collectionName;
-            ash.processOps(null, rsp, Collections.singletonList(new CommandOperation(AutoScalingParams.CMD_SET_POLICY,
singletonMap(
-                policy
-                , Collections.singletonList(newPolicy)))));
-            if (!"success".equals(rsp.getValues().get("result"))) {
-              throw new SolrException(ErrorCode.SERVER_ERROR, "unable to create new policy");
-            }
-            message.getProperties().put(Policy.POLICY, policy);
-
-          } else {
-            throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Cannot create collection");
-          }
-        }
-
         replicaPositions = Assign.identifyNodes(ocmh
             , clusterState, nodeList, collectionName, message, shardNames, numNrtReplicas,
numTlogReplicas, numPullReplicas);
       }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb49230e/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 f7b2fce..d2e40f7 100644
--- a/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/DeleteCollectionCmd.java
@@ -19,14 +19,12 @@
 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;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
-import org.apache.solr.cloud.autoscaling.AutoScalingHandler;
 import org.apache.solr.common.NonExistentCoreException;
 import org.apache.solr.common.SolrException;
 import org.apache.solr.common.cloud.ClusterState;
@@ -34,15 +32,11 @@ import org.apache.solr.common.cloud.DocCollection;
 import org.apache.solr.common.cloud.SolrZkClient;
 import org.apache.solr.common.cloud.ZkNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
-import org.apache.solr.common.params.AutoScalingParams;
 import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
-import org.apache.solr.common.util.CommandOperation;
 import org.apache.solr.common.util.NamedList;
-import org.apache.solr.common.util.StrUtils;
 import org.apache.solr.common.util.Utils;
 import org.apache.solr.core.snapshots.SolrSnapshotManager;
-import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.util.TimeOut;
 import org.apache.zookeeper.KeeperException;
 import org.slf4j.Logger;
@@ -115,31 +109,6 @@ public class DeleteCollectionCmd implements OverseerCollectionMessageHandler.Cmd
         throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
             "Could not fully remove collection: " + collection);
       }
-      String collectionSpecificPolicy = "COLL_POLICY_" + collection;
-      if (collectionSpecificPolicy.equals(policy)) {
-        for (Map.Entry<String, ClusterState.CollectionRef> e : state.getCollectionStates().entrySet())
{
-          if (collection.equals(e.getKey())) continue;
-          DocCollection c = e.getValue().get();
-          if (collectionSpecificPolicy.equals(c.getPolicyName())) {
-            log.info(StrUtils.formatString("{0} is being used by collection {1} . So, it's
not deleted", collectionSpecificPolicy, e.getKey()));
-            return;
-          }
-
-        }
-        AutoScalingHandler ash = (AutoScalingHandler) ocmh.overseer.getZkController().getCoreContainer()
-            .getRequestHandler(AutoScalingHandler.HANDLER_PATH);
-        SolrQueryResponse rsp = new SolrQueryResponse();
-        try {
-          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");
-          } else {
-            throw e;
-          }
-        }
-      }
-
 
     } finally {
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/eb49230e/solr/core/src/test/org/apache/solr/cloud/autoscaling/TestPolicyCloud.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TestPolicyCloud.java b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TestPolicyCloud.java
index 51cfb1d..bd3d5fd 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/TestPolicyCloud.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/TestPolicyCloud.java
@@ -48,7 +48,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.solr.cloud.autoscaling.AutoScalingHandlerTest.createAutoScalingRequest;
-import static org.apache.solr.common.cloud.ZkStateReader.SOLR_AUTOSCALING_CONF_PATH;
 import static org.apache.solr.common.util.Utils.getObjectByPath;
 
 @LuceneTestCase.Slow
@@ -180,47 +179,6 @@ public class TestPolicyCloud extends SolrCloudTestCase {
 
   }
 
-  public void testCreateCollectionWithPolicyAndMaxShardsPerNode() throws Exception {
-    CloudSolrClient solrClient = cluster.getSolrClient();
-    Map original = Utils.getJson(solrClient.getZkStateReader().getZkClient(), SOLR_AUTOSCALING_CONF_PATH,
true);
-    String setClusterPolicyCommand = "{" +
-        " 'set-cluster-policy': [" +
-        "      {'cores':'<10', 'node':'#ANY'}," +
-        "      {'replica':'<2', 'shard': '#EACH', 'node': '#ANY'}," +
-        "      {'nodeRole':'overseer', 'replica':0}" +
-        "    ]" +
-        "}";
-    SolrRequest req = createAutoScalingRequest(SolrRequest.METHOD.POST, setClusterPolicyCommand);
-    NamedList<Object> response = solrClient.request(req);
-    assertEquals(response.get("result").toString(), "success");
-    Map data = Utils.getJson(solrClient.getZkStateReader().getZkClient(), SOLR_AUTOSCALING_CONF_PATH,
true);
-    List clusterPolicy = (List) data.get("cluster-policy");
-    assertNotNull(clusterPolicy);
-    assertEquals(3, clusterPolicy.size());
-
-    CollectionAdminRequest.createCollection("myColl", "conf", 1, 2)
-        .process(cluster.getSolrClient());
-    data = Utils.getJson(solrClient.getZkStateReader().getZkClient(), SOLR_AUTOSCALING_CONF_PATH,
true);
-    assertEquals("Did create unexpected new policy  " + Utils.toJSONString(data),
-       null,  Utils.getObjectByPath(data, false, "policies/COLL_POLICY_myColl"));
-    CollectionAdminRequest.createCollection("myColl2", "conf", 1, 2)
-        .setMaxShardsPerNode(4)
-        .process(cluster.getSolrClient());
-    data = Utils.getJson(solrClient.getZkStateReader().getZkClient(), SOLR_AUTOSCALING_CONF_PATH,
true);
-
-    assertEquals("Did not create expected new policy  " + Utils.toJSONString(data),
-        "<5",  Utils.getObjectByPath(data, false, "policies/COLL_POLICY_myColl2[0]/replica"));
-
-    CollectionAdminRequest.deleteCollection("myColl2").process(cluster.getSolrClient());
-
-    data = Utils.getJson(solrClient.getZkStateReader().getZkClient(), SOLR_AUTOSCALING_CONF_PATH,
true);
-    assertEquals("Did not delete new policy  " + Utils.toJSONString(data),
-        null,  Utils.getObjectByPath(data, false, "policies/COLL_POLICY_myColl2"));
-
-    solrClient.getZkStateReader().getZkClient().setData(SOLR_AUTOSCALING_CONF_PATH, Utils.toJSON(original),
true);
-
-  }
-
   public void testCreateCollectionAddShardWithReplicaTypeUsingPolicy() throws Exception {
     JettySolrRunner jetty = cluster.getJettySolrRunners().get(0);
     String nrtNodeName = jetty.getNodeName();


Mime
View raw message