dineshchitlangia commented on a change in pull request #9: HDDS-2240. Command 
line tool for OM Admin
URL: https://github.com/apache/hadoop-ozone/pull/9#discussion_r334744659
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/ratis/OzoneManagerRatisServer.java
 ##########
 @@ -617,13 +620,45 @@ private void setServerRole(RaftPeerRole currentRole,
     }
   }
 
-  private GroupInfoReply getGroupInfo() throws IOException {
+  public GroupInfoReply getGroupInfo() throws IOException {
     GroupInfoRequest groupInfoRequest = new GroupInfoRequest(clientId,
         raftPeerId, raftGroupId, nextCallId());
     GroupInfoReply groupInfo = server.getGroupInfo(groupInfoRequest);
     return groupInfo;
   }
 
+  public Map<String, String> getServerRoles() throws IOException {
+    GroupInfoReply groupInfo = getGroupInfo();
+    if (groupInfo == null) {
+      throw new IOException(ozoneManager.getOMNodeId() +
+          ": Failed to get GroupInfo.");
+    } else {
+      Map<String, String> serverRoles = new HashMap<>();
+
+      RoleInfoProto roleInfoProto = groupInfo.getRoleInfoProto();
+      String selfNodeId = new String(roleInfoProto.getSelf().getId()
+          .toByteArray(), StandardCharsets.UTF_8);
+      String selfRole = roleInfoProto.getRole().name();
+      serverRoles.put(selfNodeId, selfRole);
+
+      if (roleInfoProto.hasLeaderInfo()) {
+        for (ServerRpcProto followerInfo :
+            roleInfoProto.getLeaderInfo().getFollowerInfoList()) {
+          String nodeId = new String(
+              followerInfo.getId().getId().toByteArray());
 
 Review comment:
   Findbugs violation: Specify encoding scheme.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org

Reply via email to