Mercurial > hg > thermostat-ng > agent
changeset 2710:dd67c96690d4
Remove configListenAddress field from AgentInformation.
Reviewed-by: jmatsuok
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-June/023910.html
author | Severin Gehwolf <sgehwolf@redhat.com> |
---|---|
date | Mon, 26 Jun 2017 19:31:01 +0200 |
parents | b9ab00ccce2f |
children | 325ba70eb3c1 |
files | agent/core/src/main/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapter.java agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInfoDAOTest.java agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapterTest.java storage/core/src/main/java/com/redhat/thermostat/storage/model/AgentInformation.java storage/core/src/test/java/com/redhat/thermostat/storage/model/AgentInformationTest.java |
diffstat | 5 files changed, 7 insertions(+), 107 deletions(-) [+] |
line wrap: on
line diff
--- a/agent/core/src/main/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapter.java Thu Jun 22 04:49:39 2017 -0400 +++ b/agent/core/src/main/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapter.java Mon Jun 26 19:31:01 2017 +0200 @@ -51,7 +51,6 @@ private static final String START_TIME = "startTime"; private static final String STOP_TIME = "stopTime"; private static final String ALIVE = "alive"; - private static final String CONFIG_LISTEN_ADDRESS = "configListenAddress"; private static final String TYPE_LONG = "$numberLong"; @Override @@ -78,8 +77,6 @@ writeLong(out, info.getStopTime()); out.name(ALIVE); out.value(info.isAlive()); - out.name(CONFIG_LISTEN_ADDRESS); - out.value(info.getConfigListenAddress()); out.endObject(); } @@ -115,8 +112,6 @@ writeLong(out, info.getStopTime()); out.name(ALIVE); out.value(info.isAlive()); - out.name(CONFIG_LISTEN_ADDRESS); - out.value(info.getConfigListenAddress()); out.endObject(); out.endObject();
--- a/agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInfoDAOTest.java Thu Jun 22 04:49:39 2017 -0400 +++ b/agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInfoDAOTest.java Mon Jun 26 19:31:01 2017 +0200 @@ -80,7 +80,6 @@ public void setUp() throws Exception { info = new AgentInformation("1234"); info.setAlive(true); - info.setConfigListenAddress("foobar:666"); info.setStartTime(100); info.setStopTime(10);
--- a/agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapterTest.java Thu Jun 22 04:49:39 2017 -0400 +++ b/agent/core/src/test/java/com/redhat/thermostat/agent/internal/AgentInformationTypeAdapterTest.java Mon Jun 26 19:31:01 2017 +0200 @@ -53,12 +53,12 @@ public void testWrite() throws Exception { AgentInformationTypeAdapter adapter = new AgentInformationTypeAdapter(); final String expected = "[{\"agentId\":\"agent1\",\"startTime\":{\"$numberLong\":\"4000\"}," - + "\"stopTime\":{\"$numberLong\":\"6000\"},\"alive\":false,\"configListenAddress\":\"127.0.0.1:12000\"}," + + "\"stopTime\":{\"$numberLong\":\"6000\"},\"alive\":false}," + "{\"agentId\":\"agent2\",\"startTime\":{\"$numberLong\":\"5000\"},\"stopTime\":{\"$numberLong\":\"0\"}," - + "\"alive\":true,\"configListenAddress\":\"1.2.3.4:12000\"}]"; + + "\"alive\":true}]"; - AgentInformation first = createAgentInformation("agent1", 4000L, 6000L, false, "127.0.0.1:12000"); - AgentInformation second = createAgentInformation("agent2", 5000L, 0L, true, "1.2.3.4:12000"); + AgentInformation first = createAgentInformation("agent1", 4000L, 6000L, false); + AgentInformation second = createAgentInformation("agent2", 5000L, 0L, true); List<AgentInformation> infos = Arrays.asList(first, second); String json = adapter.toJson(infos); @@ -69,22 +69,20 @@ public void testUpdate() throws Exception { AgentInformationUpdateTypeAdapter adapter = new AgentInformationUpdateTypeAdapter(); final String expected = "{\"set\":{\"startTime\":{\"$numberLong\":\"5000\"}," - + "\"stopTime\":{\"$numberLong\":\"7000\"},\"alive\":false,\"configListenAddress\":\"1.2.3.4:12000\"}}"; + + "\"stopTime\":{\"$numberLong\":\"7000\"},\"alive\":false}}"; - AgentInformation info = createAgentInformation("agent2", 5000L, 7000L, false, "1.2.3.4:12000"); + AgentInformation info = createAgentInformation("agent2", 5000L, 7000L, false); AgentInformationUpdate update = new AgentInformationUpdate(info); String json = adapter.toJson(update); assertEquals(expected, json); } - private AgentInformation createAgentInformation(String agentId, long startTime, long stopTime, - boolean alive, String configListenAddress) { + private AgentInformation createAgentInformation(String agentId, long startTime, long stopTime, boolean alive) { AgentInformation info = new AgentInformation(agentId); info.setStartTime(startTime); info.setStopTime(stopTime); info.setAlive(alive); - info.setConfigListenAddress(configListenAddress); return info; }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/AgentInformation.java Thu Jun 22 04:49:39 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/AgentInformation.java Mon Jun 26 19:31:01 2017 +0200 @@ -36,12 +36,8 @@ package com.redhat.thermostat.storage.model; -import java.net.InetSocketAddress; -import java.util.List; import java.util.Objects; -import com.redhat.thermostat.common.utils.HostPortPair; -import com.redhat.thermostat.common.utils.HostPortsParser; import com.redhat.thermostat.storage.core.Entity; import com.redhat.thermostat.storage.core.Persist; @@ -92,26 +88,6 @@ this.alive = alive; } - @Persist - public String getConfigListenAddress() { - return address; - } - - @Persist - public void setConfigListenAddress(String address) { - this.address = address; - } - - public InetSocketAddress getRequestQueueAddress() { - String address = getConfigListenAddress(); - HostPortsParser parser = new HostPortsParser(address); - parser.parse(); - List<HostPortPair> result = parser.getHostsPorts(); - HostPortPair hostAndPort = result.get(0); - InetSocketAddress target = new InetSocketAddress(hostAndPort.getHost(), hostAndPort.getPort()); - return target; - } - @Override public String toString() { return "agent " + getAgentId();
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/model/AgentInformationTest.java Thu Jun 22 04:49:39 2017 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +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.storage.model; - -import static org.junit.Assert.assertEquals; - -import java.net.InetSocketAddress; - -import org.junit.Test; - -public class AgentInformationTest { - - @Test - public void configurationAddressIsParsedCorrectly() { - final String HOST = "example.com"; - final int PORT = 80; - - AgentInformation info = new AgentInformation(); - info.setConfigListenAddress(HOST + ":" + PORT); - - assertEquals(new InetSocketAddress(HOST, PORT), info.getRequestQueueAddress()); - } - - @Test - public void configurationIPv6AddressIsParsedCorrectly() { - final String HOST = "[1fff:0:a88:85a3::ac1f]"; - final int PORT = 80; - - AgentInformation info = new AgentInformation(); - info.setConfigListenAddress(HOST + ":" + PORT); - - assertEquals(new InetSocketAddress(HOST, PORT), info.getRequestQueueAddress()); - } -}