changeset 87:6e27e3007d8c

Store data as proper types using generics for Key Review thread: http://icedtea.classpath.org/pipermail/thermostat/2012-February/000097.html
author Jon VanAlten <vanaltj@gmail.com>
date Fri, 24 Feb 2012 19:18:02 -0500
parents df202ded9de9
children 76493f3d3aeb
files agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatVmListener.java agent/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatVmClassListenerTest.java client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java client/src/main/java/com/redhat/thermostat/client/VmRef.java common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatDAO.java common/src/main/java/com/redhat/thermostat/common/storage/Category.java common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java common/src/main/java/com/redhat/thermostat/common/storage/Key.java common/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatDAOTest.java pom.xml
diffstat 17 files changed, 170 insertions(+), 169 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java	Fri Feb 24 19:18:02 2012 -0500
@@ -68,20 +68,20 @@
     private static final Logger logger = LoggingUtils.getLogger(JvmStatHostListener.class);
 
     private static final Category vmInfoCategory = new Category("vm-info");
-    private static final Key vmInfoIdKey = new Key("vm-id", true);
-    private static final Key vmInfoPidKey = new Key("vm-pid", false);
-    private static final Key vmInfoRuntimeVersionKey = new Key("runtime-version", false);
-    private static final Key vmInfoJavaHomeKey = new Key("java-home", false);
-    private static final Key vmInfoMainClassKey = new Key("main-class", false);
-    private static final Key vmInfoCommandLineKey = new Key("command-line", false);
-    private static final Key vmInfoVmNameKey = new Key("vm-name", false);
-    private static final Key vmInfoVmArgumentsKey = new Key("vm-arguments", false);
-    private static final Key vmInfoVmInfoKey = new Key("vm-info", false);
-    private static final Key vmInfoVmVersionKey = new Key("vm-version", false);
-    private static final Key vmInfoEnvironmentKey = new Key("environment", false);
-    private static final Key vmInfoLibrariesKey = new Key("libraries", false);
-    private static final Key vmInfoStartTimeKey = new Key("start-time", false);
-    private static final Key vmInfoStopTimeKey = new Key("stop-time", false);
+    private static final Key<Integer> vmInfoIdKey = new Key<>("vm-id", true);
+    private static final Key<Integer> vmInfoPidKey = new Key<>("vm-pid", false);
+    private static final Key<String> vmInfoRuntimeVersionKey = new Key<>("runtime-version", false);
+    private static final Key<String> vmInfoJavaHomeKey = new Key<>("java-home", false);
+    private static final Key<String> vmInfoMainClassKey = new Key<>("main-class", false);
+    private static final Key<String> vmInfoCommandLineKey = new Key<>("command-line", false);
+    private static final Key<String> vmInfoVmArgumentsKey = new Key<>("vm-arguments", false);
+    private static final Key<String> vmInfoVmNameKey = new Key<>("vm-name", false);
+    private static final Key<String> vmInfoVmInfoKey = new Key<>("vm-info", false);
+    private static final Key<String> vmInfoVmVersionKey = new Key<>("vm-version", false);
+    private static final Key<Map<String, String>> vmInfoEnvironmentKey = new Key<>("environment", false);
+    private static final Key<List<String>> vmInfoLibrariesKey = new Key<>("libraries", false);
+    private static final Key<Long> vmInfoStartTimeKey = new Key<>("start-time", false);
+    private static final Key<Long> vmInfoStopTimeKey = new Key<>("stop-time", false);
 
     static {
         vmInfoCategory.addKey(vmInfoIdKey);
@@ -161,6 +161,7 @@
                 JvmStatDataExtractor extractor = new JvmStatDataExtractor(vm);
                 Map<String, String> properties = new HashMap<String, String>();
                 Map<String, String> environment = ProcessEnvironmentBuilder.build(vmId);
+                // TODO actually figure out the loaded libraries.
                 List<String> loadedNativeLibraries = new ArrayList<String>();
                 info = new VmInfo(vmId, startTime, stopTime,
                         extractor.getJavaVersion(), extractor.getJavaHome(),
@@ -206,8 +207,8 @@
 
         // FIXME save these as proper objects (ie. not as strings)
 
-        chunk.put(vmInfoIdKey, String.valueOf(info.getVmId()));
-        chunk.put(vmInfoPidKey, String.valueOf(info.getVmPid()));
+        chunk.put(vmInfoIdKey, info.getVmId());
+        chunk.put(vmInfoPidKey, info.getVmPid());
         chunk.put(vmInfoRuntimeVersionKey, info.getJavaVersion());
         chunk.put(vmInfoJavaHomeKey, info.getJavaHome());
         chunk.put(vmInfoMainClassKey, info.getMainClass());
@@ -216,17 +217,17 @@
         chunk.put(vmInfoVmNameKey, info.getVmName());
         chunk.put(vmInfoVmInfoKey, info.getVmInfo());
         chunk.put(vmInfoVmVersionKey, info.getVmVersion());
-        chunk.put(vmInfoEnvironmentKey, info.getEnvironment().toString());
-        chunk.put(vmInfoLibrariesKey, info.getLoadedNativeLibraries().toString());
-        chunk.put(vmInfoStartTimeKey, String.valueOf(info.getStartTimeStamp()));
-        chunk.put(vmInfoStopTimeKey, String.valueOf(info.getStopTimeStamp()));
+        chunk.put(vmInfoEnvironmentKey, info.getEnvironment());
+        chunk.put(vmInfoLibrariesKey, info.getLoadedNativeLibraries());
+        chunk.put(vmInfoStartTimeKey, info.getStartTimeStamp());
+        chunk.put(vmInfoStopTimeKey, info.getStopTimeStamp());
         return chunk;
     }
 
     private Chunk makeVmInfoUpdateStoppedChunk(int vmId, long stopTimeStamp) {
         Chunk chunk = new Chunk(vmInfoCategory, false);
-        chunk.put(vmInfoIdKey, String.valueOf(vmId));
-        chunk.put(vmInfoStopTimeKey, String.valueOf(stopTimeStamp));
+        chunk.put(vmInfoIdKey, vmId);
+        chunk.put(vmInfoStopTimeKey, stopTimeStamp);
         return chunk;
     }
 
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatVmListener.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatVmListener.java	Fri Feb 24 19:18:02 2012 -0500
@@ -64,44 +64,44 @@
     private static final Category vmGcStatsCategory = new Category("vm-gc-stats");
     private static final Category vmMemoryStatsCategory = new Category("vm-memory-stats");
 
-    private static final Key vmGcStatVmIdKey = new Key("vm-id", false);
-    private static final Key vmGcStatTimeStampKey = new Key("timestamp", false);
-    private static final Key vmGcStatCollectorKey = new Key("collector", false);
-    private static final Key vmGcStatRunCountKey = new Key("runtime-count", false);
+    private static final Key<Integer> vmGcStatVmIdKey = new Key<>("vm-id", false);
+    private static final Key<Long> vmGcStatTimeStampKey = new Key<>("timestamp", false);
+    private static final Key<String> vmGcStatCollectorKey = new Key<>("collector", false);
+    private static final Key<Long> vmGcStatRunCountKey = new Key<>("runtime-count", false);
     /** time in microseconds */
-    private static final Key vmGCstatWallTimeKey = new Key("wall-time", false);
+    private static final Key<Long> vmGCstatWallTimeKey = new Key<>("wall-time", false);
 
-    private static final Key vmMemoryStatVmIdKey = new Key("vm-id", false);
-    private static final Key vmMemoryStatTimestampKey = new Key("timestamp", false);
-    private static final Key vmMemoryStatEdenGenKey = new Key("eden.gen", false);
-    private static final Key vmMemoryStatEdenCollectorKey = new Key("eden.collector", false);
-    private static final Key vmMemoryStatEdenCapacityKey = new Key("eden.capacity", false);
-    private static final Key vmMemoryStatEdenMaxCapacityKey = new Key("eden.max-capacity", false);
-    private static final Key vmMemoryStatEdenUsedKey = new Key("eden.used", false);
+    private static final Key<Integer> vmMemoryStatVmIdKey = new Key<>("vm-id", false);
+    private static final Key<Long> vmMemoryStatTimestampKey = new Key<>("timestamp", false);
+    private static final Key<String> vmMemoryStatEdenGenKey = new Key<>("eden.gen", false);
+    private static final Key<String> vmMemoryStatEdenCollectorKey = new Key<>("eden.collector", false);
+    private static final Key<Long> vmMemoryStatEdenCapacityKey = new Key<>("eden.capacity", false);
+    private static final Key<Long> vmMemoryStatEdenMaxCapacityKey = new Key<>("eden.max-capacity", false);
+    private static final Key<Long> vmMemoryStatEdenUsedKey = new Key<>("eden.used", false);
 
-    private static final Key vmMemoryStatS0GenKey = new Key("s0.gen", false);
-    private static final Key vmMemoryStatS0CollectorKey = new Key("s0.collector", false);
-    private static final Key vmMemoryStatS0CapacityKey = new Key("s0.capacity", false);
-    private static final Key vmMemoryStatS0MaxCapacityKey = new Key("s0.max-capacity", false);
-    private static final Key vmMemoryStatS0UsedKey = new Key("s0.used", false);
+    private static final Key<String> vmMemoryStatS0GenKey = new Key<>("s0.gen", false);
+    private static final Key<String> vmMemoryStatS0CollectorKey = new Key<>("s0.collector", false);
+    private static final Key<Long> vmMemoryStatS0CapacityKey = new Key<>("s0.capacity", false);
+    private static final Key<Long> vmMemoryStatS0MaxCapacityKey = new Key<>("s0.max-capacity", false);
+    private static final Key<Long> vmMemoryStatS0UsedKey = new Key<>("s0.used", false);
 
-    private static final Key vmMemoryStatS1GenKey = new Key("s1.gen", false);
-    private static final Key vmMemoryStatS1CollectorKey = new Key("s1.collector", false);
-    private static final Key vmMemoryStatS1CapacityKey = new Key("s1.capacity", false);
-    private static final Key vmMemoryStatS1MaxCapacityKey = new Key("s1.max-capacity", false);
-    private static final Key vmMemoryStatS1UsedKey = new Key("s1.used", false);
+    private static final Key<String> vmMemoryStatS1GenKey = new Key<>("s1.gen", false);
+    private static final Key<String> vmMemoryStatS1CollectorKey = new Key<>("s1.collector", false);
+    private static final Key<Long> vmMemoryStatS1CapacityKey = new Key<>("s1.capacity", false);
+    private static final Key<Long> vmMemoryStatS1MaxCapacityKey = new Key<>("s1.max-capacity", false);
+    private static final Key<Long> vmMemoryStatS1UsedKey = new Key<>("s1.used", false);
 
-    private static final Key vmMemoryStatOldGenKey = new Key("old.gen", false);
-    private static final Key vmMemoryStatOldCollectorKey = new Key("old.collector", false);
-    private static final Key vmMemoryStatOldCapacityKey = new Key("old.capacity", false);
-    private static final Key vmMemoryStatOldMaxCapacityKey = new Key("old.max-capacity", false);
-    private static final Key vmMemoryStatOldUsedKey = new Key("old.used", false);
+    private static final Key<String> vmMemoryStatOldGenKey = new Key<>("old.gen", false);
+    private static final Key<String> vmMemoryStatOldCollectorKey = new Key<>("old.collector", false);
+    private static final Key<Long> vmMemoryStatOldCapacityKey = new Key<>("old.capacity", false);
+    private static final Key<Long> vmMemoryStatOldMaxCapacityKey = new Key<>("old.max-capacity", false);
+    private static final Key<Long> vmMemoryStatOldUsedKey = new Key<>("old.used", false);
 
-    private static final Key vmMemoryStatPermGenKey = new Key("perm.gen", false);
-    private static final Key vmMemoryStatPermCollectorKey = new Key("perm.collector", false);
-    private static final Key vmMemoryStatPermCapacityKey = new Key("perm.capacity", false);
-    private static final Key vmMemoryStatPermMaxCapacityKey = new Key("perm.max-capacity", false);
-    private static final Key vmMemoryStatPermUsedKey = new Key("perm.used", false);
+    private static final Key<String> vmMemoryStatPermGenKey = new Key<>("perm.gen", false);
+    private static final Key<String> vmMemoryStatPermCollectorKey = new Key<>("perm.collector", false);
+    private static final Key<Long> vmMemoryStatPermCapacityKey = new Key<>("perm.capacity", false);
+    private static final Key<Long> vmMemoryStatPermMaxCapacityKey = new Key<>("perm.max-capacity", false);
+    private static final Key<Long> vmMemoryStatPermUsedKey = new Key<>("perm.used", false);
 
     private final int vmId;
     private final SystemBackend backend;
@@ -238,11 +238,11 @@
         Chunk chunk = new Chunk(vmGcStatsCategory, false);
 
         // TODO leave as original data structures
-        chunk.put(vmGcStatVmIdKey, String.valueOf(vmGcStat.getVmId()));
-        chunk.put(vmGcStatTimeStampKey, String.valueOf(vmGcStat.getTimeStamp()));
+        chunk.put(vmGcStatVmIdKey, vmGcStat.getVmId());
+        chunk.put(vmGcStatTimeStampKey, vmGcStat.getTimeStamp());
         chunk.put(vmGcStatCollectorKey, vmGcStat.getCollectorName());
-        chunk.put(vmGcStatRunCountKey, String.valueOf(vmGcStat.getRunCount()));
-        chunk.put(vmGCstatWallTimeKey, String.valueOf(vmGcStat.getWallTime()));
+        chunk.put(vmGcStatRunCountKey, vmGcStat.getRunCount());
+        chunk.put(vmGCstatWallTimeKey, vmGcStat.getWallTime());
 
         return chunk;
     }
@@ -250,49 +250,49 @@
     private Chunk makeVmMemoryStatChunk(VmMemoryStat vmMemStat) {
         Chunk chunk = new Chunk(vmMemoryStatsCategory, false);
 
-        chunk.put(vmMemoryStatVmIdKey, String.valueOf(vmMemStat.getVmId()));
-        chunk.put(vmMemoryStatTimestampKey, String.valueOf(vmMemStat.getTimeStamp()));
+        chunk.put(vmMemoryStatVmIdKey, vmMemStat.getVmId());
+        chunk.put(vmMemoryStatTimestampKey, vmMemStat.getTimeStamp());
 
         Generation newGen = vmMemStat.getGeneration("new");
         Space eden = newGen.getSpace("eden");
 
         chunk.put(vmMemoryStatEdenGenKey, newGen.name);
         chunk.put(vmMemoryStatEdenCollectorKey, newGen.collector);
-        chunk.put(vmMemoryStatEdenCapacityKey, String.valueOf(eden.capacity));
-        chunk.put(vmMemoryStatEdenMaxCapacityKey, String.valueOf(eden.maxCapacity));
-        chunk.put(vmMemoryStatEdenUsedKey, String.valueOf(eden.used));
+        chunk.put(vmMemoryStatEdenCapacityKey, eden.capacity);
+        chunk.put(vmMemoryStatEdenMaxCapacityKey, eden.maxCapacity);
+        chunk.put(vmMemoryStatEdenUsedKey, eden.used);
 
         Space s0 = newGen.getSpace("s0");
         chunk.put(vmMemoryStatS0GenKey, newGen.name);
         chunk.put(vmMemoryStatS0CollectorKey, newGen.collector);
-        chunk.put(vmMemoryStatS0CapacityKey, String.valueOf(s0.capacity));
-        chunk.put(vmMemoryStatS0MaxCapacityKey, String.valueOf(s0.maxCapacity));
-        chunk.put(vmMemoryStatS0UsedKey, String.valueOf(s0.used));
+        chunk.put(vmMemoryStatS0CapacityKey, s0.capacity);
+        chunk.put(vmMemoryStatS0MaxCapacityKey, s0.maxCapacity);
+        chunk.put(vmMemoryStatS0UsedKey, s0.used);
 
         Space s1 = newGen.getSpace("s1");
         chunk.put(vmMemoryStatS1GenKey, newGen.name);
         chunk.put(vmMemoryStatS1CollectorKey, newGen.collector);
-        chunk.put(vmMemoryStatS1CapacityKey, String.valueOf(s1.capacity));
-        chunk.put(vmMemoryStatS1MaxCapacityKey, String.valueOf(s1.maxCapacity));
-        chunk.put(vmMemoryStatS1UsedKey, String.valueOf(s1.used));
+        chunk.put(vmMemoryStatS1CapacityKey, s1.capacity);
+        chunk.put(vmMemoryStatS1MaxCapacityKey, s1.maxCapacity);
+        chunk.put(vmMemoryStatS1UsedKey, s1.used);
 
         Generation oldGen = vmMemStat.getGeneration("old");
         Space old = oldGen.getSpace("old");
 
         chunk.put(vmMemoryStatOldGenKey, oldGen.name);
         chunk.put(vmMemoryStatOldCollectorKey, oldGen.collector);
-        chunk.put(vmMemoryStatOldCapacityKey, String.valueOf(old.capacity));
-        chunk.put(vmMemoryStatOldMaxCapacityKey, String.valueOf(old.maxCapacity));
-        chunk.put(vmMemoryStatOldUsedKey, String.valueOf(old.used));
+        chunk.put(vmMemoryStatOldCapacityKey, old.capacity);
+        chunk.put(vmMemoryStatOldMaxCapacityKey, old.maxCapacity);
+        chunk.put(vmMemoryStatOldUsedKey, old.used);
 
         Generation permGen = vmMemStat.getGeneration("perm");
         Space perm = permGen.getSpace("perm");
 
         chunk.put(vmMemoryStatPermGenKey, permGen.name);
         chunk.put(vmMemoryStatPermCollectorKey, permGen.collector);
-        chunk.put(vmMemoryStatPermCapacityKey, String.valueOf(perm.capacity));
-        chunk.put(vmMemoryStatPermMaxCapacityKey, String.valueOf(perm.maxCapacity));
-        chunk.put(vmMemoryStatPermUsedKey, String.valueOf(perm.used));
+        chunk.put(vmMemoryStatPermCapacityKey, perm.capacity);
+        chunk.put(vmMemoryStatPermMaxCapacityKey, perm.maxCapacity);
+        chunk.put(vmMemoryStatPermUsedKey, perm.used);
 
         return chunk;
     }
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java	Fri Feb 24 19:18:02 2012 -0500
@@ -87,35 +87,35 @@
     private List<Category> categories = new ArrayList<Category>();
 
     private Category hostInfoCategory = new Category("host-info");
-    private Key hostNameKey = new Key("hostname", true);
-    private Key osNameKey = new Key("os_name", false);
-    private Key osKernelKey = new Key("os_kernel", false);
-    private Key cpuCountKey = new Key("cpu_num", false);
-    private Key cpuModelKey = new Key("cpu_model", false);
-    private Key hostMemoryTotalKey = new Key("memory_total", false);
+    private Key<String> hostNameKey = new Key<>("hostname", true);
+    private Key<String> osNameKey = new Key<>("os_name", false);
+    private Key<String> osKernelKey = new Key<>("os_kernel", false);
+    private Key<Integer> cpuCountKey = new Key<>("cpu_num", false);
+    private Key<String> cpuModelKey = new Key<>("cpu_model", false);
+    private Key<Long> hostMemoryTotalKey = new Key<>("memory_total", false);
 
     private Category networkInfoCategory = new Category("network-info");
-    private Key ifaceKey = new Key("iface", true);
-    private Key ip4AddrKey = new Key("ipv4addr", false);
-    private Key ip6AddrKey = new Key("ipv6addr", false);
+    private Key<String> ifaceKey = new Key<>("iface", true);
+    private Key<String> ip4AddrKey = new Key<>("ipv4addr", false);
+    private Key<String> ip6AddrKey = new Key<>("ipv6addr", false);
 
     private Category cpuStatCategory = new Category("cpu-stats");
-    private Key cpu5LoadKey = new Key("5load", false);
-    private Key cpu10LoadKey = new Key("10load", false);
-    private Key cpu15LoadKey = new Key("15load", false);
+    private Key<Double> cpu5LoadKey = new Key<>("5load", false);
+    private Key<Double> cpu10LoadKey = new Key<>("10load", false);
+    private Key<Double> cpu15LoadKey = new Key<>("15load", false);
 
     private Category memoryStatCategory = new Category("memory-stats");
-    private Key memoryTotalKey = new Key("total", false);
-    private Key memoryFreeKey = new Key("free", false);
-    private Key memoryBuffersKey = new Key("buffers", false);
-    private Key memoryCachedKey = new Key("cached", false);
-    private Key memorySwapTotalKey = new Key("swap-total", false);
-    private Key memorySwapFreeKey = new Key("swap-free", false);
-    private Key memoryCommitLimitKey = new Key("commit-limit", false);
+    private Key<Long> memoryTotalKey = new Key<>("total", false);
+    private Key<Long> memoryFreeKey = new Key<>("free", false);
+    private Key<Long> memoryBuffersKey = new Key<>("buffers", false);
+    private Key<Long> memoryCachedKey = new Key<>("cached", false);
+    private Key<Long> memorySwapTotalKey = new Key<>("swap-total", false);
+    private Key<Long> memorySwapFreeKey = new Key<>("swap-free", false);
+    private Key<Long> memoryCommitLimitKey = new Key<>("commit-limit", false);
 
     private Category vmCpuStatCategory = new Category("vm-cpu-stats");
-    private Key vmCpuVmIdKey = new Key("vm-id", false);
-    private Key vmCpuLoadKey = new Key("processor-usage", false);
+    private Key<Integer> vmCpuVmIdKey = new Key<>("vm-id", false);
+    private Key<Double> vmCpuLoadKey = new Key<>("processor-usage", false);
 
     {
         // Set up categories that will later be registered.
@@ -268,10 +268,10 @@
 
     private Chunk makeCpuChunk(CpuStat cpuStat) {
         Chunk chunk = new Chunk(cpuStatCategory, false);
-        chunk.put(Key.TIMESTAMP, Long.toString(cpuStat.getTimeStamp()));
-        chunk.put(cpu5LoadKey, Double.toString(cpuStat.getLoad5()));
-        chunk.put(cpu10LoadKey, Double.toString(cpuStat.getLoad10()));
-        chunk.put(cpu15LoadKey, Double.toString(cpuStat.getLoad15()));
+        chunk.put(Key.TIMESTAMP, cpuStat.getTimeStamp());
+        chunk.put(cpu5LoadKey, cpuStat.getLoad5());
+        chunk.put(cpu10LoadKey, cpuStat.getLoad10());
+        chunk.put(cpu15LoadKey, cpuStat.getLoad15());
         return chunk;
     }
 
@@ -280,9 +280,9 @@
         chunk.put(hostNameKey, hostInfo.getHostname());
         chunk.put(osNameKey, hostInfo.getOsName());
         chunk.put(osKernelKey, hostInfo.getOsKernel());
-        chunk.put(cpuCountKey, Integer.toString(hostInfo.getCpuCount()));
+        chunk.put(cpuCountKey, hostInfo.getCpuCount());
         chunk.put(cpuModelKey, hostInfo.getCpuModel());
-        chunk.put(hostMemoryTotalKey, Long.toString(hostInfo.getTotalMemory()));
+        chunk.put(hostMemoryTotalKey, hostInfo.getTotalMemory());
         return chunk;
     }
 
@@ -302,22 +302,22 @@
 
     private Chunk makeMemoryChunk(MemoryStat mem) {
         Chunk chunk = new Chunk(memoryStatCategory, false);
-        chunk.put(Key.TIMESTAMP, Long.toString(mem.getTimeStamp()));
-        chunk.put(memoryTotalKey, Long.toString(mem.getTotal()));
-        chunk.put(memoryFreeKey, Long.toString(mem.getFree()));
-        chunk.put(memoryBuffersKey, Long.toString(mem.getBuffers()));
-        chunk.put(memoryCachedKey, Long.toString(mem.getCached()));
-        chunk.put(memorySwapTotalKey, Long.toString(mem.getSwapTotal()));
-        chunk.put(memorySwapFreeKey, Long.toString(mem.getSwapFree()));
-        chunk.put(memoryCommitLimitKey, Long.toString(mem.getCommitLimit()));
+        chunk.put(Key.TIMESTAMP, mem.getTimeStamp());
+        chunk.put(memoryTotalKey, mem.getTotal());
+        chunk.put(memoryFreeKey, mem.getFree());
+        chunk.put(memoryBuffersKey, mem.getBuffers());
+        chunk.put(memoryCachedKey, mem.getCached());
+        chunk.put(memorySwapTotalKey, mem.getSwapTotal());
+        chunk.put(memorySwapFreeKey, mem.getSwapFree());
+        chunk.put(memoryCommitLimitKey, mem.getCommitLimit());
         return chunk;
     }
 
     private Chunk makeVmCpuChunk(VmCpuStat stat) {
         Chunk chunk = new Chunk(vmCpuStatCategory, false);
-        chunk.put(Key.TIMESTAMP, Long.toString(stat.getTimeStamp()));
-        chunk.put(vmCpuVmIdKey, Integer.toString(stat.getVmId()));
-        chunk.put(vmCpuLoadKey, Double.toString(stat.getCpuLoad()));
+        chunk.put(Key.TIMESTAMP, stat.getTimeStamp());
+        chunk.put(vmCpuVmIdKey, stat.getVmId());
+        chunk.put(vmCpuLoadKey, stat.getCpuLoad());
         return chunk;
     }
 
--- a/agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatVmClassListenerTest.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatVmClassListenerTest.java	Fri Feb 24 19:18:02 2012 -0500
@@ -70,8 +70,8 @@
 
         ArgumentCaptor<Chunk> chunkArg = ArgumentCaptor.forClass(Chunk.class);
         verify(backend).store(chunkArg.capture());
-        assertEquals("1234", chunkArg.getValue().get(new Key("loadedClasses", false)));
-        assertEquals("123", chunkArg.getValue().get(new Key("vm-id", false)));
+        assertEquals((Long) 1234L, chunkArg.getValue().get(new Key<Long>("loadedClasses", false)));
+        assertEquals((Integer) 123, chunkArg.getValue().get(new Key<Integer>("vm-id", false)));
     }
 
     @Test
--- a/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/HostPanelFacadeImpl.java	Fri Feb 24 19:18:02 2012 -0500
@@ -119,8 +119,8 @@
                 osName.setText((String) hostInfo.get("os_name"));
                 osKernel.setText((String) hostInfo.get("os_kernel"));
                 cpuModel.setText((String) hostInfo.get("cpu_model"));
-                cpuCount.setText((String) hostInfo.get("cpu_num"));
-                memoryTotal.setText((String) hostInfo.get("memory_total"));
+                cpuCount.setText(((Integer) hostInfo.get("cpu_num")).toString());
+                memoryTotal.setText(((Long) hostInfo.get("memory_total")).toString());
 
                 doNetworkTableUpdateAsync();
 
@@ -238,11 +238,11 @@
         long memoryData = 0;
         while (cursor.hasNext()) {
             DBObject stat = cursor.next();
-            timestamp = Long.valueOf((String) stat.get("timestamp"));
+            timestamp = (Long) stat.get("timestamp");
             if (type.getInternalName().equals("used")) {
-                memoryData = Long.valueOf((String) stat.get("total")) - Long.valueOf((String) stat.get("free"));
+                memoryData = (Long) stat.get("total") - (Long) stat.get("free");
             } else {
-                memoryData = Long.valueOf((String) stat.get(type.getInternalName()));
+                memoryData = (Long) stat.get(type.getInternalName());
             }
             data.add(new DiscreteTimeData<Long>(timestamp, memoryData));
         }
@@ -307,8 +307,8 @@
             double data = 0;
             while (cursor.hasNext()) {
                 DBObject stat = cursor.next();
-                timestamp = Long.valueOf((String) stat.get("timestamp"));
-                data = Double.valueOf((String) stat.get("5load"));
+                timestamp = (Long) stat.get("timestamp");
+                data = (Double) stat.get("5load");
                 load.add(new DiscreteTimeData<Double>(timestamp, data));
             }
             // TODO we may also want to avoid sending out thousands of values.
--- a/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/MainWindowFacadeImpl.java	Fri Feb 24 19:18:02 2012 -0500
@@ -125,7 +125,7 @@
         DBCursor cursor = vmInfoCollection.find(new BasicDBObject("agent-id", hostRef.getAgentId()));
         while (cursor.hasNext()) {
             DBObject vmObject = cursor.next();
-            String id = (String) vmObject.get("vm-id");
+            Integer id = (Integer) vmObject.get("vm-id");
             // TODO can we do better than the main class?
             String mainClass = (String) vmObject.get("main-class");
             VmRef ref = new VmRef(hostRef, id, mainClass);
--- a/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/VmPanelFacadeImpl.java	Fri Feb 24 19:18:02 2012 -0500
@@ -113,12 +113,12 @@
             public void run() {
                 BasicDBObject queryObject = new BasicDBObject();
                 queryObject.put("agent-id", ref.getAgent().getAgentId());
-                queryObject.put("vm-id", ref.getId());
+                queryObject.put("vm-id", Integer.valueOf(ref.getId()));
                 DBObject vmInfoObject = vmInfoCollection.findOne(queryObject);
-                vmPid.setText((String) vmInfoObject.get("vm-pid"));
-                long actualStartTime = Long.valueOf((String) vmInfoObject.get("start-time"));
+                vmPid.setText(((Integer) vmInfoObject.get("vm-pid")).toString());
+                long actualStartTime = (Long) vmInfoObject.get("start-time");
                 startTime.setText(vmRunningTimeFormat.format(new Date(actualStartTime)));
-                long actualStopTime = Long.valueOf((String) vmInfoObject.get("stop-time"));
+                long actualStopTime = (Long) vmInfoObject.get("stop-time");
                 if (actualStopTime >= actualStartTime) {
                     // Only show a stop time if we have actually stopped.
                     stopTime.setText(vmRunningTimeFormat.format(new Date(actualStopTime)));
@@ -220,7 +220,7 @@
     public String[] getCollectorNames() {
         BasicDBObject queryObject = new BasicDBObject();
         queryObject.put("agent-id", ref.getAgent().getAgentId());
-        queryObject.put("vm-id", ref.getId());
+        queryObject.put("vm-id", Integer.valueOf(ref.getId()));
         List results = vmGcStatsCollection.distinct("collector", queryObject);
         List<String> collectorNames = new ArrayList<String>(results);
 
@@ -258,7 +258,7 @@
             ArrayList<DiscreteTimeData<Double>> result = new ArrayList<DiscreteTimeData<Double>>();
             BasicDBObject queryObject = new BasicDBObject();
             queryObject.put("agent-id", facade.ref.getAgent().getAgentId());
-            queryObject.put("vm-id", facade.ref.getId());
+            queryObject.put("vm-id", Integer.valueOf(facade.ref.getId()));
             if (after != Long.MIN_VALUE) {
                 // TODO once we have an index and the 'column' is of type long, use a
                 // query which can utilize an index. this one doesn't
@@ -270,9 +270,9 @@
             double walltime;
             while (cursor.hasNext()) {
                 DBObject current = cursor.next();
-                timestamp = Long.valueOf((String) current.get("timestamp"));
+                timestamp = (Long) current.get("timestamp");
                 // convert microseconds to seconds
-                walltime = 1.0E-6 * Long.valueOf((String) current.get("wall-time"));
+                walltime = 1.0E-6 * (Long) current.get("wall-time");
                 result.add(new DiscreteTimeData<Double>(timestamp, walltime));
             }
 
@@ -390,7 +390,7 @@
     private VmMemoryStat getLatestMemoryInfo() {
         BasicDBObject query = new BasicDBObject();
         query.put("agent-id", ref.getAgent().getAgentId());
-        query.put("vm-id", ref.getId());
+        query.put("vm-id", Integer.valueOf(ref.getId()));
         // TODO ensure timestamp is an indexed column
         BasicDBObject sortByTimeStamp = new BasicDBObject("timestamp", -1);
         DBCursor cursor;
@@ -409,8 +409,8 @@
         String[] spaceNames = new String[] { "eden", "s0", "s1", "old", "perm" };
         List<Generation> generations = new ArrayList<Generation>();
 
-        long timestamp = Long.valueOf((String)dbObj.get("timestamp"));
-        int vmId = Integer.valueOf((String)dbObj.get("vm-id"));
+        long timestamp = (Long) dbObj.get("timestamp");
+        int vmId = (Integer) dbObj.get("vm-id");
         for (String spaceName: spaceNames) {
             DBObject info = (DBObject) dbObj.get(spaceName);
             String generationName = (String) info.get("gen");
@@ -430,9 +430,9 @@
             }
             Space space = new Space();
             space.name = spaceName;
-            space.capacity = Long.valueOf((String)info.get("capacity"));
-            space.maxCapacity = Long.valueOf((String)info.get("max-capacity"));
-            space.used = Long.valueOf((String) info.get("used"));
+            space.capacity = (Long) info.get("capacity");
+            space.maxCapacity = (Long)info.get("max-capacity");
+            space.used = (Long) info.get("used");
             if (target.spaces == null) {
                 target.spaces = new ArrayList<Space>();
             }
--- a/client/src/main/java/com/redhat/thermostat/client/VmRef.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/client/src/main/java/com/redhat/thermostat/client/VmRef.java	Fri Feb 24 19:18:02 2012 -0500
@@ -42,9 +42,9 @@
     private final String uid;
     private final String name;
 
-    public VmRef(HostRef hostRef, String id, String name) {
+    public VmRef(HostRef hostRef, Integer id, String name) {
         this.hostRef = hostRef;
-        this.uid = id;
+        this.uid = id.toString();
         this.name = name;
     }
 
--- a/common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatConverter.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatConverter.java	Fri Feb 24 19:18:02 2012 -0500
@@ -37,7 +37,6 @@
 package com.redhat.thermostat.common.dao;
 
 import com.redhat.thermostat.common.VmClassStat;
-import com.redhat.thermostat.common.storage.Category;
 import com.redhat.thermostat.common.storage.Chunk;
 import com.redhat.thermostat.common.storage.Key;
 
@@ -45,9 +44,9 @@
 
     public Chunk vmClassStatToChunk(VmClassStat vmClassStat) {
         Chunk chunk = new Chunk(VmClassStatDAO.vmClassStatsCategory, false);
-        chunk.put(VmClassStatDAO.vmIdKey, String.valueOf(vmClassStat.getVmId()));
-        chunk.put(Key.TIMESTAMP, String.valueOf(vmClassStat.getTimestamp()));
-        chunk.put(VmClassStatDAO.loadedClassesKey, String.valueOf(vmClassStat.getLoadedClasses()));
+        chunk.put(VmClassStatDAO.vmIdKey, vmClassStat.getVmId());
+        chunk.put(Key.TIMESTAMP, vmClassStat.getTimestamp());
+        chunk.put(VmClassStatDAO.loadedClassesKey, vmClassStat.getLoadedClasses());
         return chunk;
     }
 }
--- a/common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatDAO.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmClassStatDAO.java	Fri Feb 24 19:18:02 2012 -0500
@@ -41,8 +41,8 @@
 
 public class VmClassStatDAO {
 
-    static final Key vmIdKey = new Key("vm-id", false);
-    static final Key loadedClassesKey = new Key("loadedClasses", false);
+    static final Key<Integer> vmIdKey = new Key<>("vm-id", false);
+    static final Key<Long> loadedClassesKey = new Key<>("loadedClasses", false);
 
     public static final Category vmClassStatsCategory = new Category("vm-class-stats");
 
--- a/common/src/main/java/com/redhat/thermostat/common/storage/Category.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/storage/Category.java	Fri Feb 24 19:18:02 2012 -0500
@@ -45,7 +45,7 @@
 
 public class Category {
     private final String name;
-    private final List<Key> keys;
+    private final List<Key<?>> keys;
     private boolean locked = false;
 
     private ConnectionKey connectionKey;
@@ -65,7 +65,7 @@
         }
         categoryNames.add(name);
         this.name = name;
-        keys = new ArrayList<Key>();
+        keys = new ArrayList<Key<?>>();
     }
 
     public String getName() {
@@ -76,7 +76,7 @@
         locked = true;
     }
 
-    public synchronized void addKey(Key key) {
+    public synchronized void addKey(Key<?> key) {
         if (!locked) {
             keys.add(key);
         } else {
@@ -84,7 +84,7 @@
         }
     }
 
-    public synchronized Collection<Key> getKeys() {
+    public synchronized Collection<Key<?>> getKeys() {
         return Collections.unmodifiableCollection(keys);
     }
 
--- a/common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java	Fri Feb 24 19:18:02 2012 -0500
@@ -47,7 +47,7 @@
     private final Category category;
     private final boolean replace;
 
-    private Map<Key, String> values = new HashMap<Key, String>();
+    private Map<Key<?>, Object> values = new HashMap<Key<?>, Object>();
 
     /**
      * 
@@ -70,11 +70,13 @@
         return replace;
     }
 
-    public void put(Key entry, String value) {
+    public <T> void put(Key<T> entry, T value) {
         values.put(entry, value);
     }
 
-    public String get(Key entry) {
-        return values.get(entry);
+    @SuppressWarnings("unchecked")
+    public <T> T get(Key<T> entry) {
+        // We only allow matching types in put(), so this cast should be fine.
+        return (T) values.get(entry);
     }
 }
--- a/common/src/main/java/com/redhat/thermostat/common/storage/Key.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/storage/Key.java	Fri Feb 24 19:18:02 2012 -0500
@@ -40,10 +40,10 @@
  * A Key is used to refer to data in a {@link Chunk}.  It may also be a partial key to the
  * set of data represented by a {@link Chunk} in a category.
  */
-public class Key {
+public class Key<T> {
 
     // Key used by most Categories.
-    public static Key TIMESTAMP = new Key("timestamp", false);
+    public static Key<Long> TIMESTAMP = new Key<>("timestamp", false);
 
     private String name;
     private boolean isPartialCategoryKey;
@@ -69,7 +69,7 @@
         if ((o == null) || (o.getClass() != this.getClass())) {
             return false;
         }
-        Key e = (Key) o;
+        Key<?> e = (Key<?>) o;
         return (isPartialCategoryKey == e.isPartialCategoryKey()) &&
             name.equals(e.getName());
     }
--- a/common/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/main/java/com/redhat/thermostat/common/storage/MongoStorage.java	Fri Feb 24 19:18:02 2012 -0500
@@ -38,7 +38,6 @@
 
 import java.net.UnknownHostException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.UUID;
 
@@ -130,7 +129,7 @@
             replaceKey = getAgentDBObject();
             replaceKeyNestedParts = new HashMap<String, BasicDBObject>();
         }
-        for (Key key : cat.getKeys()) {
+        for (Key<?> key : cat.getKeys()) {
             boolean isKey = key.isPartialCategoryKey();
             String[] entryParts = key.getName().split("\\.");
             if (entryParts.length == 2) {
@@ -153,7 +152,7 @@
                 }
             } else {
                 String mongoKey = key.getName();
-                String value = chunk.get(key);
+                Object value = chunk.get(key);
                 if ((value == null) && isKey) {
                     throwMissingKey(key.getName());
                 }
@@ -184,7 +183,7 @@
         BasicDBObject updateKey = getAgentDBObject();
         Map<String, BasicDBObject> nestedParts = new HashMap<String, BasicDBObject>();
         Map<String, BasicDBObject> updateKeyNestedParts = new HashMap<String, BasicDBObject>();
-        for (Key key : cat.getKeys()) {
+        for (Key<?> key : cat.getKeys()) {
             boolean isKey = key.isPartialCategoryKey();
             String[] entryParts = key.getName().split("\\.");
             if (entryParts.length == 2) {
@@ -207,7 +206,7 @@
                 }
             } else {
                 String mongoKey = key.getName();
-                String value = chunk.get(key);
+                Object value = chunk.get(key);
                 if (value == null) {
                     if (isKey) {
                         throwMissingKey(key.getName());
--- a/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java	Fri Feb 24 19:18:02 2012 -0500
@@ -54,8 +54,8 @@
         Chunk chunk = dao.vmClassStatToChunk(stat);
 
         assertEquals("vm-class-stats", chunk.getCategory().getName());
-        assertEquals("1234", chunk.get(Key.TIMESTAMP));
-        assertEquals("123", chunk.get(new Key("vm-id", false)));
-        assertEquals("12345", chunk.get(new Key("loadedClasses", false)));
+        assertEquals((Long) 1234L, chunk.get(Key.TIMESTAMP));
+        assertEquals((Integer) 123, chunk.get(new Key<Integer>("vm-id", false)));
+        assertEquals((Long) 12345L, chunk.get(new Key<Long>("loadedClasses", false)));
     }
 }
--- a/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatDAOTest.java	Fri Feb 24 17:35:11 2012 -0500
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatDAOTest.java	Fri Feb 24 19:18:02 2012 -0500
@@ -50,10 +50,10 @@
     @Test
     public void testCategory() {
         assertEquals("vm-class-stats", VmClassStatDAO.vmClassStatsCategory.getName());
-        Collection<Key> keys = VmClassStatDAO.vmClassStatsCategory.getKeys();
-        assertTrue(keys.contains(new Key("vm-id", false)));
-        assertTrue(keys.contains(new Key("timestamp", false)));
-        assertTrue(keys.contains(new Key("loadedClasses", false)));
+        Collection<Key<?>> keys = VmClassStatDAO.vmClassStatsCategory.getKeys();
+        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<Long>("loadedClasses", false)));
         assertEquals(3, keys.size());
 
     }
--- a/pom.xml	Fri Feb 24 17:35:11 2012 -0500
+++ b/pom.xml	Fri Feb 24 19:18:02 2012 -0500
@@ -51,7 +51,7 @@
   <properties>
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <thermostat.build.directory>target</thermostat.build.directory>
-    <thermostat.java.version>1.6</thermostat.java.version>
+    <thermostat.java.version>1.7</thermostat.java.version>
     <java.dir>/usr/share/java</java.dir>
   </properties>