use of org.apache.druid.java.util.http.client.response.StatusResponseHolder in project druid by druid-io.
the class JettyTest method testTimeouts.
@Test
// this test will deadlock if it hits an issue, so ignored by default
@Ignore
public void testTimeouts() throws Exception {
// test for request timeouts properly not locking up all threads
final ExecutorService executor = Executors.newFixedThreadPool(100);
final AtomicLong count = new AtomicLong(0);
final CountDownLatch latch = new CountDownLatch(1000);
for (int i = 0; i < 10000; i++) {
executor.execute(new Runnable() {
@Override
public void run() {
executor.execute(new Runnable() {
@Override
public void run() {
long startTime = System.currentTimeMillis();
long startTime2 = 0;
try {
ListenableFuture<StatusResponseHolder> go = client.go(new Request(HttpMethod.GET, new URL("http://localhost:" + port + "/slow/hello")), StatusResponseHandler.getInstance());
startTime2 = System.currentTimeMillis();
go.get();
} catch (Exception e) {
e.printStackTrace();
} finally {
System.out.printf(Locale.ENGLISH, "Response time client%dtime taken for getting future%dCounter %d%n", System.currentTimeMillis() - startTime, System.currentTimeMillis() - startTime2, count.incrementAndGet());
latch.countDown();
}
}
});
}
});
}
latch.await();
}
use of org.apache.druid.java.util.http.client.response.StatusResponseHolder in project druid by druid-io.
the class DirectDruidClientTest method testCancel.
@Test
public void testCancel() {
Capture<Request> capturedRequest = EasyMock.newCapture();
ListenableFuture<Object> cancelledFuture = Futures.immediateCancelledFuture();
SettableFuture<Object> cancellationFuture = SettableFuture.create();
EasyMock.expect(httpClient.go(EasyMock.capture(capturedRequest), EasyMock.<HttpResponseHandler>anyObject(), EasyMock.anyObject(Duration.class))).andReturn(cancelledFuture).once();
EasyMock.expect(httpClient.go(EasyMock.capture(capturedRequest), EasyMock.<HttpResponseHandler>anyObject(), EasyMock.anyObject(Duration.class))).andReturn(cancellationFuture).anyTimes();
EasyMock.replay(httpClient);
TimeBoundaryQuery query = Druids.newTimeBoundaryQueryBuilder().dataSource("test").build();
query = query.withOverriddenContext(ImmutableMap.of(DirectDruidClient.QUERY_FAIL_TIME, Long.MAX_VALUE));
cancellationFuture.set(new StatusResponseHolder(HttpResponseStatus.OK, new StringBuilder("cancelled")));
Sequence results = client.run(QueryPlus.wrap(query));
Assert.assertEquals(HttpMethod.POST, capturedRequest.getValue().getMethod());
Assert.assertEquals(0, client.getNumOpenConnections());
QueryInterruptedException exception = null;
try {
results.toList();
} catch (QueryInterruptedException e) {
exception = e;
}
Assert.assertNotNull(exception);
EasyMock.verify(httpClient);
}
use of org.apache.druid.java.util.http.client.response.StatusResponseHolder in project druid by druid-io.
the class WorkerTaskRunnerQueryAdpaterTest method getHttpClientRequestCapture.
private Capture<Request> getHttpClientRequestCapture(HttpResponseStatus httpStatus, String responseContent) {
SettableFuture<StatusResponseHolder> futureResult = SettableFuture.create();
futureResult.set(new StatusResponseHolder(httpStatus, new StringBuilder(responseContent)));
Capture<Request> capturedRequest = EasyMock.newCapture();
EasyMock.expect(httpClient.go(EasyMock.capture(capturedRequest), EasyMock.<HttpResponseHandler>anyObject())).andReturn(futureResult).once();
return capturedRequest;
}
use of org.apache.druid.java.util.http.client.response.StatusResponseHolder in project druid by druid-io.
the class CompactionResourceTestClient method getDataSourceCompactionConfig.
public DataSourceCompactionConfig getDataSourceCompactionConfig(String dataSource) throws Exception {
String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.GET, new URL(url)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while getting compaction config status[%s] content[%s]", response.getStatus(), response.getContent());
}
return jsonMapper.readValue(response.getContent(), new TypeReference<DataSourceCompactionConfig>() {
});
}
use of org.apache.druid.java.util.http.client.response.StatusResponseHolder in project druid by druid-io.
the class CompactionResourceTestClient method deleteCompactionConfig.
public void deleteCompactionConfig(final String dataSource) throws Exception {
String url = StringUtils.format("%sconfig/compaction/%s", getCoordinatorURL(), StringUtils.urlEncode(dataSource));
StatusResponseHolder response = httpClient.go(new Request(HttpMethod.DELETE, new URL(url)), responseHandler).get();
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
throw new ISE("Error while deleting compaction config status[%s] content[%s]", response.getStatus(), response.getContent());
}
}
Aggregations