HoustonPutman commented on code in PR #1730:
URL: https://github.com/apache/solr/pull/1730#discussion_r1246930356


##########
solr/core/src/java/org/apache/solr/cloud/api/collections/MigrateReplicasCmd.java:
##########
@@ -0,0 +1,158 @@
+/*
+ * 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.
+ */
+
+package org.apache.solr.cloud.api.collections;
+
+import static org.apache.solr.common.params.CommonAdminParams.ASYNC;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import org.apache.solr.common.SolrException;
+import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.Replica;
+import org.apache.solr.common.cloud.ReplicaPosition;
+import org.apache.solr.common.cloud.ZkNodeProps;
+import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.CollectionParams;
+import org.apache.solr.common.params.CommonAdminParams;
+import org.apache.solr.common.util.CollectionUtil;
+import org.apache.solr.common.util.NamedList;
+
+public class MigrateReplicasCmd implements CollApiCmds.CollectionApiCommand {
+
+  private final CollectionCommandContext ccc;
+
+  public MigrateReplicasCmd(CollectionCommandContext ccc) {
+    this.ccc = ccc;
+  }
+
+  @Override
+  public void call(ClusterState state, ZkNodeProps message, NamedList<Object> 
results)
+      throws Exception {
+    ZkStateReader zkStateReader = ccc.getZkStateReader();
+    Set<String> sourceNodes = getNodesFromParam(message, 
CollectionParams.SOURCE_NODES);
+    Set<String> targetNodes = getNodesFromParam(message, 
CollectionParams.TARGET_NODES);
+    boolean waitForFinalState = 
message.getBool(CommonAdminParams.WAIT_FOR_FINAL_STATE, false);
+    if (sourceNodes.isEmpty()) {
+      throw new SolrException(
+          SolrException.ErrorCode.BAD_REQUEST, "sourceNodes is a required 
param");
+    }
+    String async = message.getStr(ASYNC);
+    int timeout = message.getInt("timeout", 10 * 60); // 10 minutes
+    boolean parallel = message.getBool("parallel", false);
+    ClusterState clusterState = zkStateReader.getClusterState();
+
+    for (String sourceNode : sourceNodes) {
+      if (!clusterState.liveNodesContain(sourceNode)) {
+        throw new SolrException(
+            SolrException.ErrorCode.BAD_REQUEST, "Source Node: " + sourceNode 
+ " is not live");
+      }

Review Comment:
   Currently the ReplaceNode/BalanceReplicas logic does not allow for moving 
replicas off of non-live nodes. I think that's something that we should think 
about for a separate ticket. Especially now that cores are not deleted on 
startup if they don't exist in Zookeeper. 
https://github.com/apache/solr/pull/1321



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to