geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kl...@apache.org
Subject [09/20] incubator-geode git commit: GEODE-907: Clean up some issues after rebasing
Date Wed, 24 Feb 2016 22:07:28 GMT
GEODE-907: Clean up some issues after rebasing

- CPU usage should be a double and not a string


Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/f42c86d8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/f42c86d8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/f42c86d8

Branch: refs/heads/feature/GEODE-953
Commit: f42c86d81c4e9d84432056c508831a26d9e946d7
Parents: 022733e
Author: Jens Deppe <jdeppe@pivotal.io>
Authored: Sat Feb 20 21:56:25 2016 -0800
Committer: Jens Deppe <jdeppe@pivotal.io>
Committed: Tue Feb 23 14:04:51 2016 -0800

----------------------------------------------------------------------
 geode-pulse/build.gradle                                |  3 +++
 .../pulse/internal/service/ClusterMemberService.java    | 12 ++++++++----
 .../pulse/controllers/PulseControllerJUnitTest.java     |  3 +--
 3 files changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f42c86d8/geode-pulse/build.gradle
----------------------------------------------------------------------
diff --git a/geode-pulse/build.gradle b/geode-pulse/build.gradle
index cf07751..4879345 100755
--- a/geode-pulse/build.gradle
+++ b/geode-pulse/build.gradle
@@ -36,6 +36,9 @@ dependencies {
   compile 'org.springframework.security:spring-security-ldap:' + project.'spring-security.version'
   compile 'org.springframework.security:spring-security-web:' + project.'spring-security.version'
   compile 'org.springframework:spring-tx:' + project.'spring-tx.version'
+  compile 'com.fasterxml.jackson.core:jackson-annotations:' + project.'jackson.version'
+  compile 'com.fasterxml.jackson.core:jackson-core:' + project.'jackson.version'
+  compile 'com.fasterxml.jackson.core:jackson-databind:' + project.'jackson.version'
 
   providedCompile 'commons-logging:commons-logging:' + project.'commons-logging.version'
 

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f42c86d8/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
index 4b535cb..25c405a 100644
--- a/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
+++ b/geode-pulse/src/main/java/com/vmware/gemfire/tools/pulse/internal/service/ClusterMemberService.java
@@ -32,6 +32,8 @@ import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Service;
 
 import javax.servlet.http.HttpServletRequest;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.ArrayList;
 import java.util.List;
@@ -89,19 +91,17 @@ public class ClusterMemberService implements PulseService {
       }
       memberJSON.put("redundancyZones", mapper.valueToTree(redundancyZones));
 
-      DecimalFormat df2 = new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN);
-
       long usedHeapSize = cluster.getUsedHeapSize();
       long currentHeap = clusterMember.getCurrentHeapSize();
       if (usedHeapSize > 0) {
         double heapUsage = ((double) currentHeap / (double) usedHeapSize) * 100;
-        memberJSON.put(this.HEAP_USAGE, Double.valueOf(df2.format(heapUsage)));
+        memberJSON.put(this.HEAP_USAGE, truncate(heapUsage, 2));
       } else {
         memberJSON.put(this.HEAP_USAGE, 0);
       }
       double currentCPUUsage = clusterMember.getCpuUsage();
 
-      memberJSON.put("cpuUsage", df2.format(currentCPUUsage));
+      memberJSON.put("cpuUsage", truncate(currentCPUUsage, 2));
       memberJSON.put("currentHeapUsage", clusterMember.getCurrentHeapSize());
       memberJSON.put("isManager", clusterMember.isManager());
       memberJSON.put("uptime", TimeUtils.convertTimeSecondsToHMS(clusterMember.getUptime()));
@@ -125,4 +125,8 @@ public class ClusterMemberService implements PulseService {
     // Send json response
     return responseJSON;
   }
+
+  private double truncate(double value, int places) {
+    return new BigDecimal(value).setScale(places, RoundingMode.HALF_UP).doubleValue();
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/f42c86d8/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
index 664126d..9ae6c0c 100644
--- a/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
+++ b/geode-pulse/src/test/java/com/vmware/gemfire/tools/pulse/controllers/PulseControllerJUnitTest.java
@@ -3,7 +3,6 @@ package com.vmware.gemfire.tools.pulse.controllers;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.gemstone.gemfire.test.junit.categories.UnitTest;
 import com.vmware.gemfire.tools.pulse.internal.PulseAppListener;
-import com.vmware.gemfire.tools.pulse.internal.ServiceConfiguration;
 import com.vmware.gemfire.tools.pulse.internal.controllers.PulseController;
 import com.vmware.gemfire.tools.pulse.internal.data.Cluster;
 import com.vmware.gemfire.tools.pulse.internal.data.PulseConfig;
@@ -123,7 +122,7 @@ public class PulseControllerJUnitTest {
     member.setUptime(1L);
     member.setHost(PHYSICAL_HOST_NAME);
     member.setGemfireVersion(GEMFIRE_VERSION);
-    member.setCpuUsage(55.77D);
+    member.setCpuUsage(55.77123D);
 
     member.setMemberRegions(new HashMap<String, Cluster.Region>() {{
       put(REGION_NAME, region);


Mime
View raw message