Skip to content

Instantly share code, notes, and snippets.

@jsanda
Created May 9, 2014 12:49
Show Gist options
  • Save jsanda/39cdcc0df952fd5918f3 to your computer and use it in GitHub Desktop.
Save jsanda/39cdcc0df952fd5918f3 to your computer and use it in GitHub Desktop.
@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);
long timestamp2 = timestamp1 - 2500;
double value2 = 2.4567;
insertFuture = dataAccess.insertData("raw", metricId, timestamp2, ImmutableMap.of(DataType.RAW.ordinal(),
value2), TTL);
// wait for insert to finish
getUninterruptibly(insertFuture);
final CountDownLatch responseReceived = new CountDownLatch(1);
final Buffer buffer = new Buffer();
final HttpClient httpClient = platformManager.vertx().createHttpClient().setPort(7474);
// platformManager.vertx().runOnContext(new Handler<Void>() {
// @Override
// public void handle(Void event) {
// httpClient.getNow("/rhq-metrics/" + metricId + "/data", new Handler<HttpClientResponse>() {
// public void handle(HttpClientResponse response) {
// response.bodyHandler(new Handler<Buffer>() {
// public void handle(Buffer content) {
// buffer.appendBuffer(content);
// responseReceived.countDown();
// }
// });
// }
// });
// }
// });
httpClient.getNow("/rhq-metrics/" + metricId + "/data", new Handler<HttpClientResponse>() {
public void handle(HttpClientResponse response) {
response.bodyHandler(new Handler<Buffer>() {
public void handle(Buffer content) {
buffer.appendBuffer(content);
responseReceived.countDown();
}
});
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment