Skip to content

Commit cb3a3da

Browse files
K0zkaminchen07
authored andcommitted
simplify setCpuUsed
- variables inlined - cpu utilization is not cast to float from double Signed-off-by: Laszlo Hornyak <laszlo.hornyak@gmail.com> Signed-off-by: Min Chen <min.chen@citrix.com>
1 parent d3237e7 commit cb3a3da

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

‎server/src/com/cloud/api/query/dao/UserVmJoinDaoImpl.java‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,10 @@ public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm,
166166
userVmResponse.setKeyPairName(userVm.getKeypairName());
167167

168168
if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
169-
DecimalFormat decimalFormat = new DecimalFormat("#.##");
170169
// stats calculation
171-
String cpuUsed = null;
172170
VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
173171
if (vmStats != null) {
174-
float cpuUtil = (float) vmStats.getCPUUtilization();
175-
cpuUsed = decimalFormat.format(cpuUtil) + "%";
176-
userVmResponse.setCpuUsed(cpuUsed);
172+
userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%");
177173

178174
userVmResponse.setNetworkKbsRead((long) vmStats.getNetworkReadKBs());
179175

0 commit comments

Comments
 (0)