Mercurial > hg > thermostat-ng > agent
changeset 2762:8a51183ffad8
Introduce the schema in agent
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2017-September/025087.html
reviewed-by: stooke
line wrap: on
line diff
--- a/main/src/main/resources/com/redhat/thermostat/main/internal/bootstrapbundles.properties Fri Sep 22 13:00:56 2017 -0400 +++ b/main/src/main/resources/com/redhat/thermostat/main/internal/bootstrapbundles.properties Tue Sep 26 15:10:28 2017 +0200 @@ -3,6 +3,7 @@ thermostat-common-core-@project.version@.jar, \ thermostat-plugin-validator-@project.version@.jar, \ thermostat-launcher-@project.version@.jar, \ + thermostat-lang-schema-@project.version@.jar, \ commons-cli-@commons-cli.version@.jar, \ org.apache.felix.scr-@felix.scr.version@.jar, \ gson-@gson.version@.jar, \
--- a/plugins/jvm-overview/agent/pom.xml Fri Sep 22 13:00:56 2017 -0400 +++ b/plugins/jvm-overview/agent/pom.xml Tue Sep 26 15:10:28 2017 +0200 @@ -127,6 +127,11 @@ <dependencies> <dependency> + <groupId>com.redhat.thermostat.lang.schema</groupId> + <artifactId>thermostat-lang-schema</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope>
--- a/plugins/jvm-overview/agent/src/main/java/com/redhat/thermostat/jvm/overview/agent/model/VmId.java Fri Sep 22 13:00:56 2017 -0400 +++ b/plugins/jvm-overview/agent/src/main/java/com/redhat/thermostat/jvm/overview/agent/model/VmId.java Tue Sep 26 15:10:28 2017 +0200 @@ -36,12 +36,13 @@ package com.redhat.thermostat.jvm.overview.agent.model; -import com.redhat.thermostat.storage.core.Id; +import com.redhat.thermostat.lang.schema.models.Id; +import com.redhat.thermostat.lang.schema.annotations.Type; /** * This class uniquely identifies a Java Virtual Machine - * */ +@Type(description = "Unique Virtual Machine Identifier") public class VmId extends Id { public VmId(String id) {
--- a/plugins/jvm-overview/agent/src/test/java/com/redhat/thermostat/jvm/overview/agent/VmIdTest.java Fri Sep 22 13:00:56 2017 -0400 +++ b/plugins/jvm-overview/agent/src/test/java/com/redhat/thermostat/jvm/overview/agent/VmIdTest.java Tue Sep 26 15:10:28 2017 +0200 @@ -37,7 +37,7 @@ package com.redhat.thermostat.jvm.overview.agent; import com.redhat.thermostat.jvm.overview.agent.model.VmId; -import com.redhat.thermostat.storage.core.Id; +import com.redhat.thermostat.lang.schema.models.Id; import org.junit.Before; import org.junit.Test;
--- a/storage/core/pom.xml Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/pom.xml Tue Sep 26 15:10:28 2017 +0200 @@ -93,6 +93,11 @@ <dependencies> <dependency> + <groupId>com.redhat.thermostat.lang.schema</groupId> + <artifactId>thermostat-lang-schema</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-core</artifactId> <scope>test</scope>
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/AgentId.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/AgentId.java Tue Sep 26 15:10:28 2017 +0200 @@ -36,6 +36,8 @@ package com.redhat.thermostat.storage.core; +import com.redhat.thermostat.lang.schema.models.Id; + /** * This class uniquely identifies a Thermostat agent *
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Entity.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Entity.java Tue Sep 26 15:10:28 2017 +0200 @@ -47,6 +47,7 @@ * * @see Persist */ +@Deprecated @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) public @interface Entity {
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Id.java Fri Sep 22 13:00:56 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.storage.core; - -import java.util.Objects; -import java.util.UUID; - -/** - * - */ -public class Id { - private String id; - - public Id() { - id = UUID.randomUUID().toString(); - } - - public Id(String id) { - this.id = Objects.requireNonNull(id); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - Id other = (Id) o; - return Objects.equals(this.id, other.get()); - } - - public String get() { - return id; - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } -}
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Key.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Key.java Tue Sep 26 15:10:28 2017 +0200 @@ -42,6 +42,7 @@ * Keys are attributes in {@link Category}s. Think of them as * column names in a table if you're familiar with SQL. */ +@Deprecated public class Key<T> { // Keys used by most Categories.
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Persist.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Persist.java Tue Sep 26 15:10:28 2017 +0200 @@ -46,6 +46,7 @@ * form of storage when needed. Properties without this annotation will not be * persisted. */ +@Deprecated @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) public @interface Persist {
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/core/Ref.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/core/Ref.java Tue Sep 26 15:10:28 2017 +0200 @@ -36,6 +36,7 @@ package com.redhat.thermostat.storage.core; +@Deprecated public interface Ref { String getStringID();
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/AgentInformation.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/AgentInformation.java Tue Sep 26 15:10:28 2017 +0200 @@ -38,14 +38,19 @@ import java.util.Objects; +import com.redhat.thermostat.lang.schema.annotations.Schema; +import com.redhat.thermostat.lang.schema.models.Timestamp; import com.redhat.thermostat.storage.core.Entity; import com.redhat.thermostat.storage.core.Persist; @Entity public class AgentInformation extends BasePojo { - private long startTime; - private long stopTime; + @Schema(required = true) + private Timestamp startTime; + + @Schema(required = true) + private Timestamp stopTime; private boolean alive; private String address; @@ -56,26 +61,28 @@ public AgentInformation(String writerId) { super(writerId); + startTime = new Timestamp(0); + stopTime = new Timestamp(0); } @Persist public long getStartTime() { - return startTime; + return startTime.get(); } @Persist public void setStartTime(long startTime) { - this.startTime = startTime; + this.startTime = new Timestamp(startTime); } @Persist public void setStopTime(long stopTime) { - this.stopTime = stopTime; + this.stopTime = new Timestamp(stopTime); } @Persist public long getStopTime() { - return stopTime; + return stopTime.get(); } @Persist
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/BasePojo.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/BasePojo.java Tue Sep 26 15:10:28 2017 +0200 @@ -41,6 +41,7 @@ import com.redhat.thermostat.storage.core.Persist; +@Deprecated public class BasePojo implements Pojo { private String agentId;
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/Pojo.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/Pojo.java Tue Sep 26 15:10:28 2017 +0200 @@ -63,6 +63,7 @@ * that such properties cannot be of abstract types. * */ +@Deprecated public interface Pojo { }
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojo.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojo.java Tue Sep 26 15:10:28 2017 +0200 @@ -40,6 +40,7 @@ * Any Pojo which is taken as a timestamped piece of data should * implement this interface. */ +@Deprecated public interface TimeStampedPojo extends Pojo { public long getTimeStamp();
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojoComparator.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojoComparator.java Tue Sep 26 15:10:28 2017 +0200 @@ -38,6 +38,7 @@ import java.util.Comparator; +@Deprecated public final class TimeStampedPojoComparator<T extends TimeStampedPojo> implements Comparator<T> { @Override
--- a/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojoCorrelator.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/main/java/com/redhat/thermostat/storage/model/TimeStampedPojoCorrelator.java Tue Sep 26 15:10:28 2017 +0200 @@ -44,6 +44,7 @@ import static com.redhat.thermostat.common.utils.IteratorUtils.head; +@Deprecated public class TimeStampedPojoCorrelator implements Iterable<TimeStampedPojoCorrelator.Correlation> { public static class Correlation {
--- a/storage/core/src/test/java/com/redhat/thermostat/storage/core/IdTest.java Fri Sep 22 13:00:56 2017 -0400 +++ b/storage/core/src/test/java/com/redhat/thermostat/storage/core/IdTest.java Tue Sep 26 15:10:28 2017 +0200 @@ -40,6 +40,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import com.redhat.thermostat.lang.schema.models.Id; import org.junit.Before; import org.junit.Test;