changeset 105:c6eda3616df8

Split out DAO and converters from SystemBackend
author Omair Majid <omajid@redhat.com>
date Tue, 06 Mar 2012 17:16:36 -0500
parents 8ebd71ff78cc
children 60a9e2735d62
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/JvmStatHostListenerTest.java agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatVmListenerTest.java agent/src/test/java/com/redhat/thermostat/backend/system/SystemBackendTest.java common/src/main/java/com/redhat/thermostat/common/dao/CpuStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/CpuStatDAO.java common/src/main/java/com/redhat/thermostat/common/dao/HostInfoConverter.java common/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAO.java common/src/main/java/com/redhat/thermostat/common/dao/MemoryStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/MemoryStatDAO.java common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverter.java common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAO.java common/src/main/java/com/redhat/thermostat/common/dao/VmCpuStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/VmCpuStatDAO.java common/src/main/java/com/redhat/thermostat/common/dao/VmGcStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/VmGcStatDAO.java common/src/main/java/com/redhat/thermostat/common/dao/VmInfoConverter.java common/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAO.java common/src/main/java/com/redhat/thermostat/common/dao/VmMemoryStatConverter.java common/src/main/java/com/redhat/thermostat/common/dao/VmMemoryStatDAO.java common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java common/src/test/java/com/redhat/thermostat/common/dao/CpuStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/CpuStatDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/HostInfoConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/HostInfoDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/MemoryStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/MemoryStatDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmCpuStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmCpuStatDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmGcStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmGcStatDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmInfoConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmMemoryStatConverterTest.java common/src/test/java/com/redhat/thermostat/common/dao/VmMemoryStatDAOTest.java
diffstat 40 files changed, 2148 insertions(+), 512 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java	Tue Mar 06 22:45:29 2012 +0100
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatHostListener.java	Tue Mar 06 17:16:36 2012 -0500
@@ -58,37 +58,16 @@
 import com.redhat.thermostat.agent.JvmStatusListener;
 import com.redhat.thermostat.agent.JvmStatusNotifier;
 import com.redhat.thermostat.common.VmInfo;
+import com.redhat.thermostat.common.dao.VmInfoConverter;
+import com.redhat.thermostat.common.dao.VmInfoDAO;
 import com.redhat.thermostat.common.storage.Category;
 import com.redhat.thermostat.common.storage.Chunk;
-import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 
 public class JvmStatHostListener implements HostListener, JvmStatusNotifier {
 
     private static final Logger logger = LoggingUtils.getLogger(JvmStatHostListener.class);
 
-    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 final Category vmInfoCategory = new Category("vm-info",
-            vmInfoIdKey, vmInfoPidKey, vmInfoRuntimeVersionKey, vmInfoJavaHomeKey,
-            vmInfoMainClassKey, vmInfoCommandLineKey,
-            vmInfoVmArgumentsKey, vmInfoVmNameKey, vmInfoVmInfoKey, vmInfoVmVersionKey,
-            vmInfoEnvironmentKey, vmInfoLibrariesKey,
-            vmInfoStartTimeKey, vmInfoStopTimeKey);
-
     private SystemBackend backend;
 
     private Map<Integer, JvmStatVmListener> listenerMap = new HashMap<Integer, JvmStatVmListener>();
@@ -97,7 +76,6 @@
 
     public static Collection<Category> getCategories() {
         ArrayList<Category> categories = new ArrayList<Category>();
-        categories.add(vmInfoCategory);
         return categories;
     }
 
@@ -157,7 +135,7 @@
                         extractor.getMainClass(), extractor.getCommandLine(),
                         extractor.getVmName(), extractor.getVmInfo(), extractor.getVmVersion(), extractor.getVmArguments(),
                         properties, environment, loadedNativeLibraries);
-                backend.store(makeVmInfoChunk(info));
+                backend.store(new VmInfoConverter().vmInfoToChunk(info));
                 logger.finer("Sent VM_STARTED messsage");
             } catch (MonitorException me) {
                 logger.log(Level.WARNING, "error getting vm info for " + vmId, me);
@@ -191,32 +169,11 @@
         }
     }
 
-    private Chunk makeVmInfoChunk(VmInfo info) {
-        Chunk chunk = new Chunk(vmInfoCategory, true);
-
-        // FIXME save these as proper objects (ie. not as strings)
-
-        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());
-        chunk.put(vmInfoCommandLineKey, info.getJavaCommandLine());
-        chunk.put(vmInfoVmArgumentsKey, info.getVmArguments());
-        chunk.put(vmInfoVmNameKey, info.getVmName());
-        chunk.put(vmInfoVmInfoKey, info.getVmInfo());
-        chunk.put(vmInfoVmVersionKey, info.getVmVersion());
-        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, vmId);
-        chunk.put(vmInfoStopTimeKey, stopTimeStamp);
+        // FIXME later
+        Chunk chunk = new Chunk(VmInfoDAO.vmInfoCategory, false);
+        chunk.put(VmInfoDAO.vmInfoIdKey, vmId);
+        chunk.put(VmInfoDAO.vmInfoStopTimeKey, stopTimeStamp);
         return chunk;
     }
 
--- a/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatVmListener.java	Tue Mar 06 22:45:29 2012 +0100
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/JvmStatVmListener.java	Tue Mar 06 17:16:36 2012 -0500
@@ -52,69 +52,15 @@
 import com.redhat.thermostat.common.VmMemoryStat;
 import com.redhat.thermostat.common.VmMemoryStat.Generation;
 import com.redhat.thermostat.common.VmMemoryStat.Space;
+import com.redhat.thermostat.common.dao.VmGcStatConverter;
+import com.redhat.thermostat.common.dao.VmMemoryStatConverter;
 import com.redhat.thermostat.common.storage.Category;
-import com.redhat.thermostat.common.storage.Chunk;
-import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 
 public class JvmStatVmListener implements VmListener {
 
     private static final Logger logger = LoggingUtils.getLogger(JvmStatVmListener.class);
 
-    private static final Key<Integer> vmGcStatVmIdKey = new Key<>("vm-id", 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<Long> vmGCstatWallTimeKey = new Key<>("wall-time", false);
-
-    static final Category vmGcStatsCategory = new Category("vm-gc-stats",
-            vmGcStatVmIdKey, Key.TIMESTAMP, vmGcStatCollectorKey,
-            vmGcStatRunCountKey, vmGCstatWallTimeKey);
-
-    private static final Key<Integer> vmMemoryStatVmIdKey = new Key<>("vm-id", 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<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<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<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<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);
-
-    static final Category vmMemoryStatsCategory = new Category("vm-memory-stats",
-            vmMemoryStatVmIdKey, Key.TIMESTAMP,
-            vmMemoryStatEdenGenKey, vmMemoryStatEdenCollectorKey,
-            vmMemoryStatEdenCapacityKey, vmMemoryStatEdenMaxCapacityKey,vmMemoryStatEdenUsedKey,
-            vmMemoryStatS0GenKey, vmMemoryStatS0CollectorKey, vmMemoryStatS0CapacityKey,
-            vmMemoryStatS0MaxCapacityKey, vmMemoryStatS0UsedKey,
-            vmMemoryStatS1GenKey, vmMemoryStatS1CollectorKey, vmMemoryStatS1CapacityKey,
-            vmMemoryStatS1MaxCapacityKey, vmMemoryStatS1UsedKey,
-            vmMemoryStatOldGenKey, vmMemoryStatOldCollectorKey, vmMemoryStatOldCapacityKey,
-            vmMemoryStatOldMaxCapacityKey, vmMemoryStatOldUsedKey,
-            vmMemoryStatPermGenKey, vmMemoryStatPermCollectorKey, vmMemoryStatPermCapacityKey,
-            vmMemoryStatPermMaxCapacityKey, vmMemoryStatPermUsedKey);
-
     private final int vmId;
     private final SystemBackend backend;
 
@@ -125,10 +71,6 @@
 
     public static Collection<Category> getCategories() {
         ArrayList<Category> categories = new ArrayList<Category>();
-
-        categories.add(vmGcStatsCategory);
-        categories.add(vmMemoryStatsCategory);
-
         return categories;
     }
 
@@ -162,7 +104,7 @@
                         extractor.getCollectorName(i),
                         extractor.getCollectorInvocations(i),
                         extractor.getCollectorTime(i));
-                backend.store(makeVmGcStatChunk(stat));
+                backend.store(new VmGcStatConverter().vmGcStatToChunk(stat));
             }
         } catch (MonitorException e) {
             logger.log(Level.WARNING, "error gathering gc info for vm " + vmId, e);
@@ -202,73 +144,11 @@
                     s.used = extractor.getSpaceUsed(generation, space);
                 }
             }
-            backend.store(makeVmMemoryStatChunk(stat));
+            backend.store(new VmMemoryStatConverter().vmMemoryStatToChunk(stat));
         } catch (MonitorException e) {
             logger.log(Level.WARNING, "error gathering memory info for vm " + vmId, e);
         }
     }
 
-    private Chunk makeVmGcStatChunk(VmGcStat vmGcStat) {
-        Chunk chunk = new Chunk(vmGcStatsCategory, false);
-
-        // TODO leave as original data structures
-        chunk.put(vmGcStatVmIdKey, vmGcStat.getVmId());
-        chunk.put(Key.TIMESTAMP, vmGcStat.getTimeStamp());
-        chunk.put(vmGcStatCollectorKey, vmGcStat.getCollectorName());
-        chunk.put(vmGcStatRunCountKey, vmGcStat.getRunCount());
-        chunk.put(vmGCstatWallTimeKey, vmGcStat.getWallTime());
-
-        return chunk;
-    }
-
-    private Chunk makeVmMemoryStatChunk(VmMemoryStat vmMemStat) {
-        Chunk chunk = new Chunk(vmMemoryStatsCategory, false);
-
-        chunk.put(vmMemoryStatVmIdKey, vmMemStat.getVmId());
-        chunk.put(Key.TIMESTAMP, 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, 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, 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, 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, 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, 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	Tue Mar 06 22:45:29 2012 +0100
+++ b/agent/src/main/java/com/redhat/thermostat/backend/system/SystemBackend.java	Tue Mar 06 17:16:36 2012 -0500
@@ -55,15 +55,22 @@
 import com.redhat.thermostat.agent.JvmStatusListener;
 import com.redhat.thermostat.agent.JvmStatusNotifier;
 import com.redhat.thermostat.backend.Backend;
-import com.redhat.thermostat.common.CpuStat;
-import com.redhat.thermostat.common.HostInfo;
-import com.redhat.thermostat.common.MemoryStat;
 import com.redhat.thermostat.common.NetworkInterfaceInfo;
-import com.redhat.thermostat.common.VmCpuStat;
+import com.redhat.thermostat.common.dao.CpuStatConverter;
+import com.redhat.thermostat.common.dao.CpuStatDAO;
+import com.redhat.thermostat.common.dao.HostInfoConverter;
+import com.redhat.thermostat.common.dao.HostInfoDAO;
+import com.redhat.thermostat.common.dao.MemoryStatConverter;
+import com.redhat.thermostat.common.dao.MemoryStatDAO;
+import com.redhat.thermostat.common.dao.NetworkInterfaceInfoConverter;
+import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO;
 import com.redhat.thermostat.common.dao.VmClassStatDAO;
+import com.redhat.thermostat.common.dao.VmCpuStatConverter;
+import com.redhat.thermostat.common.dao.VmCpuStatDAO;
+import com.redhat.thermostat.common.dao.VmGcStatDAO;
+import com.redhat.thermostat.common.dao.VmInfoDAO;
+import com.redhat.thermostat.common.dao.VmMemoryStatDAO;
 import com.redhat.thermostat.common.storage.Category;
-import com.redhat.thermostat.common.storage.Chunk;
-import com.redhat.thermostat.common.storage.Key;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 
 public class SystemBackend extends Backend implements JvmStatusNotifier, JvmStatusListener {
@@ -87,59 +94,18 @@
 
     private static List<Category> categories = new ArrayList<Category>();
 
-    private static Key<String> hostNameKey = new Key<>("hostname", true);
-    private static Key<String> osNameKey = new Key<>("os_name", false);
-    private static Key<String> osKernelKey = new Key<>("os_kernel", false);
-    private static Key<Integer> cpuCountKey = new Key<>("cpu_num", false);
-    private static Key<String> cpuModelKey = new Key<>("cpu_model", false);
-    private static Key<Long> hostMemoryTotalKey = new Key<>("memory_total", false);
-
-    static Category hostInfoCategory = new Category("host-info",
-            hostNameKey, osNameKey, osKernelKey,
-            cpuCountKey, cpuModelKey, hostMemoryTotalKey);
-
-    private static Key<String> ifaceKey = new Key<>("iface", true);
-    private static Key<String> ip4AddrKey = new Key<>("ipv4addr", false);
-    private static Key<String> ip6AddrKey = new Key<>("ipv6addr", false);
-
-    static Category networkInfoCategory = new Category("network-info",
-            Key.TIMESTAMP, ifaceKey, ip4AddrKey, ip6AddrKey);
-
-    private static Key<Double> cpu5LoadKey = new Key<>("5load", false);
-    private static Key<Double> cpu10LoadKey = new Key<>("10load", false);
-    private static Key<Double> cpu15LoadKey = new Key<>("15load", false);
-
-    static Category cpuStatCategory = new Category("cpu-stats",
-            Key.TIMESTAMP, cpu5LoadKey, cpu10LoadKey, cpu15LoadKey);
-
-    private static Key<Long> memoryTotalKey = new Key<>("total", false);
-    private static Key<Long> memoryFreeKey = new Key<>("free", false);
-    private static Key<Long> memoryBuffersKey = new Key<>("buffers", false);
-    private static Key<Long> memoryCachedKey = new Key<>("cached", false);
-    private static Key<Long> memorySwapTotalKey = new Key<>("swap-total", false);
-    private static Key<Long> memorySwapFreeKey = new Key<>("swap-free", false);
-    private static Key<Long> memoryCommitLimitKey = new Key<>("commit-limit", false);
-
-    static Category memoryStatCategory = new Category("memory-stats",
-            Key.TIMESTAMP, memoryTotalKey, memoryFreeKey, memoryBuffersKey,
-            memoryCachedKey, memorySwapTotalKey, memorySwapFreeKey, memoryCommitLimitKey);
-
-    private static Key<Integer> vmCpuVmIdKey = new Key<>("vm-id", false);
-    private static Key<Double> vmCpuLoadKey = new Key<>("processor-usage", false);
-
-    static Category vmCpuStatCategory = new Category("vm-cpu-stats",
-            vmCpuLoadKey, vmCpuVmIdKey);
 
     static {
         // Set up categories that will later be registered.
-        categories.add(hostInfoCategory);
-        categories.add(networkInfoCategory);
-        categories.add(cpuStatCategory);
-        categories.add(memoryStatCategory);
-        categories.add(vmCpuStatCategory);
-        categories.addAll(JvmStatHostListener.getCategories());
-        categories.addAll(JvmStatVmListener.getCategories());
+        categories.add(CpuStatDAO.cpuStatCategory);
+        categories.add(HostInfoDAO.hostInfoCategory);
+        categories.add(MemoryStatDAO.memoryStatCategory);
+        categories.add(NetworkInterfaceInfoDAO.networkInfoCategory);
         categories.add(VmClassStatDAO.vmClassStatsCategory);
+        categories.add(VmCpuStatDAO.vmCpuStatCategory);
+        categories.add(VmGcStatDAO.vmGcStatsCategory);
+        categories.add(VmInfoDAO.vmInfoCategory);
+        categories.add(VmMemoryStatDAO.vmMemoryStatsCategory);
     }
 
     @Override
@@ -173,21 +139,21 @@
         if (!getObserveNewJvm()) {
             logger.fine("not monitoring new vms");
         }
-        store(makeHostChunk(HostInfoBuilder.build()));
+        store(new HostInfoConverter().hostInfoToChunk(HostInfoBuilder.build()));
 
         timer = new Timer();
         timer.scheduleAtFixedRate(new TimerTask() {
             @Override
             public void run() {
-                store(makeCpuChunk(new CpuStatBuilder().build()));
+                store(new CpuStatConverter().cpuStatToChunk(new CpuStatBuilder().build()));
                 for (NetworkInterfaceInfo info: NetworkInfoBuilder.build().getInterfaces()) {
-                    store(makeNetworkChunk(info));
+                    store(new NetworkInterfaceInfoConverter().networkInfoToChunk(info));
                 }
-                store(makeMemoryChunk(new MemoryStatBuilder().build()));
+                store(new MemoryStatConverter().memoryStatToChunk(new MemoryStatBuilder().build()));
 
                 for (Integer pid : pidsToMonitor) {
                     new VmCpuStatBuilder();
-                    store(makeVmCpuChunk(VmCpuStatBuilder.build(pid)));
+                    store(new VmCpuStatConverter().vmCpuStatToChunk(VmCpuStatBuilder.build(pid)));
                 }
             }
         }, 0, procCheckInterval);
@@ -242,61 +208,6 @@
         return Collections.unmodifiableCollection(categories);
     }
 
-    private Chunk makeCpuChunk(CpuStat cpuStat) {
-        Chunk chunk = new Chunk(cpuStatCategory, false);
-        chunk.put(Key.TIMESTAMP, cpuStat.getTimeStamp());
-        chunk.put(cpu5LoadKey, cpuStat.getLoad5());
-        chunk.put(cpu10LoadKey, cpuStat.getLoad10());
-        chunk.put(cpu15LoadKey, cpuStat.getLoad15());
-        return chunk;
-    }
-
-    private Chunk makeHostChunk(HostInfo hostInfo) {
-        Chunk chunk = new Chunk(hostInfoCategory, false);
-        chunk.put(hostNameKey, hostInfo.getHostname());
-        chunk.put(osNameKey, hostInfo.getOsName());
-        chunk.put(osKernelKey, hostInfo.getOsKernel());
-        chunk.put(cpuCountKey, hostInfo.getCpuCount());
-        chunk.put(cpuModelKey, hostInfo.getCpuModel());
-        chunk.put(hostMemoryTotalKey, hostInfo.getTotalMemory());
-        return chunk;
-    }
-
-    private Chunk makeNetworkChunk(NetworkInterfaceInfo info) {
-        Chunk chunk = new Chunk(networkInfoCategory, true);
-        chunk.put(ifaceKey, info.getInterfaceName());
-        String ip4 = info.getIp4Addr();
-        if (ip4 != null) {
-            chunk.put(ip4AddrKey, ip4);
-        }
-        String ip6 = info.getIp6Addr();
-        if (ip6 != null) {
-            chunk.put(ip6AddrKey, ip6);
-        }
-        return chunk;
-    }
-
-    private Chunk makeMemoryChunk(MemoryStat mem) {
-        Chunk chunk = new Chunk(memoryStatCategory, false);
-        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, stat.getTimeStamp());
-        chunk.put(vmCpuVmIdKey, stat.getVmId());
-        chunk.put(vmCpuLoadKey, stat.getCpuLoad());
-        return chunk;
-    }
-
     @Override
     public boolean attachToNewProcessByDefault() {
         return true;
--- a/agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatHostListenerTest.java	Tue Mar 06 22:45:29 2012 +0100
+++ b/agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatHostListenerTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -36,25 +36,18 @@
 
 package com.redhat.thermostat.backend.system;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyString;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
-import java.util.Collection;
 import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
 import java.util.Set;
 
 import org.junit.Test;
 import org.mockito.Matchers;
 
-import com.redhat.thermostat.common.storage.Key;
-
 import sun.jvmstat.monitor.HostIdentifier;
 import sun.jvmstat.monitor.MonitoredHost;
 import sun.jvmstat.monitor.MonitoredVm;
@@ -92,25 +85,4 @@
         verify(vm).addVmListener(Matchers.isA(JvmStatVmClassListener.class));
     }
 
-    @Test
-    public void testCategory() {
-        assertEquals("vm-info", JvmStatHostListener.vmInfoCategory.getName());
-        Collection<Key<?>> keys = JvmStatHostListener.vmInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<Integer>("vm-id", true)));
-        assertTrue(keys.contains(new Key<Integer>("vm-pid", false)));
-        assertTrue(keys.contains(new Key<String>("runtime-version", false)));
-        assertTrue(keys.contains(new Key<String>("java-home", false)));
-        assertTrue(keys.contains(new Key<String>("main-class", false)));
-        assertTrue(keys.contains(new Key<String>("command-line", false)));
-        assertTrue(keys.contains(new Key<String>("vm-arguments", false)));
-        assertTrue(keys.contains(new Key<String>("vm-name", false)));
-        assertTrue(keys.contains(new Key<String>("vm-info", false)));
-        assertTrue(keys.contains(new Key<String>("vm-version", false)));
-        assertTrue(keys.contains(new Key<Map<String, String>>("environment", false)));
-        assertTrue(keys.contains(new Key<List<String>>("libraries", false)));
-        assertTrue(keys.contains(new Key<Long>("start-time", false)));
-        assertTrue(keys.contains(new Key<Long>("stop-time", false)));
-        assertEquals(14, keys.size());
-
-    }
 }
\ No newline at end of file
--- a/agent/src/test/java/com/redhat/thermostat/backend/system/JvmStatVmListenerTest.java	Tue Mar 06 22:45:29 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,92 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.backend.system;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.common.storage.Key;
-
-public class JvmStatVmListenerTest {
-
-    @Test
-    public void testCategories() {
-        assertEquals("vm-gc-stats", JvmStatVmListener.vmGcStatsCategory.getName());
-        Collection<Key<?>> keys = JvmStatVmListener.vmGcStatsCategory.getKeys();
-        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
-        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
-        assertTrue(keys.contains(new Key<String>("collector", false)));
-        assertTrue(keys.contains(new Key<Long>("runtime-count", false)));
-        assertTrue(keys.contains(new Key<Long>("wall-time", false)));
-        assertEquals(5, keys.size());
-        
-        assertEquals("vm-memory-stats", JvmStatVmListener.vmMemoryStatsCategory.getName());
-        keys = JvmStatVmListener.vmMemoryStatsCategory.getKeys();
-        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
-        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
-        assertTrue(keys.contains(new Key<String>("eden.gen", false)));
-        assertTrue(keys.contains(new Key<String>("eden.collector", false)));
-        assertTrue(keys.contains(new Key<Long>("eden.capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("eden.max-capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("eden.used", false)));
-        assertTrue(keys.contains(new Key<String>("s0.gen", false)));
-        assertTrue(keys.contains(new Key<String>("s0.collector", false)));
-        assertTrue(keys.contains(new Key<Long>("s0.capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("s0.max-capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("s0.used", false)));
-        assertTrue(keys.contains(new Key<String>("s1.gen", false)));
-        assertTrue(keys.contains(new Key<String>("s1.collector", false)));
-        assertTrue(keys.contains(new Key<Long>("s1.capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("s1.max-capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("s1.used", false)));
-        assertTrue(keys.contains(new Key<String>("old.gen", false)));
-        assertTrue(keys.contains(new Key<String>("old.collector", false)));
-        assertTrue(keys.contains(new Key<Long>("old.capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("old.max-capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("old.used", false)));
-        assertTrue(keys.contains(new Key<String>("perm.gen", false)));
-        assertTrue(keys.contains(new Key<String>("perm.collector", false)));
-        assertTrue(keys.contains(new Key<Long>("perm.capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("perm.max-capacity", false)));
-        assertTrue(keys.contains(new Key<Long>("perm.used", false)));
-        assertEquals(27, keys.size());
-    }
-}
--- a/agent/src/test/java/com/redhat/thermostat/backend/system/SystemBackendTest.java	Tue Mar 06 22:45:29 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/*
- * Copyright 2012 Red Hat, Inc.
- *
- * This file is part of Thermostat.
- *
- * Thermostat is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 2, or (at your
- * option) any later version.
- *
- * Thermostat is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Thermostat; see the file COPYING.  If not see
- * <http://www.gnu.org/licenses/>.
- *
- * Linking this code with other modules is making a combined work
- * based on this code.  Thus, the terms and conditions of the GNU
- * General Public License cover the whole combination.
- *
- * As a special exception, the copyright holders of this code give
- * you permission to link this code with independent modules to
- * produce an executable, regardless of the license terms of these
- * independent modules, and to copy and distribute the resulting
- * executable under terms of your choice, provided that you also
- * meet, for each linked independent module, the terms and conditions
- * of the license of that module.  An independent module is a module
- * which is not derived from or based on this code.  If you modify
- * this code, you may extend this exception to your version of the
- * library, but you are not obligated to do so.  If you do not wish
- * to do so, delete this exception statement from your version.
- */
-
-package com.redhat.thermostat.backend.system;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Collection;
-
-import org.junit.Test;
-
-import com.redhat.thermostat.common.storage.Key;
-
-public class SystemBackendTest {
-
-    @Test
-    public void testCategories() {
-        assertEquals("host-info", SystemBackend.hostInfoCategory.getName());
-        Collection<Key<?>> keys = SystemBackend.hostInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<String>("hostname", true)));
-        assertTrue(keys.contains(new Key<String>("os_name", false)));
-        assertTrue(keys.contains(new Key<String>("os_kernel", false)));
-        assertTrue(keys.contains(new Key<Integer>("cpu_num", false)));
-        assertTrue(keys.contains(new Key<String>("cpu_model", false)));
-        assertTrue(keys.contains(new Key<Long>("memory_total", false)));
-        assertEquals(6, keys.size());
-
-
-        assertEquals("network-info", SystemBackend.networkInfoCategory.getName());
-        keys = SystemBackend.networkInfoCategory.getKeys();
-        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
-        assertTrue(keys.contains(new Key<String>("iface", true)));
-        assertTrue(keys.contains(new Key<String>("ipv4addr", false)));
-        assertTrue(keys.contains(new Key<String>("ipv6addr", false)));
-        assertEquals(4, keys.size());
-
-
-        assertEquals("cpu-stats", SystemBackend.cpuStatCategory.getName());
-        keys = SystemBackend.cpuStatCategory.getKeys();
-        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
-        assertTrue(keys.contains(new Key<Double>("5load", false)));
-        assertTrue(keys.contains(new Key<Double>("10load", false)));
-        assertTrue(keys.contains(new Key<Double>("15load", false)));
-        assertEquals(4, keys.size());
-
-
-        assertEquals("memory-stats", SystemBackend.memoryStatCategory.getName());
-        keys = SystemBackend.memoryStatCategory.getKeys();
-        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
-        assertTrue(keys.contains(new Key<Long>("total", false)));
-        assertTrue(keys.contains(new Key<Long>("free", false)));
-        assertTrue(keys.contains(new Key<Long>("buffers", false)));
-        assertTrue(keys.contains(new Key<Long>("cached", false)));
-        assertTrue(keys.contains(new Key<Long>("swap-total", false)));
-        assertTrue(keys.contains(new Key<Long>("swap-free", false)));
-        assertTrue(keys.contains(new Key<Long>("commit-limit", false)));
-        assertEquals(8, keys.size());
-
-
-        assertEquals("vm-cpu-stats", SystemBackend.vmCpuStatCategory.getName());
-        keys = SystemBackend.vmCpuStatCategory.getKeys();
-        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
-        assertTrue(keys.contains(new Key<Integer>("processor-usage", false)));
-        assertEquals(2, keys.size());
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/CpuStatConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.mongodb.DBObject;
+import com.redhat.thermostat.common.CpuStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class CpuStatConverter {
+
+    public Chunk cpuStatToChunk(CpuStat cpuStat) {
+        Chunk chunk = new Chunk(CpuStatDAO.cpuStatCategory, false);
+        chunk.put(Key.TIMESTAMP, cpuStat.getTimeStamp());
+        chunk.put(CpuStatDAO.cpu5LoadKey, cpuStat.getLoad5());
+        chunk.put(CpuStatDAO.cpu10LoadKey, cpuStat.getLoad10());
+        chunk.put(CpuStatDAO.cpu15LoadKey, cpuStat.getLoad15());
+        return chunk;
+    }
+
+    public CpuStat fromDB(DBObject dbObj) {
+        long timestamp = (long) dbObj.get("timestamp");
+        double load5 = (Double) dbObj.get("5load");
+        double load10 = (Double) dbObj.get("10load");
+        double load15 = (Double) dbObj.get("15load");
+        return new CpuStat(timestamp, load5, load10, load15);
+    }
+
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/CpuStatDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class CpuStatDAO {
+
+    static Key<Double> cpu5LoadKey = new Key<>("5load", false);
+    static Key<Double> cpu10LoadKey = new Key<>("10load", false);
+    static Key<Double> cpu15LoadKey = new Key<>("15load", false);
+
+    public static final Category cpuStatCategory = new Category("cpu-stats",
+            Key.TIMESTAMP, cpu5LoadKey, cpu10LoadKey, cpu15LoadKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/HostInfoConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.HostInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+
+public class HostInfoConverter {
+
+    public Chunk hostInfoToChunk(HostInfo hostInfo) {
+        Chunk chunk = new Chunk(HostInfoDAO.hostInfoCategory, false);
+        chunk.put(HostInfoDAO.hostNameKey, hostInfo.getHostname());
+        chunk.put(HostInfoDAO.osNameKey, hostInfo.getOsName());
+        chunk.put(HostInfoDAO.osKernelKey, hostInfo.getOsKernel());
+        chunk.put(HostInfoDAO.cpuCountKey, hostInfo.getCpuCount());
+        chunk.put(HostInfoDAO.cpuModelKey, hostInfo.getCpuModel());
+        chunk.put(HostInfoDAO.hostMemoryTotalKey, hostInfo.getTotalMemory());
+        return chunk;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/HostInfoDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class HostInfoDAO {
+
+    static Key<String> hostNameKey = new Key<>("hostname", true);
+    static Key<String> osNameKey = new Key<>("os_name", false);
+    static Key<String> osKernelKey = new Key<>("os_kernel", false);
+    static Key<Integer> cpuCountKey = new Key<>("cpu_num", false);
+    static Key<String> cpuModelKey = new Key<>("cpu_model", false);
+    static Key<Long> hostMemoryTotalKey = new Key<>("memory_total", false);
+
+    public static final Category hostInfoCategory = new Category("host-info",
+            hostNameKey, osNameKey, osKernelKey,
+            cpuCountKey, cpuModelKey, hostMemoryTotalKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/MemoryStatConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.MemoryStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class MemoryStatConverter {
+
+    public Chunk memoryStatToChunk(MemoryStat mem) {
+        Chunk chunk = new Chunk(MemoryStatDAO.memoryStatCategory, false);
+        chunk.put(Key.TIMESTAMP, mem.getTimeStamp());
+        chunk.put(MemoryStatDAO.memoryTotalKey, mem.getTotal());
+        chunk.put(MemoryStatDAO.memoryFreeKey, mem.getFree());
+        chunk.put(MemoryStatDAO.memoryBuffersKey, mem.getBuffers());
+        chunk.put(MemoryStatDAO.memoryCachedKey, mem.getCached());
+        chunk.put(MemoryStatDAO.memorySwapTotalKey, mem.getSwapTotal());
+        chunk.put(MemoryStatDAO.memorySwapFreeKey, mem.getSwapFree());
+        chunk.put(MemoryStatDAO.memoryCommitLimitKey, mem.getCommitLimit());
+        return chunk;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/MemoryStatDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class MemoryStatDAO {
+
+    static Key<Long> memoryTotalKey = new Key<>("total", false);
+    static Key<Long> memoryFreeKey = new Key<>("free", false);
+    static Key<Long> memoryBuffersKey = new Key<>("buffers", false);
+    static Key<Long> memoryCachedKey = new Key<>("cached", false);
+    static Key<Long> memorySwapTotalKey = new Key<>("swap-total", false);
+    static Key<Long> memorySwapFreeKey = new Key<>("swap-free", false);
+    static Key<Long> memoryCommitLimitKey = new Key<>("commit-limit", false);
+
+    public static final Category memoryStatCategory = new Category("memory-stats",
+            Key.TIMESTAMP, memoryTotalKey, memoryFreeKey, memoryBuffersKey,
+            memoryCachedKey, memorySwapTotalKey, memorySwapFreeKey, memoryCommitLimitKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.NetworkInterfaceInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+
+public class NetworkInterfaceInfoConverter {
+
+    public Chunk networkInfoToChunk(NetworkInterfaceInfo info) {
+        Chunk chunk = new Chunk(NetworkInterfaceInfoDAO.networkInfoCategory, true);
+        chunk.put(NetworkInterfaceInfoDAO.ifaceKey, info.getInterfaceName());
+        String ip4 = info.getIp4Addr();
+        if (ip4 != null) {
+            chunk.put(NetworkInterfaceInfoDAO.ip4AddrKey, ip4);
+        }
+        String ip6 = info.getIp6Addr();
+        if (ip6 != null) {
+            chunk.put(NetworkInterfaceInfoDAO.ip6AddrKey, ip6);
+        }
+        return chunk;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class NetworkInterfaceInfoDAO {
+
+    static Key<String> ifaceKey = new Key<>("iface", true);
+    static Key<String> ip4AddrKey = new Key<>("ipv4addr", false);
+    static Key<String> ip6AddrKey = new Key<>("ipv6addr", false);
+
+    public static final Category networkInfoCategory = new Category("network-info",
+            Key.TIMESTAMP, ifaceKey, ip4AddrKey, ip6AddrKey);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmCpuStatConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.mongodb.DBObject;
+import com.redhat.thermostat.common.VmCpuStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmCpuStatConverter {
+
+    public Chunk vmCpuStatToChunk(VmCpuStat vmCpuStat) {
+        Chunk chunk = new Chunk(VmCpuStatDAO.vmCpuStatCategory, false);
+        chunk.put(Key.TIMESTAMP, vmCpuStat.getTimeStamp());
+        chunk.put(VmCpuStatDAO.vmCpuVmIdKey, vmCpuStat.getVmId());
+        chunk.put(VmCpuStatDAO.vmCpuLoadKey, vmCpuStat.getCpuLoad());
+        return chunk;
+    }
+
+    public VmCpuStat fromDB(DBObject dbObj) {
+        long timestamp = (Long) dbObj.get("timestamp");
+        int vmId = (Integer) dbObj.get("vm-id");
+        double processorUsage = (Double) dbObj.get("processor-usage");
+        return new VmCpuStat(timestamp, vmId, processorUsage);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmCpuStatDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmCpuStatDAO {
+
+    static final Key<Integer> vmCpuVmIdKey = new Key<>("vm-id", false);
+    static final Key<Double> vmCpuLoadKey = new Key<>("processor-usage", false);
+
+    public static final Category vmCpuStatCategory = new Category("vm-cpu-stats",
+            Key.TIMESTAMP, vmCpuLoadKey, vmCpuVmIdKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmGcStatConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.mongodb.DBObject;
+import com.redhat.thermostat.common.VmGcStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmGcStatConverter {
+
+    public Chunk vmGcStatToChunk(VmGcStat vmGcStat) {
+        Chunk chunk = new Chunk(VmGcStatDAO.vmGcStatsCategory, false);
+
+        chunk.put(VmGcStatDAO.vmGcStatVmIdKey, vmGcStat.getVmId());
+        chunk.put(Key.TIMESTAMP, vmGcStat.getTimeStamp());
+        chunk.put(VmGcStatDAO.vmGcStatCollectorKey, vmGcStat.getCollectorName());
+        chunk.put(VmGcStatDAO.vmGcStatRunCountKey, vmGcStat.getRunCount());
+        chunk.put(VmGcStatDAO.vmGCstatWallTimeKey, vmGcStat.getWallTime());
+
+        return chunk;
+    }
+
+    public VmGcStat fromDBObject(DBObject dbObj) {
+        int vmId = (Integer) dbObj.get("vm-id");
+        String collectorName = (String) dbObj.get("collector");
+        long timestamp = (Long) dbObj.get("timestamp");
+        long runCount = (Long) dbObj.get("runtime-count");
+        long wallTime = (Long) dbObj.get("wall-time");
+
+        return new VmGcStat(vmId, timestamp, collectorName, runCount, wallTime);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmGcStatDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmGcStatDAO {
+
+    static final Key<Integer> vmGcStatVmIdKey = new Key<>("vm-id", false);
+    static final Key<String> vmGcStatCollectorKey = new Key<>("collector", false);
+    static final Key<Long> vmGcStatRunCountKey = new Key<>("runtime-count", false);
+    /** time in microseconds */
+    static final Key<Long> vmGCstatWallTimeKey = new Key<>("wall-time", false);
+
+    public static final Category vmGcStatsCategory = new Category("vm-gc-stats",
+            vmGcStatVmIdKey, Key.TIMESTAMP, vmGcStatCollectorKey,
+            vmGcStatRunCountKey, vmGCstatWallTimeKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmInfoConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.VmInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+
+public class VmInfoConverter {
+
+    public Chunk vmInfoToChunk(VmInfo info) {
+        Chunk chunk = new Chunk(VmInfoDAO.vmInfoCategory, true);
+
+        chunk.put(VmInfoDAO.vmInfoIdKey, info.getVmId());
+        chunk.put(VmInfoDAO.vmInfoPidKey, info.getVmPid());
+        chunk.put(VmInfoDAO.vmInfoRuntimeVersionKey, info.getJavaVersion());
+        chunk.put(VmInfoDAO.vmInfoJavaHomeKey, info.getJavaHome());
+        chunk.put(VmInfoDAO.vmInfoMainClassKey, info.getMainClass());
+        chunk.put(VmInfoDAO.vmInfoCommandLineKey, info.getJavaCommandLine());
+        chunk.put(VmInfoDAO.vmInfoVmArgumentsKey, info.getVmArguments());
+        chunk.put(VmInfoDAO.vmInfoVmNameKey, info.getVmName());
+        chunk.put(VmInfoDAO.vmInfoVmInfoKey, info.getVmInfo());
+        chunk.put(VmInfoDAO.vmInfoVmVersionKey, info.getVmVersion());
+        chunk.put(VmInfoDAO.vmInfoEnvironmentKey, info.getEnvironment());
+        chunk.put(VmInfoDAO.vmInfoLibrariesKey, info.getLoadedNativeLibraries());
+        chunk.put(VmInfoDAO.vmInfoStartTimeKey, info.getStartTimeStamp());
+        chunk.put(VmInfoDAO.vmInfoStopTimeKey, info.getStopTimeStamp());
+        return chunk;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmInfoDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import java.util.List;
+import java.util.Map;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmInfoDAO {
+
+    // FIXME make it non-public
+    public static final Key<Integer> vmInfoIdKey = new Key<>("vm-id", true);
+    static final Key<Integer> vmInfoPidKey = new Key<>("vm-pid", false);
+    static final Key<String> vmInfoRuntimeVersionKey = new Key<>("runtime-version", false);
+    static final Key<String> vmInfoJavaHomeKey = new Key<>("java-home", false);
+    static final Key<String> vmInfoMainClassKey = new Key<>("main-class", false);
+    static final Key<String> vmInfoCommandLineKey = new Key<>("command-line", false);
+    static final Key<String> vmInfoVmArgumentsKey = new Key<>("vm-arguments", false);
+    static final Key<String> vmInfoVmNameKey = new Key<>("vm-name", false);
+    static final Key<String> vmInfoVmInfoKey = new Key<>("vm-info", false);
+    static final Key<String> vmInfoVmVersionKey = new Key<>("vm-version", false);
+    static final Key<Map<String, String>> vmInfoEnvironmentKey = new Key<>("environment", false);
+    static final Key<List<String>> vmInfoLibrariesKey = new Key<>("libraries", false);
+    static final Key<Long> vmInfoStartTimeKey = new Key<>("start-time", false);
+    // FIXME make it non-public
+    public static final Key<Long> vmInfoStopTimeKey = new Key<>("stop-time", false);
+
+    public static final Category vmInfoCategory = new Category("vm-info",
+            vmInfoIdKey, vmInfoPidKey, vmInfoRuntimeVersionKey, vmInfoJavaHomeKey,
+            vmInfoMainClassKey, vmInfoCommandLineKey,
+            vmInfoVmArgumentsKey, vmInfoVmNameKey, vmInfoVmInfoKey, vmInfoVmVersionKey,
+            vmInfoEnvironmentKey, vmInfoLibrariesKey,
+            vmInfoStartTimeKey, vmInfoStopTimeKey);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmMemoryStatConverter.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.VmMemoryStat;
+import com.redhat.thermostat.common.VmMemoryStat.Generation;
+import com.redhat.thermostat.common.VmMemoryStat.Space;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmMemoryStatConverter {
+
+    public Chunk vmMemoryStatToChunk(VmMemoryStat vmMemStat) {
+        Chunk chunk = new Chunk(VmMemoryStatDAO.vmMemoryStatsCategory, false);
+
+        chunk.put(VmMemoryStatDAO.vmMemoryStatVmIdKey, vmMemStat.getVmId());
+        chunk.put(Key.TIMESTAMP, vmMemStat.getTimeStamp());
+
+        Generation newGen = vmMemStat.getGeneration("new");
+        Space eden = newGen.getSpace("eden");
+
+        chunk.put(VmMemoryStatDAO.vmMemoryStatEdenGenKey, newGen.name);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatEdenCollectorKey, newGen.collector);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatEdenCapacityKey, eden.capacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatEdenMaxCapacityKey, eden.maxCapacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatEdenUsedKey, eden.used);
+
+        Space s0 = newGen.getSpace("s0");
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS0GenKey, newGen.name);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS0CollectorKey, newGen.collector);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS0CapacityKey, s0.capacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS0MaxCapacityKey, s0.maxCapacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS0UsedKey, s0.used);
+
+        Space s1 = newGen.getSpace("s1");
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS1GenKey, newGen.name);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS1CollectorKey, newGen.collector);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS1CapacityKey, s1.capacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS1MaxCapacityKey, s1.maxCapacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatS1UsedKey, s1.used);
+
+        Generation oldGen = vmMemStat.getGeneration("old");
+        Space old = oldGen.getSpace("old");
+
+        chunk.put(VmMemoryStatDAO.vmMemoryStatOldGenKey, oldGen.name);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatOldCollectorKey, oldGen.collector);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatOldCapacityKey, old.capacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatOldMaxCapacityKey, old.maxCapacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatOldUsedKey, old.used);
+
+        Generation permGen = vmMemStat.getGeneration("perm");
+        Space perm = permGen.getSpace("perm");
+
+        chunk.put(VmMemoryStatDAO.vmMemoryStatPermGenKey, permGen.name);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatPermCollectorKey, permGen.collector);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatPermCapacityKey, perm.capacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatPermMaxCapacityKey, perm.maxCapacity);
+        chunk.put(VmMemoryStatDAO.vmMemoryStatPermUsedKey, perm.used);
+
+        return chunk;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/main/java/com/redhat/thermostat/common/dao/VmMemoryStatDAO.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import com.redhat.thermostat.common.storage.Category;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmMemoryStatDAO {
+
+    static final Key<Integer> vmMemoryStatVmIdKey = new Key<>("vm-id", false);
+    static final Key<String> vmMemoryStatEdenGenKey = new Key<>("eden.gen", false);
+    static final Key<String> vmMemoryStatEdenCollectorKey = new Key<>("eden.collector", false);
+    static final Key<Long> vmMemoryStatEdenCapacityKey = new Key<>("eden.capacity", false);
+    static final Key<Long> vmMemoryStatEdenMaxCapacityKey = new Key<>("eden.max-capacity", false);
+    static final Key<Long> vmMemoryStatEdenUsedKey = new Key<>("eden.used", false);
+
+    static final Key<String> vmMemoryStatS0GenKey = new Key<>("s0.gen", false);
+    static final Key<String> vmMemoryStatS0CollectorKey = new Key<>("s0.collector", false);
+    static final Key<Long> vmMemoryStatS0CapacityKey = new Key<>("s0.capacity", false);
+    static final Key<Long> vmMemoryStatS0MaxCapacityKey = new Key<>("s0.max-capacity", false);
+    static final Key<Long> vmMemoryStatS0UsedKey = new Key<>("s0.used", false);
+
+    static final Key<String> vmMemoryStatS1GenKey = new Key<>("s1.gen", false);
+    static final Key<String> vmMemoryStatS1CollectorKey = new Key<>("s1.collector", false);
+    static final Key<Long> vmMemoryStatS1CapacityKey = new Key<>("s1.capacity", false);
+    static final Key<Long> vmMemoryStatS1MaxCapacityKey = new Key<>("s1.max-capacity", false);
+    static final Key<Long> vmMemoryStatS1UsedKey = new Key<>("s1.used", false);
+
+    static final Key<String> vmMemoryStatOldGenKey = new Key<>("old.gen", false);
+    static final Key<String> vmMemoryStatOldCollectorKey = new Key<>("old.collector", false);
+    static final Key<Long> vmMemoryStatOldCapacityKey = new Key<>("old.capacity", false);
+    static final Key<Long> vmMemoryStatOldMaxCapacityKey = new Key<>("old.max-capacity", false);
+    static final Key<Long> vmMemoryStatOldUsedKey = new Key<>("old.used", false);
+
+    static final Key<String> vmMemoryStatPermGenKey = new Key<>("perm.gen", false);
+    static final Key<String> vmMemoryStatPermCollectorKey = new Key<>("perm.collector", false);
+    static final Key<Long> vmMemoryStatPermCapacityKey = new Key<>("perm.capacity", false);
+    static final Key<Long> vmMemoryStatPermMaxCapacityKey = new Key<>("perm.max-capacity", false);
+    static final Key<Long> vmMemoryStatPermUsedKey = new Key<>("perm.used", false);
+
+    public static final Category vmMemoryStatsCategory = new Category("vm-memory-stats",
+            vmMemoryStatVmIdKey, Key.TIMESTAMP,
+            vmMemoryStatEdenGenKey, vmMemoryStatEdenCollectorKey,
+            vmMemoryStatEdenCapacityKey, vmMemoryStatEdenMaxCapacityKey,vmMemoryStatEdenUsedKey,
+            vmMemoryStatS0GenKey, vmMemoryStatS0CollectorKey, vmMemoryStatS0CapacityKey,
+            vmMemoryStatS0MaxCapacityKey, vmMemoryStatS0UsedKey,
+            vmMemoryStatS1GenKey, vmMemoryStatS1CollectorKey, vmMemoryStatS1CapacityKey,
+            vmMemoryStatS1MaxCapacityKey, vmMemoryStatS1UsedKey,
+            vmMemoryStatOldGenKey, vmMemoryStatOldCollectorKey, vmMemoryStatOldCapacityKey,
+            vmMemoryStatOldMaxCapacityKey, vmMemoryStatOldUsedKey,
+            vmMemoryStatPermGenKey, vmMemoryStatPermCollectorKey, vmMemoryStatPermCapacityKey,
+            vmMemoryStatPermMaxCapacityKey, vmMemoryStatPermUsedKey);
+
+}
--- a/common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java	Tue Mar 06 22:45:29 2012 +0100
+++ b/common/src/main/java/com/redhat/thermostat/common/storage/Chunk.java	Tue Mar 06 17:16:36 2012 -0500
@@ -50,11 +50,10 @@
     private Map<Key<?>, Object> values = new HashMap<Key<?>, Object>();
 
     /**
-     * 
-     * @param timestamp The time that should be associated with the data in this nugget.
+     *
      * @param category The {@link Category} of this data.  This should be a Category that the {@link Backend}
      * who is producing this Chunk has registered via {@link Storage#registerCategory()}
-     * @param add whether this chunk should replace the values based on the keys for this category,
+     * @param replace whether this chunk should replace the values based on the keys for this category,
      * or be added to a set of values in this category
      */
     public Chunk(Category category, boolean replace) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/CpuStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.CpuStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class CpuStatConverterTest {
+
+    @Test
+    public void testCpuStatToChunk() {
+        CpuStat stat = new CpuStat(10, 5.0, 10.0, 15.0);
+        Chunk chunk = new CpuStatConverter().cpuStatToChunk(stat);
+        assertNotNull(chunk);
+        assertEquals("cpu-stats", chunk.getCategory().getName());
+        assertEquals((Long) 10L, chunk.get(new Key<Long>("timestamp", false)));
+        assertEquals(5.0, chunk.get(new Key<Double>("5load", false)), 0.001);
+        assertEquals(10.0, chunk.get(new Key<Double>("10load", false)), 0.001);
+        assertEquals(15.0, chunk.get(new Key<Double>("15load", false)), 0.001);
+
+    }
+
+    // TODO test conversion the other way too
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/CpuStatDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class CpuStatDAOTest {
+
+    public void testCategory() {
+        assertEquals("cpu-stats", CpuStatDAO.cpuStatCategory.getName());
+        Collection<Key<?>> keys = CpuStatDAO.cpuStatCategory.getKeys();
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<Double>("5load", false)));
+        assertTrue(keys.contains(new Key<Double>("10load", false)));
+        assertTrue(keys.contains(new Key<Double>("15load", false)));
+        assertEquals(4, keys.size());
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/HostInfoConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.HostInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class HostInfoConverterTest {
+
+    @Test
+    public void testHostInfoToChunk() {
+        HostInfo info = new HostInfo("a-host", "an-os", "a-kernel", "a-cpu", 9, 99);
+
+        Chunk chunk = new HostInfoConverter().hostInfoToChunk(info);
+
+        assertEquals("host-info", chunk.getCategory().getName());
+        assertEquals("a-host", chunk.get(new Key<String>("hostname", true)));
+        assertEquals("an-os", chunk.get(new Key<String>("os_name", false)));
+        assertEquals("a-kernel", chunk.get(new Key<String>("os_kernel", false)));
+        assertEquals("a-cpu", chunk.get(new Key<String>("cpu_model", false)));
+        assertEquals((Integer)9, chunk.get(new Key<Integer>("cpu_num", false)));
+        assertEquals((Long) 99L, chunk.get(new Key<Long>("memory_total", false)));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/HostInfoDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class HostInfoDAOTest {
+
+    @Test
+    public void testCategory() {
+        assertEquals("host-info", HostInfoDAO.hostInfoCategory.getName());
+        Collection<Key<?>> keys = HostInfoDAO.hostInfoCategory.getKeys();
+        assertTrue(keys.contains(new Key<String>("hostname", true)));
+        assertTrue(keys.contains(new Key<String>("os_name", false)));
+        assertTrue(keys.contains(new Key<String>("os_kernel", false)));
+        assertTrue(keys.contains(new Key<String>("cpu_model", false)));
+        assertTrue(keys.contains(new Key<Integer>("cpu_num", false)));
+        assertTrue(keys.contains(new Key<Long>("memory_total", false)));
+        assertEquals(6, keys.size());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/MemoryStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.MemoryStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class MemoryStatConverterTest {
+
+    @Test
+    public void testMemoryStatToChunk() {
+        MemoryStat stat = new MemoryStat(0, 1, 2, 3, 4, 5, 6, 7);
+
+        Chunk chunk = new MemoryStatConverter().memoryStatToChunk(stat);
+
+        assertEquals((Long) 0l, chunk.get(Key.TIMESTAMP));
+        assertEquals((Long) 1l, chunk.get(new Key<Long>("total", false)));
+        assertEquals((Long) 2l, chunk.get(new Key<Long>("free", false)));
+        assertEquals((Long) 3l, chunk.get(new Key<Long>("buffers", false)));
+        assertEquals((Long) 4l, chunk.get(new Key<Long>("cached", false)));
+        assertEquals((Long) 5l, chunk.get(new Key<Long>("swap-total", false)));
+        assertEquals((Long) 6l, chunk.get(new Key<Long>("swap-free", false)));
+        assertEquals((Long) 7l, chunk.get(new Key<Long>("commit-limit", false)));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/MemoryStatDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class MemoryStatDAOTest {
+    @Test
+    public void testCategory() {
+        assertEquals("memory-stats", MemoryStatDAO.memoryStatCategory.getName());
+        Collection<Key<?>> keys = MemoryStatDAO.memoryStatCategory.getKeys();
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<Long>("total", false)));
+        assertTrue(keys.contains(new Key<Long>("free", false)));
+        assertTrue(keys.contains(new Key<Long>("buffers", false)));
+        assertTrue(keys.contains(new Key<Long>("cached", false)));
+        assertTrue(keys.contains(new Key<Long>("swap-total", false)));
+        assertTrue(keys.contains(new Key<Long>("swap-free", false)));
+        assertTrue(keys.contains(new Key<Long>("commit-limit", false)));
+        assertEquals(8, keys.size());
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.NetworkInterfaceInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class NetworkInterfaceInfoConverterTest {
+
+    @Test
+    public void testNetworkInfoToChunk() {
+        NetworkInterfaceInfo info = new NetworkInterfaceInfo("eth0");
+        info.setIp4Addr("4");
+        info.setIp6Addr("6");
+
+        Chunk chunk = new NetworkInterfaceInfoConverter().networkInfoToChunk(info);
+
+        assertEquals("network-info", chunk.getCategory().getName());
+        assertEquals("eth0", chunk.get(new Key<String>("iface", true)));
+        assertEquals("4", chunk.get(new Key<String>("ipv4addr", false)));
+        assertEquals("6", chunk.get(new Key<String>("ipv6addr", false)));
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/NetworkInterfaceInfoDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class NetworkInterfaceInfoDAOTest {
+
+    @Test
+    public void testCategory() {
+        Collection<Key<?>> keys;
+
+        assertEquals("network-info", NetworkInterfaceInfoDAO.networkInfoCategory.getName());
+        keys = NetworkInterfaceInfoDAO.networkInfoCategory.getKeys();
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<String>("iface", true)));
+        assertTrue(keys.contains(new Key<String>("ipv4addr", false)));
+        assertTrue(keys.contains(new Key<String>("ipv6addr", false)));
+        assertEquals(4, keys.size());
+    }
+}
--- a/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java	Tue Mar 06 22:45:29 2012 +0100
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmClassStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -58,4 +58,6 @@
         assertEquals((Integer) 123, chunk.get(new Key<Integer>("vm-id", false)));
         assertEquals((Long) 12345L, chunk.get(new Key<Long>("loadedClasses", false)));
     }
+
+    // TODO test conversion the other way too
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmCpuStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.VmCpuStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmCpuStatConverterTest {
+
+    @Test
+    public void testVmCpuStatToChunk() {
+        VmCpuStat vmCpuStat = new VmCpuStat(123, 456, 7.0);
+        Chunk chunk = new VmCpuStatConverter().vmCpuStatToChunk(vmCpuStat);
+        assertNotNull(chunk);
+        assertEquals("vm-cpu-stats", chunk.getCategory().getName());
+        assertEquals((Long) 123L, chunk.get(Key.TIMESTAMP));
+        assertEquals((Integer) 456, chunk.get(new Key<Long>("vm-id", false)));
+        assertEquals(7.0, chunk.get(new Key<Double>("processor-usage", false)), 0.001);
+
+    }
+
+    // TODO test conversion the other way too
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmCpuStatDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmCpuStatDAOTest {
+
+    @Test
+    public void testCategory() {
+        assertEquals("vm-cpu-stats", VmCpuStatDAO.vmCpuStatCategory.getName());
+        Collection<Key<?>> keys = VmCpuStatDAO.vmCpuStatCategory.getKeys();
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
+        assertTrue(keys.contains(new Key<Integer>("processor-usage", false)));
+        assertEquals(3, keys.size());
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmGcStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.VmGcStat;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmGcStatConverterTest {
+
+    @Test
+    public void testVmGcStatToChunk() {
+        final long RUN_COUNT = 10;
+        final long WALL_TIME = 9;
+        VmGcStat stat = new VmGcStat(123, 456, "collector1", RUN_COUNT, WALL_TIME);
+        Chunk chunk = new VmGcStatConverter().vmGcStatToChunk(stat);
+        assertNotNull(chunk);
+        assertEquals("vm-gc-stats", chunk.getCategory().getName());
+        assertEquals((Long)456L, chunk.get(new Key<Long>("timestamp", false)));
+        assertEquals((Integer)123, chunk.get(new Key<Integer>("vm-id", false)));
+        assertEquals("collector1", chunk.get(new Key<String>("collector", false)));
+        assertEquals((Long)RUN_COUNT, chunk.get(new Key<Long>("runtime-count", false)));
+        assertEquals((Long)WALL_TIME, chunk.get(new Key<Long>("wall-time", false)));
+
+    }
+
+    // TODO test conversion the other way too
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmGcStatDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmGcStatDAOTest {
+
+    @Test
+    public void testCategory() {
+        assertEquals("vm-gc-stats", VmGcStatDAO.vmGcStatsCategory.getName());
+        Collection<Key<?>> keys = VmGcStatDAO.vmGcStatsCategory.getKeys();
+        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<String>("collector", false)));
+        assertTrue(keys.contains(new Key<Long>("runtime-count", false)));
+        assertTrue(keys.contains(new Key<Long>("wall-time", false)));
+        assertEquals(5, keys.size());
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmInfoConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.VmInfo;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmInfoConverterTest {
+
+    @Test
+    public void testVmInfoToChunk() {
+        Map<String, String> environment = new HashMap<String, String>();
+        Map<String, String> properties = new HashMap<String, String>();
+        List<String> loadedNativeLibraries = new ArrayList<String>();
+        VmInfo info = new VmInfo(0, 1, 2,
+                "java-version", "java-home", "main-class", "command-line",
+                "vm-name", "vm-info", "vm-version", "vm-arguments",
+                properties, environment, loadedNativeLibraries);
+
+        Chunk chunk = new VmInfoConverter().vmInfoToChunk(info);
+
+        assertNotNull(chunk);
+        assertEquals((Integer) 0, chunk.get(new Key<Integer>("vm-id", true)));
+        assertEquals((Integer) 0, chunk.get(new Key<Integer>("vm-pid", false)));
+        assertEquals((Long) 1l, chunk.get(new Key<Long>("start-time", false)));
+        assertEquals((Long) 2l, chunk.get(new Key<Long>("stop-time", false)));
+        assertEquals("java-version", chunk.get(new Key<String>("runtime-version", false)));
+        assertEquals("java-home", chunk.get(new Key<String>("java-home", false)));
+        assertEquals("main-class", chunk.get(new Key<String>("main-class", false)));
+        assertEquals("command-line", chunk.get(new Key<String>("command-line", false)));
+        assertEquals("vm-name", chunk.get(new Key<String>("vm-name", false)));
+        assertEquals("vm-info", chunk.get(new Key<String>("vm-info", false)));
+        assertEquals("vm-version", chunk.get(new Key<String>("vm-version", false)));
+        assertEquals("vm-arguments", chunk.get(new Key<String>("vm-arguments", false)));
+
+        // FIXME test environment, properties and loaded native libraries later
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmInfoDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmInfoDAOTest {
+    @Test
+    public void testCategory() {
+        assertEquals("vm-info", VmInfoDAO.vmInfoCategory.getName());
+        Collection<Key<?>> keys = VmInfoDAO.vmInfoCategory.getKeys();
+        assertTrue(keys.contains(new Key<Integer>("vm-id", true)));
+        assertTrue(keys.contains(new Key<Integer>("vm-pid", false)));
+        assertTrue(keys.contains(new Key<String>("runtime-version", false)));
+        assertTrue(keys.contains(new Key<String>("java-home", false)));
+        assertTrue(keys.contains(new Key<String>("main-class", false)));
+        assertTrue(keys.contains(new Key<String>("command-line", false)));
+        assertTrue(keys.contains(new Key<String>("vm-arguments", false)));
+        assertTrue(keys.contains(new Key<String>("vm-name", false)));
+        assertTrue(keys.contains(new Key<String>("vm-info", false)));
+        assertTrue(keys.contains(new Key<String>("vm-version", false)));
+        assertTrue(keys.contains(new Key<Map<String, String>>("environment", false)));
+        assertTrue(keys.contains(new Key<List<String>>("libraries", false)));
+        assertTrue(keys.contains(new Key<Long>("start-time", false)));
+        assertTrue(keys.contains(new Key<Long>("stop-time", false)));
+        assertEquals(14, keys.size());
+
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmMemoryStatConverterTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,120 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.VmMemoryStat;
+import com.redhat.thermostat.common.VmMemoryStat.Generation;
+import com.redhat.thermostat.common.VmMemoryStat.Space;
+import com.redhat.thermostat.common.storage.Chunk;
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmMemoryStatConverterTest {
+
+    @Test
+    public void testVmMemoryStatToChunk() {
+        List<Generation> generations = new ArrayList<Generation>();
+
+        int i = 0;
+        for (String genName: new String[] { "new", "old", "perm" }) {
+            Generation gen = new Generation();
+            gen.name = genName;
+            gen.collector = gen.name;
+            generations.add(gen);
+            List<Space> spaces = new ArrayList<Space>();
+            gen.spaces = spaces;
+            String[] spaceNames = null;
+            if (genName.equals("new")) {
+                spaceNames = new String[] { "eden", "s0", "s1" };
+            } else if (genName.equals("old")) {
+                spaceNames = new String[] { "old" };
+            } else {
+                spaceNames = new String[] { "perm" };
+            }
+            for (String spaceName: spaceNames) {
+                Space space = new Space();
+                space.name = spaceName;
+                space.index = 0;
+                space.used = i++;
+                space.capacity = i++;
+                space.maxCapacity = i++;
+                spaces.add(space);
+            }
+        }
+
+        VmMemoryStat stat = new VmMemoryStat(1, 2, generations);
+
+        Chunk chunk = new VmMemoryStatConverter().vmMemoryStatToChunk(stat);
+
+        assertNotNull(chunk);
+        assertEquals((Long) 1l, chunk.get(new Key<Long>("timestamp", false)));
+        assertEquals((Integer) 2, chunk.get(new Key<Integer>("vm-id", false)));
+        assertEquals("new", chunk.get(new Key<String>("eden.gen", false)));
+        assertEquals("new", chunk.get(new Key<String>("eden.collector", false)));
+        assertEquals((Long) 0l, chunk.get(new Key<Long>("eden.used", false)));
+        assertEquals((Long) 1l, chunk.get(new Key<Long>("eden.capacity", false)));
+        assertEquals((Long) 2l, chunk.get(new Key<Long>("eden.max-capacity", false)));
+        assertEquals("new", chunk.get(new Key<String>("s0.gen", false)));
+        assertEquals("new", chunk.get(new Key<String>("s0.collector", false)));
+        assertEquals((Long) 3l, chunk.get(new Key<Long>("s0.used", false)));
+        assertEquals((Long) 4l, chunk.get(new Key<Long>("s0.capacity", false)));
+        assertEquals((Long) 5l, chunk.get(new Key<Long>("s0.max-capacity", false)));
+        assertEquals("new", chunk.get(new Key<String>("s1.gen", false)));
+        assertEquals("new", chunk.get(new Key<String>("s1.collector", false)));
+        assertEquals((Long) 6l, chunk.get(new Key<Long>("s1.used", false)));
+        assertEquals((Long) 7l, chunk.get(new Key<Long>("s1.capacity", false)));
+        assertEquals((Long) 8l, chunk.get(new Key<Long>("s1.max-capacity", false)));
+        assertEquals("old", chunk.get(new Key<String>("old.gen", false)));
+        assertEquals("old", chunk.get(new Key<String>("old.collector", false)));
+        assertEquals((Long) 9l, chunk.get(new Key<Long>("old.used", false)));
+        assertEquals((Long) 10l, chunk.get(new Key<Long>("old.capacity", false)));
+        assertEquals((Long) 11l, chunk.get(new Key<Long>("old.max-capacity", false)));
+        assertEquals("perm", chunk.get(new Key<String>("perm.gen", false)));
+        assertEquals("perm", chunk.get(new Key<String>("perm.collector", false)));
+        assertEquals((Long) 12l, chunk.get(new Key<Long>("perm.used", false)));
+        assertEquals((Long) 13l, chunk.get(new Key<Long>("perm.capacity", false)));
+        assertEquals((Long) 14l, chunk.get(new Key<Long>("perm.max-capacity", false)));
+
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/src/test/java/com/redhat/thermostat/common/dao/VmMemoryStatDAOTest.java	Tue Mar 06 17:16:36 2012 -0500
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2012 Red Hat, Inc.
+ *
+ * This file is part of Thermostat.
+ *
+ * Thermostat is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation; either version 2, or (at your
+ * option) any later version.
+ *
+ * Thermostat is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Thermostat; see the file COPYING.  If not see
+ * <http://www.gnu.org/licenses/>.
+ *
+ * Linking this code with other modules is making a combined work
+ * based on this code.  Thus, the terms and conditions of the GNU
+ * General Public License cover the whole combination.
+ *
+ * As a special exception, the copyright holders of this code give
+ * you permission to link this code with independent modules to
+ * produce an executable, regardless of the license terms of these
+ * independent modules, and to copy and distribute the resulting
+ * executable under terms of your choice, provided that you also
+ * meet, for each linked independent module, the terms and conditions
+ * of the license of that module.  An independent module is a module
+ * which is not derived from or based on this code.  If you modify
+ * this code, you may extend this exception to your version of the
+ * library, but you are not obligated to do so.  If you do not wish
+ * to do so, delete this exception statement from your version.
+ */
+
+package com.redhat.thermostat.common.dao;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.redhat.thermostat.common.storage.Key;
+
+public class VmMemoryStatDAOTest {
+    @Test
+    public void testCategories() {
+        Collection<Key<?>> keys;
+
+        assertEquals("vm-memory-stats", VmMemoryStatDAO.vmMemoryStatsCategory.getName());
+        keys = VmMemoryStatDAO.vmMemoryStatsCategory.getKeys();
+        assertTrue(keys.contains(new Key<Integer>("vm-id", false)));
+        assertTrue(keys.contains(new Key<Long>("timestamp", false)));
+        assertTrue(keys.contains(new Key<String>("eden.gen", false)));
+        assertTrue(keys.contains(new Key<String>("eden.collector", false)));
+        assertTrue(keys.contains(new Key<Long>("eden.capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("eden.max-capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("eden.used", false)));
+        assertTrue(keys.contains(new Key<String>("s0.gen", false)));
+        assertTrue(keys.contains(new Key<String>("s0.collector", false)));
+        assertTrue(keys.contains(new Key<Long>("s0.capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("s0.max-capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("s0.used", false)));
+        assertTrue(keys.contains(new Key<String>("s1.gen", false)));
+        assertTrue(keys.contains(new Key<String>("s1.collector", false)));
+        assertTrue(keys.contains(new Key<Long>("s1.capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("s1.max-capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("s1.used", false)));
+        assertTrue(keys.contains(new Key<String>("old.gen", false)));
+        assertTrue(keys.contains(new Key<String>("old.collector", false)));
+        assertTrue(keys.contains(new Key<Long>("old.capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("old.max-capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("old.used", false)));
+        assertTrue(keys.contains(new Key<String>("perm.gen", false)));
+        assertTrue(keys.contains(new Key<String>("perm.collector", false)));
+        assertTrue(keys.contains(new Key<Long>("perm.capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("perm.max-capacity", false)));
+        assertTrue(keys.contains(new Key<Long>("perm.used", false)));
+        assertEquals(27, keys.size());
+    }
+}