Skip to content

Commit 7df1b43

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 ec3464b commit 7df1b43

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
@@ -165,14 +165,10 @@ public UserVmResponse newUserVmResponse(String objectName, UserVmJoinVO userVm,
165165
userVmResponse.setKeyPairName(userVm.getKeypairName());
166166

167167
if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
168-
DecimalFormat decimalFormat = new DecimalFormat("#.##");
169168
// stats calculation
170-
String cpuUsed = null;
171169
VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
172170
if (vmStats != null) {
173-
float cpuUtil = (float) vmStats.getCPUUtilization();
174-
cpuUsed = decimalFormat.format(cpuUtil) + "%";
175-
userVmResponse.setCpuUsed(cpuUsed);
171+
userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%");
176172

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

0 commit comments

Comments
 (0)