hanishakoneru commented on a change in pull request #1494:
URL: https://github.com/apache/ozone/pull/1494#discussion_r657199346



##########
File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
##########
@@ -104,9 +104,127 @@
   private final RaftGroupId raftGroupId;
   private final RaftGroup raftGroup;
   private final RaftPeerId raftPeerId;
+  private final List<RaftPeer> raftPeers;
 
   private final OzoneManager ozoneManager;
   private final OzoneManagerStateMachine omStateMachine;
+  private final String ratisStorageDir;
+
+  private final ClientId clientId = ClientId.randomId();
+  private static final AtomicLong CALL_ID_COUNTER = new AtomicLong();
+
+  private static long nextCallId() {
+    return CALL_ID_COUNTER.getAndIncrement() & Long.MAX_VALUE;
+  }
+
+  /**
+   * Returns an OM Ratis server.
+   * @param conf configuration
+   * @param om the OM instance starting the ratis server
+   * @param raftGroupIdStr raft group id string
+   * @param localRaftPeerId raft peer id of this Ratis server
+   * @param addr address of the ratis server
+   * @param peers peer nodes in the raft ring
+   * @throws IOException
+   */
+  @SuppressWarnings({"parameternumber", "java:S107"})
+  private OzoneManagerRatisServer(ConfigurationSource conf, OzoneManager om,
+      String raftGroupIdStr, RaftPeerId localRaftPeerId,
+      InetSocketAddress addr, List<RaftPeer> peers,
+      SecurityConfig secConfig, CertificateClient certClient)
+      throws IOException {
+    this.ozoneManager = om;
+    this.omRatisAddress = addr;
+    this.port = addr.getPort();
+    this.ratisStorageDir = OzoneManagerRatisUtils.getOMRatisDirectory(conf);
+    RaftProperties serverProperties = newRaftProperties(conf);
+
+    this.raftPeerId = localRaftPeerId;
+    this.raftGroupId = RaftGroupId.valueOf(
+        getRaftGroupIdFromOmServiceId(raftGroupIdStr));
+    this.raftPeers = Lists.newArrayList();
+    this.raftPeers.addAll(peers);
+    this.raftGroup = RaftGroup.valueOf(raftGroupId, peers);
+
+    StringBuilder raftPeersStr = new StringBuilder();
+    for (RaftPeer peer : peers) {
+      raftPeersStr.append(", ").append(peer.getAddress());
+    }
+    LOG.info("Instantiating OM Ratis server with groupID: {} and " +
+        "peers: {}", raftGroupIdStr, raftPeersStr.toString().substring(2));
+
+    this.omStateMachine = getStateMachine(conf);
+
+    Parameters parameters = createServerTlsParameters(secConfig, certClient);
+    this.server = RaftServer.newBuilder()
+        .setServerId(this.raftPeerId)
+        .setGroup(this.raftGroup)
+        .setProperties(serverProperties)
+        .setParameters(parameters)
+        .setStateMachine(omStateMachine)
+        .build();
+  }
+
+  /**
+   * Creates an instance of OzoneManagerRatisServer.
+   */
+  public static OzoneManagerRatisServer newOMRatisServer(
+      ConfigurationSource ozoneConf, OzoneManager omProtocol,
+      OMNodeDetails omNodeDetails, List<OMNodeDetails> peerNodes,
+      SecurityConfig secConfig, CertificateClient certClient,
+      boolean isBootstrapping) throws IOException {
+
+    // RaftGroupId is the omServiceId
+    String omServiceId = omNodeDetails.getServiceId();
+
+    String omNodeId = omNodeDetails.getNodeId();
+    RaftPeerId localRaftPeerId = RaftPeerId.getRaftPeerId(omNodeId);
+
+    InetSocketAddress ratisAddr = new InetSocketAddress(
+        omNodeDetails.getInetAddress(), omNodeDetails.getRatisPort());
+
+    RaftPeer localRaftPeer = RaftPeer.newBuilder()
+        .setId(localRaftPeerId)
+        .setAddress(ratisAddr)
+        .build();
+
+    List<RaftPeer> raftPeers = new ArrayList<>();
+
+    // If the OM is started in bootstrap mode, do not add it to the ratis ring.
+    // It will be added later using SetConfiguration from the leader OM.
+    if (isBootstrapping) {
+      LOG.debug("OM started in Bootstrap mode and hence will not be added " +
+          "to Ratis group during startup.");
+    } else {
+      // On regular startup, add current OM to Ratis ring
+      raftPeers.add(localRaftPeer);
+    }
+
+    for (OMNodeDetails peerInfo : peerNodes) {
+      String peerNodeId = peerInfo.getNodeId();
+      RaftPeerId raftPeerId = RaftPeerId.valueOf(peerNodeId);

Review comment:
       Updated the patch. Please take a look. Thanks.




-- 
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:
[email protected]



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

Reply via email to