You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/09/29 02:17:33 UTC

[GitHub] [ozone] Xushaohong commented on a change in pull request #2686: HDDS-5686. Support transfer leadership in raft based ha cluster

Xushaohong commented on a change in pull request #2686:
URL: https://github.com/apache/ozone/pull/2686#discussion_r718097028



##########
File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/failover/FailoverCommand.java
##########
@@ -0,0 +1,369 @@
+/*
+ * 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.hadoop.ozone.admin.failover;
+
+import org.apache.commons.lang3.EnumUtils;
+import org.apache.hadoop.hdds.NodeDetails;
+import org.apache.hadoop.hdds.cli.GenericCli;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.cli.OzoneAdmin;
+import org.apache.hadoop.hdds.cli.SubcommandWithParent;
+import org.apache.hadoop.hdds.conf.ConfigurationException;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.ScmConfigKeys;
+import org.apache.hadoop.hdds.scm.ha.SCMHAUtils;
+import org.apache.hadoop.ozone.OmUtils;
+import org.apache.hadoop.ozone.ha.ConfUtils;
+import org.apache.hadoop.ozone.om.OMConfigKeys;
+import org.apache.hadoop.ozone.om.ha.OMHANodeDetails;
+import org.apache.ratis.client.RaftClient;
+import org.apache.ratis.client.RaftClientConfigKeys;
+import org.apache.ratis.client.api.GroupManagementApi;
+import org.apache.ratis.conf.Parameters;
+import org.apache.ratis.conf.RaftProperties;
+import org.apache.ratis.proto.RaftProtos;
+import org.apache.ratis.protocol.*;
+import org.apache.ratis.retry.ExponentialBackoffRetry;
+import org.apache.ratis.util.TimeDuration;
+import org.kohsuke.MetaInfServices;
+import picocli.CommandLine;
+
+import java.io.IOException;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+import static org.apache.hadoop.hdds.scm.ScmConfigKeys.*;
+
+/**
+ * Subcommand for admin operations related to failover actions.
+ */
+@CommandLine.Command(
+    name = "failover",
+    description = "manually transfer leadership of raft group to target node",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class
+)
+@MetaInfServices(SubcommandWithParent.class)
+public class FailoverCommand extends GenericCli
+    implements SubcommandWithParent {
+
+  public static final RaftGroupId PSEUDO_RAFT_GROUP_ID = RaftGroupId.randomId();
+  public static final int TRANSFER_LEADER_WAIT_MS = 120_000;
+  public static final String RANDOM = "RANDOM";
+
+  enum Domain {
+    OM,
+    SCM,
+  }
+
+  @CommandLine.ParentCommand
+  private OzoneAdmin parent;
+
+  @CommandLine.Parameters(
+      description = "['om'/'scm']"
+  )
+  private String domain;
+
+  @CommandLine.Parameters(
+      description = "[host/host:port/'random'] ratis rpc address of " +
+      "target domain if 'random' then choose arbitrary follower node "
+  )
+  private String tgtAddress;
+
+  @CommandLine.Option(
+      names = {"-id", "--service-id"},

Review comment:
       This is for the case where SCMs have consistent but different ports from the default. This key ```OZONE_SCM_RATIS_PORT_KEY``` is only used between SCM nodes right now and the config of the client may not cover it.
   Another scenario could be that SCMs have inconsistent ratis ports such as MiniOzoneCluster.




-- 
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-unsubscribe@ozone.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org