Created
May 9, 2014 12:49
-
-
Save jsanda/39cdcc0df952fd5918f3 to your computer and use it in GitHub Desktop.
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); | |
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