Mercurial > hg > thermostat-ng > agent
changeset 2679:b88b3c8a79c7
Add the host overview plugin into the agent. Along the way,
perform some package renaming and merge hostoverview-common into host-overview-agent.
Reviewed-by: neugens, mtorre, sgehwolf
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-May/023310.html
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023406.html
author | Simon Tooke <stooke@redhat.com> |
---|---|
date | Wed, 31 May 2017 12:06:16 -0400 |
parents | 259b1bc3fb64 |
children | 8babf77875ec |
files | plugins/com.redhat.thermostat.host.overview/agent/pom.xml plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/HostInfoBuilderImpl.java plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/HostOverviewBackend.java plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/models/HostInfoBuilder.java plugins/com.redhat.thermostat.host.overview/agent/src/test/java/com/redhat/thermostat/host/overview/agent/internal/HostInfoBuilderTest.java plugins/com.redhat.thermostat.host.overview/agent/src/test/java/com/redhat/thermostat/host/overview/agent/internal/HostOverviewBackendTest.java plugins/com.redhat.thermostat.host.overview/common/pom.xml plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/HostInfoDAO.java plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOImpl.java plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoTypeAdapter.java plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/model/HostInfo.java plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOTest.java plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoTypeAdapterTest.java plugins/com.redhat.thermostat.host.overview/distribution/assemblies/plugin-assembly.xml plugins/com.redhat.thermostat.host.overview/distribution/pom.xml plugins/com.redhat.thermostat.host.overview/distribution/thermostat-plugin.xml plugins/com.redhat.thermostat.host.overview/pom.xml plugins/host-overview/agent/pom.xml plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/Activator.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapter.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackend.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginConfiguration.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginDAOBase.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilder.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilderImpl.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAO.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImpl.java plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/model/HostInfo.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapterTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackendTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilderTest.java plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOTest.java plugins/host-overview/distribution/assemblies/plugin-assembly.xml plugins/host-overview/distribution/configFiles/gateway.properties plugins/host-overview/distribution/pom.xml plugins/host-overview/distribution/thermostat-plugin.xml plugins/host-overview/pom.xml plugins/pom.xml |
diffstat | 38 files changed, 1804 insertions(+), 1700 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/com.redhat.thermostat.host.overview/agent/pom.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,183 +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-host-overview</artifactId> - <groupId>com.redhat.thermostat</groupId> - <version>1.99.12-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-host-overview-agent</artifactId> - <packaging>bundle</packaging> - <name>Thermostat Host Overview Agent plugin</name> - - <build> - <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.host.overview.agent</Bundle-SymbolicName> - <Export-Package /> - <Private-Package> - com.redhat.thermostat.host.overview.agent.internal, - com.redhat.thermostat.host.overview.agent.internal.models - </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> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>copy</id> - <phase>generate-resources</phase> - <goals> - <goal>copy-resources</goal> - </goals> - <configuration> - <overwrite>true</overwrite> - <outputDirectory>${project.build.directory}</outputDirectory> - <resources> - <resource> - <directory>../../../common/portability/target</directory> - <includes> - <include>${sharedlib.prefix}thermostat-common-portability${sharedlib.suffix}</include> - </includes> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> - <configuration> - <!-- the test needs to link to common-portability native libraries --> - <systemPropertyVariables> - <com.redhat.thermostat.shared.loader.testNativesHome>${project.build.directory}</com.redhat.thermostat.shared.loader.testNativesHome> - </systemPropertyVariables> - </configuration> - </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-portability</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-host-overview-common</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-agent-core</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> - <!-- declarative services --> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - </dependency> - </dependencies> -</project>
--- a/plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/HostInfoBuilderImpl.java Tue May 30 16:30:17 2017 -0400 +++ /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.host.overview.agent.internal; - -import com.redhat.thermostat.common.portability.PortableHost; -import com.redhat.thermostat.common.portability.PortableHostFactory; -import com.redhat.thermostat.host.overview.agent.internal.models.HostInfoBuilder; -import com.redhat.thermostat.host.overview.common.model.HostInfo; -import com.redhat.thermostat.storage.core.WriterID; - -/** - * Build Host information via helper classes - */ -class HostInfoBuilderImpl implements HostInfoBuilder { - - private final WriterID writerID; - private final PortableHost helper; - - HostInfoBuilderImpl(final WriterID writerID) { - this(writerID, PortableHostFactory.getInstance()); - } - - HostInfoBuilderImpl(final WriterID writerID, PortableHost helper) { - this.writerID = writerID; - this.helper = helper; - } - - @Override - public HostInfo build() { - String wId = writerID.getWriterID(); - return new HostInfo(wId, - helper.getHostName(), - helper.getOSName(), - helper.getOSVersion(), - helper.getCPUModel(), - helper.getCPUCount(), - helper.getTotalMemory()); - } -}
--- a/plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/HostOverviewBackend.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,125 +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.host.overview.agent.internal; - -import org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Deactivate; -import org.apache.felix.scr.annotations.Reference; -import org.apache.felix.scr.annotations.Service; -import org.osgi.framework.FrameworkUtil; - -import com.redhat.thermostat.backend.Backend; -import com.redhat.thermostat.backend.BaseBackend; -import com.redhat.thermostat.common.Version; -import com.redhat.thermostat.host.overview.agent.internal.models.HostInfoBuilder; -import com.redhat.thermostat.host.overview.common.HostInfoDAO; -import com.redhat.thermostat.host.overview.common.model.HostInfo; -import com.redhat.thermostat.storage.core.WriterID; - -@Component -@Service(value = Backend.class) -public class HostOverviewBackend extends BaseBackend { - - private final HostInfoBuilderCreator builderCreator; - - @Reference - private HostInfoDAO hostInfoDAO; - - @Reference - private WriterID writerID; - - private boolean started; - - public HostOverviewBackend() { - this(new Version(FrameworkUtil.getBundle(HostOverviewBackend.class)), null, null, new HostInfoBuilderCreator()); - } - - HostOverviewBackend(Version version, HostInfoDAO hostInfoDAO, WriterID writerID, - HostInfoBuilderCreator builderCreator) { - super("Host Overview Backend", - "Gathers general information about a host", - "Red Hat, Inc.", - version.getVersionNumber()); - this.hostInfoDAO = hostInfoDAO; - this.writerID = writerID; - this.builderCreator = builderCreator; - } - - @Override - public boolean activate() { - HostInfoBuilder builder = builderCreator.create(writerID); - HostInfo hostInfo = builder.build(); - hostInfoDAO.putHostInfo(hostInfo); - started = true; - return true; - } - - @Override - public boolean deactivate() { - started = false; - return true; - } - - @Override - public boolean isActive() { - return started; - } - - @Override - public int getOrderValue() { - return ORDER_DEFAULT_GROUP; - } - - // For testing purposes - static class HostInfoBuilderCreator { - HostInfoBuilder create(WriterID writerID) { - return new HostInfoBuilderImpl(writerID); - } - } - - @Activate - @Deactivate - protected void noop() { - /* Map unused DS activate/deactivate methods to this NOOP method to - * prevent it from trying to use Backend.activate/deactivate and - * giving an error about them being incompatible. - */ - } - -} -
--- a/plugins/com.redhat.thermostat.host.overview/agent/src/main/java/com/redhat/thermostat/host/overview/agent/internal/models/HostInfoBuilder.java Tue May 30 16:30:17 2017 -0400 +++ /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.host.overview.agent.internal.models; - -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -/** - * Interface for building a HostInfo structure - * HostInfo contains information about a target machine's OS and hardware - */ -public interface HostInfoBuilder { - HostInfo build(); -}
--- a/plugins/com.redhat.thermostat.host.overview/agent/src/test/java/com/redhat/thermostat/host/overview/agent/internal/HostInfoBuilderTest.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +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.host.overview.agent.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.Assume; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.common.portability.PortableHost; -import com.redhat.thermostat.host.overview.agent.internal.models.HostInfoBuilder; -import com.redhat.thermostat.host.overview.common.model.HostInfo; -import com.redhat.thermostat.shared.config.OS; -import com.redhat.thermostat.storage.core.WriterID; - -public class HostInfoBuilderTest { - - private WriterID writerId; - private PortableHost helper; - - @Before - public void setup() { - writerId = mock(WriterID.class); - helper = mock(PortableHost.class); - when(helper.getHostName()).thenReturn("testhost"); - when(helper.getOSName()).thenReturn("testos"); - when(helper.getOSVersion()).thenReturn("testversion"); - when(helper.getCPUModel()).thenReturn("testcpu"); - when(helper.getCPUCount()).thenReturn(4567); - when(helper.getTotalMemory()).thenReturn(9876L); - } - - @Test - public void testSimpleBuild() { - Assume.assumeTrue(OS.IS_WINDOWS); - HostInfo info = new HostInfoBuilderImpl(writerId).build(); - assertNotNull(info); - } - - @Test - public void testGetInfo() { - final HostInfoBuilder ib = new HostInfoBuilderImpl(writerId, helper); - final HostInfo hi = ib.build(); - assertEquals("testhost",hi.getHostname()); - assertEquals("testos", hi.getOsName()); - assertEquals("testcpu", hi.getCpuModel()); - assertEquals("testversion", hi.getOsKernel()); - assertEquals(4567, hi.getCpuCount()); - assertEquals(9876L, hi.getTotalMemory()); - } -} -
--- a/plugins/com.redhat.thermostat.host.overview/agent/src/test/java/com/redhat/thermostat/host/overview/agent/internal/HostOverviewBackendTest.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +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.host.overview.agent.internal; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.common.Version; -import com.redhat.thermostat.host.overview.agent.internal.HostOverviewBackend.HostInfoBuilderCreator; -import com.redhat.thermostat.host.overview.agent.internal.models.HostInfoBuilder; -import com.redhat.thermostat.host.overview.common.HostInfoDAO; -import com.redhat.thermostat.host.overview.common.model.HostInfo; -import com.redhat.thermostat.storage.core.WriterID; - -public class HostOverviewBackendTest { - - private HostOverviewBackend backend; - private HostInfoDAO hostInfoDAO; - private WriterID writerID; - private HostInfo info; - private HostInfoBuilder builder; - private HostInfoBuilderCreator builderCreator; - - @Before - public void setup() { - hostInfoDAO = mock(HostInfoDAO.class); - Version version = mock(Version.class); - when(version.getVersionNumber()).thenReturn("0.0.0"); - writerID = mock(WriterID.class); - - info = mock(HostInfo.class); - builder = mock(HostInfoBuilder.class); - when(builder.build()).thenReturn(info); - builderCreator = mock(HostInfoBuilderCreator.class); - when(builderCreator.create(writerID)).thenReturn(builder); - - backend = new HostOverviewBackend(version, hostInfoDAO, writerID, builderCreator); - } - - @Test - public void testActivate() { - backend.activate(); - assertTrue(backend.isActive()); - - verify(builderCreator).create(writerID); - verify(builder).build(); - verify(hostInfoDAO).putHostInfo(info); - } - - @Test - public void testDeactivate() { - backend.activate(); - backend.deactivate(); - assertFalse(backend.isActive()); - } -} -
--- a/plugins/com.redhat.thermostat.host.overview/common/pom.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,159 +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-host-overview</artifactId> - <groupId>com.redhat.thermostat</groupId> - <version>1.99.12-SNAPSHOT</version> - </parent> - <artifactId>thermostat-host-overview-common</artifactId> - <packaging>bundle</packaging> - <name>Thermostat Host Overview 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.host.overview.common</Bundle-SymbolicName> - <Export-Package> - com.redhat.thermostat.host.overview.common, - com.redhat.thermostat.host.overview.common.model - </Export-Package> - <Private-Package> - com.redhat.thermostat.host.overview.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-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> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-client</artifactId> - </dependency> - <!-- This will likely have to match what jetty-project's pom uses --> - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - <version>${jetty.javax.servlet.osgi.version}</version> - </dependency> - <!-- declarative services --> - <dependency> - <groupId>org.apache.felix</groupId> - <artifactId>org.apache.felix.scr.annotations</artifactId> - </dependency> - </dependencies> -</project>
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/HostInfoDAO.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +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.host.overview.common; - -import com.redhat.thermostat.annotations.Service; -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -@Service -public interface HostInfoDAO { - - void putHostInfo(HostInfo info); - -} -
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOImpl.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,185 +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.host.overview.common.internal; - -import java.io.IOException; -import java.net.URI; -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 org.apache.felix.scr.annotations.Activate; -import org.apache.felix.scr.annotations.Component; -import org.apache.felix.scr.annotations.Service; -import org.eclipse.jetty.client.HttpClient; -import org.eclipse.jetty.client.HttpContentResponse; -import org.eclipse.jetty.client.HttpRequest; -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 com.redhat.thermostat.common.utils.LoggingUtils; -import com.redhat.thermostat.host.overview.common.HostInfoDAO; -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -@Component -@Service(value = HostInfoDAO.class) -public class HostInfoDAOImpl implements HostInfoDAO { - - private static final Logger logger = LoggingUtils.getLogger(HostInfoDAOImpl.class); - - private static final String GATEWAY_URL = "http://localhost:26000/api/v100"; // TODO configurable - private static final String GATEWAY_PATH = "/host-info/systems/*/agents/"; - private static final String CONTENT_TYPE = "application/json"; - - private final JsonHelper jsonHelper; - private final HttpHelper httpHelper; - - public HostInfoDAOImpl() { - this(new HttpHelper(new HttpClient()), new JsonHelper(new HostInfoTypeAdapter())); - } - - HostInfoDAOImpl(HttpHelper httpHelper, JsonHelper jsonHelper) { - this.httpHelper = httpHelper; - this.jsonHelper = jsonHelper; - } - - @Activate - void activate() throws Exception { - httpHelper.startClient(); - } - - @Override - public void putHostInfo(final HostInfo info) { - try { - String json = jsonHelper.toJson(Arrays.asList(info)); - StringContentProvider provider = httpHelper.createContentProvider(json); - String url = getURL(info.getAgentId()); - Request httpRequest = httpHelper.newRequest(url); - httpRequest.method(HttpMethod.POST); - httpRequest.content(provider, CONTENT_TYPE); - 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()); - } - } catch (IOException | InterruptedException | TimeoutException | ExecutionException e) { - logger.log(Level.WARNING, "Failed to send host information to web gateway", e); - } - } - - private String getURL(String agentId) { - StringBuilder builder = new StringBuilder(); - builder.append(GATEWAY_URL); - builder.append(GATEWAY_PATH); - builder.append(agentId); - return builder.toString(); - } - - // For testing purposes - static class JsonHelper { - - private final HostInfoTypeAdapter typeAdapter; - - public JsonHelper(HostInfoTypeAdapter typeAdapter) { - this.typeAdapter = typeAdapter; - } - - String toJson(List<HostInfo> infos) throws IOException { - return typeAdapter.toJson(infos); - } - - } - - // For testing purposes - static class HttpHelper { - - private final HttpClient httpClient; - - HttpHelper(HttpClient httpClient) { - this.httpClient = httpClient; - } - - void startClient() throws Exception { - httpClient.start(); - } - - StringContentProvider createContentProvider(String content) { - return new StringContentProvider(content); - } - - Request newRequest(String url) { - return new MockRequest(httpClient, URI.create(url)); - } - - } - - // FIXME This class should be removed when the web gateway has a microservice for this DAO - private static class MockRequest extends HttpRequest { - - MockRequest(HttpClient client, URI uri) { - super(client, uri); - } - - @Override - public ContentResponse send() throws InterruptedException, TimeoutException, ExecutionException { - return new MockResponse(); - } - - } - - // FIXME This class should be removed when the web gateway has a microservice for this DAO - private static class MockResponse extends HttpContentResponse { - - MockResponse() { - super(null, null, null); - } - - @Override - public int getStatus() { - return HttpStatus.OK_200; - } - - } - -} -
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/internal/HostInfoTypeAdapter.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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.host.overview.common.internal; - -import java.io.IOException; -import java.util.List; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -public class HostInfoTypeAdapter extends TypeAdapter<List<HostInfo>> { - - private static final String AGENT_ID = "agentId"; - private static final String HOSTNAME = "hostname"; - private static final String OS_NAME = "osName"; - private static final String OS_KERNEL = "osKernel"; - private static final String CPU_MODEL = "cpuModel"; - private static final String CPU_COUNT = "cpuCount"; - private static final String TOTAL_MEMORY = "totalMemory"; - private static final String TYPE_LONG = "$numberLong"; - - @Override - public void write(JsonWriter out, List<HostInfo> value) throws IOException { - // Request is an array of HostInfo objects - out.beginArray(); - - for (HostInfo info : value) { - writeHostInfo(out, info); - } - - out.endArray(); - } - - private void writeHostInfo(JsonWriter out, HostInfo info) throws IOException { - out.beginObject(); - - // Write each field of HostInfo as part of a JSON object - out.name(AGENT_ID); - out.value(info.getAgentId()); - out.name(HOSTNAME); - out.value(info.getHostname()); - out.name(OS_NAME); - out.value(info.getOsName()); - out.name(OS_KERNEL); - out.value(info.getOsKernel()); - out.name(CPU_MODEL); - out.value(info.getCpuModel()); - out.name(CPU_COUNT); - out.value(info.getCpuCount()); - out.name(TOTAL_MEMORY); - writeLong(out, info.getTotalMemory()); - - out.endObject(); - } - - private void writeLong(JsonWriter out, long totalMemory) throws IOException { - // Write MongoDB representation of a Long - out.beginObject(); - out.name(TYPE_LONG); - out.value(String.valueOf(totalMemory)); - out.endObject(); - } - - @Override - public List<HostInfo> read(JsonReader in) throws IOException { - throw new UnsupportedOperationException(); - } - -}
--- a/plugins/com.redhat.thermostat.host.overview/common/src/main/java/com/redhat/thermostat/host/overview/common/model/HostInfo.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +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.host.overview.common.model; - -import com.redhat.thermostat.storage.core.Entity; -import com.redhat.thermostat.storage.core.Persist; -import com.redhat.thermostat.storage.model.BasePojo; - -@Entity -public class HostInfo extends BasePojo { - - private String hostname; - private String osName; - private String osKernel; - private String cpuModel; - private int cpuCount; - private long totalMemory; - - public HostInfo() { - this(null, null, null, null, null, -1, -1); - } - - public HostInfo(String writerId, String hostname, String osName, String osKernel, String cpuModel, int cpuCount, long totalMemory) { - super(writerId); - this.hostname = hostname; - this.osName = osName; - this.osKernel = osKernel; - this.cpuModel = cpuModel; - this.cpuCount = cpuCount; - this.totalMemory = totalMemory; - } - - @Persist - public void setHostname(String hostname) { - this.hostname = hostname; - } - - @Persist - public void setOsName(String osName) { - this.osName = osName; - } - - @Persist - public void setOsKernel(String osKernel) { - this.osKernel = osKernel; - } - - @Persist - public void setCpuModel(String cpuModel) { - this.cpuModel = cpuModel; - } - - @Persist - public void setCpuCount(int cpuCount) { - this.cpuCount = cpuCount; - } - - @Persist - public void setTotalMemory(long totalMemory) { - this.totalMemory = totalMemory; - } - - @Persist - public String getHostname() { - return hostname; - } - - @Persist - public String getOsName() { - return osName; - } - - @Persist - public String getOsKernel() { - return osKernel; - } - - @Persist - public String getCpuModel() { - return cpuModel; - } - - @Persist - public int getCpuCount() { - return cpuCount; - } - - /** - * Total memory in bytes - */ - @Persist - public long getTotalMemory() { - return totalMemory; - } - -} -
--- a/plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoDAOTest.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +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.host.overview.common.internal; - -import static org.mockito.Matchers.anyListOf; -import static org.mockito.Matchers.anyString; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - -import java.util.Arrays; - -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.host.overview.common.internal.HostInfoDAOImpl.HttpHelper; -import com.redhat.thermostat.host.overview.common.internal.HostInfoDAOImpl.JsonHelper; -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -public class HostInfoDAOTest { - - private static final String URL = "http://localhost:26000/api/v100/host-info/systems/*/agents/foo-agent"; - private static final String SOME_JSON = "{\"some\" : \"json\"}"; - private static final String HOST_NAME = "a host name"; - private static final String OS_NAME = "some os"; - private static final String OS_KERNEL = "some kernel"; - private static final String CPU_MODEL = "some cpu that runs fast"; - private static final int CPU_NUM = -1; - private static final long MEMORY_TOTAL = 0xCAFEBABEl; - private static final String CONTENT_TYPE = "application/json"; - - private HostInfo info; - private JsonHelper jsonHelper; - private HttpHelper httpHelper; - private StringContentProvider contentProvider; - private Request request; - private ContentResponse response; - - @Before - public void setup() throws Exception { - info = new HostInfo("foo-agent", HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); - - httpHelper = mock(HttpHelper.class); - contentProvider = mock(StringContentProvider.class); - when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider); - request = mock(Request.class); - when(httpHelper.newRequest(anyString())).thenReturn(request); - response = mock(ContentResponse.class); - when(response.getStatus()).thenReturn(HttpStatus.OK_200); - when(request.send()).thenReturn(response); - - jsonHelper = mock(JsonHelper.class); - when(jsonHelper.toJson(anyListOf(HostInfo.class))).thenReturn(SOME_JSON); - } - - @Test - public void testPutHostInfo() throws Exception { - HostInfoDAOImpl dao = new HostInfoDAOImpl(httpHelper, jsonHelper); - dao.activate(); - dao.putHostInfo(info); - - verify(httpHelper).newRequest(URL); - verify(request).method(HttpMethod.POST); - verify(jsonHelper).toJson(eq(Arrays.asList(info))); - verify(httpHelper).createContentProvider(SOME_JSON); - verify(request).content(contentProvider, CONTENT_TYPE); - verify(request).send(); - verify(response).getStatus(); - } - -} -
--- a/plugins/com.redhat.thermostat.host.overview/common/src/test/java/com/redhat/thermostat/host/overview/common/internal/HostInfoTypeAdapterTest.java Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,75 +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.host.overview.common.internal; - -import static org.junit.Assert.assertEquals; - -import java.util.Arrays; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.host.overview.common.model.HostInfo; - -public class HostInfoTypeAdapterTest { - - private HostInfoTypeAdapter adapter; - - @Before - public void setup() { - adapter = new HostInfoTypeAdapter(); - } - - @Test - public void testWrite() throws Exception { - final String expected = "[{\"agentId\":\"myAgent1\",\"hostname\":\"myHost1\"," - + "\"osName\":\"myOS1\",\"osKernel\":\"myKernel1\",\"cpuModel\":\"myCPU1\"," - + "\"cpuCount\":4,\"totalMemory\":{\"$numberLong\":\"400000000\"}}," - + "{\"agentId\":\"myAgent2\",\"hostname\":\"myHost2\",\"osName\":\"myOS2\"," - + "\"osKernel\":\"myKernel2\",\"cpuModel\":\"myCPU2\",\"cpuCount\":2," - + "\"totalMemory\":{\"$numberLong\":\"800000000\"}}]"; - - HostInfo first = new HostInfo("myAgent1", "myHost1", "myOS1", "myKernel1", "myCPU1", 4, 400000000L); - HostInfo second = new HostInfo("myAgent2", "myHost2", "myOS2", "myKernel2", "myCPU2", 2, 800000000L); - List<HostInfo> infos = Arrays.asList(first, second); - - String json = adapter.toJson(infos); - assertEquals(expected, json); - } - -}
--- a/plugins/com.redhat.thermostat.host.overview/distribution/assemblies/plugin-assembly.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +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. - ---> -<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> - <id>plugin-assembly</id> - <formats> - <format>zip</format> - </formats> - <baseDirectory>${thermostat.plugin}</baseDirectory> - <includeBaseDirectory>true</includeBaseDirectory> - - <dependencySets> - <dependencySet> - <includes> - <include>com.redhat.thermostat:thermostat-host-overview-common</include> - <include>com.redhat.thermostat:thermostat-host-overview-agent</include> - </includes> - <useProjectArtifact>false</useProjectArtifact> - <useStrictFiltering>true</useStrictFiltering> - </dependencySet> - </dependencySets> - - <files> - <file> - <source>thermostat-plugin.xml</source> - <outputDirectory>/</outputDirectory> - <filtered>true</filtered> - </file> - </files> -</assembly> -
--- a/plugins/com.redhat.thermostat.host.overview/distribution/pom.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +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> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-host-overview</artifactId> - <version>1.99.12-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-host-overview-distribution</artifactId> - <packaging>pom</packaging> - - <name>Thermostat Host Overview plugin distribution</name> - - <properties> - <thermostat.plugin>host-overview</thermostat.plugin> - </properties> - - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <configuration> - <descriptors> - <descriptor>assemblies/plugin-assembly.xml</descriptor> - </descriptors> - <appendAssemblyId>false</appendAssemblyId> - </configuration> - <executions> - <execution> - <id>assemble-plugin</id> - <phase>package</phase> - <goals> - <goal>single</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <dependencies> - <dependency> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-host-overview-agent</artifactId> - <version>${project.version}</version> - </dependency> - </dependencies> - -</project> -
--- a/plugins/com.redhat.thermostat.host.overview/distribution/thermostat-plugin.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,52 +0,0 @@ -<?xml version="1.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. - ---> -<plugin xmlns="http://icedtea.classpath.org/thermostat/plugins/v1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://icedtea.classpath.org/thermostat/plugins/v1.0 thermostat-plugin.xsd"> - <extensions> - <extension> - <name>agent</name> - <bundles> - <bundle><symbolic-name>com.redhat.thermostat.host.overview.common</symbolic-name><version>${project.version}</version></bundle> - <bundle><symbolic-name>com.redhat.thermostat.host.overview.agent</symbolic-name><version>${project.version}</version></bundle> - </bundles> - </extension> - </extensions> -</plugin> -
--- a/plugins/com.redhat.thermostat.host.overview/pom.xml Tue May 30 16:30:17 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,60 +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> - <groupId>com.redhat.thermostat</groupId> - <artifactId>thermostat-plugins</artifactId> - <version>1.99.12-SNAPSHOT</version> - </parent> - - <artifactId>thermostat-host-overview</artifactId> - <packaging>pom</packaging> - - <name>Thermostat Host Overview plugin</name> - - <modules> - <module>common</module> - <module>agent</module> - <module>distribution</module> - </modules> - -</project> -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/pom.xml Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,180 @@ +<?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-host-overview</artifactId> + <groupId>com.redhat.thermostat</groupId> + <version>1.99.12-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-host-overview-agent</artifactId> + <packaging>bundle</packaging> + <name>Thermostat Host Overview Agent plugin</name> + + <build> + <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.host.overview.agent</Bundle-SymbolicName> + <Bundle-Activator>com.redhat.thermostat.host.overview.internal.Activator</Bundle-Activator> + <Export-Package>com.redhat.thermostat.host.overview.model</Export-Package> + <Private-Package> + com.redhat.thermostat.host.overview.internal, + com.redhat.thermostat.host.overview.internal.common, + com.redhat.thermostat.host.overview.internal.models + </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> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>copy</id> + <phase>generate-resources</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <overwrite>true</overwrite> + <outputDirectory>${project.build.directory}</outputDirectory> + <resources> + <resource> + <directory>../../../common/portability/target</directory> + <includes> + <include>${sharedlib.prefix}thermostat-common-portability${sharedlib.suffix}</include> + </includes> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <!-- the test needs to link to common-portability native libraries --> + <systemPropertyVariables> + <com.redhat.thermostat.shared.loader.testNativesHome>${project.build.directory}</com.redhat.thermostat.shared.loader.testNativesHome> + </systemPropertyVariables> + </configuration> + </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-portability</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-agent-core</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> + <!-- declarative services --> + <dependency> + <groupId>org.apache.felix</groupId> + <artifactId>org.apache.felix.scr.annotations</artifactId> + </dependency> + </dependencies> +</project>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/Activator.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,107 @@ +/* + * 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.host.overview.internal; + +import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource; +import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.host.overview.internal.common.PluginConfiguration; +import com.redhat.thermostat.host.overview.internal.models.HostInfoDAO; +import com.redhat.thermostat.host.overview.internal.models.HostInfoDAOImpl; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.framework.ServiceRegistration; +import org.osgi.util.tracker.ServiceTracker; + +import java.util.logging.Level; +import java.util.logging.Logger; + +public class Activator implements BundleActivator { + + private static final Logger logger = LoggingUtils.getLogger(Activator.class); + + private final HostInfoDAOCreator creator; + private ServiceTracker tracker; + private ServiceRegistration reg; + + public Activator() { + this(new HostInfoDAOCreator()); + } + + Activator(HostInfoDAOCreator creator) { + this.creator = creator; + } + + @Override + public void start(BundleContext context) throws Exception { + tracker = new ServiceTracker(context, ConfigurationInfoSource.class.getName(), null) { + @Override + public Object addingService(ServiceReference reference) { + ConfigurationInfoSource source = (ConfigurationInfoSource) super.addingService(reference); + try { + HostInfoDAO dao = creator.createDAO(new PluginConfiguration(source, HostInfoDAOImpl.PLUGIN_ID)); + reg = context.registerService(HostInfoDAO.class.getName(), dao, null); + } catch (Exception e) { + logger.log(Level.SEVERE, "Failed to create " + HostInfoDAO.class.getSimpleName(), e); + } + return source; + } + + @Override + public void removedService(ServiceReference reference, Object service) { + if (reg != null) { + reg.unregister(); + } + super.removedService(reference, service); + } + }; + tracker.open(); + } + + @Override + public void stop(BundleContext context) throws Exception { + tracker.close(); + } + + static class HostInfoDAOCreator { + HostInfoDAO createDAO(PluginConfiguration config) throws Exception { + return new HostInfoDAOImpl(config); + } + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapter.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,105 @@ +/* + * 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.host.overview.internal; + +import java.io.IOException; +import java.util.List; + +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.redhat.thermostat.host.overview.model.HostInfo; + +public class HostInfoTypeAdapter extends TypeAdapter<List<HostInfo>> { + + private static final String AGENT_ID = "agentId"; + private static final String HOSTNAME = "hostname"; + private static final String OS_NAME = "osName"; + private static final String OS_KERNEL = "osKernel"; + private static final String CPU_MODEL = "cpuModel"; + private static final String CPU_COUNT = "cpuCount"; + private static final String TOTAL_MEMORY = "totalMemory"; + private static final String TYPE_LONG = "$numberLong"; + + @Override + public void write(JsonWriter out, List<HostInfo> value) throws IOException { + // Request is an array of HostInfo objects + out.beginArray(); + + for (HostInfo info : value) { + writeHostInfo(out, info); + } + + out.endArray(); + } + + private void writeHostInfo(JsonWriter out, HostInfo info) throws IOException { + out.beginObject(); + + // Write each field of HostInfo as part of a JSON object + out.name(AGENT_ID); + out.value(info.getAgentId()); + out.name(HOSTNAME); + out.value(info.getHostname()); + out.name(OS_NAME); + out.value(info.getOsName()); + out.name(OS_KERNEL); + out.value(info.getOsKernel()); + out.name(CPU_MODEL); + out.value(info.getCpuModel()); + out.name(CPU_COUNT); + out.value(info.getCpuCount()); + out.name(TOTAL_MEMORY); + writeLong(out, info.getTotalMemory()); + + out.endObject(); + } + + private void writeLong(JsonWriter out, long totalMemory) throws IOException { + // Write MongoDB representation of a Long + out.beginObject(); + out.name(TYPE_LONG); + out.value(String.valueOf(totalMemory)); + out.endObject(); + } + + @Override + public List<HostInfo> read(JsonReader in) throws IOException { + throw new UnsupportedOperationException(); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackend.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,126 @@ +/* + * 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.host.overview.internal; + +import com.redhat.thermostat.host.overview.internal.models.HostInfoBuilderImpl; +import org.apache.felix.scr.annotations.Activate; +import org.apache.felix.scr.annotations.Component; +import org.apache.felix.scr.annotations.Deactivate; +import org.apache.felix.scr.annotations.Reference; +import org.apache.felix.scr.annotations.Service; +import org.osgi.framework.FrameworkUtil; + +import com.redhat.thermostat.backend.Backend; +import com.redhat.thermostat.backend.BaseBackend; +import com.redhat.thermostat.common.Version; +import com.redhat.thermostat.host.overview.internal.models.HostInfoBuilder; +import com.redhat.thermostat.host.overview.internal.models.HostInfoDAO; +import com.redhat.thermostat.host.overview.model.HostInfo; +import com.redhat.thermostat.storage.core.WriterID; + +@Component +@Service(value = Backend.class) +public class HostOverviewBackend extends BaseBackend { + + private final HostInfoBuilderCreator builderCreator; + + @Reference + private HostInfoDAO hostInfoDAO; + + @Reference + private WriterID writerID; + + private boolean started; + + public HostOverviewBackend() { + this(new Version(FrameworkUtil.getBundle(HostOverviewBackend.class)), null, null, new HostInfoBuilderCreator()); + } + + HostOverviewBackend(Version version, HostInfoDAO hostInfoDAO, WriterID writerID, + HostInfoBuilderCreator builderCreator) { + super("Host Overview Backend", + "Gathers general information about a host", + "Red Hat, Inc.", + version.getVersionNumber()); + this.hostInfoDAO = hostInfoDAO; + this.writerID = writerID; + this.builderCreator = builderCreator; + } + + @Override + public boolean activate() { + HostInfoBuilder builder = builderCreator.create(writerID); + HostInfo hostInfo = builder.build(); + hostInfoDAO.put(hostInfo.getHostname(), hostInfo); + started = true; + return true; + } + + @Override + public boolean deactivate() { + started = false; + return true; + } + + @Override + public boolean isActive() { + return started; + } + + @Override + public int getOrderValue() { + return ORDER_DEFAULT_GROUP; + } + + // For testing purposes + static class HostInfoBuilderCreator { + HostInfoBuilder create(WriterID writerID) { + return new HostInfoBuilderImpl(writerID); + } + } + + @Activate + @Deactivate + protected void noop() { + /* Map unused DS activate/deactivate methods to this NOOP method to + * prevent it from trying to use Backend.activate/deactivate and + * giving an error about them being incompatible. + */ + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginConfiguration.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,74 @@ +/* + * 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.host.overview.internal.common; + +import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource; + +import java.io.File; +import java.io.IOException; +import java.util.Map; + +public class PluginConfiguration { + + private static final String CONFIG_FILE = "gateway.properties"; + private static final String URL_PROP = "gatewayURL"; + + private final ConfigurationInfoSource source; + private final String pluginId; + + public PluginConfiguration(ConfigurationInfoSource source, final String pluginId) { + this.source = source; + this.pluginId = pluginId; + } + + public String getGatewayURL() throws IOException { + Map<String, String> props = source.getConfiguration(pluginId, CONFIG_FILE); + String url = props.get(URL_PROP); + if (url == null) { + throw new IOException("No gateway URL found for " + pluginId + " in " + getConfigFilePath()); + } + return url; + } + + private String getConfigFilePath() { + StringBuilder builder = new StringBuilder(); + builder.append("$THERMOSTAT_HOME").append(File.separator).append("etc").append(File.separator) + .append("plugins.d").append(File.separator).append(pluginId).append(File.separator) + .append(CONFIG_FILE); + return builder.toString(); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/common/PluginDAOBase.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,93 @@ +/* + * 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.host.overview.internal.common; + +import java.io.IOException; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeoutException; +import java.util.logging.Level; +import java.util.logging.Logger; + +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 com.redhat.thermostat.common.utils.LoggingUtils; + +abstract public class PluginDAOBase<Tobj,Tdao> { + + private static final Logger logger = LoggingUtils.getLogger(PluginDAOBase.class); + + private static final String CONTENT_TYPE = "application/json"; + + private final String gatewayURL; + protected final HttpClient httpClient; + + public PluginDAOBase(PluginConfiguration config, HttpClient client) throws IOException { + this.gatewayURL = config.getGatewayURL(); + this.httpClient = client; + } + + protected abstract String toJsonString(Tobj obj) throws IOException; + + public void put(String systemid, final Tobj obj) { + try { + final String json = toJsonString(obj); + final StringContentProvider provider = new StringContentProvider(json); + final String url = gatewayURL + "/systems/" + systemid; + final Request httpRequest = httpClient.newRequest(url); + httpRequest.method(HttpMethod.POST); + httpRequest.content(provider, CONTENT_TYPE); + sendRequest(httpRequest); + } catch (IOException | InterruptedException | TimeoutException | ExecutionException e) { + logger.log(Level.WARNING, "Failed to send " + obj.getClass().getName() + " to web gateway", e); + } + } + + private void sendRequest(Request httpRequest) + throws InterruptedException, TimeoutException, ExecutionException, IOException { + final ContentResponse resp = httpRequest.send(); + final int status = resp.getStatus(); + if (status != HttpStatus.OK_200) { + throw new IOException("Gateway returned HTTP status " + String.valueOf(status) + " - " + resp.getReason()); + } + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilder.java Wed May 31 12:06:16 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.host.overview.internal.models; + +import com.redhat.thermostat.host.overview.model.HostInfo; + +/** + * Interface for building a HostInfo structure + * HostInfo contains information about a target machine's OS and hardware + */ +public interface HostInfoBuilder { + HostInfo build(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilderImpl.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,72 @@ +/* + * 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.host.overview.internal.models; + +import com.redhat.thermostat.common.portability.PortableHost; +import com.redhat.thermostat.common.portability.PortableHostFactory; +import com.redhat.thermostat.host.overview.model.HostInfo; +import com.redhat.thermostat.storage.core.WriterID; + +/** + * Build Host information via helper classes + */ +public class HostInfoBuilderImpl implements HostInfoBuilder { + + private final WriterID writerID; + private final PortableHost helper; + + public HostInfoBuilderImpl(final WriterID writerID) { + this(writerID, PortableHostFactory.getInstance()); + } + + HostInfoBuilderImpl(final WriterID writerID, PortableHost helper) { + this.writerID = writerID; + this.helper = helper; + } + + @Override + public HostInfo build() { + String wId = writerID.getWriterID(); + return new HostInfo(wId, + helper.getHostName(), + helper.getOSName(), + helper.getOSVersion(), + helper.getCPUModel(), + helper.getCPUCount(), + helper.getTotalMemory()); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAO.java Wed May 31 12:06:16 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.host.overview.internal.models; + +import com.redhat.thermostat.annotations.Service; +import com.redhat.thermostat.host.overview.model.HostInfo; + +@Service +public interface HostInfoDAO { + + void put(String systemid, HostInfo info); + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOImpl.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,156 @@ +/* + * 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.host.overview.internal.models; + +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; +import java.util.List; +import java.util.logging.Logger; + +import com.redhat.thermostat.host.overview.internal.HostInfoTypeAdapter; +import com.redhat.thermostat.host.overview.internal.common.PluginConfiguration; +import com.redhat.thermostat.host.overview.internal.common.PluginDAOBase; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.HttpContentResponse; +import org.eclipse.jetty.client.HttpRequest; +import org.eclipse.jetty.client.api.Request; +import org.eclipse.jetty.client.util.StringContentProvider; +import org.eclipse.jetty.http.HttpStatus; + +import com.redhat.thermostat.common.utils.LoggingUtils; +import com.redhat.thermostat.host.overview.model.HostInfo; + +public class HostInfoDAOImpl extends PluginDAOBase<HostInfo, HostInfoDAOImpl> implements HostInfoDAO { + + private static final Logger logger = LoggingUtils.getLogger(HostInfoDAOImpl.class); + + public static final String PLUGIN_ID = "host-overview"; + + private final JsonHelper jsonHelper; + private final HttpHelper httpHelper; + + public HostInfoDAOImpl(PluginConfiguration config) throws Exception { + this(config, new HttpClient()); + } + + public HostInfoDAOImpl(PluginConfiguration config, HttpClient client) throws Exception { + this(config, client, new JsonHelper(new HostInfoTypeAdapter()), new HttpHelper(client)); + } + + HostInfoDAOImpl(PluginConfiguration config, HttpClient client, JsonHelper jsonHelper, HttpHelper httpHelper) throws Exception { + super(config, client); + this.jsonHelper = jsonHelper; + this.httpHelper = httpHelper; + this.httpHelper.startClient(this.httpClient); + } + + public String getPluginId() { + return PLUGIN_ID; + } + + public Logger getLogger() { + return logger; + } + + @Override + protected String toJsonString(HostInfo obj) throws IOException { + return jsonHelper.toJson(Arrays.asList(obj)); + } + + // For testing purposes + static class JsonHelper { + + private final HostInfoTypeAdapter typeAdapter; + + JsonHelper(HostInfoTypeAdapter typeAdapter) { + this.typeAdapter = typeAdapter; + } + + String toJson(List<HostInfo> infos) throws IOException { + return typeAdapter.toJson(infos); + } + + } + + // For testing purposes + static class HttpHelper { + + private final HttpClient httpClient; + + HttpHelper(HttpClient httpClient) { + this.httpClient = httpClient; + } + + void startClient(HttpClient httpClient) throws Exception { + httpClient.start(); + } + + StringContentProvider createContentProvider(String content) { + return new StringContentProvider(content); + } + + Request newRequest(String url) { + return new MockRequest(httpClient, URI.create(url)); + } + + } + + // FIXME This class should be removed when the web gateway has a microservice for this DAO + private static class MockRequest extends HttpRequest { + + MockRequest(HttpClient client, URI uri) { + super(client, uri); + } + } + + // FIXME This class should be removed when the web gateway has a microservice for this DAO + private static class MockResponse extends HttpContentResponse { + + MockResponse() { + super(null, null, null); + } + + @Override + public int getStatus() { + return HttpStatus.OK_200; + } + + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/main/java/com/redhat/thermostat/host/overview/model/HostInfo.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,131 @@ +/* + * 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.host.overview.model; + +import com.redhat.thermostat.storage.core.Entity; +import com.redhat.thermostat.storage.core.Persist; +import com.redhat.thermostat.storage.model.BasePojo; + +@Entity +public class HostInfo extends BasePojo { + + private String hostname; + private String osName; + private String osKernel; + private String cpuModel; + private int cpuCount; + private long totalMemory; + + public HostInfo() { + this(null, null, null, null, null, -1, -1); + } + + public HostInfo(String writerId, String hostname, String osName, String osKernel, String cpuModel, int cpuCount, long totalMemory) { + super(writerId); + this.hostname = hostname; + this.osName = osName; + this.osKernel = osKernel; + this.cpuModel = cpuModel; + this.cpuCount = cpuCount; + this.totalMemory = totalMemory; + } + + @Persist + public void setHostname(String hostname) { + this.hostname = hostname; + } + + @Persist + public void setOsName(String osName) { + this.osName = osName; + } + + @Persist + public void setOsKernel(String osKernel) { + this.osKernel = osKernel; + } + + @Persist + public void setCpuModel(String cpuModel) { + this.cpuModel = cpuModel; + } + + @Persist + public void setCpuCount(int cpuCount) { + this.cpuCount = cpuCount; + } + + @Persist + public void setTotalMemory(long totalMemory) { + this.totalMemory = totalMemory; + } + + @Persist + public String getHostname() { + return hostname; + } + + @Persist + public String getOsName() { + return osName; + } + + @Persist + public String getOsKernel() { + return osKernel; + } + + @Persist + public String getCpuModel() { + return cpuModel; + } + + @Persist + public int getCpuCount() { + return cpuCount; + } + + /** + * Total memory in bytes + */ + @Persist + public long getTotalMemory() { + return totalMemory; + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostInfoTypeAdapterTest.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,75 @@ +/* + * 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.host.overview.internal; + +import static org.junit.Assert.assertEquals; + +import java.util.Arrays; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.host.overview.model.HostInfo; + +public class HostInfoTypeAdapterTest { + + private HostInfoTypeAdapter adapter; + + @Before + public void setup() { + adapter = new HostInfoTypeAdapter(); + } + + @Test + public void testWrite() throws Exception { + final String expected = "[{\"agentId\":\"myAgent1\",\"hostname\":\"myHost1\"," + + "\"osName\":\"myOS1\",\"osKernel\":\"myKernel1\",\"cpuModel\":\"myCPU1\"," + + "\"cpuCount\":4,\"totalMemory\":{\"$numberLong\":\"400000000\"}}," + + "{\"agentId\":\"myAgent2\",\"hostname\":\"myHost2\",\"osName\":\"myOS2\"," + + "\"osKernel\":\"myKernel2\",\"cpuModel\":\"myCPU2\",\"cpuCount\":2," + + "\"totalMemory\":{\"$numberLong\":\"800000000\"}}]"; + + HostInfo first = new HostInfo("myAgent1", "myHost1", "myOS1", "myKernel1", "myCPU1", 4, 400000000L); + HostInfo second = new HostInfo("myAgent2", "myHost2", "myOS2", "myKernel2", "myCPU2", 2, 800000000L); + List<HostInfo> infos = Arrays.asList(first, second); + + String json = adapter.toJson(infos); + assertEquals(expected, json); + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/HostOverviewBackendTest.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,96 @@ +/* + * 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.host.overview.internal; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.common.Version; +import com.redhat.thermostat.host.overview.internal.models.HostInfoBuilder; +import com.redhat.thermostat.host.overview.internal.models.HostInfoDAO; +import com.redhat.thermostat.host.overview.model.HostInfo; +import com.redhat.thermostat.storage.core.WriterID; + +public class HostOverviewBackendTest { + + private HostOverviewBackend backend; + private HostInfoDAO hostInfoDAO; + private WriterID writerID; + private HostInfo info; + private HostInfoBuilder builder; + private HostOverviewBackend.HostInfoBuilderCreator builderCreator; + + @Before + public void setup() { + hostInfoDAO = mock(HostInfoDAO.class); + Version version = mock(Version.class); + when(version.getVersionNumber()).thenReturn("0.0.0"); + writerID = mock(WriterID.class); + + info = mock(HostInfo.class); + builder = mock(HostInfoBuilder.class); + when(builder.build()).thenReturn(info); + builderCreator = mock(HostOverviewBackend.HostInfoBuilderCreator.class); + when(builderCreator.create(writerID)).thenReturn(builder); + + backend = new HostOverviewBackend(version, hostInfoDAO, writerID, builderCreator); + } + + @Test + public void testActivate() { + backend.activate(); + assertTrue(backend.isActive()); + + verify(builderCreator).create(writerID); + verify(builder).build(); + verify(hostInfoDAO).put(info.getHostname(), info); + } + + @Test + public void testDeactivate() { + backend.activate(); + backend.deactivate(); + assertFalse(backend.isActive()); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoBuilderTest.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,89 @@ +/* + * 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.host.overview.internal.models; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import org.junit.Assume; +import org.junit.Before; +import org.junit.Test; + +import com.redhat.thermostat.common.portability.PortableHost; +import com.redhat.thermostat.host.overview.model.HostInfo; +import com.redhat.thermostat.shared.config.OS; +import com.redhat.thermostat.storage.core.WriterID; + +public class HostInfoBuilderTest { + + private WriterID writerId; + private PortableHost helper; + + @Before + public void setup() { + writerId = mock(WriterID.class); + helper = mock(PortableHost.class); + when(helper.getHostName()).thenReturn("testhost"); + when(helper.getOSName()).thenReturn("testos"); + when(helper.getOSVersion()).thenReturn("testversion"); + when(helper.getCPUModel()).thenReturn("testcpu"); + when(helper.getCPUCount()).thenReturn(4567); + when(helper.getTotalMemory()).thenReturn(9876L); + } + + @Test + public void testSimpleBuild() { + Assume.assumeTrue(OS.IS_WINDOWS); + HostInfo info = new HostInfoBuilderImpl(writerId).build(); + assertNotNull(info); + } + + @Test + public void testGetInfo() { + final HostInfoBuilder ib = new HostInfoBuilderImpl(writerId, helper); + final HostInfo hi = ib.build(); + assertEquals("testhost",hi.getHostname()); + assertEquals("testos", hi.getOsName()); + assertEquals("testcpu", hi.getCpuModel()); + assertEquals("testversion", hi.getOsKernel()); + assertEquals(4567, hi.getCpuCount()); + assertEquals(9876L, hi.getTotalMemory()); + } +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/agent/src/test/java/com/redhat/thermostat/host/overview/internal/models/HostInfoDAOTest.java Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,129 @@ +/* + * 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.host.overview.internal.models; + +import static org.mockito.Matchers.anyListOf; +import static org.mockito.Matchers.anyString; +import static org.mockito.Matchers.eq; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +import com.redhat.thermostat.common.config.experimental.ConfigurationInfoSource; +import com.redhat.thermostat.host.overview.internal.common.PluginConfiguration; + +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.api.ContentProvider; +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.host.overview.model.HostInfo; +import org.mockito.Matchers; + +public class HostInfoDAOTest { + + private static final String URL = "http://localhost:26000/api/systems/v0.0.3"; + private static final String SOME_JSON = "{\"some\" : \"json\"}"; + private static final String HOST_NAME = "a host name"; + private static final String OS_NAME = "some os"; + private static final String OS_KERNEL = "some kernel"; + private static final String CPU_MODEL = "some cpu that runs fast"; + private static final int CPU_NUM = -1; + private static final long MEMORY_TOTAL = 0xCAFEBABEl; + private static final String CONTENT_TYPE = "application/json"; + + private static final String URL_PROP = "gatewayURL"; + + private HostInfo info; + private HttpClient httpClient; + private HostInfoDAOImpl.JsonHelper jsonHelper; + private HostInfoDAOImpl.HttpHelper httpHelper; + private StringContentProvider contentProvider; + private Request request; + private ContentResponse response; + private ConfigurationInfoSource cfiSource; + + @Before + public void setup() throws Exception { + info = new HostInfo("foo-agent", HOST_NAME, OS_NAME, OS_KERNEL, CPU_MODEL, CPU_NUM, MEMORY_TOTAL); + + httpHelper = mock(HostInfoDAOImpl.HttpHelper.class); + contentProvider = mock(StringContentProvider.class); + when(httpHelper.createContentProvider(anyString())).thenReturn(contentProvider); + request = mock(Request.class); + httpClient = mock(HttpClient.class); + request = mock(Request.class); + when(httpClient.newRequest(anyString())).thenReturn(request); + when(httpHelper.newRequest(anyString())).thenReturn(request); + response = mock(ContentResponse.class); + when(response.getStatus()).thenReturn(HttpStatus.OK_200); + when(request.send()).thenReturn(response); + + jsonHelper = mock(HostInfoDAOImpl.JsonHelper.class); + when(jsonHelper.toJson(anyListOf(HostInfo.class))).thenReturn(SOME_JSON); + + cfiSource = mock(ConfigurationInfoSource.class); + Map<String,String> map = new HashMap<>(); + map.put(URL_PROP, URL); + when(cfiSource.getConfiguration(anyString(),anyString())).thenReturn(map); + } + + @Test + public void testPutHostInfo() throws Exception { + + HostInfoDAOImpl dao = new HostInfoDAOImpl(new PluginConfiguration(cfiSource, HostInfoDAOImpl.PLUGIN_ID), httpClient, jsonHelper, httpHelper); + dao.put(info.getAgentId(), info); + + verify(httpClient).newRequest(URL + "/systems/" + info.getAgentId()); + verify(request).method(HttpMethod.POST); + verify(jsonHelper).toJson(eq(Arrays.asList(info))); + verify(request).content(Matchers.any(ContentProvider.class), eq(CONTENT_TYPE)); + verify(request).send(); + verify(response).getStatus(); + } + +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/distribution/assemblies/plugin-assembly.xml Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,74 @@ +<?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. + +--> +<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> + <id>plugin-assembly</id> + <formats> + <format>zip</format> + </formats> + <includeBaseDirectory>false</includeBaseDirectory> + + <dependencySets> + <dependencySet> + <includes> + <include>com.redhat.thermostat:thermostat-host-overview-agent</include> + </includes> + <useProjectArtifact>false</useProjectArtifact> + <useStrictFiltering>true</useStrictFiltering> + <outputDirectory>plugins/${thermostat.plugin}</outputDirectory> + </dependencySet> + </dependencySets> + + <fileSets> + <fileSet> + <includes> + <include>thermostat-plugin.xml</include> + </includes> + <outputDirectory>plugins/${thermostat.plugin}</outputDirectory> + <filtered>true</filtered> + </fileSet> + <fileSet> + <directory>configFiles</directory> + <outputDirectory>etc/plugins.d/${thermostat.plugin}</outputDirectory> + <filtered>true</filtered> + </fileSet> + </fileSets> +</assembly> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/distribution/configFiles/gateway.properties Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,2 @@ +# URL to the jvm-memory microservice provided by the Thermostat web gateway +gatewayURL=http://localhost:30000/systems/0.0.1 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/distribution/pom.xml Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,89 @@ +<?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> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-host-overview</artifactId> + <version>1.99.12-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-host-overview-distribution</artifactId> + <packaging>pom</packaging> + + <name>Thermostat Host Overview plugin distribution</name> + + <properties> + <thermostat.plugin>host-overview</thermostat.plugin> + </properties> + + <build> + <plugins> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <descriptors> + <descriptor>assemblies/plugin-assembly.xml</descriptor> + </descriptors> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>assemble-plugin</id> + <phase>package</phase> + <goals> + <goal>single</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-host-overview-agent</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + +</project> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/distribution/thermostat-plugin.xml Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,51 @@ +<?xml version="1.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. + +--> +<plugin xmlns="http://icedtea.classpath.org/thermostat/plugins/v1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://icedtea.classpath.org/thermostat/plugins/v1.0 thermostat-plugin.xsd"> + <extensions> + <extension> + <name>agent</name> + <bundles> + <bundle><symbolic-name>com.redhat.thermostat.host.overview.agent</symbolic-name><version>${project.version}</version></bundle> + </bundles> + </extension> + </extensions> +</plugin> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/host-overview/pom.xml Wed May 31 12:06:16 2017 -0400 @@ -0,0 +1,59 @@ +<?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> + <groupId>com.redhat.thermostat</groupId> + <artifactId>thermostat-plugins</artifactId> + <version>1.99.12-SNAPSHOT</version> + </parent> + + <artifactId>thermostat-host-overview</artifactId> + <packaging>pom</packaging> + + <name>Thermostat Host Overview plugin</name> + + <modules> + <module>agent</module> + <module>distribution</module> + </modules> + +</project> +
--- a/plugins/pom.xml Tue May 30 16:30:17 2017 -0400 +++ b/plugins/pom.xml Wed May 31 12:06:16 2017 -0400 @@ -53,7 +53,7 @@ <modules> <!--<module>thread</module>--> <module>killvm</module> - <module>com.redhat.thermostat.host.overview</module> + <module>host-overview</module> <!--<module>host-cpu</module>--> <!--<module>host-memory</module>--> <!--<module>vm-byteman</module>-->