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-11272. Statistics some node status information #7025

Merged
merged 4 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -227,6 +227,15 @@ public int getHealthyVolumeCount() {
}
}

public int getFailedVolumeCount() {
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
try {
lock.readLock().lock();
return failedVolumeCount;
} finally {
lock.readLock().unlock();
}
}

/**
* Returns count of healthy metadata volumes reported from datanode.
* @return count of healthy metdata log volumes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
Expand Down Expand Up @@ -477,6 +478,22 @@ public List<DatanodeInfo> getDeadNodes() {
return getNodes(null, NodeState.DEAD);
}

public List<DatanodeInfo> getDecommissioningNodes() {
return getNodes(NodeOperationalState.DECOMMISSIONING, null);
}

public int getDecommissioningNodeCount() {
return getDecommissioningNodes().size();
}

public List<DatanodeInfo> getEnteringMaintenanceNodes() {
return getNodes(NodeOperationalState.ENTERING_MAINTENANCE, null);
}

public int getEnteringMaintenanceNodeCount() {
return getEnteringMaintenanceNodes().size();
}
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved

/**
* Returns all the nodes with the specified status.
*
Expand All @@ -501,6 +518,26 @@ public List<DatanodeInfo> getNodes(
return nodeStateMap.getDatanodeInfos(opState, health);
}

public List<DatanodeInfo> getVolumeFailuresNodes() {
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
List<DatanodeInfo> allNodes = nodeStateMap.getAllDatanodeInfos();
if (allNodes.size() < 1) {
return allNodes;
}
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved

List<DatanodeInfo> failedVolumeNodes = new ArrayList<>();
for (DatanodeInfo dn : allNodes) {
if (dn.getFailedVolumeCount() > 0) {
failedVolumeNodes.add(dn);
}
}

return failedVolumeNodes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Can use Java Stream API filter for conciseness.

}

public int getVolumeFailuresNodeCount() {
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
return getVolumeFailuresNodes().size();
}

/**
* Returns all the nodes which have registered to NodeStateManager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,8 @@ public Map<String, String> getNodeStatistics() {
Map<String, String> nodeStatistics = new HashMap<>();
// Statistics node usaged
nodeUsageStatistics(nodeStatistics);
// Statistics node states
nodeStateStatistics(nodeStatistics);
// todo: Statistics of other instances
return nodeStatistics;
}
Expand Down Expand Up @@ -1265,6 +1267,19 @@ private void nodeUsageStatistics(Map<String, String> nodeStatics) {
nodeStatics.put(UsageStatics.STDEV.getLabel(), decimalFormat.format(dev));
}

private void nodeStateStatistics(Map<String, String> nodeStatics) {
int healthyNodeCount = nodeStateManager.getHealthyNodeCount();
int deadNodeCount = nodeStateManager.getDeadNodeCount();
int decommissioningNodeCount = nodeStateManager.getDecommissioningNodeCount();
int enteringMaintenanceNodeCount = nodeStateManager.getEnteringMaintenanceNodeCount();
int volumeFailuresNodeCount = nodeStateManager.getVolumeFailuresNodeCount();
nodeStatics.put(StateStatics.HEALTHY.getLabel(), String.valueOf(healthyNodeCount));
nodeStatics.put(StateStatics.DEAD.getLabel(), String.valueOf(deadNodeCount));
nodeStatics.put(StateStatics.DECOMMISSIONING.getLabel(), String.valueOf(decommissioningNodeCount));
nodeStatics.put(StateStatics.ENTERING_MAINTENANCE.getLabel(), String.valueOf(enteringMaintenanceNodeCount));
nodeStatics.put(StateStatics.VOLUME_FAILURES.getLabel(), String.valueOf(volumeFailuresNodeCount));
}

/**
* Based on the current time and the last heartbeat, calculate the time difference
* and get a string of the relative value. E.g. "2s ago", "1m 2s ago", etc.
Expand Down Expand Up @@ -1346,6 +1361,21 @@ public String getLabel() {
}
}

private enum StateStatics {
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
HEALTHY("Healthy"),
DEAD("Dead"),
DECOMMISSIONING("Decommissioning"),
ENTERING_MAINTENANCE("EnteringMaintenance"),
VOLUME_FAILURES("VolumeFailures");
private String label;
public String getLabel() {
return label;
}
StateStatics(String label) {
this.label = label;
}
}

/**
* Returns the min of no healthy volumes reported out of the set
* of datanodes constituting the pipeline.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,30 @@ <h2>Statistics</h2>
<td>Standard Deviation</td>
<td>{{statistics.nodes.usages.stdev}}</td>
</tr>
<tr>
<th>Datanode State</th>
<th>Count</th>
</tr>
<tr>
<td>Healthy Nodes</td>
<td>{{statistics.nodes.state.healthy}}</td>
</tr>
<tr>
<td>Dead Nodes</td>
<td>{{statistics.nodes.state.dead}}</td>
</tr>
<tr>
<td>Decommissioning Nodes</td>
<td>{{statistics.nodes.state.decommissioning}}</td>
</tr>
<tr>
<td>Entering Maintenance Nodes</td>
<td>{{statistics.nodes.state.enteringmaintenance}}</td>
</tr>
<tr>
<td>Volume Failures Nodes</td>
<td>{{statistics.nodes.state.volumefailures}}</td>
</tr>
ivandika3 marked this conversation as resolved.
Show resolved Hide resolved
</tbody>
</table>

Expand Down
35 changes: 26 additions & 9 deletions hadoop-hdds/server-scm/src/main/resources/webapps/scm/scm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
max : "N/A",
median : "N/A",
stdev : "N/A"
},
state : {
healthy : "N/A",
dead : "N/A",
decommissioning : "N/A",
enteringmaintenance : "N/A",
volumefailures : "N/A"
}
}
}
Expand Down Expand Up @@ -92,15 +99,25 @@
$scope.lastIndex = Math.ceil(nodeStatusCopy.length / $scope.RecordsToDisplay);
$scope.nodeStatus = nodeStatusCopy.slice(0, $scope.RecordsToDisplay);

ctrl.nodemanagermetrics.NodeStatistics.forEach(function(obj) {
if(obj.key == "Min") {
$scope.statistics.nodes.usages.min = obj.value;
} else if(obj.key == "Max") {
$scope.statistics.nodes.usages.max = obj.value;
} else if(obj.key == "Median") {
$scope.statistics.nodes.usages.median = obj.value;
} else if(obj.key == "Stdev") {
$scope.statistics.nodes.usages.stdev = obj.value;
ctrl.nodemanagermetrics.NodeStatistics.forEach(({key, value}) => {
if(key == "Min") {
$scope.statistics.nodes.usages.min = value;
} else if(key == "Max") {
$scope.statistics.nodes.usages.max = value;
} else if(key == "Median") {
$scope.statistics.nodes.usages.median = value;
} else if(key == "Stdev") {
$scope.statistics.nodes.usages.stdev = value;
} else if(key == "Healthy") {
$scope.statistics.nodes.state.healthy = value;
} else if(key == "Dead") {
$scope.statistics.nodes.state.dead = value;
} else if(key == "Decommissioning") {
$scope.statistics.nodes.state.decommissioning = value;
} else if(key == "EnteringMaintenance") {
$scope.statistics.nodes.state.enteringmaintenance = value;
} else if(key == "VolumeFailures") {
$scope.statistics.nodes.state.volumefailures = value;
}
});
});
Expand Down