changeset 2711:325ba70eb3c1

Refactor Vm Memory to merge agent and common bundles. Reviewed-By: jerboaa Review-Thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023914.html
author Joshua Matsuoka <jmatsuok@redhat.com>
date Tue, 27 Jun 2017 10:52:26 -0400
parents dd67c96690d4
children 30ac0c82bc98
files plugins/vm-memory/agent/pom.xml plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/Constants.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackend.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractor.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListener.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAO.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAOImpl.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapter.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAO.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAOImpl.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapter.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/model/VmMemoryStat.java plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/model/VmTlabStat.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackendTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractorTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListenerTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAOImplTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapterTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAOTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapterTest.java plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/model/VmMemoryStatTest.java plugins/vm-memory/common/pom.xml plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/Constants.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmMemoryStatDAO.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmTlabStatDAO.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatTypeAdapter.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOImpl.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatTypeAdapter.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/model/VmMemoryStat.java plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/model/VmTlabStat.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImplTest.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatTypeAdapterTest.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOTest.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatTypeAdapterTest.java plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/model/VmMemoryStatTest.java plugins/vm-memory/distribution/assemblies/plugin-assembly.xml plugins/vm-memory/distribution/thermostat-plugin.xml plugins/vm-memory/pom.xml
diffstat 39 files changed, 1845 insertions(+), 1998 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/vm-memory/agent/pom.xml	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/pom.xml	Tue Jun 27 10:52:26 2017 -0400
@@ -56,9 +56,12 @@
           <instructions>
             <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor>
             <Bundle-SymbolicName>com.redhat.thermostat.vm.memory.agent</Bundle-SymbolicName>
-            <Export-Package />
+            <Export-Package>
+              com.redhat.thermostat.vm.memory.agent.model
+            </Export-Package>
             <Private-Package>
-              com.redhat.thermostat.vm.memory.agent.internal
+              com.redhat.thermostat.vm.memory.agent.internal,
+              com.redhat.thermostat.vm.memory.agent.internal.models
             </Private-Package>
             <!-- Do not autogenerate uses clauses in Manifests -->
             <_nouses>true</_nouses>
@@ -107,11 +110,6 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-vm-memory-common</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-agent-core</artifactId>
       <version>${project.version}</version>
     </dependency>
@@ -127,6 +125,11 @@
     </dependency>
     <dependency>
       <groupId>com.redhat.thermostat</groupId>
+      <artifactId>thermostat-common-plugin</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.redhat.thermostat</groupId>
       <artifactId>thermostat-common-test</artifactId>
       <version>${project.version}</version>
       <scope>test</scope>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/Constants.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal;
+
+import com.redhat.thermostat.common.Ordered;
+
+public class Constants {
+
+    public static final int ORDER = Ordered.ORDER_MEMORY_GROUP + 40;
+
+    private Constants() {
+        throw new AssertionError("Do not instantiate this");
+    }
+
+}
\ No newline at end of file
--- a/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackend.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackend.java	Tue Jun 27 10:52:26 2017 -0400
@@ -49,9 +49,8 @@
 import com.redhat.thermostat.jvm.overview.agent.VmStatusListenerRegistrar;
 import com.redhat.thermostat.jvm.overview.agent.VmUpdateListener;
 import com.redhat.thermostat.storage.core.WriterID;
-import com.redhat.thermostat.vm.memory.common.Constants;
-import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAO;
 
 @Component
 @Service(value = Backend.class)
--- a/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractor.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractor.java	Tue Jun 27 10:52:26 2017 -0400
@@ -38,7 +38,7 @@
 
 import com.redhat.thermostat.jvm.overview.agent.VmUpdate;
 import com.redhat.thermostat.jvm.overview.agent.VmUpdateException;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
 
 /**
  * A helper class to provide type-safe access to commonly used jvmstat monitors
--- a/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListener.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListener.java	Tue Jun 27 10:52:26 2017 -0400
@@ -47,12 +47,12 @@
 import com.redhat.thermostat.jvm.overview.agent.VmUpdate;
 import com.redhat.thermostat.jvm.overview.agent.VmUpdateException;
 import com.redhat.thermostat.jvm.overview.agent.VmUpdateListener;
-import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Space;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAO;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
 
 public class VmMemoryVmListener implements VmUpdateListener {
     
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAO.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.redhat.thermostat.annotations.Service;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+
+@Service
+public interface VmMemoryStatDAO {
+
+    public void putVmMemoryStat(VmMemoryStat stat);
+
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAOImpl.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.common.utils.LoggingUtils;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
+
+@Component
+@Service(value = VmMemoryStatDAO.class)
+public class VmMemoryStatDAOImpl implements VmMemoryStatDAO {
+
+    private static final Logger logger = LoggingUtils.getLogger(VmMemoryStatDAOImpl.class);
+    private static final String PLUGIN_ID = "vm-memory";
+    private static final String CONTENT_TYPE = "application/json";
+
+    private final HttpClient client;
+    private final HttpHelper httpHelper;
+    private final JsonHelper jsonHelper;
+    private final ConfigurationCreator configCreator;
+
+    private String gatewayURL;
+
+    @Reference
+    private ConfigurationInfoSource configInfoSource;
+
+    public VmMemoryStatDAOImpl() {
+        this(new HttpClient(), new JsonHelper(new VmMemoryStatTypeAdapter()), new HttpHelper(),
+                new ConfigurationCreator(), null);
+    }
+
+    VmMemoryStatDAOImpl(HttpClient client, JsonHelper jh, HttpHelper hh, ConfigurationCreator creator,
+            ConfigurationInfoSource source) {
+        this.client = client;
+        this.httpHelper = hh;
+        this.jsonHelper = jh;
+        this.configCreator = creator;
+        this.configInfoSource = source;
+    }
+
+    @Activate
+    void activate() throws Exception {
+        PluginConfiguration config = configCreator.create(configInfoSource);
+        this.gatewayURL = config.getGatewayURL();
+
+        httpHelper.startClient(client);
+    }
+
+    @Override
+    public void putVmMemoryStat(final VmMemoryStat stat) {
+        try {
+            String json = jsonHelper.toJson(Arrays.asList(stat));
+            StringContentProvider provider = httpHelper.createContentProvider(json);
+
+            Request httpRequest = client.newRequest(gatewayURL);
+            httpRequest.method(HttpMethod.POST);
+            httpRequest.content(provider, CONTENT_TYPE);
+            sendRequest(httpRequest);
+        } catch (Exception e) {
+            logger.log(Level.WARNING, "Failed to send VmMemoryStat to Web Gateway", e);
+        }
+    }
+
+    private void sendRequest(Request httpRequest)
+            throws InterruptedException, TimeoutException, ExecutionException, IOException {
+        ContentResponse resp = httpRequest.send();
+        int status = resp.getStatus();
+        if (status != HttpStatus.OK_200) {
+            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
+        }
+    }
+
+    protected Logger getLogger() {
+        return logger;
+    }
+
+    // For testing purposes
+    static class JsonHelper {
+
+        private final VmMemoryStatTypeAdapter adapter;
+
+        public JsonHelper(VmMemoryStatTypeAdapter adapter) {
+            this.adapter = adapter;
+        }
+
+        String toJson(List<VmMemoryStat> stats) throws IOException {
+            return adapter.toJson(stats);
+        }
+    }
+
+    // For testing purposes
+    static class HttpHelper {
+
+        void startClient(HttpClient httpClient) throws Exception {
+            httpClient.start();
+        }
+
+        StringContentProvider createContentProvider(String content) {
+            return new StringContentProvider(content);
+        }
+
+    }
+
+    // For Testing purposes
+    static class ConfigurationCreator {
+
+        PluginConfiguration create(ConfigurationInfoSource source) {
+            return new PluginConfiguration(source, PLUGIN_ID);
+        }
+
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapter.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+
+import java.io.IOException;
+import java.util.List;
+
+import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
+import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space;
+
+public class VmMemoryStatTypeAdapter extends TypeAdapter<List<VmMemoryStat>> {
+
+    private static final String GENERATIONS = "generations";
+    private static final String TIMESTAMP = "timeStamp";
+    private static final String AGENT_ID = "agentId";
+    private static final String VM_ID = "jvmId";
+    private static final String METASPACE_MAX_CAPACITY = "metaspaceMaxCapacity";
+    private static final String METASPACE_MIN_CAPACITY = "metaspaceMinCapacity";
+    private static final String METASPACE_CAPACITY = "metaspaceCapacity";
+    private static final String METASPACE_USED = "metaspaceUsed";
+    private static final String NAME = "name";
+    private static final String CAPACITY = "capacity";
+    private static final String MAX_CAPACITY = "maxCapacity";
+    private static final String SPACES = "spaces";
+    private static final String COLLECTOR = "collector";
+    private static final String INDEX = "index";
+    private static final String USED = "used";
+    private static final String TYPE_LONG = "$numberLong";
+
+    @Override
+    public List<VmMemoryStat> read(JsonReader in) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void write(JsonWriter out, List<VmMemoryStat> stats) throws IOException {
+        out.beginArray();
+        for (VmMemoryStat stat : stats) {
+            writeStat(out, stat);
+        }
+        out.endArray();
+    }
+
+    public void writeStat(JsonWriter out, VmMemoryStat stat) throws IOException {
+        out.beginObject();
+        out.name(AGENT_ID);
+        out.value(stat.getAgentId());
+        out.name(VM_ID);
+        out.value(stat.getVmId());
+        out.name(TIMESTAMP);
+        writeLong(out, stat.getTimeStamp());
+        out.name(METASPACE_MAX_CAPACITY);
+        writeLong(out, stat.getMetaspaceMaxCapacity());
+        out.name(METASPACE_MIN_CAPACITY);
+        writeLong(out, stat.getMetaspaceMinCapacity());
+        out.name(METASPACE_CAPACITY);
+        writeLong(out, stat.getMetaspaceCapacity());
+        out.name(METASPACE_USED);
+        writeLong(out, stat.getMetaspaceUsed());
+        out.name(GENERATIONS);
+        out.beginArray();
+        for (Generation g : stat.getGenerations()) {
+            writeGeneration(out, g);
+        }
+        out.endArray();
+        out.endObject();
+    }
+
+    public void writeLong(JsonWriter out, long value) throws IOException {
+        // Write MongoDB representation of a Long
+        out.beginObject();
+        out.name(TYPE_LONG);
+        out.value(String.valueOf(value));
+        out.endObject();
+    }
+
+    public void writeGeneration(JsonWriter out, Generation g) throws IOException {
+        out.beginObject();
+        out.name(NAME);
+        out.value(g.getName());
+        out.name(CAPACITY);
+        writeLong(out, g.getCapacity());
+        out.name(MAX_CAPACITY);
+        writeLong(out, g.getMaxCapacity());
+        out.name(COLLECTOR);
+        out.value(g.getCollector());
+        out.name(SPACES);
+        out.beginArray();
+        for (Space s : g.getSpaces()) {
+            writeSpace(out, s);
+        }
+        out.endArray();
+        out.endObject();
+    }
+
+    public void writeSpace(JsonWriter out, Space s) throws IOException {
+        out.beginObject();
+        out.name(INDEX);
+        out.value(s.getIndex());
+        out.name(NAME);
+        out.value(s.getName());
+        out.name(CAPACITY);
+        writeLong(out, s.getCapacity());
+        out.name(MAX_CAPACITY);
+        writeLong(out, s.getMaxCapacity());
+        out.name(USED);
+        writeLong(out, s.getUsed());
+        out.endObject();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAO.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.redhat.thermostat.annotations.Service;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
+
+@Service
+public interface VmTlabStatDAO {
+
+    public void putStat(VmTlabStat stat);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAOImpl.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,164 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeoutException;
+import java.util.logging.Logger;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.common.utils.LoggingUtils;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpStatus;
+
+@Component
+@Service(value = VmTlabStatDAO.class)
+public class VmTlabStatDAOImpl implements VmTlabStatDAO {
+
+    private static final Logger logger = LoggingUtils.getLogger(VmTlabStatDAOImpl.class);
+    private static final String PLUGIN_ID = "vm-memory";
+    private static final String CONTENT_TYPE = "application/json";
+
+    private final HttpClient client;
+    private final HttpHelper httpHelper;
+    private final JsonHelper jsonHelper;
+    private final ConfigurationCreator configurationCreator;
+
+    private String gatewayURL;
+
+    @Reference
+    private ConfigurationInfoSource configInfoSource;
+
+    public VmTlabStatDAOImpl() throws Exception {
+        this(new HttpClient(), new HttpHelper(), new JsonHelper(new VmTlabStatTypeAdapter()), new ConfigurationCreator(), null);
+    }
+
+    VmTlabStatDAOImpl(HttpClient client, HttpHelper httpHelper, JsonHelper jsonHelper,
+            ConfigurationCreator configurationCreator, ConfigurationInfoSource configInfoSource) throws Exception {
+        this.client = client;
+        this.httpHelper = httpHelper;
+        this.jsonHelper = jsonHelper;
+        this.configurationCreator = configurationCreator;
+        this.configInfoSource = configInfoSource;
+    }
+
+    @Activate
+    void activate() throws Exception {
+        PluginConfiguration config = configurationCreator.create(configInfoSource);
+        this.gatewayURL = config.getGatewayURL();
+
+        this.httpHelper.startClient(this.client);
+    }
+
+    @Override
+    public void putStat(final VmTlabStat stat) {
+//      TODO: Re-enable when web-gateway service for TLAB stats is available
+//      Also see VmTlabStatDAOTest for disabled tests
+        return;
+//        try {
+//            String json = jsonHelper.toJson(Arrays.asList(stat));
+//            StringContentProvider provider = httpHelper.createContentProvider(json);
+//
+//            Request httpRequest = client.newRequest(gatewayURL);
+//            httpRequest.method(HttpMethod.POST);
+//            httpRequest.content(provider, CONTENT_TYPE);
+//            sendRequest(httpRequest);
+//        } catch (Exception e) {
+//            logger.log(Level.WARNING, "Failed to send VmTlabStat to Web Gateway", e);
+//        }
+    }
+
+    private void sendRequest(Request httpRequest)
+            throws InterruptedException, TimeoutException, ExecutionException, IOException {
+        ContentResponse resp = httpRequest.send();
+        int status = resp.getStatus();
+        if (status != HttpStatus.OK_200) {
+            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
+        }
+    }
+
+    protected Logger getLogger() {
+        return logger;
+    }
+
+    static class JsonHelper {
+
+        private final VmTlabStatTypeAdapter adapter;
+
+        public JsonHelper(VmTlabStatTypeAdapter adapter) {
+            this.adapter = adapter;
+        }
+
+        String toJson(List<VmTlabStat> stats) throws IOException {
+            return adapter.toJson(stats);
+        }
+    }
+
+    // For testing purposes
+    static class HttpHelper {
+
+        void startClient(HttpClient httpClient) throws Exception {
+            httpClient.start();
+        }
+
+        StringContentProvider createContentProvider(String content) {
+            return new StringContentProvider(content);
+        }
+
+    }
+
+    // For testing purposes
+    static class ConfigurationCreator {
+
+        PluginConfiguration create(ConfigurationInfoSource source) {
+            return new PluginConfiguration(source, PLUGIN_ID);
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapter.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.google.gson.TypeAdapter;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
+
+import java.io.IOException;
+import java.util.List;
+
+public class VmTlabStatTypeAdapter extends TypeAdapter<List<VmTlabStat>> {
+
+    private static final String AGENT_ID = "agentId";
+    private static final String VM_ID = "vmId";
+    private static final String TIMESTAMP = "timeStamp";
+    private static final String ALLOC_THREADS = "allocThreads";
+    private static final String TOTAL_ALLOCATIONS = "totalAllocations";
+    private static final String REFILLS = "refills";
+    private static final String MAX_REFILLS = "maxRefills";
+    private static final String SLOW_ALLOCATIONS = "slowAllocations";
+    private static final String MAX_SLOW_ALLOCATIONS = "maxSlowAllocations";
+    private static final String GC_WASTE = "gcWaste";
+    private static final String MAX_GC_WASTE = "maxGcWaste";
+    private static final String SLOW_WASTE = "slowWaste";
+    private static final String MAX_SLOW_WASTE = "maxSlowWaste";
+    private static final String FAST_WASTE = "fastWaste";
+    private static final String MAX_FAST_WASTE = "maxFastWaste";
+    private static final String TYPE_LONG = "$numberLong";
+
+    @Override
+    public List<VmTlabStat> read(JsonReader in) throws IOException {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override
+    public void write(JsonWriter out, List<VmTlabStat> stats) throws IOException {
+        out.beginArray();
+        for (VmTlabStat tlabStat : stats) {
+            writeStat(out, tlabStat);
+        }
+        out.endArray();
+    }
+
+    public void writeStat(JsonWriter out, VmTlabStat stat) throws IOException {
+        out.beginObject();
+        out.name(VM_ID);
+        out.value(stat.getVmId());
+        out.name(AGENT_ID);
+        out.value(stat.getAgentId());
+        out.name(TIMESTAMP);
+        writeLong(out, stat.getTimeStamp());
+        out.name(ALLOC_THREADS);
+        writeLong(out, stat.getTotalAllocatingThreads());
+        out.name(TOTAL_ALLOCATIONS);
+        writeLong(out, stat.getTotalAllocations());
+        out.name(REFILLS);
+        writeLong(out, stat.getTotalRefills());
+        out.name(MAX_REFILLS);
+        writeLong(out, stat.getMaxRefills());
+        out.name(SLOW_ALLOCATIONS);
+        writeLong(out, stat.getTotalSlowAllocations());
+        out.name(MAX_SLOW_ALLOCATIONS);
+        writeLong(out, stat.getMaxSlowAllocations());
+        out.name(GC_WASTE);
+        writeLong(out, stat.getTotalGcWaste());
+        out.name(MAX_GC_WASTE);
+        writeLong(out, stat.getMaxGcWaste());
+        out.name(SLOW_WASTE);
+        writeLong(out, stat.getTotalSlowWaste());
+        out.name(MAX_SLOW_WASTE);
+        writeLong(out, stat.getMaxSlowWaste());
+        out.name(FAST_WASTE);
+        writeLong(out, stat.getTotalFastWaste());
+        out.name(MAX_FAST_WASTE);
+        writeLong(out, stat.getMaxFastWaste());
+        out.endObject();
+    }
+
+    public void writeLong(JsonWriter out, long value) throws IOException {
+        // Write MongoDB representation of a Long
+        out.beginObject();
+        out.name(TYPE_LONG);
+        out.value(String.valueOf(value));
+        out.endObject();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/model/VmMemoryStat.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,308 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.model;
+
+import com.redhat.thermostat.storage.core.Entity;
+import com.redhat.thermostat.storage.core.Persist;
+import com.redhat.thermostat.storage.model.BasePojo;
+import com.redhat.thermostat.storage.model.Pojo;
+import com.redhat.thermostat.storage.model.TimeStampedPojo;
+
+@Entity
+public class VmMemoryStat extends BasePojo implements TimeStampedPojo {
+
+    public static final long UNKNOWN = -1;
+
+    public static final String METASPACE_NAME = "metaspace";
+
+    @Entity
+    public static class Generation implements Pojo {
+        public static final String COLLECTOR_NONE = "none";
+        private String name;
+        private long capacity;
+        private long maxCapacity;
+        private Space[] spaces;
+        private String collector;
+
+        @Persist
+        public String getName() {
+            return name;
+        }
+
+        @Persist
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        @Persist
+        public long getCapacity() {
+            return capacity;
+        }
+
+        @Persist
+        public void setCapacity(long capacity) {
+            this.capacity = capacity;
+        }
+
+        @Persist
+        public long getMaxCapacity() {
+            return maxCapacity;
+        }
+
+        @Persist
+        public void setMaxCapacity(long maxCapacity) {
+            this.maxCapacity = maxCapacity;
+        }
+
+        @Persist
+        public Space[] getSpaces() {
+            return spaces;
+        }
+
+        @Persist
+        public void setSpaces(Space[] spaces) {
+            this.spaces = spaces;
+        }
+
+        @Persist
+        public String getCollector() {
+            return collector;
+        }
+
+        @Persist
+        public void setCollector(String collector) {
+            this.collector = collector;
+        }
+
+        public Space getSpace(String string) {
+            for (Space s : spaces) {
+                if (s.name.equals(string)) {
+                    return s;
+                }
+            }
+            return null;
+        }
+    }
+
+    @Entity
+    public static class Space implements Pojo {
+
+        private int index;
+        private String name;
+        private long capacity;
+        private long maxCapacity;
+        private long used;
+
+        @Persist
+        public int getIndex() {
+            return index;
+        }
+
+        @Persist
+        public void setIndex(int index) {
+            this.index = index;
+        }
+
+        @Persist
+        public String getName() {
+            return name;
+        }
+
+        @Persist
+        public void setName(String name) {
+            this.name = name;
+        }
+
+        @Persist
+        public long getCapacity() {
+            return capacity;
+        }
+
+        @Persist
+        public void setCapacity(long capacity) {
+            this.capacity = capacity;
+        }
+
+        @Persist
+        public long getMaxCapacity() {
+            return maxCapacity;
+        }
+
+        @Persist
+        public void setMaxCapacity(long maxCapacity) {
+            this.maxCapacity = maxCapacity;
+        }
+
+        @Persist
+        public long getUsed() {
+            return used;
+        }
+
+        @Persist
+        public void setUsed(long used) {
+            this.used = used;
+        }
+
+    }
+
+    private Generation[] generations;
+    private long timestamp;
+    private String vmId;
+    private long metaspaceMaxCapacity;
+    private long metaspaceMinCapacity;
+    private long metaspaceCapacity;
+    private long metaspaceUsed;
+
+    public VmMemoryStat() {
+        this(null, UNKNOWN, null, null, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN);
+    }
+
+    public VmMemoryStat(String writerId, long timestamp, String vmId, Generation[] generations,
+            long metaspaceMaxCapacity, long metaspaceMinCapacity, long metaspaceCapacity, long metaspaceUsed) {
+        super(writerId);
+        this.timestamp = timestamp;
+        this.vmId = vmId;
+        if (generations != null) {
+            this.generations = generations;
+        }
+        this.metaspaceMaxCapacity = metaspaceMaxCapacity;
+        this.metaspaceMinCapacity = metaspaceMinCapacity;
+        this.metaspaceCapacity = metaspaceCapacity;
+        this.metaspaceUsed = metaspaceUsed;
+        checkSaneValuesForMetaspace();
+    }
+
+    @Persist
+    public String getVmId() {
+        return vmId;
+    }
+
+    @Persist
+    public void setVmId(String vmId) {
+        this.vmId = vmId;
+    }
+
+    @Persist
+    @Override
+    public long getTimeStamp() {
+        return timestamp;
+    }
+
+    @Persist
+    public void setTimeStamp(long timeStamp) {
+        this.timestamp = timeStamp;
+    }
+
+    @Persist
+    public Generation[] getGenerations() {
+        return generations;
+    }
+
+    @Persist
+    public void setGenerations(Generation[] generations) {
+        this.generations = generations;
+    }
+
+    public Generation getGeneration(String name) {
+        for (Generation g : generations) {
+            if (g.name.equals(name)) {
+                return g;
+            }
+        }
+        return null;
+    }
+
+    @Persist
+    public long getMetaspaceCapacity() {
+        return metaspaceCapacity;
+    }
+
+    @Persist
+    public void setMetaspaceCapacity(long capacity) {
+        this.metaspaceCapacity = capacity;
+    }
+
+    @Persist
+    public long getMetaspaceMaxCapacity() {
+        return metaspaceMaxCapacity;
+    }
+
+    @Persist
+    public void setMetaspaceMaxCapacity(long maxCapacity) {
+        this.metaspaceMaxCapacity = maxCapacity;
+    }
+
+    @Persist
+    public long getMetaspaceMinCapacity() {
+        return metaspaceMinCapacity;
+    }
+
+    @Persist
+    public void setMetaspaceMinCapacity(long minCapacity) {
+        this.metaspaceMinCapacity = minCapacity;
+    }
+
+    @Persist
+    public long getMetaspaceUsed() {
+        return metaspaceUsed;
+    }
+
+    @Persist
+    public void setMetaspaceUsed(long used) {
+        this.metaspaceUsed = used;
+    }
+
+    public boolean isMetaspacePresent() {
+        checkSaneValuesForMetaspace();
+        if (metaspaceCapacity == UNKNOWN) {
+            return false;
+        }
+        return true;
+    }
+
+    private void checkSaneValuesForMetaspace() {
+        // either all values must be unknown or no values must be unknown
+        if (metaspaceMaxCapacity == UNKNOWN && metaspaceMinCapacity == UNKNOWN &&
+                metaspaceCapacity == UNKNOWN && metaspaceUsed == UNKNOWN) {
+            return;
+        } else if (metaspaceMaxCapacity == UNKNOWN || metaspaceMinCapacity == UNKNOWN ||
+                metaspaceCapacity == UNKNOWN || metaspaceUsed == UNKNOWN) {
+            throw new AssertionError("Invalid values for metaspace");
+        }
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/main/java/com/redhat/thermostat/vm/memory/agent/model/VmTlabStat.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,260 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.model;
+
+import com.redhat.thermostat.storage.core.Entity;
+import com.redhat.thermostat.storage.core.Persist;
+import com.redhat.thermostat.storage.model.BasePojo;
+import com.redhat.thermostat.storage.model.TimeStampedPojo;
+
+@Entity
+public class VmTlabStat extends BasePojo implements TimeStampedPojo {
+
+    // See https://blogs.oracle.com/jonthecollector/entry/the_real_thing
+    // See hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
+
+    public static final long UNKNOWN = -1;
+
+    private String vmId;
+    private long timeStamp;
+
+    private long allocThreads;
+    private long totalAllocations;
+
+    private long refills;
+    private long maxRefills;
+
+    private long slowAllocations;
+    private long maxSlowAllocations;
+
+    private long gcWaste;
+    private long maxGcWaste;
+
+    private long slowWaste;
+    private long maxSlowWaste;
+
+    private long fastWaste;
+    private long maxFastWaste;
+
+    /** for de-serialization only */
+    public VmTlabStat() {
+        super(null);
+    }
+
+    public VmTlabStat(long timeStamp, String agentId, String vmId,
+            long threadCount, long totalAllocations,
+            long refills, long maxRefills,
+            long slowAllocations, long maxSlowAllocations,
+            long gcWaste, long maxGcWaste,
+            long slowWaste,    long maxSlowWaste,
+            long fastWaste, long maxFastWaste) {
+        super(agentId);
+        this.vmId = vmId;
+        this.timeStamp = timeStamp;
+        this.allocThreads = threadCount;
+        this.totalAllocations = totalAllocations;
+        this.refills = refills;
+        this.maxRefills = maxRefills;
+        this.slowAllocations = slowAllocations;
+        this.maxSlowAllocations = maxSlowAllocations;
+        this.gcWaste = gcWaste;
+        this.maxGcWaste = maxGcWaste;
+        this.slowWaste = slowWaste;
+        this.maxSlowWaste = maxSlowWaste;
+        this.fastWaste = fastWaste;
+        this.maxFastWaste = maxFastWaste;
+    }
+
+    @Persist
+    public String getVmId() {
+        return vmId;
+    }
+
+    @Persist
+    public void setVmId(String vmId) {
+        this.vmId = vmId;
+    }
+
+    @Persist
+    @Override
+    public long getTimeStamp() {
+        return timeStamp;
+    }
+
+    @Persist
+    public void setTimeStamp(long timeStamp) {
+        this.timeStamp = timeStamp;
+    }
+
+    /** Number of threads that did an allocation in the last epoch */
+    @Persist
+    public long getTotalAllocatingThreads() {
+        return allocThreads;
+    }
+
+    @Persist
+    public void setTotalAllocatingThreads(long allocThreads) {
+        this.allocThreads = allocThreads;
+    }
+
+    /** Number of allocations in the last epoch */
+    @Persist
+    public long getTotalAllocations() {
+        return totalAllocations;
+    }
+
+    @Persist
+    public void setTotalAllocations(long allocations) {
+        this.totalAllocations = allocations;
+    }
+
+    // Refills:
+
+    @Persist
+    public long getTotalRefills() {
+        return refills;
+    }
+
+    @Persist
+    public void setTotalRefills(long totalRefills) {
+        this.refills = totalRefills;
+    }
+
+    /** The maximum refills by a single thread */
+    @Persist
+    public long getMaxRefills() {
+        return maxRefills;
+    }
+
+    @Persist
+    public void setMaxRefills(long maxRefills) {
+        this.maxRefills = maxRefills;
+    }
+
+    // Slow Allocations:
+
+    /** Total number of allocations done outside of a TLAB */
+    @Persist
+    public long getTotalSlowAllocations() {
+        return slowAllocations;
+    }
+
+    @Persist
+    public void setTotalSlowAllocations(long slowAllocations) {
+        this.slowAllocations = slowAllocations;
+    }
+
+    /** Maximum number of allocations done outside of a TLAB by a single thread */
+    @Persist
+    public long getMaxSlowAllocations() {
+        return maxSlowAllocations;
+    }
+
+    @Persist
+    public void setMaxSlowAllocations(long maxSlowAllocations) {
+        this.maxSlowAllocations = maxSlowAllocations;
+    }
+
+    // Refill Waste:
+
+    /** Unused space in the current TLABs when GC starts */
+    @Persist
+    public long getTotalGcWaste() {
+        return gcWaste;
+    }
+
+    @Persist
+    public void setTotalGcWaste(long gcWaste) {
+        this.gcWaste = gcWaste;
+    }
+
+    /** Max unused space for a single thread's TLAB when GC starts */
+    @Persist
+    public long getMaxGcWaste() {
+        return maxGcWaste;
+    }
+
+    @Persist
+    public void setMaxGcWaste(long maxGcWaste) {
+        this.maxGcWaste = maxGcWaste;
+    }
+
+    /** Sum of unused space in TLABs when they're retired to allocate a new ones */
+    @Persist
+    public long getTotalSlowWaste() {
+        return slowWaste;
+    }
+
+    @Persist
+    public void setTotalSlowWaste(long slowWaste) {
+        this.slowWaste = slowWaste;
+    }
+
+    /** Maximum unused space in TLABS when they are retired to allocate a new one */
+    @Persist
+    public long getMaxSlowWaste() {
+        return maxSlowWaste;
+    }
+
+    @Persist
+    public void setMaxSlowWaste(long maxSlowWaste) {
+        this.maxSlowWaste = maxSlowWaste;
+    }
+
+    /** Sum of unused space in fast-allocated TLABs when they are retired to allocate a new one */
+    @Persist
+    public long getTotalFastWaste() {
+        return fastWaste;
+    }
+
+    @Persist
+    public void setTotalFastWaste(long fastWaste) {
+        this.fastWaste = fastWaste;
+    }
+
+    /** Maximum unused space in a single thread's fast-allocated TLABs when they are retired to allocate a new one */
+    @Persist
+    public long getMaxFastWaste() {
+        return maxFastWaste;
+    }
+
+    @Persist
+    public void setMaxFastWaste(long maxFastWaste) {
+        this.maxFastWaste = maxFastWaste;
+    }
+
+}
--- a/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackendTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryBackendTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -49,8 +49,8 @@
 import com.redhat.thermostat.jvm.overview.agent.VmStatusListenerRegistrar;
 import com.redhat.thermostat.storage.core.WriterID;
 import com.redhat.thermostat.vm.memory.agent.internal.VmMemoryBackend.ListenerCreator;
-import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAO;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.osgi.framework.Bundle;
--- a/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractorTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryDataExtractorTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -46,7 +46,7 @@
 import org.junit.Before;
 import org.junit.Test;
 
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
 
 public class VmMemoryDataExtractorTest {
 
--- a/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListenerTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/VmMemoryVmListenerTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -52,12 +52,12 @@
 import org.junit.Test;
 import org.mockito.ArgumentCaptor;
 
-import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Space;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAO;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAO;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
 
 public class VmMemoryVmListenerTest {
     private static final String[] GEN_NAMES = new String[] { "Gen1", "Gen2" };
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatDAOImplTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,153 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import static org.mockito.Matchers.anyListOf;
+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.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAOImpl.HttpHelper;
+import com.redhat.thermostat.vm.memory.agent.internal.models.VmMemoryStatDAOImpl.JsonHelper;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space;
+
+public class VmMemoryStatDAOImplTest {
+
+    private static final String JSON = "{\"this\":\"is\",\"test\":\"JSON\"}";
+    private static final String CONTENT_TYPE = "application/json";
+    private static final String GATEWAY_URL = "http://example.com/jvm-memory/0.0.2/";
+    
+    private HttpClient httpClient;
+    private HttpHelper httpHelper;
+    private JsonHelper jsonHelper;
+    private StringContentProvider contentProvider;
+    private Request request;
+    private ContentResponse response;
+    private PluginConfiguration config;
+    VmMemoryStatDAOImpl.ConfigurationCreator creator;
+    ConfigurationInfoSource source;
+
+    @Before
+    public void setUp() throws Exception {
+        httpClient = mock(HttpClient.class);
+        request = mock(Request.class);
+        when(httpClient.newRequest(anyString())).thenReturn(request);
+        response = mock(ContentResponse.class);
+        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
+        when(request.send()).thenReturn(response);
+
+        httpHelper = mock(HttpHelper.class);
+        contentProvider = mock(StringContentProvider.class);
+        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
+        jsonHelper = mock(JsonHelper.class);
+        when(jsonHelper.toJson(anyListOf(VmMemoryStat.class))).thenReturn(JSON);
+        
+        config = mock(PluginConfiguration.class);
+        when(config.getGatewayURL()).thenReturn(GATEWAY_URL);
+
+        source = mock(ConfigurationInfoSource.class);
+
+        creator = mock(VmMemoryStatDAOImpl.ConfigurationCreator.class);
+        when(creator.create(source)).thenReturn(config);
+    }
+
+    @Test
+    public void testPutVmMemoryStat() throws Exception {
+        List<Generation> generations = new ArrayList<Generation>();
+
+        int i = 0;
+        for (String genName: new String[] { "new", "old", "perm" }) {
+            Generation gen = new Generation();
+            gen.setName(genName);
+            gen.setCollector(gen.getName());
+            generations.add(gen);
+            List<Space> spaces = new ArrayList<Space>();
+            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.setName(spaceName);
+                space.setIndex(0);
+                space.setUsed(i++);
+                space.setCapacity(i++);
+                space.setMaxCapacity(i++);
+                spaces.add(space);
+            }
+            gen.setSpaces(spaces.toArray(new Space[spaces.size()]));
+        }
+        VmMemoryStat stat = new VmMemoryStat("foo-agent", 1, "vmId", generations.toArray(new Generation[generations.size()]),
+                2, 3, 4, 5);
+
+        VmMemoryStatDAOImpl dao = new VmMemoryStatDAOImpl(httpClient, jsonHelper, httpHelper, creator, source);
+        dao.activate();
+        dao.putVmMemoryStat(stat);
+
+        verify(httpClient).newRequest(GATEWAY_URL);
+        verify(request).method(HttpMethod.POST);
+        verify(jsonHelper).toJson(Arrays.asList(stat));
+        verify(httpHelper).createContentProvider(JSON);
+        verify(request).content(contentProvider, CONTENT_TYPE);
+        verify(request).send();
+        verify(response).getStatus();
+    }
+    
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmMemoryStatTypeAdapterTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Generation;
+import static com.redhat.thermostat.vm.memory.agent.model.VmMemoryStat.Space;
+import static org.junit.Assert.assertEquals;
+
+public class VmMemoryStatTypeAdapterTest {
+
+    @Test
+    public void testWrite() throws IOException {
+        VmMemoryStatTypeAdapter typeAdapter = new VmMemoryStatTypeAdapter();
+        VmMemoryStat stat = new VmMemoryStat();
+        stat.setTimeStamp(100l);
+        stat.setVmId("VM-1");
+        stat.setAgentId("AGENT-1");
+        stat.setMetaspaceCapacity(2000l);
+        stat.setMetaspaceMaxCapacity(4096l);
+        stat.setMetaspaceMinCapacity(2048l);
+        stat.setMetaspaceUsed(3000l);
+        Generation[] gens = new Generation[1];
+        Generation gen1 = new Generation();
+        gen1.setCapacity(1002l);
+        gen1.setCollector("Collector 1");
+        gen1.setMaxCapacity(2048l);
+        gen1.setName("Name");
+        Space[] spaces = new Space[1];
+        Space space = new Space();
+        space.setName("Space Name");
+        space.setMaxCapacity(1024l);
+        space.setCapacity(500l);
+        space.setIndex(1);
+        space.setUsed(400l);
+        spaces[0] = space;
+        gen1.setSpaces(spaces);
+        gens[0] = gen1;
+        stat.setGenerations(gens);
+        assertEquals("[{\"agentId\":\"AGENT-1\",\"jvmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"metaspaceMaxCapacity\":{\"$numberLong\":\"4096\"},\"metaspaceMinCapacity\":{\"$numberLong\":\"2048\"},\"metaspaceCapacity\":{\"$numberLong\":\"2000\"},\"metaspaceUsed\":{\"$numberLong\":\"3000\"},\"generations\":[{\"name\":\"Name\",\"capacity\":{\"$numberLong\":\"1002\"},\"maxCapacity\":{\"$numberLong\":\"2048\"},\"collector\":\"Collector 1\",\"spaces\":[{\"index\":1,\"name\":\"Space Name\",\"capacity\":{\"$numberLong\":\"500\"},\"maxCapacity\":{\"$numberLong\":\"1024\"},\"used\":{\"$numberLong\":\"400\"}}]}]}]", typeAdapter.toJson(Arrays.asList(stat)));
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatDAOTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import static com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAOImpl.HttpHelper;
+import static com.redhat.thermostat.vm.memory.agent.internal.models.VmTlabStatDAOImpl.JsonHelper;
+import static org.mockito.Matchers.anyListOf;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+
+import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
+import com.redhat.thermostat.common.plugin.PluginConfiguration;
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.ContentResponse;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpMethod;
+import org.eclipse.jetty.http.HttpStatus;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class VmTlabStatDAOTest {
+
+    private static final String JSON = "{\"this\":\"is\",\"test\":\"JSON\"}";
+    private static final String VM_ID = "0xcafe";
+    private static final String AGENT_ID = "agent";
+    private static final String CONTENT_TYPE = "application/json";
+    private static final String GATEWAY_URL = "http://example.com/jvm-memory/0.0.2/";
+    
+    private HttpClient httpClient;
+    private HttpHelper httpHelper;
+    private JsonHelper jsonHelper;
+    private StringContentProvider contentProvider;
+    private Request request;
+    private ContentResponse response;
+    private PluginConfiguration config;
+
+    @Before
+    public void setUp() throws Exception {
+        httpClient = mock(HttpClient.class);
+        request = mock(Request.class);
+        when(httpClient.newRequest(anyString())).thenReturn(request);
+        response = mock(ContentResponse.class);
+        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
+        when(request.send()).thenReturn(response);
+
+        httpHelper = mock(HttpHelper.class);
+        contentProvider = mock(StringContentProvider.class);
+        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
+        jsonHelper = mock(JsonHelper.class);
+        when(jsonHelper.toJson(anyListOf(VmTlabStat.class))).thenReturn(JSON);
+        
+        config = mock(PluginConfiguration.class);
+        when(config.getGatewayURL()).thenReturn(GATEWAY_URL);
+    }
+
+    @Test
+    public void testActivation() throws Exception {
+        PluginConfiguration pluginConfig = mock(PluginConfiguration.class);
+        when(pluginConfig.getGatewayURL()).thenReturn("someGatewayURL");
+        VmTlabStatDAOImpl.ConfigurationCreator configCreator = mock(VmTlabStatDAOImpl.ConfigurationCreator.class);
+        ConfigurationInfoSource configInfoSource = mock(ConfigurationInfoSource.class);
+        when(configCreator.create(configInfoSource)).thenReturn(pluginConfig);
+
+        VmTlabStatDAOImpl dao = new VmTlabStatDAOImpl(httpClient, httpHelper, jsonHelper, configCreator, configInfoSource);
+        dao.activate();
+
+        verify(pluginConfig, times(1)).getGatewayURL();
+        verify(httpHelper, times(1)).startClient(httpClient);
+    }
+
+    @Test
+    @Ignore
+    public void verifyPutStat() throws Exception {
+//      TODO: Remove @Ignore when web-gateway service for TLAB stats is available
+//      See VmTlabStatDAOImpl.putStat()
+
+        VmTlabStat stat = new VmTlabStat();
+        stat.setAgentId(AGENT_ID);
+        stat.setVmId(VM_ID);
+        stat.setTimeStamp(1000l);
+        stat.setTotalAllocatingThreads(10l);
+        stat.setTotalAllocations(1342l);
+        stat.setTotalRefills(58l);
+        stat.setMaxRefills(90l);
+        stat.setTotalSlowAllocations(343l);
+        stat.setMaxSlowAllocations(989l);
+        stat.setTotalGcWaste(788l);
+        stat.setMaxGcWaste(992l);
+        stat.setTotalSlowWaste(899l);
+        stat.setMaxSlowWaste(634l);
+        stat.setTotalFastWaste(678l);
+        stat.setMaxFastWaste(333l);
+
+        VmTlabStatDAOImpl.ConfigurationCreator configurationCreator = new VmTlabStatDAOImpl.ConfigurationCreator();
+        ConfigurationInfoSource configInfoSource = mock(ConfigurationInfoSource.class);
+        VmTlabStatDAO dao = new VmTlabStatDAOImpl(httpClient, httpHelper, jsonHelper, configurationCreator, configInfoSource);
+        dao.putStat(stat);
+
+        verify(httpClient).newRequest(GATEWAY_URL);
+        verify(request).method(HttpMethod.POST);
+        verify(jsonHelper).toJson(Arrays.asList(stat));
+        verify(httpHelper).createContentProvider(JSON);
+        verify(request).content(contentProvider, CONTENT_TYPE);
+        verify(request).send();
+        verify(response).getStatus();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/internal/models/VmTlabStatTypeAdapterTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.agent.internal.models;
+
+import com.redhat.thermostat.vm.memory.agent.model.VmTlabStat;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Arrays;
+
+import static org.junit.Assert.assertEquals;
+
+public class VmTlabStatTypeAdapterTest {
+
+    @Test
+    public void testWrite() throws IOException {
+        VmTlabStatTypeAdapter typeAdapter = new VmTlabStatTypeAdapter();
+        VmTlabStat stat = new VmTlabStat();
+        stat.setAgentId("AGENT-1");
+        stat.setVmId("VM-1");
+        stat.setTimeStamp(1000l);
+        stat.setTotalAllocatingThreads(10l);
+        stat.setTotalAllocations(1342l);
+        stat.setTotalRefills(58l);
+        stat.setMaxRefills(90l);
+        stat.setTotalSlowAllocations(343l);
+        stat.setMaxSlowAllocations(989l);
+        stat.setTotalGcWaste(788l);
+        stat.setMaxGcWaste(992l);
+        stat.setTotalSlowWaste(899l);
+        stat.setMaxSlowWaste(634l);
+        stat.setTotalFastWaste(678l);
+        stat.setMaxFastWaste(333l);
+        assertEquals("[{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"timeStamp\":{\"$numberLong\":\"1000\"},\"allocThreads\":{\"$numberLong\":\"10\"},\"totalAllocations\":{\"$numberLong\":\"1342\"},\"refills\":{\"$numberLong\":\"58\"},\"maxRefills\":{\"$numberLong\":\"90\"},\"slowAllocations\":{\"$numberLong\":\"343\"},\"maxSlowAllocations\":{\"$numberLong\":\"989\"},\"gcWaste\":{\"$numberLong\":\"788\"},\"maxGcWaste\":{\"$numberLong\":\"992\"},\"slowWaste\":{\"$numberLong\":\"899\"},\"maxSlowWaste\":{\"$numberLong\":\"634\"},\"fastWaste\":{\"$numberLong\":\"678\"},\"maxFastWaste\":{\"$numberLong\":\"333\"}}]", typeAdapter.toJson(Arrays.asList(stat)));
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/vm-memory/agent/src/test/java/com/redhat/thermostat/vm/memory/agent/model/VmMemoryStatTest.java	Tue Jun 27 10:52:26 2017 -0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2012-2017 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.vm.memory.common.model;
+
+import com.redhat.thermostat.testutils.DataObjectTest;
+
+public class VmMemoryStatTest extends DataObjectTest {
+
+    @Override
+    public Class<?>[] getDataClasses() {
+        return new Class<?>[] { VmMemoryStatTest.class };
+    }
+
+}
+
--- a/plugins/vm-memory/common/pom.xml	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,144 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Copyright 2012-2017 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.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <artifactId>thermostat-vm-memory</artifactId>
-    <groupId>com.redhat.thermostat</groupId>
-    <version>1.99.12-SNAPSHOT</version>
-  </parent>
-  <artifactId>thermostat-vm-memory-common</artifactId>
-  <packaging>bundle</packaging>
-  <name>Thermostat VM Memory Common plugin</name>
-  <build>
-    <resources>
-      <resource>
-        <directory>src/main/resources</directory>
-        <filtering>true</filtering>
-        <excludes>
-          <exclude>**/*.png</exclude>
-        </excludes>
-      </resource>
-      <resource>
-        <directory>src/main/resources</directory>
-        <filtering>false</filtering>
-        <includes>
-          <include>**/*.png</include>
-        </includes>
-      </resource>
-    </resources>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Bundle-Vendor>Red Hat, Inc.</Bundle-Vendor>
-            <Bundle-SymbolicName>com.redhat.thermostat.vm.memory.common</Bundle-SymbolicName>
-            <Export-Package>
-              com.redhat.thermostat.vm.memory.common,
-              com.redhat.thermostat.vm.memory.common.model
-            </Export-Package>
-            <Private-Package>
-              com.redhat.thermostat.vm.memory.common.internal
-            </Private-Package>
-            <!-- Do not autogenerate uses clauses in Manifests -->
-            <_nouses>true</_nouses>
-          </instructions>
-        </configuration>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-scr-plugin</artifactId>
-        <executions>
-          <execution>
-            <id>generate-scr-scrdescriptor</id>
-            <goals>
-              <goal>scr</goal>
-            </goals>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.core</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>org.osgi</groupId>
-      <artifactId>org.osgi.compendium</artifactId>
-      <scope>provided</scope>
-    </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-common-core</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-common-plugin</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-storage-core</artifactId>
-      <version>${project.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>com.redhat.thermostat</groupId>
-      <artifactId>thermostat-common-test</artifactId>
-      <version>${project.version}</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-</project>
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/Constants.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common;
-
-import com.redhat.thermostat.common.Ordered;
-
-public class Constants {
-
-    public static final int ORDER = Ordered.ORDER_MEMORY_GROUP + 40;
-
-    private Constants() {
-        throw new AssertionError("Do not instantiate this");
-    }
-
-}
\ No newline at end of file
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmMemoryStatDAO.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common;
-
-import java.util.Arrays;
-import java.util.List;
-
-import com.redhat.thermostat.annotations.Service;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-
-@Service
-public interface VmMemoryStatDAO {
-
-    public void putVmMemoryStat(VmMemoryStat stat);
-
-}
-
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/VmTlabStatDAO.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common;
-
-import com.redhat.thermostat.annotations.Service;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
-
-@Service
-public interface VmTlabStatDAO {
-
-    public void putStat(VmTlabStat stat);
-
-}
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImpl.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,168 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugin.PluginConfiguration;
-import com.redhat.thermostat.common.utils.LoggingUtils;
-import com.redhat.thermostat.vm.memory.common.VmMemoryStatDAO;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-
-@Component
-@Service(value = VmMemoryStatDAO.class)
-public class VmMemoryStatDAOImpl implements VmMemoryStatDAO {
-
-    private static final Logger logger = LoggingUtils.getLogger(VmMemoryStatDAOImpl.class);
-    private static final String PLUGIN_ID = "vm-memory";
-    private static final String CONTENT_TYPE = "application/json";
-
-    private final HttpClient client;
-    private final HttpHelper httpHelper;
-    private final JsonHelper jsonHelper;
-    private final ConfigurationCreator configCreator;
-
-    private String gatewayURL;
-
-    @Reference
-    private ConfigurationInfoSource configInfoSource;
-
-    public VmMemoryStatDAOImpl() {
-        this(new HttpClient(), new JsonHelper(new VmMemoryStatTypeAdapter()), new HttpHelper(),
-                new ConfigurationCreator(), null);
-    }
-
-    VmMemoryStatDAOImpl(HttpClient client, JsonHelper jh, HttpHelper hh, ConfigurationCreator creator,
-            ConfigurationInfoSource source) {
-        this.client = client;
-        this.httpHelper = hh;
-        this.jsonHelper = jh;
-        this.configCreator = creator;
-        this.configInfoSource = source;
-    }
-
-    @Activate
-    void activate() throws Exception {
-        PluginConfiguration config = configCreator.create(configInfoSource);
-        this.gatewayURL = config.getGatewayURL();
-
-        httpHelper.startClient(client);
-    }
-
-    @Override
-    public void putVmMemoryStat(final VmMemoryStat stat) {
-        try {
-            String json = jsonHelper.toJson(Arrays.asList(stat));
-            StringContentProvider provider = httpHelper.createContentProvider(json);
-
-            Request httpRequest = client.newRequest(gatewayURL);
-            httpRequest.method(HttpMethod.POST);
-            httpRequest.content(provider, CONTENT_TYPE);
-            sendRequest(httpRequest);
-        } catch (Exception e) {
-            logger.log(Level.WARNING, "Failed to send VmMemoryStat to Web Gateway", e);
-        }
-    }
-
-    private void sendRequest(Request httpRequest)
-            throws InterruptedException, TimeoutException, ExecutionException, IOException {
-        ContentResponse resp = httpRequest.send();
-        int status = resp.getStatus();
-        if (status != HttpStatus.OK_200) {
-            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
-        }
-    }
-
-    protected Logger getLogger() {
-        return logger;
-    }
-
-    // For testing purposes
-    static class JsonHelper {
-
-        private final VmMemoryStatTypeAdapter adapter;
-
-        public JsonHelper(VmMemoryStatTypeAdapter adapter) {
-            this.adapter = adapter;
-        }
-
-        String toJson(List<VmMemoryStat> stats) throws IOException {
-            return adapter.toJson(stats);
-        }
-    }
-
-    // For testing purposes
-    static class HttpHelper {
-
-        void startClient(HttpClient httpClient) throws Exception {
-            httpClient.start();
-        }
-
-        StringContentProvider createContentProvider(String content) {
-            return new StringContentProvider(content);
-        }
-
-    }
-
-    // For Testing purposes
-    static class ConfigurationCreator {
-
-        PluginConfiguration create(ConfigurationInfoSource source) {
-            return new PluginConfiguration(source, PLUGIN_ID);
-        }
-
-    }
-}
-
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatTypeAdapter.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,149 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-
-import java.io.IOException;
-import java.util.List;
-
-import static com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
-import static com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Space;
-
-public class VmMemoryStatTypeAdapter extends TypeAdapter<List<VmMemoryStat>> {
-
-    private static final String GENERATIONS = "generations";
-    private static final String TIMESTAMP = "timeStamp";
-    private static final String AGENT_ID = "agentId";
-    private static final String VM_ID = "jvmId";
-    private static final String METASPACE_MAX_CAPACITY = "metaspaceMaxCapacity";
-    private static final String METASPACE_MIN_CAPACITY = "metaspaceMinCapacity";
-    private static final String METASPACE_CAPACITY = "metaspaceCapacity";
-    private static final String METASPACE_USED = "metaspaceUsed";
-    private static final String NAME = "name";
-    private static final String CAPACITY = "capacity";
-    private static final String MAX_CAPACITY = "maxCapacity";
-    private static final String SPACES = "spaces";
-    private static final String COLLECTOR = "collector";
-    private static final String INDEX = "index";
-    private static final String USED = "used";
-    private static final String TYPE_LONG = "$numberLong";
-
-    @Override
-    public List<VmMemoryStat> read(JsonReader in) throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void write(JsonWriter out, List<VmMemoryStat> stats) throws IOException {
-        out.beginArray();
-        for (VmMemoryStat stat : stats) {
-            writeStat(out, stat);
-        }
-        out.endArray();
-    }
-
-    public void writeStat(JsonWriter out, VmMemoryStat stat) throws IOException {
-        out.beginObject();
-        out.name(AGENT_ID);
-        out.value(stat.getAgentId());
-        out.name(VM_ID);
-        out.value(stat.getVmId());
-        out.name(TIMESTAMP);
-        writeLong(out, stat.getTimeStamp());
-        out.name(METASPACE_MAX_CAPACITY);
-        writeLong(out, stat.getMetaspaceMaxCapacity());
-        out.name(METASPACE_MIN_CAPACITY);
-        writeLong(out, stat.getMetaspaceMinCapacity());
-        out.name(METASPACE_CAPACITY);
-        writeLong(out, stat.getMetaspaceCapacity());
-        out.name(METASPACE_USED);
-        writeLong(out, stat.getMetaspaceUsed());
-        out.name(GENERATIONS);
-        out.beginArray();
-        for (Generation g : stat.getGenerations()) {
-            writeGeneration(out, g);
-        }
-        out.endArray();
-        out.endObject();
-    }
-
-    public void writeLong(JsonWriter out, long value) throws IOException {
-        // Write MongoDB representation of a Long
-        out.beginObject();
-        out.name(TYPE_LONG);
-        out.value(String.valueOf(value));
-        out.endObject();
-    }
-
-    public void writeGeneration(JsonWriter out, Generation g) throws IOException {
-        out.beginObject();
-        out.name(NAME);
-        out.value(g.getName());
-        out.name(CAPACITY);
-        writeLong(out, g.getCapacity());
-        out.name(MAX_CAPACITY);
-        writeLong(out, g.getMaxCapacity());
-        out.name(COLLECTOR);
-        out.value(g.getCollector());
-        out.name(SPACES);
-        out.beginArray();
-        for (Space s : g.getSpaces()) {
-            writeSpace(out, s);
-        }
-        out.endArray();
-        out.endObject();
-    }
-
-    public void writeSpace(JsonWriter out, Space s) throws IOException {
-        out.beginObject();
-        out.name(INDEX);
-        out.value(s.getIndex());
-        out.name(NAME);
-        out.value(s.getName());
-        out.name(CAPACITY);
-        writeLong(out, s.getCapacity());
-        out.name(MAX_CAPACITY);
-        writeLong(out, s.getMaxCapacity());
-        out.name(USED);
-        writeLong(out, s.getUsed());
-        out.endObject();
-    }
-}
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOImpl.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,165 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeoutException;
-import java.util.logging.Logger;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugin.PluginConfiguration;
-import com.redhat.thermostat.common.utils.LoggingUtils;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.Service;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpStatus;
-
-@Component
-@Service(value = VmTlabStatDAO.class)
-public class VmTlabStatDAOImpl implements VmTlabStatDAO {
-
-    private static final Logger logger = LoggingUtils.getLogger(VmTlabStatDAOImpl.class);
-    private static final String PLUGIN_ID = "vm-memory";
-    private static final String CONTENT_TYPE = "application/json";
-
-    private final HttpClient client;
-    private final HttpHelper httpHelper;
-    private final JsonHelper jsonHelper;
-    private final ConfigurationCreator configurationCreator;
-
-    private String gatewayURL;
-
-    @Reference
-    private ConfigurationInfoSource configInfoSource;
-
-    public VmTlabStatDAOImpl() throws Exception {
-        this(new HttpClient(), new HttpHelper(), new JsonHelper(new VmTlabStatTypeAdapter()), new ConfigurationCreator(), null);
-    }
-
-    VmTlabStatDAOImpl(HttpClient client, HttpHelper httpHelper, JsonHelper jsonHelper,
-            ConfigurationCreator configurationCreator, ConfigurationInfoSource configInfoSource) throws Exception {
-        this.client = client;
-        this.httpHelper = httpHelper;
-        this.jsonHelper = jsonHelper;
-        this.configurationCreator = configurationCreator;
-        this.configInfoSource = configInfoSource;
-    }
-
-    @Activate
-    void activate() throws Exception {
-        PluginConfiguration config = configurationCreator.create(configInfoSource);
-        this.gatewayURL = config.getGatewayURL();
-
-        this.httpHelper.startClient(this.client);
-    }
-
-    @Override
-    public void putStat(final VmTlabStat stat) {
-//      TODO: Re-enable when web-gateway service for TLAB stats is available
-//      Also see VmTlabStatDAOTest for disabled tests
-        return;
-//        try {
-//            String json = jsonHelper.toJson(Arrays.asList(stat));
-//            StringContentProvider provider = httpHelper.createContentProvider(json);
-//
-//            Request httpRequest = client.newRequest(gatewayURL);
-//            httpRequest.method(HttpMethod.POST);
-//            httpRequest.content(provider, CONTENT_TYPE);
-//            sendRequest(httpRequest);
-//        } catch (Exception e) {
-//            logger.log(Level.WARNING, "Failed to send VmTlabStat to Web Gateway", e);
-//        }
-    }
-
-    private void sendRequest(Request httpRequest)
-            throws InterruptedException, TimeoutException, ExecutionException, IOException {
-        ContentResponse resp = httpRequest.send();
-        int status = resp.getStatus();
-        if (status != HttpStatus.OK_200) {
-            throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason());
-        }
-    }
-
-    protected Logger getLogger() {
-        return logger;
-    }
-
-    static class JsonHelper {
-
-        private final VmTlabStatTypeAdapter adapter;
-
-        public JsonHelper(VmTlabStatTypeAdapter adapter) {
-            this.adapter = adapter;
-        }
-
-        String toJson(List<VmTlabStat> stats) throws IOException {
-            return adapter.toJson(stats);
-        }
-    }
-
-    // For testing purposes
-    static class HttpHelper {
-
-        void startClient(HttpClient httpClient) throws Exception {
-            httpClient.start();
-        }
-
-        StringContentProvider createContentProvider(String content) {
-            return new StringContentProvider(content);
-        }
-
-    }
-
-    // For testing purposes
-    static class ConfigurationCreator {
-
-        PluginConfiguration create(ConfigurationInfoSource source) {
-            return new PluginConfiguration(source, PLUGIN_ID);
-        }
-    }
-}
-
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatTypeAdapter.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,122 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import com.google.gson.TypeAdapter;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
-
-import java.io.IOException;
-import java.util.List;
-
-public class VmTlabStatTypeAdapter extends TypeAdapter<List<VmTlabStat>> {
-
-    private static final String AGENT_ID = "agentId";
-    private static final String VM_ID = "vmId";
-    private static final String TIMESTAMP = "timeStamp";
-    private static final String ALLOC_THREADS = "allocThreads";
-    private static final String TOTAL_ALLOCATIONS = "totalAllocations";
-    private static final String REFILLS = "refills";
-    private static final String MAX_REFILLS = "maxRefills";
-    private static final String SLOW_ALLOCATIONS = "slowAllocations";
-    private static final String MAX_SLOW_ALLOCATIONS = "maxSlowAllocations";
-    private static final String GC_WASTE = "gcWaste";
-    private static final String MAX_GC_WASTE = "maxGcWaste";
-    private static final String SLOW_WASTE = "slowWaste";
-    private static final String MAX_SLOW_WASTE = "maxSlowWaste";
-    private static final String FAST_WASTE = "fastWaste";
-    private static final String MAX_FAST_WASTE = "maxFastWaste";
-    private static final String TYPE_LONG = "$numberLong";
-
-    @Override
-    public List<VmTlabStat> read(JsonReader in) throws IOException {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void write(JsonWriter out, List<VmTlabStat> stats) throws IOException {
-        out.beginArray();
-        for (VmTlabStat tlabStat : stats) {
-            writeStat(out, tlabStat);
-        }
-        out.endArray();
-    }
-
-    public void writeStat(JsonWriter out, VmTlabStat stat) throws IOException {
-        out.beginObject();
-        out.name(VM_ID);
-        out.value(stat.getVmId());
-        out.name(AGENT_ID);
-        out.value(stat.getAgentId());
-        out.name(TIMESTAMP);
-        writeLong(out, stat.getTimeStamp());
-        out.name(ALLOC_THREADS);
-        writeLong(out, stat.getTotalAllocatingThreads());
-        out.name(TOTAL_ALLOCATIONS);
-        writeLong(out, stat.getTotalAllocations());
-        out.name(REFILLS);
-        writeLong(out, stat.getTotalRefills());
-        out.name(MAX_REFILLS);
-        writeLong(out, stat.getMaxRefills());
-        out.name(SLOW_ALLOCATIONS);
-        writeLong(out, stat.getTotalSlowAllocations());
-        out.name(MAX_SLOW_ALLOCATIONS);
-        writeLong(out, stat.getMaxSlowAllocations());
-        out.name(GC_WASTE);
-        writeLong(out, stat.getTotalGcWaste());
-        out.name(MAX_GC_WASTE);
-        writeLong(out, stat.getMaxGcWaste());
-        out.name(SLOW_WASTE);
-        writeLong(out, stat.getTotalSlowWaste());
-        out.name(MAX_SLOW_WASTE);
-        writeLong(out, stat.getMaxSlowWaste());
-        out.name(FAST_WASTE);
-        writeLong(out, stat.getTotalFastWaste());
-        out.name(MAX_FAST_WASTE);
-        writeLong(out, stat.getMaxFastWaste());
-        out.endObject();
-    }
-
-    public void writeLong(JsonWriter out, long value) throws IOException {
-        // Write MongoDB representation of a Long
-        out.beginObject();
-        out.name(TYPE_LONG);
-        out.value(String.valueOf(value));
-        out.endObject();
-    }
-}
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/model/VmMemoryStat.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,308 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.model;
-
-import com.redhat.thermostat.storage.core.Entity;
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.BasePojo;
-import com.redhat.thermostat.storage.model.Pojo;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
-
-@Entity
-public class VmMemoryStat extends BasePojo implements TimeStampedPojo {
-
-    public static final long UNKNOWN = -1;
-
-    public static final String METASPACE_NAME = "metaspace";
-
-    @Entity
-    public static class Generation implements Pojo {
-        public static final String COLLECTOR_NONE = "none";
-        private String name;
-        private long capacity;
-        private long maxCapacity;
-        private Space[] spaces;
-        private String collector;
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Persist
-        public long getCapacity() {
-            return capacity;
-        }
-
-        @Persist
-        public void setCapacity(long capacity) {
-            this.capacity = capacity;
-        }
-
-        @Persist
-        public long getMaxCapacity() {
-            return maxCapacity;
-        }
-
-        @Persist
-        public void setMaxCapacity(long maxCapacity) {
-            this.maxCapacity = maxCapacity;
-        }
-
-        @Persist
-        public Space[] getSpaces() {
-            return spaces;
-        }
-
-        @Persist
-        public void setSpaces(Space[] spaces) {
-            this.spaces = spaces;
-        }
-
-        @Persist
-        public String getCollector() {
-            return collector;
-        }
-
-        @Persist
-        public void setCollector(String collector) {
-            this.collector = collector;
-        }
-
-        public Space getSpace(String string) {
-            for (Space s : spaces) {
-                if (s.name.equals(string)) {
-                    return s;
-                }
-            }
-            return null;
-        }
-    }
-
-    @Entity
-    public static class Space implements Pojo {
-
-        private int index;
-        private String name;
-        private long capacity;
-        private long maxCapacity;
-        private long used;
-
-        @Persist
-        public int getIndex() {
-            return index;
-        }
-
-        @Persist
-        public void setIndex(int index) {
-            this.index = index;
-        }
-
-        @Persist
-        public String getName() {
-            return name;
-        }
-
-        @Persist
-        public void setName(String name) {
-            this.name = name;
-        }
-
-        @Persist
-        public long getCapacity() {
-            return capacity;
-        }
-
-        @Persist
-        public void setCapacity(long capacity) {
-            this.capacity = capacity;
-        }
-
-        @Persist
-        public long getMaxCapacity() {
-            return maxCapacity;
-        }
-
-        @Persist
-        public void setMaxCapacity(long maxCapacity) {
-            this.maxCapacity = maxCapacity;
-        }
-
-        @Persist
-        public long getUsed() {
-            return used;
-        }
-
-        @Persist
-        public void setUsed(long used) {
-            this.used = used;
-        }
-
-    }
-
-    private Generation[] generations;
-    private long timestamp;
-    private String vmId;
-    private long metaspaceMaxCapacity;
-    private long metaspaceMinCapacity;
-    private long metaspaceCapacity;
-    private long metaspaceUsed;
-
-    public VmMemoryStat() {
-        this(null, UNKNOWN, null, null, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN);
-    }
-
-    public VmMemoryStat(String writerId, long timestamp, String vmId, Generation[] generations,
-            long metaspaceMaxCapacity, long metaspaceMinCapacity, long metaspaceCapacity, long metaspaceUsed) {
-        super(writerId);
-        this.timestamp = timestamp;
-        this.vmId = vmId;
-        if (generations != null) {
-            this.generations = generations;
-        }
-        this.metaspaceMaxCapacity = metaspaceMaxCapacity;
-        this.metaspaceMinCapacity = metaspaceMinCapacity;
-        this.metaspaceCapacity = metaspaceCapacity;
-        this.metaspaceUsed = metaspaceUsed;
-        checkSaneValuesForMetaspace();
-    }
-
-    @Persist
-    public String getVmId() {
-        return vmId;
-    }
-
-    @Persist
-    public void setVmId(String vmId) {
-        this.vmId = vmId;
-    }
-
-    @Persist
-    @Override
-    public long getTimeStamp() {
-        return timestamp;
-    }
-
-    @Persist
-    public void setTimeStamp(long timeStamp) {
-        this.timestamp = timeStamp;
-    }
-
-    @Persist
-    public Generation[] getGenerations() {
-        return generations;
-    }
-
-    @Persist
-    public void setGenerations(Generation[] generations) {
-        this.generations = generations;
-    }
-
-    public Generation getGeneration(String name) {
-        for (Generation g : generations) {
-            if (g.name.equals(name)) {
-                return g;
-            }
-        }
-        return null;
-    }
-
-    @Persist
-    public long getMetaspaceCapacity() {
-        return metaspaceCapacity;
-    }
-
-    @Persist
-    public void setMetaspaceCapacity(long capacity) {
-        this.metaspaceCapacity = capacity;
-    }
-
-    @Persist
-    public long getMetaspaceMaxCapacity() {
-        return metaspaceMaxCapacity;
-    }
-
-    @Persist
-    public void setMetaspaceMaxCapacity(long maxCapacity) {
-        this.metaspaceMaxCapacity = maxCapacity;
-    }
-
-    @Persist
-    public long getMetaspaceMinCapacity() {
-        return metaspaceMinCapacity;
-    }
-
-    @Persist
-    public void setMetaspaceMinCapacity(long minCapacity) {
-        this.metaspaceMinCapacity = minCapacity;
-    }
-
-    @Persist
-    public long getMetaspaceUsed() {
-        return metaspaceUsed;
-    }
-
-    @Persist
-    public void setMetaspaceUsed(long used) {
-        this.metaspaceUsed = used;
-    }
-
-    public boolean isMetaspacePresent() {
-        checkSaneValuesForMetaspace();
-        if (metaspaceCapacity == UNKNOWN) {
-            return false;
-        }
-        return true;
-    }
-
-    private void checkSaneValuesForMetaspace() {
-        // either all values must be unknown or no values must be unknown
-        if (metaspaceMaxCapacity == UNKNOWN && metaspaceMinCapacity == UNKNOWN &&
-                metaspaceCapacity == UNKNOWN && metaspaceUsed == UNKNOWN) {
-            return;
-        } else if (metaspaceMaxCapacity == UNKNOWN || metaspaceMinCapacity == UNKNOWN ||
-                metaspaceCapacity == UNKNOWN || metaspaceUsed == UNKNOWN) {
-            throw new AssertionError("Invalid values for metaspace");
-        }
-    }
-}
-
--- a/plugins/vm-memory/common/src/main/java/com/redhat/thermostat/vm/memory/common/model/VmTlabStat.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.model;
-
-import com.redhat.thermostat.storage.core.Entity;
-import com.redhat.thermostat.storage.core.Persist;
-import com.redhat.thermostat.storage.model.BasePojo;
-import com.redhat.thermostat.storage.model.TimeStampedPojo;
-
-@Entity
-public class VmTlabStat extends BasePojo implements TimeStampedPojo {
-
-    // See https://blogs.oracle.com/jonthecollector/entry/the_real_thing
-    // See hotspot/src/share/vm/gc/shared/threadLocalAllocBuffer.hpp
-
-    public static final long UNKNOWN = -1;
-
-    private String vmId;
-    private long timeStamp;
-
-    private long allocThreads;
-    private long totalAllocations;
-
-    private long refills;
-    private long maxRefills;
-
-    private long slowAllocations;
-    private long maxSlowAllocations;
-
-    private long gcWaste;
-    private long maxGcWaste;
-
-    private long slowWaste;
-    private long maxSlowWaste;
-
-    private long fastWaste;
-    private long maxFastWaste;
-
-    /** for de-serialization only */
-    public VmTlabStat() {
-        super(null);
-    }
-
-    public VmTlabStat(long timeStamp, String agentId, String vmId,
-            long threadCount, long totalAllocations,
-            long refills, long maxRefills,
-            long slowAllocations, long maxSlowAllocations,
-            long gcWaste, long maxGcWaste,
-            long slowWaste,    long maxSlowWaste,
-            long fastWaste, long maxFastWaste) {
-        super(agentId);
-        this.vmId = vmId;
-        this.timeStamp = timeStamp;
-        this.allocThreads = threadCount;
-        this.totalAllocations = totalAllocations;
-        this.refills = refills;
-        this.maxRefills = maxRefills;
-        this.slowAllocations = slowAllocations;
-        this.maxSlowAllocations = maxSlowAllocations;
-        this.gcWaste = gcWaste;
-        this.maxGcWaste = maxGcWaste;
-        this.slowWaste = slowWaste;
-        this.maxSlowWaste = maxSlowWaste;
-        this.fastWaste = fastWaste;
-        this.maxFastWaste = maxFastWaste;
-    }
-
-    @Persist
-    public String getVmId() {
-        return vmId;
-    }
-
-    @Persist
-    public void setVmId(String vmId) {
-        this.vmId = vmId;
-    }
-
-    @Persist
-    @Override
-    public long getTimeStamp() {
-        return timeStamp;
-    }
-
-    @Persist
-    public void setTimeStamp(long timeStamp) {
-        this.timeStamp = timeStamp;
-    }
-
-    /** Number of threads that did an allocation in the last epoch */
-    @Persist
-    public long getTotalAllocatingThreads() {
-        return allocThreads;
-    }
-
-    @Persist
-    public void setTotalAllocatingThreads(long allocThreads) {
-        this.allocThreads = allocThreads;
-    }
-
-    /** Number of allocations in the last epoch */
-    @Persist
-    public long getTotalAllocations() {
-        return totalAllocations;
-    }
-
-    @Persist
-    public void setTotalAllocations(long allocations) {
-        this.totalAllocations = allocations;
-    }
-
-    // Refills:
-
-    @Persist
-    public long getTotalRefills() {
-        return refills;
-    }
-
-    @Persist
-    public void setTotalRefills(long totalRefills) {
-        this.refills = totalRefills;
-    }
-
-    /** The maximum refills by a single thread */
-    @Persist
-    public long getMaxRefills() {
-        return maxRefills;
-    }
-
-    @Persist
-    public void setMaxRefills(long maxRefills) {
-        this.maxRefills = maxRefills;
-    }
-
-    // Slow Allocations:
-
-    /** Total number of allocations done outside of a TLAB */
-    @Persist
-    public long getTotalSlowAllocations() {
-        return slowAllocations;
-    }
-
-    @Persist
-    public void setTotalSlowAllocations(long slowAllocations) {
-        this.slowAllocations = slowAllocations;
-    }
-
-    /** Maximum number of allocations done outside of a TLAB by a single thread */
-    @Persist
-    public long getMaxSlowAllocations() {
-        return maxSlowAllocations;
-    }
-
-    @Persist
-    public void setMaxSlowAllocations(long maxSlowAllocations) {
-        this.maxSlowAllocations = maxSlowAllocations;
-    }
-
-    // Refill Waste:
-
-    /** Unused space in the current TLABs when GC starts */
-    @Persist
-    public long getTotalGcWaste() {
-        return gcWaste;
-    }
-
-    @Persist
-    public void setTotalGcWaste(long gcWaste) {
-        this.gcWaste = gcWaste;
-    }
-
-    /** Max unused space for a single thread's TLAB when GC starts */
-    @Persist
-    public long getMaxGcWaste() {
-        return maxGcWaste;
-    }
-
-    @Persist
-    public void setMaxGcWaste(long maxGcWaste) {
-        this.maxGcWaste = maxGcWaste;
-    }
-
-    /** Sum of unused space in TLABs when they're retired to allocate a new ones */
-    @Persist
-    public long getTotalSlowWaste() {
-        return slowWaste;
-    }
-
-    @Persist
-    public void setTotalSlowWaste(long slowWaste) {
-        this.slowWaste = slowWaste;
-    }
-
-    /** Maximum unused space in TLABS when they are retired to allocate a new one */
-    @Persist
-    public long getMaxSlowWaste() {
-        return maxSlowWaste;
-    }
-
-    @Persist
-    public void setMaxSlowWaste(long maxSlowWaste) {
-        this.maxSlowWaste = maxSlowWaste;
-    }
-
-    /** Sum of unused space in fast-allocated TLABs when they are retired to allocate a new one */
-    @Persist
-    public long getTotalFastWaste() {
-        return fastWaste;
-    }
-
-    @Persist
-    public void setTotalFastWaste(long fastWaste) {
-        this.fastWaste = fastWaste;
-    }
-
-    /** Maximum unused space in a single thread's fast-allocated TLABs when they are retired to allocate a new one */
-    @Persist
-    public long getMaxFastWaste() {
-        return maxFastWaste;
-    }
-
-    @Persist
-    public void setMaxFastWaste(long maxFastWaste) {
-        this.maxFastWaste = maxFastWaste;
-    }
-
-}
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatDAOImplTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,153 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import static org.mockito.Matchers.anyListOf;
-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.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Test;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugin.PluginConfiguration;
-import com.redhat.thermostat.vm.memory.common.internal.VmMemoryStatDAOImpl.HttpHelper;
-import com.redhat.thermostat.vm.memory.common.internal.VmMemoryStatDAOImpl.JsonHelper;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Space;
-
-public class VmMemoryStatDAOImplTest {
-
-    private static final String JSON = "{\"this\":\"is\",\"test\":\"JSON\"}";
-    private static final String CONTENT_TYPE = "application/json";
-    private static final String GATEWAY_URL = "http://example.com/jvm-memory/0.0.2/";
-    
-    private HttpClient httpClient;
-    private HttpHelper httpHelper;
-    private JsonHelper jsonHelper;
-    private StringContentProvider contentProvider;
-    private Request request;
-    private ContentResponse response;
-    private PluginConfiguration config;
-    VmMemoryStatDAOImpl.ConfigurationCreator creator;
-    ConfigurationInfoSource source;
-
-    @Before
-    public void setUp() throws Exception {
-        httpClient = mock(HttpClient.class);
-        request = mock(Request.class);
-        when(httpClient.newRequest(anyString())).thenReturn(request);
-        response = mock(ContentResponse.class);
-        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
-        when(request.send()).thenReturn(response);
-
-        httpHelper = mock(HttpHelper.class);
-        contentProvider = mock(StringContentProvider.class);
-        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
-        jsonHelper = mock(JsonHelper.class);
-        when(jsonHelper.toJson(anyListOf(VmMemoryStat.class))).thenReturn(JSON);
-        
-        config = mock(PluginConfiguration.class);
-        when(config.getGatewayURL()).thenReturn(GATEWAY_URL);
-
-        source = mock(ConfigurationInfoSource.class);
-
-        creator = mock(VmMemoryStatDAOImpl.ConfigurationCreator.class);
-        when(creator.create(source)).thenReturn(config);
-    }
-
-    @Test
-    public void testPutVmMemoryStat() throws Exception {
-        List<Generation> generations = new ArrayList<Generation>();
-
-        int i = 0;
-        for (String genName: new String[] { "new", "old", "perm" }) {
-            Generation gen = new Generation();
-            gen.setName(genName);
-            gen.setCollector(gen.getName());
-            generations.add(gen);
-            List<Space> spaces = new ArrayList<Space>();
-            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.setName(spaceName);
-                space.setIndex(0);
-                space.setUsed(i++);
-                space.setCapacity(i++);
-                space.setMaxCapacity(i++);
-                spaces.add(space);
-            }
-            gen.setSpaces(spaces.toArray(new Space[spaces.size()]));
-        }
-        VmMemoryStat stat = new VmMemoryStat("foo-agent", 1, "vmId", generations.toArray(new Generation[generations.size()]),
-                2, 3, 4, 5);
-
-        VmMemoryStatDAOImpl dao = new VmMemoryStatDAOImpl(httpClient, jsonHelper, httpHelper, creator, source);
-        dao.activate();
-        dao.putVmMemoryStat(stat);
-
-        verify(httpClient).newRequest(GATEWAY_URL);
-        verify(request).method(HttpMethod.POST);
-        verify(jsonHelper).toJson(Arrays.asList(stat));
-        verify(httpHelper).createContentProvider(JSON);
-        verify(request).content(contentProvider, CONTENT_TYPE);
-        verify(request).send();
-        verify(response).getStatus();
-    }
-    
-}
-
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmMemoryStatTypeAdapterTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import com.redhat.thermostat.vm.memory.common.model.VmMemoryStat;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import static com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Generation;
-import static com.redhat.thermostat.vm.memory.common.model.VmMemoryStat.Space;
-import static org.junit.Assert.assertEquals;
-
-public class VmMemoryStatTypeAdapterTest {
-
-    @Test
-    public void testWrite() throws IOException {
-        VmMemoryStatTypeAdapter typeAdapter = new VmMemoryStatTypeAdapter();
-        VmMemoryStat stat = new VmMemoryStat();
-        stat.setTimeStamp(100l);
-        stat.setVmId("VM-1");
-        stat.setAgentId("AGENT-1");
-        stat.setMetaspaceCapacity(2000l);
-        stat.setMetaspaceMaxCapacity(4096l);
-        stat.setMetaspaceMinCapacity(2048l);
-        stat.setMetaspaceUsed(3000l);
-        Generation[] gens = new Generation[1];
-        Generation gen1 = new Generation();
-        gen1.setCapacity(1002l);
-        gen1.setCollector("Collector 1");
-        gen1.setMaxCapacity(2048l);
-        gen1.setName("Name");
-        Space[] spaces = new Space[1];
-        Space space = new Space();
-        space.setName("Space Name");
-        space.setMaxCapacity(1024l);
-        space.setCapacity(500l);
-        space.setIndex(1);
-        space.setUsed(400l);
-        spaces[0] = space;
-        gen1.setSpaces(spaces);
-        gens[0] = gen1;
-        stat.setGenerations(gens);
-        assertEquals("[{\"agentId\":\"AGENT-1\",\"jvmId\":\"VM-1\",\"timeStamp\":{\"$numberLong\":\"100\"},\"metaspaceMaxCapacity\":{\"$numberLong\":\"4096\"},\"metaspaceMinCapacity\":{\"$numberLong\":\"2048\"},\"metaspaceCapacity\":{\"$numberLong\":\"2000\"},\"metaspaceUsed\":{\"$numberLong\":\"3000\"},\"generations\":[{\"name\":\"Name\",\"capacity\":{\"$numberLong\":\"1002\"},\"maxCapacity\":{\"$numberLong\":\"2048\"},\"collector\":\"Collector 1\",\"spaces\":[{\"index\":1,\"name\":\"Space Name\",\"capacity\":{\"$numberLong\":\"500\"},\"maxCapacity\":{\"$numberLong\":\"1024\"},\"used\":{\"$numberLong\":\"400\"}}]}]}]", typeAdapter.toJson(Arrays.asList(stat)));
-    }
-}
\ No newline at end of file
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatDAOTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,150 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import static com.redhat.thermostat.vm.memory.common.internal.VmTlabStatDAOImpl.HttpHelper;
-import static com.redhat.thermostat.vm.memory.common.internal.VmTlabStatDAOImpl.JsonHelper;
-import static org.mockito.Matchers.anyListOf;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import java.util.Arrays;
-
-import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource;
-import com.redhat.thermostat.common.plugin.PluginConfiguration;
-import com.redhat.thermostat.vm.memory.common.VmTlabStatDAO;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.ContentResponse;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpMethod;
-import org.eclipse.jetty.http.HttpStatus;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class VmTlabStatDAOTest {
-
-    private static final String JSON = "{\"this\":\"is\",\"test\":\"JSON\"}";
-    private static final String VM_ID = "0xcafe";
-    private static final String AGENT_ID = "agent";
-    private static final String CONTENT_TYPE = "application/json";
-    private static final String GATEWAY_URL = "http://example.com/jvm-memory/0.0.2/";
-    
-    private HttpClient httpClient;
-    private HttpHelper httpHelper;
-    private JsonHelper jsonHelper;
-    private StringContentProvider contentProvider;
-    private Request request;
-    private ContentResponse response;
-    private PluginConfiguration config;
-
-    @Before
-    public void setUp() throws Exception {
-        httpClient = mock(HttpClient.class);
-        request = mock(Request.class);
-        when(httpClient.newRequest(anyString())).thenReturn(request);
-        response = mock(ContentResponse.class);
-        when(response.getStatus()).thenReturn(HttpStatus.OK_200);
-        when(request.send()).thenReturn(response);
-
-        httpHelper = mock(HttpHelper.class);
-        contentProvider = mock(StringContentProvider.class);
-        when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider);
-        jsonHelper = mock(JsonHelper.class);
-        when(jsonHelper.toJson(anyListOf(VmTlabStat.class))).thenReturn(JSON);
-        
-        config = mock(PluginConfiguration.class);
-        when(config.getGatewayURL()).thenReturn(GATEWAY_URL);
-    }
-
-    @Test
-    public void testActivation() throws Exception {
-        PluginConfiguration pluginConfig = mock(PluginConfiguration.class);
-        when(pluginConfig.getGatewayURL()).thenReturn("someGatewayURL");
-        VmTlabStatDAOImpl.ConfigurationCreator configCreator = mock(VmTlabStatDAOImpl.ConfigurationCreator.class);
-        ConfigurationInfoSource configInfoSource = mock(ConfigurationInfoSource.class);
-        when(configCreator.create(configInfoSource)).thenReturn(pluginConfig);
-
-        VmTlabStatDAOImpl dao = new VmTlabStatDAOImpl(httpClient, httpHelper, jsonHelper, configCreator, configInfoSource);
-        dao.activate();
-
-        verify(pluginConfig, times(1)).getGatewayURL();
-        verify(httpHelper, times(1)).startClient(httpClient);
-    }
-
-    @Test
-    @Ignore
-    public void verifyPutStat() throws Exception {
-//      TODO: Remove @Ignore when web-gateway service for TLAB stats is available
-//      See VmTlabStatDAOImpl.putStat()
-
-        VmTlabStat stat = new VmTlabStat();
-        stat.setAgentId(AGENT_ID);
-        stat.setVmId(VM_ID);
-        stat.setTimeStamp(1000l);
-        stat.setTotalAllocatingThreads(10l);
-        stat.setTotalAllocations(1342l);
-        stat.setTotalRefills(58l);
-        stat.setMaxRefills(90l);
-        stat.setTotalSlowAllocations(343l);
-        stat.setMaxSlowAllocations(989l);
-        stat.setTotalGcWaste(788l);
-        stat.setMaxGcWaste(992l);
-        stat.setTotalSlowWaste(899l);
-        stat.setMaxSlowWaste(634l);
-        stat.setTotalFastWaste(678l);
-        stat.setMaxFastWaste(333l);
-
-        VmTlabStatDAOImpl.ConfigurationCreator configurationCreator = new VmTlabStatDAOImpl.ConfigurationCreator();
-        ConfigurationInfoSource configInfoSource = mock(ConfigurationInfoSource.class);
-        VmTlabStatDAO dao = new VmTlabStatDAOImpl(httpClient, httpHelper, jsonHelper, configurationCreator, configInfoSource);
-        dao.putStat(stat);
-
-        verify(httpClient).newRequest(GATEWAY_URL);
-        verify(request).method(HttpMethod.POST);
-        verify(jsonHelper).toJson(Arrays.asList(stat));
-        verify(httpHelper).createContentProvider(JSON);
-        verify(request).content(contentProvider, CONTENT_TYPE);
-        verify(request).send();
-        verify(response).getStatus();
-    }
-}
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/internal/VmTlabStatTypeAdapterTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.internal;
-
-import com.google.gson.GsonBuilder;
-import com.google.gson.Gson;
-import com.redhat.thermostat.vm.memory.common.model.VmTlabStat;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-
-public class VmTlabStatTypeAdapterTest {
-
-    @Test
-    public void testWrite() throws IOException {
-        VmTlabStatTypeAdapter typeAdapter = new VmTlabStatTypeAdapter();
-        VmTlabStat stat = new VmTlabStat();
-        stat.setAgentId("AGENT-1");
-        stat.setVmId("VM-1");
-        stat.setTimeStamp(1000l);
-        stat.setTotalAllocatingThreads(10l);
-        stat.setTotalAllocations(1342l);
-        stat.setTotalRefills(58l);
-        stat.setMaxRefills(90l);
-        stat.setTotalSlowAllocations(343l);
-        stat.setMaxSlowAllocations(989l);
-        stat.setTotalGcWaste(788l);
-        stat.setMaxGcWaste(992l);
-        stat.setTotalSlowWaste(899l);
-        stat.setMaxSlowWaste(634l);
-        stat.setTotalFastWaste(678l);
-        stat.setMaxFastWaste(333l);
-        assertEquals("[{\"vmId\":\"VM-1\",\"agentId\":\"AGENT-1\",\"timeStamp\":{\"$numberLong\":\"1000\"},\"allocThreads\":{\"$numberLong\":\"10\"},\"totalAllocations\":{\"$numberLong\":\"1342\"},\"refills\":{\"$numberLong\":\"58\"},\"maxRefills\":{\"$numberLong\":\"90\"},\"slowAllocations\":{\"$numberLong\":\"343\"},\"maxSlowAllocations\":{\"$numberLong\":\"989\"},\"gcWaste\":{\"$numberLong\":\"788\"},\"maxGcWaste\":{\"$numberLong\":\"992\"},\"slowWaste\":{\"$numberLong\":\"899\"},\"maxSlowWaste\":{\"$numberLong\":\"634\"},\"fastWaste\":{\"$numberLong\":\"678\"},\"maxFastWaste\":{\"$numberLong\":\"333\"}}]", typeAdapter.toJson(Arrays.asList(stat)));
-    }
-
-}
--- a/plugins/vm-memory/common/src/test/java/com/redhat/thermostat/vm/memory/common/model/VmMemoryStatTest.java	Mon Jun 26 19:31:01 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright 2012-2017 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.vm.memory.common.model;
-
-import com.redhat.thermostat.testutils.DataObjectTest;
-
-public class VmMemoryStatTest extends DataObjectTest {
-
-    @Override
-    public Class<?>[] getDataClasses() {
-        return new Class<?>[] { VmMemoryStatTest.class };
-    }
-
-}
-
--- a/plugins/vm-memory/distribution/assemblies/plugin-assembly.xml	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/distribution/assemblies/plugin-assembly.xml	Tue Jun 27 10:52:26 2017 -0400
@@ -48,7 +48,6 @@
   <dependencySets>
     <dependencySet>
       <includes>
-        <include>com.redhat.thermostat:thermostat-vm-memory-common</include>
         <include>com.redhat.thermostat:thermostat-vm-memory-agent</include>
       </includes>
       <useProjectArtifact>false</useProjectArtifact>
--- a/plugins/vm-memory/distribution/thermostat-plugin.xml	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/distribution/thermostat-plugin.xml	Tue Jun 27 10:52:26 2017 -0400
@@ -43,7 +43,6 @@
     <extension>
       <name>agent</name>
       <bundles>
-        <bundle><symbolic-name>com.redhat.thermostat.vm.memory.common</symbolic-name><version>${project.version}</version></bundle>
         <bundle><symbolic-name>com.redhat.thermostat.vm.memory.agent</symbolic-name><version>${project.version}</version></bundle>
       </bundles>
     </extension>
--- a/plugins/vm-memory/pom.xml	Mon Jun 26 19:31:01 2017 +0200
+++ b/plugins/vm-memory/pom.xml	Tue Jun 27 10:52:26 2017 -0400
@@ -52,7 +52,6 @@
 
   <modules>
     <module>agent</module>
-    <module>common</module>
     <module>distribution</module>
   </modules>