You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/10/17 16:48:33 UTC

[GitHub] [hadoop-ozone] hanishakoneru commented on a change in pull request #9: HDDS-2240. Command line tool for OM Admin

hanishakoneru 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_r336114811
 
 

 ##########
 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:
   Thanks Dinesh. Fixed it.

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


With regards,
Apache Git Services

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