Huang Kuan Hao created HDDS-16278:
-------------------------------------
Summary: Reuse DecimalFormat in SCMNodeManager statistics
Key: HDDS-16278
URL: https://issues.apache.org/jira/browse/HDDS-16278
Project: Apache Ozone
Issue Type: Sub-task
Reporter: Huang Kuan Hao
calculateStoragePercentage / convertUnit / nodeUsageStatistics build a
DecimalFormat per datanode inside the node-stats/JMX loops:
DecimalFormat decimalFormat = new DecimalFormat("#0.00");
decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
Fix: a shared ThreadLocal<DecimalFormat> per pattern (DecimalFormat is not
thread-safe), configured once:
private static final ThreadLocal<DecimalFormat> FMT_2 =
ThreadLocal.withInitial(() -> {
DecimalFormat f = new DecimalFormat("#0.00");
f.setRoundingMode(RoundingMode.HALF_UP);
return f;
});
Behavior unchanged.
File: hadoop-hdds/server-scm/.../scm/node/SCMNodeManager.java:1332,1359,1423
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]