bharatviswa504 commented on a change in pull request #1916:
URL: https://github.com/apache/ozone/pull/1916#discussion_r573441300
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java
##########
@@ -227,12 +240,62 @@ public RaftPeerId getPeerId() {
"localHost: {}, OZONE_SCM_NAMES: {}, selfPeerId: {}",
localHost, conf.get(ScmConfigKeys.OZONE_SCM_NAMES), selfPeerId);
- raftGroupId = RaftGroupId.valueOf(UUID.nameUUIDFromBytes(
- SCM_SERVICE_ID.getBytes(StandardCharsets.UTF_8)));
+ String groupId = clusterId == null ? SCM_SERVICE_ID : clusterId;
+ raftGroupId = RaftGroupId.valueOf(
+ UUID.nameUUIDFromBytes(groupId.getBytes(StandardCharsets.UTF_8)));
raftGroup = RaftGroup.valueOf(raftGroupId, raftPeers);
}
+ SCMHAGroupBuilder(final SCMHANodeDetails details, final String clusterId) {
+
+ Preconditions.checkNotNull(clusterId);
+ // RaftGroupId is the clusterId
+ raftGroupId = RaftGroupId.valueOf(buildRaftGroupId(clusterId));
+ final String scmNodeId = details.getLocalNodeDetails().getNodeId();
+ Preconditions.checkNotNull(scmNodeId);
+ selfPeerId = RaftPeerId.getRaftPeerId(scmNodeId);
+ Preconditions.checkNotNull(scmNodeId);
Review comment:
Minor: Redundant line.
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java
##########
@@ -227,12 +240,62 @@ public RaftPeerId getPeerId() {
"localHost: {}, OZONE_SCM_NAMES: {}, selfPeerId: {}",
localHost, conf.get(ScmConfigKeys.OZONE_SCM_NAMES), selfPeerId);
- raftGroupId = RaftGroupId.valueOf(UUID.nameUUIDFromBytes(
- SCM_SERVICE_ID.getBytes(StandardCharsets.UTF_8)));
+ String groupId = clusterId == null ? SCM_SERVICE_ID : clusterId;
+ raftGroupId = RaftGroupId.valueOf(
+ UUID.nameUUIDFromBytes(groupId.getBytes(StandardCharsets.UTF_8)));
raftGroup = RaftGroup.valueOf(raftGroupId, raftPeers);
}
+ SCMHAGroupBuilder(final SCMHANodeDetails details, final String clusterId) {
+
+ Preconditions.checkNotNull(clusterId);
+ // RaftGroupId is the clusterId
+ raftGroupId = RaftGroupId.valueOf(buildRaftGroupId(clusterId));
+ final String scmNodeId = details.getLocalNodeDetails().getNodeId();
+ Preconditions.checkNotNull(scmNodeId);
+ selfPeerId = RaftPeerId.getRaftPeerId(scmNodeId);
+ Preconditions.checkNotNull(scmNodeId);
+ SCMNodeDetails localNodeDetails = details.getLocalNodeDetails();
+
+ InetSocketAddress ratisAddr =
+ new InetSocketAddress(localNodeDetails.getInetAddress(),
+ localNodeDetails.getRatisPort());
+
+ RaftPeer localRaftPeer =
+ RaftPeer.newBuilder().setId(selfPeerId).setAddress(ratisAddr)
+ .build();
+
+ List<RaftPeer> raftPeers = new ArrayList<>();
+ // Add this Ratis server to the Ratis ring
+ raftPeers.add(localRaftPeer);
+
+ for (SCMNodeDetails peerInfo : details.getPeerNodeDetails()) {
+ String peerNodeId = peerInfo.getNodeId();
+ RaftPeerId raftPeerId = RaftPeerId.valueOf(peerNodeId);
+ RaftPeer raftPeer;
+ if (peerInfo.isHostUnresolved()) {
+ raftPeer = RaftPeer.newBuilder().setId(raftPeerId)
Review comment:
Question: When the host is unresolved, we still construct raftPeer, do
we fail here if it might be due to incorrect hostname. I see OM also followed
similar approach, just trying to understand reason.
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java
##########
@@ -227,12 +240,62 @@ public RaftPeerId getPeerId() {
"localHost: {}, OZONE_SCM_NAMES: {}, selfPeerId: {}",
localHost, conf.get(ScmConfigKeys.OZONE_SCM_NAMES), selfPeerId);
- raftGroupId = RaftGroupId.valueOf(UUID.nameUUIDFromBytes(
- SCM_SERVICE_ID.getBytes(StandardCharsets.UTF_8)));
+ String groupId = clusterId == null ? SCM_SERVICE_ID : clusterId;
Review comment:
Question: In which scenario clusterID will be null, both in HA/non-HA
clusterID would be there and it will be generated during init step right?
----------------------------------------------------------------
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]