Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HDDS-9303. Display leader in table and highlight current node in OM web UI #5311

Merged
merged 13 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -87,3 +87,7 @@ body {
word-wrap: break-word;
table-layout: fixed;
}

.om-roles-background {
background-color: #dcfbcd!important;
}
Original file line number Diff line number Diff line change
Expand Up @@ -812,39 +812,29 @@ public static String getOMAddressListPrintString(List<OMNodeDetails> omList) {
public static boolean isBucketSnapshotIndicator(String key) {
return key.startsWith(OM_SNAPSHOT_INDICATOR) && key.split("/").length == 2;
}

public static String format(List<ServiceInfo> nodes, int port,
String leaderId) {
StringBuilder sb = new StringBuilder();
public static List<List<String>> format(
List<ServiceInfo> nodes, int port, String leaderId) {
List<List<String>> omInfoList = new ArrayList<>();
// Ensuring OM's are printed in correct order
List<ServiceInfo> omNodes = nodes.stream()
.filter(node -> node.getNodeType() == HddsProtos.NodeType.OM)
.sorted(Comparator.comparing(ServiceInfo::getHostname))
.collect(Collectors.toList());
int count = 0;
for (ServiceInfo info : omNodes) {
// 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++;
String role = info.getOmRoleInfo().getNodeId().equals(leaderId)
? "LEADER" : "FOLLOWER";
List<String> omInfo = new ArrayList<>();
omInfo.add(info.getHostname());
omInfo.add(info.getOmRoleInfo().getNodeId());
omInfo.add(String.valueOf(port));
omInfo.add(role);
omInfoList.add(omInfo);
}
}
// Print Stand-alone if only one OM exists
if (count == 1) {
return "STANDALONE";
} else {
return sb.toString();
}
return omInfoList;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.apache.hadoop.hdds.annotation.InterfaceAudience;
import org.apache.hadoop.hdds.server.ServiceRuntimeInfo;
import java.util.List;

/**
* This is the JMX management interface for OM information.
Expand All @@ -29,7 +30,7 @@ public interface OMMXBean extends ServiceRuntimeInfo {

String getRpcPort();

String getRatisRoles();
List<List<String>> getRatisRoles();

String getRatisLogDirectory();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3010,25 +3010,33 @@ public String getRpcPort() {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ <h2>Status</h2>
<td>OM Id</td>
<td>{{$ctrl.role.Id}}</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>
Expand All @@ -49,6 +45,36 @@ <h2>Status</h2>
</tbody>
</table>

<h2>OM Roles (HA)</h2>
<h4 ng-show="$ctrl.overview.jmx.RatisRoles.length == 1 && $ctrl.overview.jmx.RatisRoles[0].length == 1">{{$ctrl.overview.jmx.RatisRoles[0][0]}}</h4>
<div ng-show="$ctrl.overview.jmx.RatisRoles.length > 1">
<table class="table table-striped table-bordered" class="col-md-6">
<thead>
<tr>
<th>Host Name</th>
<th>Node ID</th>
<th>Ratis Port</th>
<th>Role</th>
</tr>
</thead>
<tbody ng-repeat="roles in $ctrl.overview.jmx.RatisRoles">
<tr class="om-roles-background" ng-if="$ctrl.role.Id == roles[1]">
<td>{{roles[0]}}</td>
sumitagrawl marked this conversation as resolved.
Show resolved Hide resolved
<td>{{roles[1]}}</td>
<td>{{roles[2]}}</td>
<td>{{roles[3]}}</td>
</tr>
<tr ng-if="$ctrl.role.Id != roles[1]">
<td>{{roles[0]}}</td>
<td>{{roles[1]}}</td>
<td>{{roles[2]}}</td>
<td>{{roles[3]}}</td>
</tr>
</tbody>
</table>
</div>


<h2>Meta-Data Volume Information</h2>
<table class="table table-bordered table-striped" class="col-md-6">
<tbody>
Expand Down