This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cassandra storage config YAML | |
# NOTE: | |
# See http://wiki.apache.org/cassandra/StorageConfiguration for | |
# full explanations of configuration directives | |
# /NOTE | |
# The name of the cluster. This is mainly used to prevent machines in | |
# one logical cluster from joining another. | |
cluster_name: ${cluster.name} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RateLimitTest { | |
@Test | |
public void throttle() { | |
RateLimiter rateLimiter = RateLimiter.create(5, 5, TimeUnit.SECONDS); | |
for (int i = 0; i < 25; ++i) { | |
rateLimiter.acquire(); | |
System.out.println("i = " + i); | |
} | |
rateLimiter.setRate(1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE metrics ( | |
bucket text, | |
metric_id text, | |
time timestamp, | |
attributes map<text, text> static, | |
value map<int, double>, | |
PRIMARY KEY ((bucket, metric_id), time) | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void addData(final AsyncResponse asyncResponse, Set<RawNumericMetric> rawData) { | |
ListenableFuture<Map<RawNumericMetric,Throwable>> future = metricsService.addData(rawData); | |
Futures.addCallback(future, new FutureCallback<Map<RawNumericMetric, Throwable>>() { | |
@Override | |
public void onSuccess(Map<RawNumericMetric, Throwable> errors) { | |
Response jaxrs = Response.ok().type(MediaType.APPLICATION_JSON_TYPE).build(); | |
asyncResponse.resume(jaxrs); | |
} | |
@Override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TYPE data_point (time timestamp, value map<int, double>); | |
CREATE TABLE tags ( | |
tag_name text, | |
tag_value text, | |
metric_id text, | |
values list<data_point>, | |
PRIMARY KEY (tag_name, tag_value, metric_id) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@POST | |
@Path("/metrics") | |
@Consumes({"application/json","application/xml"}) | |
public void addMetrics(@Suspended AsyncResponse asyncResponse, Collection<IdDataPoint> dataPoints) { | |
Set<RawNumericMetric> rawSet = new HashSet<>(dataPoints.size()); | |
for (IdDataPoint dataPoint : dataPoints) { | |
RawNumericMetric rawMetric = new RawNumericMetric(dataPoint.getId(), dataPoint.getValue(), | |
dataPoint.getTimestamp()); | |
rawSet.add(rawMetric); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private AggregateNumericMetric calculateAggregate(Iterable<AggregateNumericMetric> metrics, long timestamp) { | |
double min = Double.NaN; | |
double max = min; | |
int count = 0; | |
ArithmeticMeanCalculator mean = new ArithmeticMeanCalculator(); | |
for (AggregateNumericMetric metric : metrics) { | |
if (count == 0) { | |
min = metric.getMin(); | |
max = metric.getMax(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test//(dependsOnMethods = "insertMetricsForOneId") | |
public void findRawMetricsForSingleId() throws Exception { | |
final String metricId = UUID.randomUUID().toString(); | |
long timestamp1 = System.currentTimeMillis(); | |
double value1 = 2.17; | |
ResultSetFuture insertFuture = dataAccess.insertData("raw", metricId, timestamp1, | |
ImmutableMap.of(DataType.RAW.ordinal(), value1), TTL); | |
// wait for the insert to finish | |
getUninterruptibly(insertFuture); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ServerTest extends MetricsTest { | |
private static final int TTL = 360; | |
private PlatformManager platformManager; | |
private DataAccess dataAccess; | |
private RawMetricMapper rawMapper; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE rhq.raw_metrics ( | |
schedule_id int, | |
time timestamp, | |
value double, | |
PRIMARY KEY (schedule_id, time) | |
) WITH COMPACT STORAGE; | |
CREATE TABLE rhq.one_hour_metrics ( | |
schedule_id int, | |
time timestamp, |