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/02/10 07:25:07 UTC

[GitHub] [ozone] amaliujia commented on a change in pull request #1916: HDDS-4812. Move Ratis group creation to scm --init phase

amaliujia commented on a change in pull request #1916:
URL: https://github.com/apache/ozone/pull/1916#discussion_r573498042



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java
##########
@@ -189,8 +199,11 @@ public RaftPeerId getPeerId() {
       return selfPeerId;
     }
 
+    /**
+     * This will be used when the SCM HA config are not defined.
+     */
     SCMHAGroupBuilder(final SCMHAConfiguration haConf,
-                      final ConfigurationSource conf) throws IOException {
+        final ConfigurationSource conf, String clusterId) throws IOException {

Review comment:
       Can you clarify why use `clusterId` as RaftGroup id?  Is it useful somehow later?

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java
##########
@@ -69,19 +71,27 @@
     this.scm = scm;
     this.address = haConf.getRatisBindAddress();
 
-    SCMHAGroupBuilder haGrpBuilder = new SCMHAGroupBuilder(haConf, conf);
+    RaftServer server =
+        newRaftServer(scm.getClusterId(), scm.getSCMHANodeDetails(), haConf,
+            conf).setStateMachine(new SCMStateMachine(scm, this, buffer))
+            .build();
 
-    final RaftProperties serverProperties = RatisUtil
-        .newRaftProperties(haConf, conf);
-
-    RaftServer server = RaftServer.newBuilder()
-        .setServerId(haGrpBuilder.getPeerId())
-        .setGroup(haGrpBuilder.getRaftGroup())
-        .setProperties(serverProperties)
-        .setStateMachine(new SCMStateMachine(scm, this, buffer))
-        .build();
+    this.division =
+        server.getDivision(server.getGroups().iterator().next().getGroupId());
+  }
 
-    this.division = server.getDivision(haGrpBuilder.getRaftGroupId());
+  public static RaftServer.Builder newRaftServer(final String clusterId,
+      final SCMHANodeDetails haDetails, final SCMHAConfiguration haConf,
+      final ConfigurationSource conf) throws IOException {
+    final String scmNodeId = haDetails.getLocalNodeDetails().getNodeId();
+    SCMHAGroupBuilder haGrpBuilder = scmNodeId != null ?
+        new SCMHAGroupBuilder(haDetails, clusterId) :
+        new SCMHAGroupBuilder(haConf, conf, clusterId);
+    final RaftProperties serverProperties =
+        RatisUtil.newRaftProperties(haConf, conf);
+    return RaftServer.newBuilder().setServerId(haGrpBuilder.getPeerId())
+            .setGroup(haGrpBuilder.getRaftGroup())
+            .setProperties(serverProperties).setStateMachine(null);

Review comment:
       Why not pass StateMachine as a parameter to `newRaftServer`? 




----------------------------------------------------------------
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.

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