Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
brcosta committed May 13, 2014
1 parent 293217b commit 78e3b8f
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 0 deletions.
25 changes: 25 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<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>

<groupId>io.monocycle</groupId>
<artifactId>monocycle-java-api</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>Monocycle Java Agent API</name>

<properties>
<java.version>1.6</java.version>
</properties>

<dependencies>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.3.3</version>
</dependency>

</dependencies>

</project>
15 changes: 15 additions & 0 deletions src/main/java/io/monocycle/agent/api/DataHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.monocycle.agent.api;

import java.io.Serializable;

import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({ @JsonSubTypes.Type(value = DoubleDataHolder.class, name = "double"), @JsonSubTypes.Type(value = LongDataHolder.class, name = "long"),
@JsonSubTypes.Type(value = StringDataHolder.class, name = "string") })
public interface DataHolder {

Serializable getValue();

}
62 changes: 62 additions & 0 deletions src/main/java/io/monocycle/agent/api/DataPoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package io.monocycle.agent.api;

import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* POJO to represent a single DataPoint
*/
public class DataPoint {

private String metric;

private Map<String, DataHolder> valuesMap;

public DataPoint() {
valuesMap = new LinkedHashMap<String, DataHolder>();
}

public DataPoint(String metric) {
this();
this.metric = metric;
}

@JsonIgnore
public Collection<String> getKeys() {
return getValuesMap().keySet();
}

@JsonIgnore
public Collection<DataHolder> getValues() {
return getValuesMap().values();
}

public void addValue(String key, DataHolder value) {
valuesMap.put(key, value);
}

public String getMetric() {
return metric;
}

public void setMetric(String metric) {
this.metric = metric.toLowerCase();
}

public Map<String, DataHolder> getValuesMap() {
return valuesMap;
}

public void setValuesMap(Map<String, DataHolder> valuesMap) {
this.valuesMap = valuesMap;
}

@Override
public String toString() {
return getClass().getName() + " {\n\tmetric: " + metric + "\n\tvaluesMap: " + valuesMap + "\n}";
}

}
24 changes: 24 additions & 0 deletions src/main/java/io/monocycle/agent/api/DoubleDataHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.monocycle.agent.api;

public class DoubleDataHolder implements DataHolder {

private Double value;

public DoubleDataHolder() {
// Default Constructor
}

public DoubleDataHolder(Double value) {
this.value = value;
}

public Double getValue() {
return value;
}

@Override
public String toString() {
return getClass().getName() + " {\n\tvalue: " + value + "\n}";
}

}
19 changes: 19 additions & 0 deletions src/main/java/io/monocycle/agent/api/LongDataHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.monocycle.agent.api;

public class LongDataHolder implements DataHolder {

private Long value;

public LongDataHolder() {
// Default constructor
}

public LongDataHolder(Long value) {
this.value = value;
}

public Long getValue() {
return value;
}

}
38 changes: 38 additions & 0 deletions src/main/java/io/monocycle/agent/api/Server.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.monocycle.agent.api;

/**
* Server
*/
public class Server {

private String hostname;

private String description;

private ServerSummary serverSummary;

public String getHostname() {
return hostname;
}

public void setHostname(String hostname) {
this.hostname = hostname;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public ServerSummary getServerSummary() {
return serverSummary;
}

public void setServerSummary(ServerSummary serverSummary) {
this.serverSummary = serverSummary;
}

}
103 changes: 103 additions & 0 deletions src/main/java/io/monocycle/agent/api/ServerSummary.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package io.monocycle.agent.api;

import java.util.Set;

/**
* ServerSummary
*/
public class ServerSummary {

private Integer coreCount;

private Long totalMemory;

private Long totalSwap;

private String vendorName;

private String vendorDescription;

public Set<MountPointSummary> mountPoints;

public Integer getCoreCount() {
return coreCount;
}

public void setCoreCount(Integer coreCount) {
this.coreCount = coreCount;
}

public Long getTotalMemory() {
return totalMemory;
}

public void setTotalMemory(Long totalMemory) {
this.totalMemory = totalMemory;
}

public Long getTotalSwap() {
return totalSwap;
}

public void setTotalSwap(Long totalSwap) {
this.totalSwap = totalSwap;
}

public String getVendorName() {
return vendorName;
}

public void setVendorName(String vendorName) {
this.vendorName = vendorName;
}

public String getVendorDescription() {
return vendorDescription;
}

public void setVendorDescription(String vendorDescription) {
this.vendorDescription = vendorDescription;
}

public Set<MountPointSummary> getMountPoints() {
return mountPoints;
}

public void setMountPoints(Set<MountPointSummary> mountPoints) {
this.mountPoints = mountPoints;
}

public static class MountPointSummary {

private String device;

private String mountPoint;

public MountPointSummary() {
// Default Constructor
}

public MountPointSummary(String device, String mountPoint) {
this.device = device;
this.mountPoint = mountPoint;
}

public String getDevice() {
return device;
}

public void setDevice(String device) {
this.device = device;
}

public String getMountPoint() {
return mountPoint;
}

public void setMountPoint(String mountPoint) {
this.mountPoint = mountPoint;
}

}

}
24 changes: 24 additions & 0 deletions src/main/java/io/monocycle/agent/api/StringDataHolder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.monocycle.agent.api;

public class StringDataHolder implements DataHolder {

private String value;

public StringDataHolder() {
// Default Constructor
}

public StringDataHolder(String value) {
this.value = value;
}

public String getValue() {
return value;
}

@Override
public String toString() {
return getClass().getName() + " {\n\tvalue: " + value + "\n}";
}

}

0 comments on commit 78e3b8f

Please sign in to comment.