[ 
https://issues.apache.org/jira/browse/HDDS-16278?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

ASF GitHub Bot updated HDDS-16278:
----------------------------------
    Labels: pull-request-available  (was: )

> 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
>            Assignee: Huang Kuan Hao
>            Priority: Major
>              Labels: pull-request-available
>
> 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]

Reply via email to