Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hdds.conf.ConfigurationSource;
import org.apache.hadoop.hdds.conf.OzoneConfiguration;
import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
import org.apache.hadoop.hdds.scm.client.HddsClientUtils;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.ozone.conf.OMClientConfig;
Expand All @@ -49,6 +50,7 @@
import org.apache.hadoop.ozone.om.helpers.OMNodeDetails;
import org.apache.hadoop.ozone.om.helpers.OmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.RepeatedOmKeyInfo;
import org.apache.hadoop.ozone.om.helpers.ServiceInfo;
import org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -789,4 +791,31 @@ public static String getOMAddressListPrintString(List<OMNodeDetails> omList) {
printString.append("]");
return printString.toString();
}

public static String format(List<ServiceInfo> nodes, int port,
String leaderId) {
StringBuilder sb = new StringBuilder();
int count = 0;
for (ServiceInfo info : nodes) {
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated
// Printing only the OM's running
String role = info.getHostname().equals(leaderId) ? "LEADER" : "FOLLOWER";
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated
if (info.getNodeType() == HddsProtos.NodeType.OM) {
sb.append(
String.format(
" { HostName: %s | Node-Id: %s | Ratis-Port : %d | Role: %s} ",
info.getHostname(),
info.getOmRoleInfo().getNodeId(),
port,
role
));
count++;
}
}
// Print Stand-alone if only one OM exists
if (count == 1) {
return "STANDALONE";
} else {
return sb.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ public interface OMMXBean extends ServiceRuntimeInfo {

String getRpcPort();

String getOmRatisRoles();
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated

String getRatisLogDirectory();

String getRocksDbDirectory();

Comment thread
ArafatKhan2198 marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@
import static org.apache.hadoop.ozone.protocol.proto.OzoneManagerProtocolProtos.PrepareStatusResponse.PrepareStatus;
import org.apache.ratis.proto.RaftProtos.RaftPeerRole;
import org.apache.ratis.protocol.RaftGroupId;
import org.apache.ratis.protocol.RaftPeer;
import org.apache.ratis.protocol.RaftPeerId;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.ratis.util.ExitUtils;
Expand Down Expand Up @@ -2966,6 +2967,20 @@ public String getRpcPort() {
}

@Override
public String getOmRatisRoles() {
List<ServiceInfo> serviceList = null;
int port = omNodeDetails.getRatisPort();
RaftPeer leaderId;
try {
leaderId = omRatisServer.getLeader();
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated
serviceList = getServiceList();
} catch (IOException e) {
Comment thread
sadanand48 marked this conversation as resolved.
Outdated
LOG.error("IO-Exception Occurred", e);
return "Exception: " + e.toString();
}
return OmUtils.format(serviceList, port, leaderId.getId().toString());
}

public String getRatisLogDirectory() {
return OzoneManagerRatisUtils.getOMRatisDirectory(configuration);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.apache.ratis.server.RaftServer;
import org.apache.ratis.server.RaftServerConfigKeys;
import org.apache.ratis.server.protocol.TermIndex;
import org.apache.ratis.thirdparty.com.google.protobuf.ByteString;
import org.apache.ratis.util.LifeCycle;
import org.apache.ratis.util.SizeInBytes;
import org.apache.ratis.util.StringUtils;
Expand Down Expand Up @@ -728,6 +729,18 @@ private static Map<String, String> getOMHAConfigs(
.getPropsMatchPrefixAndTrimPrefix(OZONE_OM_HA_PREFIX + ".");
}

public RaftPeer getLeader() throws IOException {
RaftServer.Division division = server.getDivision(raftGroupId);
if (division.getInfo().isLeader()) {
return division.getPeer();
} else {
ByteString leaderId = division.getInfo().getRoleInfoProto()
.getFollowerInfo().getLeaderInfo().getId().getId();
return leaderId.isEmpty() ? null :
division.getRaftConf().getPeer(RaftPeerId.valueOf(leaderId));
}
}

/**
* Defines RaftServer Status.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ <h2>Status</h2>
<td>Rpc port</td>
<td>{{$ctrl.overview.jmx.RpcPort}}</td>
</tr>
<tr ng-hide="!$ctrl.overview.jmx.RatisLeader">
<td>Leader-Id</td>
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated
<td>{{$ctrl.overview.jmx.RatisLeader}}</td>
</tr>
<tr>
<td>OM Roles (HA) </td>
<td>{{$ctrl.overview.jmx.OmRatisRoles}}</td>
</tr>
<tr>
<td>Current-Role</td>
<td>{{$ctrl.role.Role}}</td>
</tr>
<tr>
<td>Group-Id</td>
<td>{{$ctrl.role.GroupId}}</td>
</tr>
</tbody>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,12 @@
require: {
overview: "^overview"
},
controller: function ($http) {
var ctrl = this;
$http.get("jmx?qry=Ratis:service=RaftServer,group=*,id=*")
.then(function (result) {
Comment thread
ArafatKhan2198 marked this conversation as resolved.
ctrl.role = result.data.beans[0];
});
}
});
})();