-
Notifications
You must be signed in to change notification settings - Fork 490
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-11206. Statistics storage usage indicators include min, max, median, stdev #6977
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,6 +83,7 @@ | |
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.Arrays; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
import java.util.concurrent.ScheduledFuture; | ||
import java.util.concurrent.TimeUnit; | ||
|
@@ -1217,6 +1218,47 @@ public static String[] calculateStoragePercentage( | |
return storagePercentage; | ||
} | ||
|
||
@Override | ||
public Map<String, String> getNodeStatics() { | ||
if (nodeStateManager.getAllNodes().size() < 1) { | ||
return new HashMap<>(); | ||
} | ||
Map<String, String> nodeStatics = new HashMap<>(); | ||
float[] usages = new float[nodeStateManager.getAllNodes().size()]; | ||
float totalOzoneUsed = 0; | ||
int i = 0; | ||
for (DatanodeInfo dni : nodeStateManager.getAllNodes()) { | ||
String[] storagePercentage = calculateStoragePercentage( | ||
dni.getStorageReports()); | ||
if (storagePercentage[0].equals("N/A")) { | ||
usages[i++] = 0; | ||
} else { | ||
float storagePerc = Float.parseFloat(storagePercentage[0]); | ||
usages[i++] = storagePerc; | ||
totalOzoneUsed = totalOzoneUsed + storagePerc; | ||
} | ||
} | ||
|
||
totalOzoneUsed /= nodeStateManager.getAllNodes().size(); | ||
Arrays.sort(usages); | ||
float median = usages[usages.length / 2]; | ||
nodeStatics.put(UsageStatics.MEDINNA.getLabel(), String.valueOf(median)); | ||
float max = usages[usages.length - 1]; | ||
nodeStatics.put(UsageStatics.MAX.getLabel(), String.valueOf(max)); | ||
float min = usages[0]; | ||
nodeStatics.put(UsageStatics.MIN.getLabel(), String.valueOf(min)); | ||
|
||
float dev = 0; | ||
for (i = 0; i < usages.length; i++) { | ||
dev += (usages[i] - totalOzoneUsed) * (usages[i] - totalOzoneUsed); | ||
} | ||
dev = (float) Math.sqrt(dev / usages.length); | ||
DecimalFormat decimalFormat = new DecimalFormat("#0.00"); | ||
decimalFormat.setRoundingMode(RoundingMode.HALF_UP); | ||
nodeStatics.put(UsageStatics.STDEV.getLabel(), decimalFormat.format(dev)); | ||
return nodeStatics; | ||
} | ||
|
||
/** | ||
* 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. | ||
|
@@ -1284,6 +1326,20 @@ public String getLabel() { | |
} | ||
} | ||
|
||
private enum UsageStatics { | ||
MIN("Min"), | ||
MAX("Max"), | ||
MEDINNA("Medina"), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comment and review, @ivandika3 . |
||
STDEV("Stdev"); | ||
private String label; | ||
public String getLabel() { | ||
return label; | ||
} | ||
UsageStatics(String label) { | ||
this.label = label; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the min of no healthy volumes reported out of the set | ||
* of datanodes constituting the pipeline. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,13 @@ | |
$scope.RecordsToDisplay = "10"; | ||
$scope.currentPage = 1; | ||
$scope.lastIndex = 0; | ||
$scope.statistical = { | ||
usages : {} | ||
} | ||
$scope.statistical.usages.min = ""; | ||
$scope.statistical.usages.max = ""; | ||
$scope.statistical.usages.medina = ""; | ||
$scope.statistical.usages.stdev = ""; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: I think it's also better to be more specific that it is the statistics for DNs (since technically we can have statistics for SCM in the future). Maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have updated it. |
||
|
||
function get_protocol(URLScheme, value, baseProto, fallbackProto) { | ||
let protocol = "unknown" | ||
|
@@ -81,6 +88,18 @@ | |
$scope.totalItems = nodeStatusCopy.length; | ||
$scope.lastIndex = Math.ceil(nodeStatusCopy.length / $scope.RecordsToDisplay); | ||
$scope.nodeStatus = nodeStatusCopy.slice(0, $scope.RecordsToDisplay); | ||
|
||
ctrl.nodemanagermetrics.NodeStatics.map(({ key, value }) => { | ||
if(key == "Min") { | ||
$scope.statistical.usages.min = value; | ||
} else if(key == "Max") { | ||
$scope.statistical.usages.max = value; | ||
} else if(key == "Medina") { | ||
$scope.statistical.usages.medina = value; | ||
} else if(key == "Stdev") { | ||
$scope.statistical.usages.stdev = value; | ||
} | ||
}); | ||
}); | ||
/*if option is 'All' display all records else display specified record on page*/ | ||
$scope.UpdateRecordsToShow = () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo:
Statics
->Statistics
.Also applies to other instances of
Statics
in the patch.