changeset 1247:352dd55544d0

Use WriterID service over Storage.get/setAgentId() (Part 2). Reviewed-by: neugens, vanaltj Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2013-September/008098.html PR1509
author Severin Gehwolf <sgehwolf@redhat.com>
date Mon, 02 Sep 2013 11:28:59 +0200
parents bac262a2c98f
children 84ea87a65eda
files host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/Activator.java host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilder.java host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackend.java host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilderTest.java host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/model/CpuStat.java host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/model/CpuStatTest.java host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/Activator.java host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackend.java host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilder.java host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilderTest.java host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/model/MemoryStat.java host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/model/MemoryStatTest.java numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/Activator.java numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/NumaBackend.java numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/NumaBackendTest.java numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaHostInfo.java numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaStat.java numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaHostInfoTest.java numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaNodeStatTest.java numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaStatTest.java numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaDAOImplTest.java
diffstat 33 files changed, 296 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/Activator.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/Activator.java	Mon Sep 02 11:28:59 2013 +0200
@@ -50,13 +50,14 @@
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.cpu.common.CpuStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class Activator implements BundleActivator {
     
     private ScheduledExecutorService executor;
     private MultipleServiceTracker tracker;
     private HostCpuBackend backend;
-    private ServiceRegistration reg;
+    private ServiceRegistration<Backend> reg;
     
     @Override
     public void start(final BundleContext context) throws Exception {
@@ -64,7 +65,8 @@
 
         Class<?>[] deps = new Class<?>[] {
                 BackendService.class,
-                CpuStatDAO.class
+                CpuStatDAO.class,
+                WriterID.class, // Host cpu backend uses it
         };
         tracker = new MultipleServiceTracker(context, deps, new Action() {
             
@@ -72,8 +74,9 @@
             public void dependenciesAvailable(Map<String, Object> services) {
                 CpuStatDAO cpuStatDao = (CpuStatDAO) services.get(CpuStatDAO.class.getName());
                 Version version = new Version(context.getBundle());
-                backend = new HostCpuBackend(executor, cpuStatDao, version);
-                reg = context.registerService(Backend.class.getName(), backend, null);
+                WriterID id = (WriterID) services.get(WriterID.class.getName());
+                backend = new HostCpuBackend(executor, cpuStatDao, version, id);
+                reg = context.registerService(Backend.class, backend, null);
             }
 
             @Override
--- a/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilder.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilder.java	Mon Sep 02 11:28:59 2013 +0200
@@ -44,6 +44,7 @@
 import com.redhat.thermostat.common.Clock;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.host.cpu.common.model.CpuStat;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 
 public class CpuStatBuilder {
@@ -53,13 +54,15 @@
     private final ProcDataSource dataSource;
     private final Clock clock;
     private final long ticksPerSecond;
+    private final WriterID writerId;
 
     private boolean initialized = false;
 
     private long[] previousCpuTicks;
     private long previousTime;
 
-    public CpuStatBuilder(Clock clock, ProcDataSource dataSource, long ticksPerSecond) {
+    public CpuStatBuilder(Clock clock, ProcDataSource dataSource, long ticksPerSecond, WriterID writerId) {
+        this.writerId = writerId;
         this.dataSource = dataSource;
         this.clock = clock;
         this.ticksPerSecond = ticksPerSecond;
@@ -94,8 +97,9 @@
         }
         previousTime = currentTime;
         previousCpuTicks = currentValues;
+        String wId = writerId.getWriterID();
 
-        return new CpuStat(currentRealTime, cpuUsage);
+        return new CpuStat(wId, currentRealTime, cpuUsage);
     }
 
     private long[] getCurrentCpuTicks() {
--- a/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackend.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/main/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackend.java	Mon Sep 02 11:28:59 2013 +0200
@@ -44,6 +44,7 @@
 import com.redhat.thermostat.common.SystemClock;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.cpu.common.CpuStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 import com.redhat.thermostat.utils.SysConf;
 
@@ -56,7 +57,8 @@
     private ScheduledExecutorService executor;
     private boolean started;
 
-    public HostCpuBackend(ScheduledExecutorService executor, CpuStatDAO cpuStatDAO, Version version) {
+    public HostCpuBackend(ScheduledExecutorService executor,
+            CpuStatDAO cpuStatDAO, Version version, final WriterID writerId) {
         super("Host CPU Backend",
                 "Gathers CPU statistics about a host",
                 "Red Hat, Inc.",
@@ -66,7 +68,7 @@
         Clock clock = new SystemClock();
         long ticksPerSecond = SysConf.getClockTicksPerSecond();
         ProcDataSource source = new ProcDataSource();
-        cpuStatBuilder = new CpuStatBuilder(clock, source, ticksPerSecond);
+        cpuStatBuilder = new CpuStatBuilder(clock, source, ticksPerSecond, writerId);
     }
 
     @Override
--- a/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/ActivatorTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -50,6 +50,7 @@
 import com.redhat.thermostat.backend.Backend;
 import com.redhat.thermostat.backend.BackendService;
 import com.redhat.thermostat.host.cpu.common.CpuStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.testutils.StubBundleContext;
 
 public class ActivatorTest {
@@ -63,7 +64,7 @@
         activator.start(context);
 
         assertEquals(0, context.getAllServices().size());
-        assertEquals(2, context.getServiceListeners().size());
+        assertEquals(3, context.getServiceListeners().size());
 
         activator.stop(context);
     }
@@ -81,9 +82,11 @@
         
         BackendService service = mock(BackendService.class);
         CpuStatDAO cpuStatDAO = mock(CpuStatDAO.class);
+        WriterID id = mock(WriterID.class);
 
         context.registerService(BackendService.class, service, null);
         context.registerService(CpuStatDAO.class, cpuStatDAO, null);
+        context.registerService(WriterID.class, id, null);
 
         Activator activator = new Activator();
 
@@ -98,7 +101,7 @@
         assertFalse(backend.isActive());
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(2, context.getAllServices().size());
+        assertEquals(3, context.getAllServices().size());
     }
 
 }
--- a/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilderTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/CpuStatBuilderTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -52,6 +52,7 @@
 import com.redhat.thermostat.common.Clock;
 import com.redhat.thermostat.common.SystemClock;
 import com.redhat.thermostat.host.cpu.common.model.CpuStat;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 
 public class CpuStatBuilderTest {
@@ -59,7 +60,8 @@
     @Test
     public void testSimpleBuild() {
         ProcDataSource dataSource = new ProcDataSource();
-        CpuStatBuilder builder= new CpuStatBuilder(new SystemClock(), dataSource, 100l);
+        WriterID writerId = mock(WriterID.class);
+        CpuStatBuilder builder= new CpuStatBuilder(new SystemClock(), dataSource, 100l, writerId);
         builder.initialize();
         CpuStat stat = builder.build();
         assertNotNull(stat);
@@ -70,7 +72,7 @@
         Clock clock = mock(Clock.class);
         ProcDataSource dataSource = mock(ProcDataSource.class);
         long ticksPerSecond = 1;
-        CpuStatBuilder builder = new CpuStatBuilder(clock, dataSource, ticksPerSecond);
+        CpuStatBuilder builder = new CpuStatBuilder(clock, dataSource, ticksPerSecond, null);
         builder.build();
     }
 
@@ -98,7 +100,8 @@
 
         ProcDataSource dataSource = mock(ProcDataSource.class);
         when(dataSource.getStatReader()).thenReturn(reader1).thenReturn(reader2);
-        CpuStatBuilder builder = new CpuStatBuilder(clock, dataSource, ticksPerSecond);
+        WriterID writerId = mock(WriterID.class);
+        CpuStatBuilder builder = new CpuStatBuilder(clock, dataSource, ticksPerSecond, writerId);
 
         builder.initialize();
 
--- a/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/agent/src/test/java/com/redhat/thermostat/host/cpu/agent/internal/HostCpuBackendTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -54,6 +54,7 @@
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.cpu.common.CpuStatDAO;
 import com.redhat.thermostat.host.cpu.common.model.CpuStat;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class HostCpuBackendTest {
     
@@ -67,8 +68,9 @@
         cpuStatDao = mock(CpuStatDAO.class);
         Version version = mock(Version.class);
         when(version.getVersionNumber()).thenReturn("0.0.0");
+        WriterID id = mock(WriterID.class);
         
-        backend = new HostCpuBackend(executor, cpuStatDao, version);
+        backend = new HostCpuBackend(executor, cpuStatDao, version, id);
     }
 
     @Test
--- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuControllerTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -99,12 +99,12 @@
         when(appSvc.getTimerFactory()).thenReturn(timerFactory);
 
         // Setup DAOs.
-        HostInfo hostInfo = new HostInfo("fluffhost1", "fluffOs1", "fluffKernel1", "fluffCpu1", 12345, 98765);
+        HostInfo hostInfo = new HostInfo("foo-agent", "fluffhost1", "fluffOs1", "fluffKernel1", "fluffCpu1", 12345, 98765);
         HostInfoDAO hostInfoDAO = mock(HostInfoDAO.class);
         when(hostInfoDAO.getHostInfo(any(HostRef.class))).thenReturn(hostInfo);
 
-        CpuStat cpuStat1 = new CpuStat(1l, new double[] {10.0, 20.0, 30.0});
-        CpuStat cpuStat2 = new CpuStat(2l, new double[] {15.0, 25.0, 35.0});
+        CpuStat cpuStat1 = new CpuStat("foo", 1l, new double[] {10.0, 20.0, 30.0});
+        CpuStat cpuStat2 = new CpuStat("foo", 2l, new double[] {15.0, 25.0, 35.0});
         CpuStatDAO cpuStatDAO = mock(CpuStatDAO.class);
         when(cpuStatDAO.getLatestCpuStats(any(HostRef.class), anyLong())).thenReturn(Arrays.asList(cpuStat1, cpuStat2));
 
--- a/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/model/CpuStat.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/common/src/main/java/com/redhat/thermostat/host/cpu/common/model/CpuStat.java	Mon Sep 02 11:28:59 2013 +0200
@@ -50,10 +50,11 @@
     private double[] perProcessorUsage;
 
     public CpuStat() {
-        this(-1, null);
+        this(null, -1, null);
     }
 
-    public CpuStat(long timestamp, double[] perProcessorUsage) {
+    public CpuStat(String writerId, long timestamp, double[] perProcessorUsage) {
+        super(writerId);
         this.timeStamp = timestamp;
         this.perProcessorUsage = perProcessorUsage;
     }
--- a/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/internal/CpuStatDAOTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -90,7 +90,7 @@
         CpuStatDAO dao = new CpuStatDAOImpl(storage);
 
         Double LOAD = 5.0;
-        CpuStat cpuStat = new CpuStat(1234L, new double[] { LOAD });
+        CpuStat cpuStat = new CpuStat("foo", 1234L, new double[] { LOAD });
 
         when(cursor.hasNext()).thenReturn(true).thenReturn(false);
         when(cursor.next()).thenReturn(cpuStat);
@@ -130,7 +130,7 @@
 
         CpuStatDAO dao = new CpuStatDAOImpl(storage);
 
-        CpuStat cpuStat = new CpuStat(1234L, new double[] { 5.0 });
+        CpuStat cpuStat = new CpuStat("foo", 1234L, new double[] { 5.0 });
 
         when(cursor.hasNext()).thenReturn(true).thenReturn(false);
         when(cursor.next()).thenReturn(cpuStat);
@@ -156,7 +156,7 @@
         Add<CpuStat> add = mock(Add.class);
         when(storage.createAdd(eq(CpuStatDAO.cpuStatCategory))).thenReturn(add);
         
-        CpuStat stat = new CpuStat(1,  new double[] {5.0, 10.0, 15.0});
+        CpuStat stat = new CpuStat("foo", 1,  new double[] {5.0, 10.0, 15.0});
         CpuStatDAO dao = new CpuStatDAOImpl(storage);
         dao.putCpuStat(stat);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/host-cpu/common/src/test/java/com/redhat/thermostat/host/cpu/common/model/CpuStatTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012, 2013 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.host.cpu.common.model;
+
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+public class CpuStatTest {
+
+    @Test
+    public void testBasicInstantiation() {
+        try {
+            // pojo converters use this
+            CpuStat.class.newInstance();
+        } catch (Exception e) {
+            fail("should be able to instantiate using no-arg constructor");
+        }
+    }
+}
--- a/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/Activator.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/Activator.java	Mon Sep 02 11:28:59 2013 +0200
@@ -50,13 +50,14 @@
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.memory.common.MemoryStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class Activator implements BundleActivator {
     
     private ScheduledExecutorService executor;
     private MultipleServiceTracker tracker;
     private HostMemoryBackend backend;
-    private ServiceRegistration reg;
+    private ServiceRegistration<?> reg;
     
     @Override
     public void start(final BundleContext context) throws Exception {
@@ -64,7 +65,8 @@
 
         Class<?>[] deps = new Class<?>[] {
                 BackendService.class,
-                MemoryStatDAO.class
+                MemoryStatDAO.class,
+                WriterID.class, // host memory backen uses it
         };
         tracker = new MultipleServiceTracker(context, deps, new Action() {
             
@@ -72,7 +74,8 @@
             public void dependenciesAvailable(Map<String, Object> services) {
                 MemoryStatDAO memoryStatDao = (MemoryStatDAO) services.get(MemoryStatDAO.class.getName());
                 Version version = new Version(context.getBundle());
-                backend = new HostMemoryBackend(executor, memoryStatDao, version);
+                WriterID id = (WriterID) services.get(WriterID.class.getName());
+                backend = new HostMemoryBackend(executor, memoryStatDao, version, id);
                 reg = context.registerService(Backend.class.getName(), backend, null);
             }
 
--- a/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackend.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackend.java	Mon Sep 02 11:28:59 2013 +0200
@@ -42,6 +42,7 @@
 import com.redhat.thermostat.backend.BaseBackend;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.memory.common.MemoryStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 
 public class HostMemoryBackend extends BaseBackend {
@@ -53,7 +54,7 @@
     private ScheduledExecutorService executor;
     private boolean started;
 
-    public HostMemoryBackend(ScheduledExecutorService executor, MemoryStatDAO memoryStatDAO, Version version) {
+    public HostMemoryBackend(ScheduledExecutorService executor, MemoryStatDAO memoryStatDAO, Version version, final WriterID writerId) {
         super("Host Memory Backend",
                 "Gathers memory statistics about a host",
                 "Red Hat, Inc.",
@@ -62,7 +63,7 @@
         this.memoryStats = memoryStatDAO;
 
         ProcDataSource source = new ProcDataSource();
-        memoryStatBuilder = new MemoryStatBuilder(source);
+        memoryStatBuilder = new MemoryStatBuilder(source, writerId);
     }
 
     @Override
--- a/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilder.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/main/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilder.java	Mon Sep 02 11:28:59 2013 +0200
@@ -45,6 +45,7 @@
 import com.redhat.thermostat.common.Size;
 import com.redhat.thermostat.common.utils.LoggingUtils;
 import com.redhat.thermostat.host.memory.common.model.MemoryStat;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 
 /**
@@ -65,9 +66,11 @@
     private static final Logger logger = LoggingUtils.getLogger(MemoryStatBuilder.class);
 
     private final ProcDataSource dataSource;
+    private final WriterID writerId;
 
-    public MemoryStatBuilder(ProcDataSource dataSource) {
+    public MemoryStatBuilder(ProcDataSource dataSource, WriterID writerId) {
         this.dataSource = dataSource;
+        this.writerId = writerId;
     }
 
     protected MemoryStat build() {
@@ -108,8 +111,8 @@
         } catch (IOException ioe) {
             logger.log(Level.WARNING, "unable to read memory info");
         }
-
-        return new MemoryStat(timestamp, total, free, buffers, cached, swapTotal, swapFree, commitLimit);
+        String wId = writerId.getWriterID();
+        return new MemoryStat(wId, timestamp, total, free, buffers, cached, swapTotal, swapFree, commitLimit);
     }
 
     private long getValue(String rawValue) {
--- a/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/ActivatorTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -50,6 +50,7 @@
 import com.redhat.thermostat.backend.Backend;
 import com.redhat.thermostat.backend.BackendService;
 import com.redhat.thermostat.host.memory.common.MemoryStatDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.testutils.StubBundleContext;
 
 public class ActivatorTest {
@@ -63,7 +64,7 @@
         activator.start(context);
 
         assertEquals(0, context.getAllServices().size());
-        assertEquals(2, context.getServiceListeners().size());
+        assertEquals(3, context.getServiceListeners().size());
 
         activator.stop(context);
     }
@@ -81,9 +82,11 @@
         
         BackendService service = mock(BackendService.class);
         MemoryStatDAO cpuStatDAO = mock(MemoryStatDAO.class);
+        WriterID writerService = mock(WriterID.class);
 
         context.registerService(BackendService.class, service, null);
         context.registerService(MemoryStatDAO.class, cpuStatDAO, null);
+        context.registerService(WriterID.class, writerService, null);
 
         Activator activator = new Activator();
 
@@ -98,7 +101,7 @@
         assertFalse(backend.isActive());
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(2, context.getAllServices().size());
+        assertEquals(3, context.getAllServices().size());
     }
 
 }
--- a/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/HostMemoryBackendTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -53,6 +53,7 @@
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.host.memory.common.MemoryStatDAO;
 import com.redhat.thermostat.host.memory.common.model.MemoryStat;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class HostMemoryBackendTest {
     
@@ -67,8 +68,9 @@
         
         Version version = mock(Version.class);
         when(version.getVersionNumber()).thenReturn("0.0.0");
+        WriterID id = mock(WriterID.class);
         
-        backend = new HostMemoryBackend(executor, memoryStatDao, version);
+        backend = new HostMemoryBackend(executor, memoryStatDao, version, id);
     }
 
     @Test
--- a/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilderTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/agent/src/test/java/com/redhat/thermostat/host/memory/agent/internal/MemoryStatBuilderTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -46,18 +46,27 @@
 import java.io.IOException;
 import java.io.StringReader;
 
+import org.junit.Before;
 import org.junit.Test;
 
 import com.redhat.thermostat.host.memory.common.model.MemoryStat;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.utils.ProcDataSource;
 
 public class MemoryStatBuilderTest {
 
     private static final int KILOBYTES_TO_BYTES = 1024;
+    
+    private WriterID writerId;
+    
+    @Before
+    public void setup() {
+        writerId = mock(WriterID.class);
+    }
 
     @Test
     public void testSimpleBuild() {
-        MemoryStat stat = new MemoryStatBuilder(new ProcDataSource()).build();
+        MemoryStat stat = new MemoryStatBuilder(new ProcDataSource(), writerId).build();
         assertNotNull(stat);
     }
 
@@ -68,7 +77,7 @@
         ProcDataSource dataSource = mock(ProcDataSource.class);
         when(dataSource.getMemInfoReader()).thenReturn(memoryReader);
 
-        MemoryStat stat = new MemoryStatBuilder(dataSource).build();
+        MemoryStat stat = new MemoryStatBuilder(dataSource, writerId).build();
         assertNotNull(stat);
         verify(dataSource).getMemInfoReader();
     }
@@ -97,7 +106,7 @@
         ProcDataSource dataSource = mock(ProcDataSource.class);
         when(dataSource.getMemInfoReader()).thenReturn(memoryReader);
 
-        MemoryStat stat = new MemoryStatBuilder(dataSource).build();
+        MemoryStat stat = new MemoryStatBuilder(dataSource, writerId).build();
 
         assertEquals(BUFFERS * KILOBYTES_TO_BYTES, stat.getBuffers());
         assertEquals(CACHED * KILOBYTES_TO_BYTES, stat.getCached());
--- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryControllerTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -71,11 +71,11 @@
     @Test
     public void testUpdate() {
         final long TOTAL_MEMORY = 512;
-        HostInfo hostInfo = new HostInfo("someHost", "someOS", "linux_0.0.1", "lreally_fast_cpu", 2, TOTAL_MEMORY);
+        HostInfo hostInfo = new HostInfo("foo-agent", "someHost", "someOS", "linux_0.0.1", "lreally_fast_cpu", 2, TOTAL_MEMORY);
         HostInfoDAO hostInfoDAO = mock(HostInfoDAO.class);
         when(hostInfoDAO.getHostInfo(any(HostRef.class))).thenReturn(hostInfo);
 
-        MemoryStat memoryStat = new MemoryStat(1, 2, 3, 4, 5, 6, 7, 8);
+        MemoryStat memoryStat = new MemoryStat("foo", 1, 2, 3, 4, 5, 6, 7, 8);
         List<MemoryStat> memoryStats = new LinkedList<>();
         memoryStats.add(memoryStat);
         MemoryStatDAO memoryStatDAO = mock(MemoryStatDAO.class);
--- a/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/model/MemoryStat.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/common/src/main/java/com/redhat/thermostat/host/memory/common/model/MemoryStat.java	Mon Sep 02 11:28:59 2013 +0200
@@ -54,10 +54,11 @@
     private long commitLimit;
 
     public MemoryStat() {
-        super();
+        super(null);
     }
 
-    public MemoryStat(long timeStamp, long total, long free, long buffers, long cached, long swapTotal, long swapFree, long commitLimit) {
+    public MemoryStat(String writerId, long timeStamp, long total, long free, long buffers, long cached, long swapTotal, long swapFree, long commitLimit) {
+        super(writerId);
         this.timeStamp = timeStamp;
         this.total = total;
         this.free = free;
--- a/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/internal/MemoryStatDAOTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -92,7 +92,8 @@
     @Test
     public void testGetLatestMemoryStats() throws DescriptorParsingException, StatementExecutionException {
 
-        MemoryStat memStat1 = new MemoryStat(TIMESTAMP, TOTAL, FREE, BUFFERS, CACHED, SWAP_TOTAL, SWAP_FREE, COMMIT_LIMIT);
+        String agentId = "system";
+        MemoryStat memStat1 = new MemoryStat(agentId, TIMESTAMP, TOTAL, FREE, BUFFERS, CACHED, SWAP_TOTAL, SWAP_FREE, COMMIT_LIMIT);
 
         @SuppressWarnings("unchecked")
         Cursor<MemoryStat> cursor = mock(Cursor.class);
@@ -106,7 +107,7 @@
         when(stmt.executeQuery()).thenReturn(cursor);
 
         HostRef hostRef = mock(HostRef.class);
-        when(hostRef.getAgentId()).thenReturn("system");
+        when(hostRef.getAgentId()).thenReturn(agentId);
 
         MemoryStatDAO dao = new MemoryStatDAOImpl(storage);
         List<MemoryStat> memoryStats = dao.getLatestMemoryStats(hostRef, Long.MIN_VALUE);
@@ -142,7 +143,7 @@
         Add<MemoryStat> add = mock(Add.class);
         when(storage.createAdd(eq(MemoryStatDAO.memoryStatCategory))).thenReturn(add);
 
-        MemoryStat stat = new MemoryStat(TIMESTAMP, TOTAL, FREE, BUFFERS, CACHED, SWAP_TOTAL, SWAP_FREE, COMMIT_LIMIT);
+        MemoryStat stat = new MemoryStat("foo", TIMESTAMP, TOTAL, FREE, BUFFERS, CACHED, SWAP_TOTAL, SWAP_FREE, COMMIT_LIMIT);
         MemoryStatDAO dao = new MemoryStatDAOImpl(storage);
         dao.putMemoryStat(stat);
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/host-memory/common/src/test/java/com/redhat/thermostat/host/memory/common/model/MemoryStatTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2012, 2013 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.host.memory.common.model;
+
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+public class MemoryStatTest {
+
+    @Test
+    public void testBasicInstantiation() {
+        try {
+            // pojo converters use this
+            MemoryStat.class.newInstance();
+        } catch (Exception e) {
+            fail("should be able to instantiate using no-arg constructor");
+        }
+    }
+}
--- a/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/Activator.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/Activator.java	Mon Sep 02 11:28:59 2013 +0200
@@ -49,18 +49,22 @@
 import com.redhat.thermostat.common.MultipleServiceTracker.Action;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.numa.common.NumaDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class Activator implements BundleActivator {
     
     private MultipleServiceTracker tracker;
     private NumaBackend backend;
-    private ServiceRegistration reg;
+    private ServiceRegistration<Backend> reg;
     
     @Override
     public void start(final BundleContext context) throws Exception {
 
         Class<?>[] deps = new Class<?>[] {
-                BackendService.class, NumaDAO.class, ApplicationService.class
+                BackendService.class,
+                NumaDAO.class,
+                ApplicationService.class,
+                WriterID.class, // numa backend uses it
         };
         tracker = new MultipleServiceTracker(context, deps, new Action() {
             
@@ -69,9 +73,10 @@
                 ApplicationService appService = (ApplicationService) services.get(ApplicationService.class.getName());
                 NumaDAO numaDAO = (NumaDAO) services.get(NumaDAO.class.getName());
                 Version version = new Version(context.getBundle());
+                WriterID writerId = (WriterID) services.get(WriterID.class.getName());
                 NumaCollector collector = new NumaCollector();
-                backend = new NumaBackend(appService, numaDAO, collector, version);
-                reg = context.registerService(Backend.class.getName(), backend, null);
+                backend = new NumaBackend(appService, numaDAO, collector, version, writerId);
+                reg = context.registerService(Backend.class, backend, null);
             }
 
             @Override
--- a/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/NumaBackend.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/agent/src/main/java/com/redhat/thermostat/numa/agent/internal/NumaBackend.java	Mon Sep 02 11:28:59 2013 +0200
@@ -48,8 +48,10 @@
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.numa.common.NumaDAO;
+import com.redhat.thermostat.numa.common.NumaHostInfo;
 import com.redhat.thermostat.numa.common.NumaNodeStat;
 import com.redhat.thermostat.numa.common.NumaStat;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class NumaBackend extends BaseBackend {
 
@@ -57,13 +59,14 @@
 
     private static final long NUMA_CHECK_INTERVAL_SECONDS = 1;
     
-    private NumaDAO numaDAO;
-    private ApplicationService appService;
+    private final NumaDAO numaDAO;
+    private final ApplicationService appService;
+    private final NumaCollector numaCollector;
+    private final WriterID writerId;
     private boolean started;
-    private NumaCollector numaCollector;
     private Timer timer;
 
-    public NumaBackend(ApplicationService appService, NumaDAO numaDAO, NumaCollector numaCollector, Version version) {
+    public NumaBackend(ApplicationService appService, NumaDAO numaDAO, NumaCollector numaCollector, Version version, WriterID writerID) {
         super("NUMA Backend",
                 "Gathers NUMA statistics about a host",
                 "Red Hat, Inc.",
@@ -71,12 +74,14 @@
         this.appService = appService;
         this.numaDAO = numaDAO;
         this.numaCollector = numaCollector;
+        this.writerId = writerID;
     }
 
     @Override
     public boolean activate() {
         int numNodes = numaCollector.getNumberOfNumaNodes();
-        numaDAO.putNumberOfNumaNodes(numNodes);
+        NumaHostInfo info = buildNumaHostInfo(numNodes);
+        numaDAO.putNumberOfNumaNodes(info);
 
         TimerFactory timerFactory = appService.getTimerFactory();
         timer = timerFactory.createTimer();
@@ -91,7 +96,8 @@
                 NumaNodeStat[] stats;
                 try {
                     stats = numaCollector.collectData();
-                    NumaStat numaStat = new NumaStat();
+                    String wId = writerId.getWriterID();
+                    NumaStat numaStat = new NumaStat(wId);
                     numaStat.setTimeStamp(System.currentTimeMillis());
                     numaStat.setNodeStats(stats);
                     numaDAO.putNumaStat(numaStat);
@@ -106,6 +112,14 @@
         return true;
     }
 
+    // package private for testing
+    NumaHostInfo buildNumaHostInfo(int numNodes) {
+        String wId = writerId.getWriterID();
+        NumaHostInfo info = new NumaHostInfo(wId);
+        info.setNumNumaNodes(numNodes);
+        return info;
+    }
+
     @Override
     public boolean deactivate() {
         started = false;
--- a/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/ActivatorTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -54,6 +54,7 @@
 import com.redhat.thermostat.common.Timer;
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.numa.common.NumaDAO;
+import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.testutils.StubBundleContext;
 
 public class ActivatorTest {
@@ -63,6 +64,7 @@
     private BackendService backendService;
     private NumaDAO numaDAO;
     private ApplicationService appService;
+    private WriterID writerId;
 
     @Before
     public void setUp() {
@@ -78,6 +80,7 @@
         backendService = mock(BackendService.class);
         numaDAO = mock(NumaDAO.class);
         appService = mock(ApplicationService.class);
+        writerId = mock(WriterID.class);
         TimerFactory timerFactory = mock(TimerFactory.class);
         Timer timer = mock(Timer.class);
         when(timerFactory.createTimer()).thenReturn(timer);
@@ -93,7 +96,7 @@
         activator.start(context);
 
         assertEquals(0, context.getAllServices().size());
-        assertEquals(3, context.getServiceListeners().size());
+        assertEquals(4, context.getServiceListeners().size());
 
         activator.stop(context);
     }
@@ -123,6 +126,7 @@
         context.registerService(BackendService.class, backendService, null);
         context.registerService(NumaDAO.class, numaDAO, null);
         context.registerService(ApplicationService.class, appService, null);
+        context.registerService(WriterID.class, writerId, null);
 
         Activator activator = new Activator();
 
@@ -139,7 +143,7 @@
         assertFalse(backend.isActive());
 
         assertEquals(0, context.getServiceListeners().size());
-        assertEquals(3, context.getAllServices().size());
+        assertEquals(4, context.getAllServices().size());
     }
 }
 
--- a/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/NumaBackendTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/agent/src/test/java/com/redhat/thermostat/numa/agent/internal/NumaBackendTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -37,7 +37,6 @@
 package com.redhat.thermostat.numa.agent.internal;
 
 import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.any;
@@ -62,8 +61,10 @@
 import com.redhat.thermostat.common.TimerFactory;
 import com.redhat.thermostat.common.Version;
 import com.redhat.thermostat.numa.common.NumaDAO;
+import com.redhat.thermostat.numa.common.NumaHostInfo;
 import com.redhat.thermostat.numa.common.NumaNodeStat;
 import com.redhat.thermostat.numa.common.NumaStat;
+import com.redhat.thermostat.storage.core.WriterID;
 
 public class NumaBackendTest {
     
@@ -84,7 +85,8 @@
         Version version = mock(Version.class);
         when(version.getVersionNumber()).thenReturn("0.0.0");
         numaDAO = mock(NumaDAO.class);
-        backend = new NumaBackend(appService, numaDAO, collector, version);
+        WriterID id = mock(WriterID.class);
+        backend = new NumaBackend(appService, numaDAO, collector, version, id);
     }
 
     @After
@@ -121,7 +123,9 @@
         verifyNoMoreInteractions(timer);
 
         Runnable action = actionCaptor.getValue();
-        verify(numaDAO).putNumberOfNumaNodes(42);
+        NumaHostInfo info = new NumaHostInfo(null);
+        info.setNumNumaNodes(42);
+        verify(numaDAO).putNumberOfNumaNodes(info);
         verifyNoMoreInteractions(numaDAO);
         verify(collector).getNumberOfNumaNodes();
         verifyNoMoreInteractions(collector);
--- a/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/client-core/src/test/java/com/redhat/thermostat/numa/client/core/internal/NumaControllerTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -40,7 +40,6 @@
 import static org.junit.Assert.assertSame;
 import static org.mockito.Matchers.any;
 import static org.mockito.Matchers.anyLong;
-import static org.mockito.Matchers.anyString;
 import static org.mockito.Matchers.eq;
 import static org.mockito.Matchers.isA;
 import static org.mockito.Mockito.doNothing;
@@ -121,8 +120,7 @@
         NumaNodeStat nodeStat13 = new NumaNodeStat();
         nodeStat13.setNumaHit(70);
         nodeStat13.setNumaMiss(30);
-        NumaStat stat1 = new NumaStat();
-        stat1.setAgentId("fluff");
+        NumaStat stat1 = new NumaStat("fluff");
         stat1.setTimeStamp(123);
         stat1.setNodeStats(new NumaNodeStat[] {nodeStat11, nodeStat12, nodeStat13 });
         NumaNodeStat nodeStat21 = new NumaNodeStat();
@@ -134,8 +132,7 @@
         NumaNodeStat nodeStat23 = new NumaNodeStat();
         nodeStat23.setNumaHit(80);
         nodeStat23.setNumaMiss(20);
-        NumaStat stat2 = new NumaStat();
-        stat2.setAgentId("fluff");
+        NumaStat stat2 = new NumaStat("fluff");
         stat2.setTimeStamp(234);
         stat2.setNodeStats(new NumaNodeStat[] {nodeStat21, nodeStat22, nodeStat23 });
         List<NumaStat> stats = Arrays.asList(stat1, stat2);
--- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaDAO.java	Mon Sep 02 11:28:59 2013 +0200
@@ -52,7 +52,7 @@
 
     static final Category<NumaHostInfo> numaHostCategory = new Category<>("numa-host-info", NumaHostInfo.class, Key.AGENT_ID, hostNumNumaNodes);
 
-    void putNumberOfNumaNodes(int numNodes);
+    void putNumberOfNumaNodes(NumaHostInfo info);
     int getNumberOfNumaNodes(HostRef ref);
 
     void putNumaStat(NumaStat stat);
--- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaHostInfo.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaHostInfo.java	Mon Sep 02 11:28:59 2013 +0200
@@ -42,6 +42,14 @@
 
 @Entity
 public class NumaHostInfo extends BasePojo {
+    
+    public NumaHostInfo() {
+        this(null);
+    }
+    
+    public NumaHostInfo(String writerId) {
+        super(writerId);
+    }
 
     private int numNumaNodes;
 
--- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaStat.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/NumaStat.java	Mon Sep 02 11:28:59 2013 +0200
@@ -48,6 +48,14 @@
     private long timeStamp = -1;
     private NumaNodeStat[] nodeStats = new NumaNodeStat[0];
 
+    public NumaStat() {
+        this(null);
+    }
+    
+    public NumaStat(String writerId) {
+        super(writerId);
+    }
+    
     @Override
     @Persist
     public long getTimeStamp() {
--- a/numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/main/java/com/redhat/thermostat/numa/common/internal/NumaDAOImpl.java	Mon Sep 02 11:28:59 2013 +0200
@@ -85,10 +85,8 @@
     }
 
     @Override
-    public void putNumberOfNumaNodes(int numNodes) {
+    public void putNumberOfNumaNodes(NumaHostInfo numaHostInfo) {
         Add<NumaHostInfo> replace = storage.createAdd(numaHostCategory);
-        NumaHostInfo numaHostInfo = new NumaHostInfo();
-        numaHostInfo.setNumNumaNodes(numNodes);
         replace.setPojo(numaHostInfo);
         replace.apply();
     }
--- a/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaHostInfoTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaHostInfoTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -37,6 +37,7 @@
 package com.redhat.thermostat.numa.common;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 import org.junit.Test;
 
@@ -44,9 +45,20 @@
 
     @Test
     public void testGetterSetter() {
-        NumaHostInfo numaHostInfo = new NumaHostInfo();
+        NumaHostInfo numaHostInfo = new NumaHostInfo("foo");
         numaHostInfo.setNumNumaNodes(42);
         assertEquals(42, numaHostInfo.getNumNumaNodes());
+        assertEquals("foo", numaHostInfo.getAgentId());
+    }
+    
+    @Test
+    public void testBasicInstantiation() {
+        try {
+            // pojo converters use this
+            NumaHostInfo.class.newInstance();
+        } catch (Exception e) {
+            fail("should be able to instantiate using no-arg constructor");
+        }
     }
 }
 
--- a/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaNodeStatTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaNodeStatTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -38,6 +38,7 @@
 package com.redhat.thermostat.numa.common;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 import org.junit.After;
 import org.junit.Before;
@@ -104,5 +105,15 @@
         String expected = "NumaStat: nodeId: 1, numaHit: 2, numaMiss: 3, numaForeign: 4, interleaveHit: 5, localNode: 6, otherNode: 7";
         assertEquals(expected, str);
     }
+    
+    @Test
+    public void testBasicInstantiation() {
+        try {
+            // pojo converters use this
+            NumaNodeStat.class.newInstance();
+        } catch (Exception e) {
+            fail("should be able to instantiate using no-arg constructor");
+        }
+    }
 }
 
--- a/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaStatTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/test/java/com/redhat/thermostat/numa/common/NumaStatTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -45,7 +45,7 @@
 
     @Test
     public void testDefaults() {
-        NumaStat numaStat = new NumaStat();
+        NumaStat numaStat = new NumaStat("foo");
         assertEquals(-1, numaStat.getTimeStamp());
         assertNotNull(numaStat.getNodeStats());
         assertEquals(0, numaStat.getNodeStats().length);
@@ -53,7 +53,7 @@
 
     @Test
     public void testGetSetValues() {
-        NumaStat numaStat = new NumaStat();
+        NumaStat numaStat = new NumaStat("bar");
         numaStat.setTimeStamp(12345);
         NumaNodeStat nodeStat1 = new NumaNodeStat();
         NumaNodeStat nodeStat2 = new NumaNodeStat();
@@ -65,5 +65,15 @@
         assertSame(nodeStat1, numaStat.getNodeStats()[0]);
         assertSame(nodeStat2, numaStat.getNodeStats()[1]);
     }
+    
+    @Test
+    public void testBasicInstantiation() {
+        try {
+            // pojo converters use this
+            NumaStat.class.newInstance();
+        } catch (Exception e) {
+            fail("should be able to instantiate using no-arg constructor");
+        }
+    }
 }
 
--- a/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaDAOImplTest.java	Mon Sep 02 11:36:26 2013 +0200
+++ b/numa/common/src/test/java/com/redhat/thermostat/numa/common/internal/NumaDAOImplTest.java	Mon Sep 02 11:28:59 2013 +0200
@@ -47,7 +47,6 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockito.ArgumentCaptor;
 
 import com.redhat.thermostat.numa.common.NumaDAO;
 import com.redhat.thermostat.numa.common.NumaHostInfo;
@@ -106,7 +105,7 @@
         stat.setLocalNode(6);
         stat.setOtherNode(7);
 
-        NumaStat numaStat = new NumaStat();
+        NumaStat numaStat = new NumaStat("agentId");
         numaStat.setTimeStamp(12345);
         numaStat.setNodeStats(new NumaNodeStat[] { stat });
         numaDAO.putNumaStat(numaStat);
@@ -118,6 +117,7 @@
         verify(add).setPojo(numaStat);
         verify(add).apply();
         verifyNoMoreInteractions(add);
+        assertEquals("agentId", numaStat.getAgentId());
     }
     
     @Test
@@ -129,13 +129,12 @@
 
         NumaDAOImpl dao = new NumaDAOImpl(storage);
 
-        dao.putNumberOfNumaNodes(4);
+        NumaHostInfo info = new NumaHostInfo("foo");
+        info.setNumNumaNodes(4);
+        dao.putNumberOfNumaNodes(info);
 
         verify(storage).createAdd(NumaDAO.numaHostCategory);
-        ArgumentCaptor<NumaHostInfo> captor = ArgumentCaptor.forClass(NumaHostInfo.class);
-        verify(add).setPojo(captor.capture());
-        NumaHostInfo info = captor.getValue();
-        assertEquals(4, info.getNumNumaNodes());
+        verify(add).setPojo(info);
         verify(add).apply();
     }