lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject lucene-solr:jira/solr-11990: SOLR-11990: Ported the refactoring made in CreateCollectionCmd to the simulated version so that simulation tests are able to create collections correctly
Date Tue, 24 Jul 2018 11:51:41 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/jira/solr-11990 defe111c9 -> 84f026b8c


SOLR-11990: Ported the refactoring made in CreateCollectionCmd to the simulated version so
that simulation tests are able to create collections correctly


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

Branch: refs/heads/jira/solr-11990
Commit: 84f026b8c4cc25edb548430b8f5ad09d2486b3b5
Parents: defe111
Author: Shalin Shekhar Mangar <shalin@apache.org>
Authored: Tue Jul 24 17:21:33 2018 +0530
Committer: Shalin Shekhar Mangar <shalin@apache.org>
Committed: Tue Jul 24 17:21:33 2018 +0530

----------------------------------------------------------------------
 .../cloud/api/collections/CreateCollectionCmd.java     |  6 +++---
 .../cloud/autoscaling/sim/SimClusterStateProvider.java | 13 ++++++++++++-
 2 files changed, 15 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f026b8/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
index c5e7b06..45ced2b 100644
--- a/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
+++ b/solr/core/src/java/org/apache/solr/cloud/api/collections/CreateCollectionCmd.java
@@ -377,7 +377,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
     return replicaPositions;
   }
 
-  private static int checkMaxShardsPerNode(ZkNodeProps message, boolean usePolicyFramework)
{
+  public static int checkMaxShardsPerNode(ZkNodeProps message, boolean usePolicyFramework)
{
     int maxShardsPerNode = message.getInt(MAX_SHARDS_PER_NODE, 1);
     if (usePolicyFramework && message.getStr(MAX_SHARDS_PER_NODE) != null &&
maxShardsPerNode > 0) {
       throw new SolrException(ErrorCode.BAD_REQUEST, "'maxShardsPerNode>0' is not supported
when autoScaling policies are used");
@@ -387,7 +387,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
     return maxShardsPerNode;
   }
 
-  private static void checkReplicaTypes(ZkNodeProps message) {
+  public static void checkReplicaTypes(ZkNodeProps message) {
     int numTlogReplicas = message.getInt(TLOG_REPLICAS, 0);
     int numNrtReplicas = message.getInt(NRT_REPLICAS, message.getInt(REPLICATION_FACTOR,
numTlogReplicas > 0 ? 0 : 1));
 
@@ -396,7 +396,7 @@ public class CreateCollectionCmd implements OverseerCollectionMessageHandler.Cmd
     }
   }
 
-  private static List<String> populateShardNames(ZkNodeProps message, String router)
{
+  public static List<String> populateShardNames(ZkNodeProps message, String router)
{
     List<String> shardNames = new ArrayList<>();
     Integer numSlices = message.getInt(OverseerCollectionMessageHandler.NUM_SLICES, null);
     if (ImplicitDocRouter.NAME.equals(router)) {

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/84f026b8/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java
b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java
index c4fbf2f..40cc72b 100644
--- a/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java
+++ b/solr/core/src/test/org/apache/solr/cloud/autoscaling/sim/SimClusterStateProvider.java
@@ -42,6 +42,7 @@ import java.util.concurrent.locks.ReentrantLock;
 
 import org.apache.solr.client.solrj.cloud.autoscaling.AutoScalingConfig;
 import org.apache.solr.client.solrj.cloud.DistribStateManager;
+import org.apache.solr.client.solrj.cloud.autoscaling.Policy;
 import org.apache.solr.client.solrj.cloud.autoscaling.PolicyHelper;
 import org.apache.solr.client.solrj.cloud.autoscaling.ReplicaInfo;
 import org.apache.solr.client.solrj.cloud.autoscaling.Suggestion;
@@ -680,8 +681,18 @@ public class SimClusterStateProvider implements ClusterStateProvider
{
     }
     boolean waitForFinalState = props.getBool(CommonAdminParams.WAIT_FOR_FINAL_STATE, false);
     List<String> nodeList = new ArrayList<>();
-    List<String> shardNames = new ArrayList<>();
     final String collectionName = props.getStr(NAME);
+
+    String router = props.getStr("router.name", DocRouter.DEFAULT_NAME);
+    String policy = props.getStr(Policy.POLICY);
+    AutoScalingConfig autoScalingConfig = cloudManager.getDistribStateManager().getAutoScalingConfig();
+    boolean usePolicyFramework = !autoScalingConfig.getPolicy().getClusterPolicy().isEmpty()
|| policy != null;
+
+    // fail fast if parameters are wrong or incomplete
+    List<String> shardNames = CreateCollectionCmd.populateShardNames(props, router);
+    CreateCollectionCmd.checkMaxShardsPerNode(props, usePolicyFramework);
+    CreateCollectionCmd.checkReplicaTypes(props);
+
     // always force getting fresh state
     collectionsStatesRef.set(null);
     ClusterState clusterState = getClusterState();


Mime
View raw message