Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 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,33 @@ 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
if (info.getNodeType() == HddsProtos.NodeType.OM) {
String role =
info.getOmRoleInfo().getNodeId().equals(leaderId) ? "LEADER" :
"FOLLOWER";
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 "Not Applicable";
} else {
return sb.toString();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public interface OMMXBean extends ServiceRuntimeInfo {

String getRpcPort();

String getRatisRoles();

String getRatisLogDirectory();

String getRocksDbDirectory();
Expand Down
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,24 @@ public String getRpcPort() {
}

@Override
public String getRatisRoles() {
List<ServiceInfo> serviceList = null;
int port = omNodeDetails.getRatisPort();
RaftPeer leaderId;
if (isRatisEnabled) {
try {
leaderId = omRatisServer.getLeader();
serviceList = getServiceList();
} catch (IOException e) {
LOG.error("IO-Exception Occurred", e);
return "Exception: " + e.toString();
}
return OmUtils.format(serviceList, port, leaderId.getId().toString());
} else {
return "Ratis-Disabled";
}
}

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,26 @@ <h2>Status</h2>
<td>Rpc port</td>
<td>{{$ctrl.overview.jmx.RpcPort}}</td>
</tr>
<tr>
<td>OM Roles (HA) </td>
<td>{{$ctrl.overview.jmx.RatisRoles}}</td>
</tr>
<tr>
<td>Current-Role</td>
<td>{{$ctrl.role.Role}}</td>
</tr>
<tr>
<td>Group-Id</td>
<td>{{$ctrl.role.GroupId}}</td>
</tr>
<tr ng-hide="!$ctrl.electionCount.Count">
<td>Election-Count</td>
<td>{{$ctrl.electionCount.Count}}</td>
</tr>
<tr ng-hide="!$ctrl.elapsedTime.Value">
<td>Last Election Elapsed Time</td>
<td>{{$ctrl.elapsedTime.Value}}</td>
</tr>
</tbody>
</table>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,36 @@
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];
});

$http.get("jmx?qry=ratis:name=ratis.leader_election.*electionCount")
.then(function (result) {
ctrl.electionCount = result.data.beans[0];
});

$http.get("jmx?qry=ratis:name=ratis.leader_election.*lastLeaderElectionElapsedTime")
.then(function (result) {
ctrl.elapsedTime = result.data.beans[0];
ctrl.elapsedTime.Value = convertMsToTime(ctrl.elapsedTime.Value);
});
}
});
function convertMsToTime(ms) {
if(ms == -1){
Comment thread
ArafatKhan2198 marked this conversation as resolved.
Outdated
return "";
}
let seconds = (ms / 1000).toFixed(1);
let minutes = (ms / (1000 * 60)).toFixed(1);
let hours = (ms / (1000 * 60 * 60)).toFixed(1);
let days = (ms / (1000 * 60 * 60 * 24)).toFixed(1);
if (seconds < 60) return seconds + " Seconds";
else if (minutes < 60) return minutes + " Minutes";
else if (hours < 24) return hours + " Hours";
else return days + " Days"
}
})();