Removed mon-http, messaging and collectd.
Moved kafka related stuff to mon-kafka. Removed all @author tags Added license to all /src/main files
This commit is contained in:
parent
102922d972
commit
ce1a305756
|
@ -8,15 +8,13 @@
|
|||
|
||||
### Platform Sub-Projects
|
||||
|
||||
* [mon-collectd](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-collectd) - Utilities for working with Collectd data.
|
||||
* [mon-dropwizard](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-dropwizard) - Utilities for building and testing dropwizard services.
|
||||
* [mon-http](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-http) - HTTP related infrastructure and utilities.
|
||||
* [mon-messaging](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-messaging) - [EIP](http://www.eaipatterns.com/) inspired messaging patterns and implementations.
|
||||
* [mon-kafka](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-kafka) - Various utilities for working with Kafka.
|
||||
* [mon-persistence](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-persistence) - Persistence related infrastructure and utilities.
|
||||
* [mon-service](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-service) - Simple service abstractions and utilities.
|
||||
* [mon-streaming](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-streaming) - Streaming related utilities.
|
||||
* [mon-testing](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-testing) - A set of testing related dependencies.
|
||||
* [mon-util](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-util) - Various utilities such as for serialization, dependency injection, date and time, invocation retries, concurrency, etc.
|
||||
* [mon-kafka](https://git.hpcloud.net/mon/mon-common/tree/master/java/mon-kafka) - Various utilities for working with Kafka.
|
||||
|
||||
### Deploying to Nexus
|
||||
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
/target
|
|
@ -1,24 +0,0 @@
|
|||
<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.hpcloud</groupId>
|
||||
<artifactId>mon-common</artifactId>
|
||||
<version>${computedVersion}</version>
|
||||
</parent>
|
||||
<artifactId>mon-collectd</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>collectd-api</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.dropwizard.persistence;
|
||||
|
||||
import io.dropwizard.db.DataSourceFactory;
|
||||
|
|
|
@ -23,7 +23,6 @@ import com.google.common.collect.ImmutableMap;
|
|||
/**
|
||||
* Support class for testing applications. Starts and stops the server once for the test suite.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
* @param <C> configuration type
|
||||
*/
|
||||
@Test
|
||||
|
|
|
@ -31,8 +31,6 @@ import com.sun.jersey.test.framework.LowLevelAppDescriptor;
|
|||
|
||||
/**
|
||||
* Support class for testing resources.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public abstract class AbstractResourceTest {
|
||||
private final Set<Object> singletons = Sets.newHashSet();
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
<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.hpcloud</groupId>
|
||||
<artifactId>mon-common</artifactId>
|
||||
<version>${computedVersion}</version>
|
||||
</parent>
|
||||
<artifactId>mon-http</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.jersey</groupId>
|
||||
<artifactId>jersey-client</artifactId>
|
||||
<version>1.18</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-testing</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,148 +0,0 @@
|
|||
package com.hpcloud.http.rest;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import com.sun.jersey.api.client.Client;
|
||||
import com.sun.jersey.api.client.ClientResponse;
|
||||
import com.sun.jersey.api.client.WebResource;
|
||||
|
||||
/**
|
||||
* REST client.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public abstract class AbstractRestClient {
|
||||
private final String serviceName;
|
||||
private final Client client;
|
||||
|
||||
@Inject
|
||||
public AbstractRestClient(String serviceName, Client client) {
|
||||
this.serviceName = serviceName;
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a resource.
|
||||
*
|
||||
* @throws RestClientException if an error occurs during the request
|
||||
* @throws UnauthorizedException if the request results in a 401
|
||||
*/
|
||||
protected <T> T createResource(String uri, Class<T> resourceType, @Nullable String body,
|
||||
Map<String, String> headers) {
|
||||
ClientResponse response = null;
|
||||
int statusCode = 0;
|
||||
|
||||
try {
|
||||
WebResource webResource = client.resource(uri);
|
||||
WebResource.Builder builder = webResource.type(MediaType.APPLICATION_JSON_TYPE).accept(
|
||||
MediaType.APPLICATION_JSON_TYPE);
|
||||
if (headers != null)
|
||||
for (Entry<String, String> header : headers.entrySet())
|
||||
builder.header(header.getKey(), header.getValue());
|
||||
response = body == null ? builder.post(ClientResponse.class, "") : builder.post(
|
||||
ClientResponse.class, body);
|
||||
statusCode = response.getStatus();
|
||||
} catch (Exception e) {
|
||||
consumeResponse(response);
|
||||
throw new RestClientException(e, "Error creating %s", uri);
|
||||
}
|
||||
|
||||
if (statusCode == 401)
|
||||
throw new UnauthorizedException("Unauthorized %s. %s", uri, response.getEntity(String.class));
|
||||
if (response == null || statusCode >= 400)
|
||||
throw new RestClientException(statusCode, "Error creating %s. Status code %s. %s", uri,
|
||||
statusCode, response.getEntity(String.class));
|
||||
|
||||
try {
|
||||
T resource = response.getEntity(resourceType);
|
||||
return resource;
|
||||
} catch (Exception e) {
|
||||
throw new RestClientException(e, "Failed to parse resource response for", uri);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a resource.
|
||||
*
|
||||
* @throws RestClientException if an error occurs during the request
|
||||
* @throws UnauthorizedException if the request results in a 401
|
||||
* @throws ResourceNotFoundException if the request results in a 404
|
||||
*/
|
||||
protected <T> T getResource(String uri, Class<T> resourceType, String resourceId,
|
||||
Map<String, String> headers) {
|
||||
ClientResponse response = null;
|
||||
int statusCode = 0;
|
||||
|
||||
try {
|
||||
WebResource webResource = client.resource(uri);
|
||||
WebResource.Builder builder = webResource.type(MediaType.APPLICATION_JSON_TYPE).accept(
|
||||
MediaType.APPLICATION_JSON_TYPE);
|
||||
if (headers != null)
|
||||
for (Entry<String, String> header : headers.entrySet())
|
||||
builder.header(header.getKey(), header.getValue());
|
||||
response = builder.get(ClientResponse.class);
|
||||
statusCode = response.getStatus();
|
||||
} catch (Exception e) {
|
||||
consumeResponse(response);
|
||||
throw new RestClientException(e, "Error getting %s", uri);
|
||||
}
|
||||
|
||||
if (statusCode == 401)
|
||||
throw new UnauthorizedException("Unauthorized %s. %s", uri, response.getEntity(String.class));
|
||||
if (statusCode == 404)
|
||||
throw new ResourceNotFoundException(serviceName, resourceId, "Not Found. %s", uri,
|
||||
response.getEntity(String.class));
|
||||
if (response == null || statusCode != 200)
|
||||
throw new RestClientException(statusCode, "Error getting %s. Status code %s. %s", uri,
|
||||
statusCode, response.getEntity(String.class));
|
||||
|
||||
try {
|
||||
T resource = response.getEntity(resourceType);
|
||||
return resource;
|
||||
} catch (Exception e) {
|
||||
throw new RestClientException(e, "Failed to parse resource response for", uri);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a resource exists.
|
||||
*
|
||||
* @throws RestClientException if an error occurs during the request
|
||||
* @throws UnauthorizedException if the request results in a 401
|
||||
*/
|
||||
protected boolean resourceExists(String uri, Map<String, String> headers) {
|
||||
ClientResponse response = null;
|
||||
int statusCode = 0;
|
||||
|
||||
try {
|
||||
WebResource webResource = client.resource(uri);
|
||||
WebResource.Builder builder = webResource.accept(MediaType.APPLICATION_JSON_TYPE);
|
||||
if (headers != null)
|
||||
for (Entry<String, String> header : headers.entrySet())
|
||||
builder.header(header.getKey(), header.getValue());
|
||||
response = builder.get(ClientResponse.class);
|
||||
statusCode = response.getStatus();
|
||||
} catch (Exception e) {
|
||||
consumeResponse(response);
|
||||
throw new RestClientException(e, "Error getting %s", uri);
|
||||
}
|
||||
|
||||
if (statusCode == 401)
|
||||
throw new UnauthorizedException("Unauthorized %s. %s", uri, response.getEntity(String.class));
|
||||
if (response == null || (statusCode >= 400 && statusCode != 404))
|
||||
throw new RestClientException(statusCode, "Error getting %s. Status code %s. %s", uri,
|
||||
statusCode, response.getEntity(String.class));
|
||||
|
||||
return statusCode == 200 || statusCode == 204;
|
||||
}
|
||||
|
||||
private void consumeResponse(ClientResponse clientResponse) {
|
||||
if (clientResponse != null && clientResponse.hasEntity())
|
||||
clientResponse.close();
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.hpcloud.http.rest;
|
||||
|
||||
/**
|
||||
* Resource Not Found Exception.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class ResourceNotFoundException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public final String service;
|
||||
public final String resourceId;
|
||||
|
||||
public ResourceNotFoundException(String service, String resourceId, Throwable ex) {
|
||||
super(ex);
|
||||
this.service = service;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String service, String resourceId, Throwable ex, String msg) {
|
||||
super(msg, ex);
|
||||
this.service = service;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String service, String resourceId, Throwable ex,
|
||||
String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args), ex);
|
||||
this.service = service;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String service, String resourceId, String msg) {
|
||||
super(msg);
|
||||
this.service = service;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public ResourceNotFoundException(String service, String resourceId, String msgFormat,
|
||||
Object... args) {
|
||||
super(String.format(msgFormat, args));
|
||||
this.service = service;
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package com.hpcloud.http.rest;
|
||||
|
||||
/**
|
||||
* REST Client Exception.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class RestClientException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
public final int statusCode;
|
||||
|
||||
public RestClientException(int statusCode, Throwable ex) {
|
||||
super(ex);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public RestClientException(int statusCode, Throwable ex, String msg) {
|
||||
super(msg, ex);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public RestClientException(int statusCode, Throwable ex, String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args), ex);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public RestClientException(String msg) {
|
||||
super(msg);
|
||||
this.statusCode = 0;
|
||||
}
|
||||
|
||||
public RestClientException(int statusCode, String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args));
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public RestClientException(Throwable ex) {
|
||||
super(ex);
|
||||
this.statusCode = 0;
|
||||
}
|
||||
|
||||
public RestClientException(Throwable ex, String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args), ex);
|
||||
this.statusCode = 0;
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package com.hpcloud.http.rest;
|
||||
|
||||
/**
|
||||
* Unauthorized Exception.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class UnauthorizedException extends RuntimeException {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public UnauthorizedException(Throwable ex) {
|
||||
super(ex);
|
||||
}
|
||||
|
||||
public UnauthorizedException(Throwable ex, String msg) {
|
||||
super(msg, ex);
|
||||
}
|
||||
|
||||
public UnauthorizedException(Throwable ex, String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args), ex);
|
||||
}
|
||||
|
||||
public UnauthorizedException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
public UnauthorizedException(String msgFormat, Object... args) {
|
||||
super(String.format(msgFormat, args));
|
||||
}
|
||||
}
|
|
@ -1,20 +1,78 @@
|
|||
<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>
|
||||
<parent>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-common</artifactId>
|
||||
<version>${computedVersion}</version>
|
||||
</parent>
|
||||
<artifactId>mon-kafka</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<artifactId>mon-kafka</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<metrics.version>3.0.1</metrics.version>
|
||||
<jackson.version>2.3.0</jackson.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-service</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codahale.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>${metrics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codahale.metrics</groupId>
|
||||
<artifactId>metrics-healthchecks</artifactId>
|
||||
<version>${metrics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.jodah</groupId>
|
||||
<artifactId>typetools</artifactId>
|
||||
<version>0.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka_2.9.2</artifactId>
|
||||
<version>0.8.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jdmk</groupId>
|
||||
<artifactId>jmxtools</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jmx</groupId>
|
||||
<artifactId>jmxri</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>4.3.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-testing</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.configuration;
|
||||
|
||||
import java.util.Properties;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.messaging.kafka;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
public class KafkaConfiguration {
|
||||
@NotEmpty public String[] zookeeperUris;
|
||||
@NotEmpty public String[] brokerUris;
|
||||
@NotEmpty public String healthCheckTopic;
|
||||
}
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.messaging.kafka;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -24,8 +40,6 @@ import com.google.common.base.Joiner;
|
|||
*
|
||||
* TODO re-work the implementation to scan the topic for the single health check message that was
|
||||
* sent, and consume only that message.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class KafkaHealthCheck extends HealthCheck {
|
||||
private final KafkaConfiguration config;
|
|
@ -0,0 +1,8 @@
|
|||
log4j.rootLogger=INFO, console
|
||||
|
||||
log4j.logger.com.hpcloud.mon=DEBUG
|
||||
log4j.logger.com.hpcloud.messaging=DEBUG
|
||||
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.conversionPattern=%-5p [%d{ISO8601}] [%.18t] %c{1}: %m%n
|
|
@ -1 +0,0 @@
|
|||
/target
|
|
@ -1,71 +0,0 @@
|
|||
<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.hpcloud</groupId>
|
||||
<artifactId>mon-common</artifactId>
|
||||
<version>${computedVersion}</version>
|
||||
</parent>
|
||||
<artifactId>mon-messaging</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<metrics.version>3.0.1</metrics.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-service</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-util</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codahale.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>${metrics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.codahale.metrics</groupId>
|
||||
<artifactId>metrics-healthchecks</artifactId>
|
||||
<version>${metrics.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.jodah</groupId>
|
||||
<artifactId>typetools</artifactId>
|
||||
<version>0.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka_2.9.2</artifactId>
|
||||
<version>0.8.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jdmk</groupId>
|
||||
<artifactId>jmxtools</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.sun.jmx</groupId>
|
||||
<artifactId>jmxri</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>4.3.0.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-testing</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,86 +0,0 @@
|
|||
package com.hpcloud.messaging.kafka;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.hpcloud.messaging.MessageHandler;
|
||||
import com.hpcloud.messaging.MessageTranslator;
|
||||
import com.hpcloud.messaging.internal.AbstractPublishSubscribeChannel;
|
||||
|
||||
/**
|
||||
* Kafka channel implementation.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Singleton
|
||||
public class KafkaChannel extends AbstractPublishSubscribeChannel {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KafkaChannel.class);
|
||||
|
||||
private final KafkaConfiguration config;
|
||||
// private Connection connection;
|
||||
private volatile boolean open;
|
||||
|
||||
@Inject
|
||||
public KafkaChannel(KafkaConfiguration config, MessageTranslator<Object, ?> inboundTranslator,
|
||||
MessageTranslator<?, Object> outboundTranslator, MetricRegistry metricRegistry) {
|
||||
super("kafka", inboundTranslator, outboundTranslator, metricRegistry);
|
||||
this.config = config;
|
||||
Preconditions.checkNotNull(config, "config");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
LOG.info("Closing Kafka channel");
|
||||
|
||||
try {
|
||||
// TODO close kafka cxn
|
||||
} finally {
|
||||
open = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open() {
|
||||
LOG.info("Opening Kafka channel");
|
||||
// TODO open kafka cxn
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the {@code message} to the {@code topic}.
|
||||
*/
|
||||
public void send(Object message, String topic) {
|
||||
Preconditions.checkNotNull(message, "message");
|
||||
Preconditions.checkNotNull(topic, "topic");
|
||||
if (!open)
|
||||
throw new IllegalStateException("The message cannot be sent since the channel is not open");
|
||||
|
||||
// TODO send message
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes the {@code subscriber} to the {@code topic}.
|
||||
*/
|
||||
@Override
|
||||
public void subscribe(MessageHandler<?> subscriber, String topic) {
|
||||
super.subscribe(subscriber, topic);
|
||||
if (!open)
|
||||
return;
|
||||
|
||||
// TODO create topic subscription
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribes the {@code subscriber} for the {@code topic}.
|
||||
*/
|
||||
@Override
|
||||
public void unsubscribe(MessageHandler<?> subscriber, String topic) {
|
||||
super.unsubscribe(subscriber, topic);
|
||||
|
||||
// TODO remove topic subscription
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package com.hpcloud.messaging.kafka;
|
||||
|
||||
import org.hibernate.validator.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class KafkaConfiguration {
|
||||
@NotEmpty public String[] zookeeperUris;
|
||||
@NotEmpty public String[] brokerUris;
|
||||
@NotEmpty public String healthCheckTopic;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.hpcloud.messaging.kafka;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import kafka.javaapi.producer.Producer;
|
||||
import kafka.producer.KeyedMessage;
|
||||
import kafka.producer.ProducerConfig;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.hpcloud.service.Service;
|
||||
|
||||
public class KafkaService implements Service {
|
||||
private final KafkaConfiguration config;
|
||||
private Producer<String, String> producer;
|
||||
|
||||
@Inject
|
||||
public KafkaService(KafkaConfiguration config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() throws Exception {
|
||||
Properties props = new Properties();
|
||||
props.put("metadata.broker.list", Joiner.on(',').join(config.brokerUris));
|
||||
props.put("serializer.class", "kafka.serializer.StringEncoder");
|
||||
props.put("partitioner.class", "example.producer.SimplePartitioner");
|
||||
props.put("request.required.acks", "1");
|
||||
ProducerConfig config = new ProducerConfig(props);
|
||||
producer = new Producer<String, String>(config);
|
||||
}
|
||||
|
||||
public void send(String message, Map<String, Object> meta, String topic, String key) {
|
||||
KeyedMessage<String, String> keyedMessage = new KeyedMessage<>(topic, key, message);
|
||||
producer.send(keyedMessage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() throws Exception {
|
||||
producer.close();
|
||||
}
|
||||
}
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -8,8 +24,6 @@ import com.hpcloud.mon.common.model.alarm.AlarmSubExpression;
|
|||
|
||||
/**
|
||||
* Represents an alarm having been created.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@JsonRootName(value = "alarm-created")
|
||||
public class AlarmCreatedEvent implements Serializable {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -8,8 +24,6 @@ import com.hpcloud.mon.common.model.metric.MetricDefinition;
|
|||
|
||||
/**
|
||||
* Represents an alarm having been deleted.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@JsonRootName(value = "alarm-deleted")
|
||||
public class AlarmDeletedEvent implements Serializable {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.event;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
|
@ -5,8 +21,6 @@ import com.hpcloud.mon.common.model.alarm.AlarmState;
|
|||
|
||||
/**
|
||||
* Represents an alarm state transition having occurred.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@JsonRootName(value = "alarm-transitioned")
|
||||
public class AlarmStateTransitionedEvent {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.event;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -9,8 +25,6 @@ import com.hpcloud.mon.common.model.alarm.AlarmSubExpression;
|
|||
|
||||
/**
|
||||
* Represents an alarm having been updated.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@JsonRootName(value = "alarm-updated")
|
||||
public class AlarmUpdatedEvent implements Serializable {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -8,8 +24,6 @@ import com.google.common.collect.Sets;
|
|||
|
||||
/**
|
||||
* Compute namespace info.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
class ComputeServiceInfo implements ServiceInfo {
|
||||
private final Set<String> supportedMetricNames = Sets.newHashSet("cpu_time", "cpu_utilization",
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -8,8 +24,6 @@ import com.google.common.collect.Sets;
|
|||
|
||||
/**
|
||||
* Object-store namespace info.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
class ObjectStoreServiceInfo implements ServiceInfo {
|
||||
private final Set<String> supportedMetricNames = Sets.newHashSet("project_write_bytes",
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model;
|
||||
|
||||
import java.util.List;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -5,8 +21,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Utilities for working with services.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class Services {
|
||||
// HPCS namespace constants
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
@ -8,8 +24,6 @@ import com.google.common.collect.Sets;
|
|||
|
||||
/**
|
||||
* Compute namespace info.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
class VolumeServiceInfo implements ServiceInfo {
|
||||
private final Set<String> supportedMetricNames = Sets.newHashSet("volume_read_ops",
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
@ -8,9 +24,6 @@ import com.hpcloud.util.stats.Statistics.Max;
|
|||
import com.hpcloud.util.stats.Statistics.Min;
|
||||
import com.hpcloud.util.stats.Statistics.Sum;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public enum AggregateFunction {
|
||||
MIN, MAX, SUM, COUNT, AVG;
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -10,13 +26,11 @@ import org.antlr.v4.runtime.ParserRuleContext;
|
|||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.hpcloud.util.Stack;
|
||||
|
||||
/**
|
||||
* Alarm expression value object.
|
||||
*
|
||||
* @author Todd Walk
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class AlarmExpression {
|
||||
private final String expression;
|
||||
|
@ -100,11 +114,13 @@ public class AlarmExpression {
|
|||
/**
|
||||
* Returns the alarm's expression.
|
||||
*/
|
||||
@JsonIgnore
|
||||
public String getExpression() {
|
||||
return expression;
|
||||
}
|
||||
|
||||
/** Returns a boolean tree representation of the alarm expression. */
|
||||
@JsonIgnore
|
||||
public Object getExpressionTree() {
|
||||
Stack<Object> stack = new Stack<Object>();
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import org.antlr.v4.runtime.BaseErrorListener;
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
* Alarm operator.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public enum AlarmOperator {
|
||||
LT("<"), LTE("<="), GT(">"), GTE(">=");
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public enum AlarmState {
|
||||
UNDETERMINED, OK, ALARM;
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -14,9 +30,6 @@ import com.hpcloud.mon.common.model.metric.MetricDefinition;
|
|||
|
||||
/**
|
||||
* Alarm sub expression value object.
|
||||
*
|
||||
* @author Todd Walk
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class AlarmSubExpression implements Serializable {
|
||||
private static final long serialVersionUID = -7458129503846747592L;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -9,8 +25,6 @@ import com.hpcloud.mon.common.model.metric.MetricDefinition;
|
|||
|
||||
/**
|
||||
* Complex alarm parser lister for sub expression extraction.
|
||||
*
|
||||
* @author Todd Walk
|
||||
*/
|
||||
class AlarmSubExpressionListener extends AlarmExpressionBaseListener {
|
||||
private final boolean simpleExpression;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -5,8 +21,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Encapsualtes a boolean expression consisting of an operator and two or more operands.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class BooleanExpression {
|
||||
public final BooleanOperator operator;
|
||||
|
|
|
@ -1,10 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.alarm;
|
||||
|
||||
/**
|
||||
* Boolean operator.
|
||||
*
|
||||
* @author Todd Walk
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public enum BooleanOperator {
|
||||
AND, OR;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.metric;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -11,8 +27,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Metric with definition information flattened alongside value information.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class Metric implements Serializable {
|
||||
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.metric;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -9,8 +25,6 @@ import com.google.common.base.Preconditions;
|
|||
|
||||
/**
|
||||
* Metric definition.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class MetricDefinition implements Serializable {
|
||||
private static final long serialVersionUID = -3074228641225201445L;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.metric;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -6,8 +22,6 @@ import com.google.common.base.Preconditions;
|
|||
|
||||
/**
|
||||
* A metric envelope.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class MetricEnvelope {
|
||||
public Metric metric;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.metric;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
|
@ -5,8 +21,6 @@ import com.hpcloud.util.Exceptions;
|
|||
|
||||
/**
|
||||
* Utilities for working with MetricEnvelopes.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class MetricEnvelopes {
|
||||
private MetricEnvelopes() {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.common.model.metric;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -16,8 +32,6 @@ import com.hpcloud.util.Exceptions;
|
|||
|
||||
/**
|
||||
* Utilities for working with Metrics.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Metrics {
|
||||
static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.mon.domain.common;
|
||||
|
||||
/**
|
||||
* Defines an entity with a surrogate key.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
* @see http://domaindrivendesign.org/search/node/Entity
|
||||
*/
|
||||
public abstract class AbstractEntity {
|
||||
|
|
|
@ -1,6 +1,18 @@
|
|||
/*
|
||||
* Alarm expression parser (for maas-api support)
|
||||
* Todd Walk, Hewlett Packard Cloud Services, 2013
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
grammar AlarmExpression;
|
||||
|
|
|
@ -12,9 +12,6 @@ import org.testng.annotations.Test;
|
|||
import com.google.common.collect.ImmutableMap;
|
||||
import com.hpcloud.mon.common.model.metric.MetricDefinition;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class AlarmExpressionTest {
|
||||
public void shouldParseExpression() {
|
||||
|
|
|
@ -13,9 +13,6 @@ import com.hpcloud.mon.common.model.alarm.AlarmOperator;
|
|||
import com.hpcloud.mon.common.model.alarm.AlarmSubExpression;
|
||||
import com.hpcloud.mon.common.model.metric.MetricDefinition;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class AlarmSubExpressionTest {
|
||||
public void shouldParseExpression() {
|
||||
|
|
|
@ -11,9 +11,6 @@ import org.testng.annotations.Test;
|
|||
import com.hpcloud.mon.common.model.metric.Metric;
|
||||
import com.hpcloud.mon.common.model.metric.Metrics;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class MetricsTest {
|
||||
public void shouldSerializeValue() {
|
||||
|
@ -33,8 +30,8 @@ public class MetricsTest {
|
|||
dimensions.put("metric_name", "cpu");
|
||||
dimensions.put("device", "2");
|
||||
dimensions.put("instance_id", "123");
|
||||
Metric metric = new Metric("hpcs.compute", dimensions, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
Metric metric = new Metric("hpcs.compute", dimensions, 123345, new double[][] { { 123, 5 },
|
||||
{ 456, 6 } });
|
||||
|
||||
String json = Metrics.toJson(metric);
|
||||
assertEquals(
|
||||
|
@ -47,8 +44,8 @@ public class MetricsTest {
|
|||
dimensions.put("metric_name", "cpu");
|
||||
dimensions.put("device", "2");
|
||||
dimensions.put("instance_id", "123");
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] { { 123, 5 },
|
||||
{ 456, 6 } });
|
||||
|
||||
Metric metric = Metrics.fromJson(Metrics.toJson(expected).getBytes());
|
||||
assertEquals(metric, expected);
|
||||
|
@ -71,8 +68,8 @@ public class MetricsTest {
|
|||
dimensions.put("metric_name", "foôbár");
|
||||
dimensions.put("device", "2");
|
||||
dimensions.put("instance_id", "123");
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] { { 123, 5 },
|
||||
{ 456, 6 } });
|
||||
|
||||
Metric metric;
|
||||
metric = Metrics.fromJson(Metrics.toJson(expected).getBytes("UTF-8"));
|
||||
|
@ -84,8 +81,8 @@ public class MetricsTest {
|
|||
dimensions.put("metric_name", "fo\u00f4b\u00e1r");
|
||||
dimensions.put("device", "2");
|
||||
dimensions.put("instance_id", "123");
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
Metric expected = new Metric("hpcs.compute", dimensions, 123345, new double[][] { { 123, 5 },
|
||||
{ 456, 6 } });
|
||||
|
||||
Metric metric;
|
||||
metric = Metrics.fromJson(Metrics.toJson(expected).getBytes("UTF-8"));
|
||||
|
@ -101,10 +98,10 @@ public class MetricsTest {
|
|||
dimensions2.put("metric_name", "foôbár");
|
||||
dimensions2.put("device", "2");
|
||||
dimensions2.put("instance_id", "123");
|
||||
Metric expected_escaped = new Metric("hpcs.compute", dimensions, 123345,
|
||||
new double[][] { { 123, 5 }, { 456, 6 } });
|
||||
Metric expected_nonescaped = new Metric("hpcs.compute", dimensions2, 123345,
|
||||
new double[][] { { 123, 5 }, { 456, 6 } });
|
||||
Metric expected_escaped = new Metric("hpcs.compute", dimensions, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
Metric expected_nonescaped = new Metric("hpcs.compute", dimensions2, 123345, new double[][] {
|
||||
{ 123, 5 }, { 456, 6 } });
|
||||
|
||||
Metric metric;
|
||||
metric = Metrics.fromJson(Metrics.toJson(expected_escaped).getBytes("UTF-8"));
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import org.skife.jdbi.v2.DBI;
|
||||
|
@ -7,8 +23,6 @@ import com.google.inject.Provider;
|
|||
|
||||
/**
|
||||
* Support module for binding persistent types.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public abstract class AbstractPersistenceModule extends AbstractModule {
|
||||
protected <T> void bindSqlType(final Class<T> sqlType) {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import org.skife.jdbi.v2.ResultSetMapperFactory;
|
||||
|
@ -6,8 +22,6 @@ import org.skife.jdbi.v2.tweak.ResultSetMapper;
|
|||
|
||||
/**
|
||||
* Produces {@link BeanMapper instances}.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class BeanMapperFactory implements ResultSetMapperFactory {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import java.io.Reader;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
@ -10,8 +26,6 @@ import org.skife.jdbi.v2.tweak.ResultSetMapper;
|
|||
|
||||
/**
|
||||
* Mapper that accumulates key/value results in a map.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class KeyValueMapper implements ResultSetMapper<Object> {
|
||||
public final Map<String, String> map = new HashMap<String, String>();
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
@ -8,8 +24,6 @@ import org.skife.jdbi.v2.Query;
|
|||
|
||||
/**
|
||||
* Utilities for building and performing queries.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class SqlQueries {
|
||||
private SqlQueries() {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -5,8 +21,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Utilities for producing SQL statements.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class SqlStatements {
|
||||
private SqlStatements() {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import static org.mockito.Matchers.any;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.persistence;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -7,9 +23,6 @@ import java.util.Map;
|
|||
import static org.testng.Assert.*;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class SqlStatementsTest {
|
||||
public void testUnionAllStatementFor() {
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<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.hpcloud</groupId>
|
||||
<artifactId>mon-common</artifactId>
|
||||
<version>${computedVersion}</version>
|
||||
</parent>
|
||||
<artifactId>mon-service</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.hpcloud</groupId>
|
||||
<artifactId>mon-testing</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.streaming.storm;
|
||||
|
||||
import backtype.storm.task.TopologyContext;
|
||||
|
@ -5,8 +21,6 @@ import backtype.storm.task.TopologyContext;
|
|||
|
||||
/**
|
||||
* Storm related logging utilities.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Logging {
|
||||
private Logging() {
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.streaming.storm;
|
||||
|
||||
/**
|
||||
* Utilities for working with streams.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Streams {
|
||||
public static final String DEFAULT_STREAM_ID = "default";
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.streaming.storm;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -7,8 +23,6 @@ import backtype.storm.tuple.Fields;
|
|||
/**
|
||||
* Deserializes tuples. Similar to a Scheme, but allows for multiple records per
|
||||
* {@link #deserialize(byte[])} call.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public interface TupleDeserializer {
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.streaming.storm;
|
||||
|
||||
import backtype.storm.Constants;
|
||||
|
@ -5,8 +21,6 @@ import backtype.storm.tuple.Tuple;
|
|||
|
||||
/**
|
||||
* Utilities for working with Tuples.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Tuples {
|
||||
private Tuples() {
|
||||
|
|
|
@ -4,9 +4,6 @@ import java.util.List;
|
|||
|
||||
import com.hpcloud.streaming.storm.TestSpout.TupleProvider;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class PeriodicTupleProvider implements TupleProvider {
|
||||
@Override
|
||||
public List<Object> get() {
|
||||
|
|
|
@ -10,9 +10,6 @@ import backtype.storm.topology.base.BaseRichSpout;
|
|||
|
||||
import com.hpcloud.streaming.storm.TupleDeserializer;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class TestSpout extends BaseRichSpout {
|
||||
private static final long serialVersionUID = 849564133745588803L;
|
||||
|
||||
|
|
|
@ -11,9 +11,6 @@ import backtype.storm.generated.StormTopology;
|
|||
import com.google.common.base.Preconditions;
|
||||
import com.hpcloud.util.Injector;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test(groups = "integration")
|
||||
public class TopologyTestCase {
|
||||
public static final String TEST_TOPOLOGY_NAME = "test-maas-alarming";
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.testing;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -17,8 +33,6 @@ import com.google.common.base.Preconditions;
|
|||
|
||||
/**
|
||||
* Duration unit, consisting of length and time unit.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Immutable
|
||||
@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE,
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
/**
|
||||
* Utilities for working with exceptions.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Exceptions {
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
@ -10,8 +26,6 @@ import com.google.inject.name.Names;
|
|||
|
||||
/**
|
||||
* Provides fully injected instances.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Injector {
|
||||
private static volatile com.google.inject.Injector injector;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -33,8 +49,6 @@ import com.google.common.primitives.Primitives;
|
|||
* <p>
|
||||
* Notes: Deserialized Joda DateTime instances use UTC chronology. Comparisons should be made by
|
||||
* millis alone.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Serialization {
|
||||
private static final ObjectMapper mapper = new ObjectMapper();
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -6,8 +22,6 @@ import java.util.ArrayList;
|
|||
* LIFO Stack semantics around an ArrayList for random access support. Indexed access via
|
||||
* {@link #get(int)} and iteration via {@link #iterator()} is in reverse order (FIFO). Not
|
||||
* threadsafe.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class Stack<T> extends ArrayList<T> {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* Utilities for working with types.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Types {
|
||||
private static Class<?> JAVASSIST_PROXY_FACTORY_CLASS;
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.concurrent;
|
||||
|
||||
/**
|
||||
* Listens to execution related events.
|
||||
*
|
||||
* @authorn Jonathan Halterman
|
||||
*/
|
||||
public interface ExecutionListener {
|
||||
void afterExecute(Runnable r, Throwable t);
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.concurrent;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
@ -20,8 +36,6 @@ import com.codahale.metrics.Timer;
|
|||
|
||||
/**
|
||||
* ThreadPoolExecutor instrumented with extensive metrics.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public class InstrumentedThreadPoolExecutor extends ThreadPoolExecutor {
|
||||
private final Logger log = LoggerFactory.getLogger(getClass());
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.concurrent;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
@ -9,8 +25,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
|||
|
||||
/**
|
||||
* Factory methods for creating thread pools.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class ThreadPools {
|
||||
private ThreadPools() {
|
||||
|
|
|
@ -1,28 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.config;
|
||||
|
||||
|
||||
/**
|
||||
* An exception thrown where there is an error parsing a configuration object.
|
||||
*/
|
||||
public class ConfigurationException extends Exception {
|
||||
private static final long serialVersionUID = 5325162099634227047L;
|
||||
private static final long serialVersionUID = 5325162099634227047L;
|
||||
|
||||
/**
|
||||
* Creates a new ConfigurationException for the given file with the given errors.
|
||||
*
|
||||
* @param file the bad configuration file
|
||||
* @param errors the errors in the file
|
||||
*/
|
||||
public ConfigurationException(String file, Iterable<String> errors) {
|
||||
super(formatMessage(file, errors));
|
||||
}
|
||||
/**
|
||||
* Creates a new ConfigurationException for the given file with the given errors.
|
||||
*
|
||||
* @param file the bad configuration file
|
||||
* @param errors the errors in the file
|
||||
*/
|
||||
public ConfigurationException(String file, Iterable<String> errors) {
|
||||
super(formatMessage(file, errors));
|
||||
}
|
||||
|
||||
private static String formatMessage(String file, Iterable<String> errors) {
|
||||
final StringBuilder msg = new StringBuilder(file)
|
||||
.append(" has the following errors:\n");
|
||||
for (String error : errors) {
|
||||
msg.append(" * ").append(error).append('\n');
|
||||
}
|
||||
return msg.toString();
|
||||
private static String formatMessage(String file, Iterable<String> errors) {
|
||||
final StringBuilder msg = new StringBuilder(file).append(" has the following errors:\n");
|
||||
for (String error : errors) {
|
||||
msg.append(" * ").append(error).append('\n');
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.config;
|
||||
|
||||
import java.io.File;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.stats;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
|
@ -8,8 +24,6 @@ import com.hpcloud.util.time.TimeResolution;
|
|||
/**
|
||||
* A time based sliding window containing statistics for a fixed number of slots of a fixed length.
|
||||
* The window provides a fixed size view over the total number of slots in the window.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class SlidingWindowStats {
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.stats;
|
||||
|
||||
/**
|
||||
* Statistic.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public interface Statistic {
|
||||
/** Adds the {@code value} to the statistic. */
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.stats;
|
||||
|
||||
/**
|
||||
* Statistic implementations.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Statistics {
|
||||
public static abstract class AbstractStatistic implements Statistic {
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.time;
|
||||
|
||||
/**
|
||||
* Time resolution.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public enum TimeResolution {
|
||||
ABSOLUTE {
|
||||
|
|
|
@ -1,9 +1,23 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.time;
|
||||
|
||||
/**
|
||||
* Utilities for working with times.
|
||||
*
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
public final class Times {
|
||||
private Times() {
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
/*
|
||||
* Copyright (c) 2014 Hewlett-Packard Development Company, L.P.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
* implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.hpcloud.util.validation;
|
||||
|
||||
import static java.lang.String.format;
|
||||
|
|
|
@ -15,9 +15,6 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class TypesTest {
|
||||
static class TestClass {
|
||||
|
@ -51,6 +48,7 @@ public class TypesTest {
|
|||
assertEquals(Types.deProxy(Injector.getInstance(TestClass.class).getClass()), TestClass.class);
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void shouldDeProxyJavassistProxy() {
|
||||
ProxyFactory proxyFactory = new ProxyFactory();
|
||||
proxyFactory.setSuperclass(ArrayList.class);
|
||||
|
|
|
@ -8,9 +8,6 @@ import org.testng.annotations.Test;
|
|||
|
||||
import com.hpcloud.util.time.TimeResolution;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class SlidingWindowStatsTest {
|
||||
public void testIndexOf() {
|
||||
|
|
|
@ -11,9 +11,6 @@ import com.hpcloud.util.stats.Statistics.Max;
|
|||
import com.hpcloud.util.stats.Statistics.Min;
|
||||
import com.hpcloud.util.stats.Statistics.Sum;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class StatisticsTest {
|
||||
@DataProvider(name = "metricTypes")
|
||||
|
|
|
@ -5,9 +5,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import org.joda.time.DateTime;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author Jonathan Halterman
|
||||
*/
|
||||
@Test
|
||||
public class TimesTest {
|
||||
public void shouldRoundDownToNearestMinute() {
|
||||
|
|
|
@ -36,17 +36,13 @@
|
|||
</scm>
|
||||
|
||||
<modules>
|
||||
<module>mon-collectd</module>
|
||||
<module>mon-dropwizard</module>
|
||||
<module>mon-http</module>
|
||||
<module>mon-messaging</module>
|
||||
<module>mon-kafka</module>
|
||||
<module>mon-model</module>
|
||||
<module>mon-persistence</module>
|
||||
<module>mon-service</module>
|
||||
<module>mon-streaming</module>
|
||||
<module>mon-testing</module>
|
||||
<module>mon-util</module>
|
||||
<module>mon-kafka</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
|
|
Loading…
Reference in New Issue