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


##########
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:
   Yeah I do think this is the correct API for that, but it (REPLACENODE) is 
not currently able to do that. AFAIK.
   
   I think we should make this a param as a part of MigrateReplicas and 
ReplaceNode. (`migrateFromNonLiveNodes` or something like that). That would 
somewhat necessitate `solr.deleteUnknownCores`, from the above linked PR, to be 
set to `true`, so that when the node is started back up, it deletes the data 
directories from those nodes.
   
   Again, I think this should be done in a separate JIRA/PR.  



-- 
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: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to