use of org.joda.time.Duration in project druid by druid-io.
the class LoadQueuePeonTest method testFailAssign.
@Test
public void testFailAssign() throws Exception {
final DataSegment segment = dataSegmentWithInterval("2014-10-22T00:00:00Z/P1D");
final CountDownLatch loadRequestSignal = new CountDownLatch(1);
final CountDownLatch segmentLoadedSignal = new CountDownLatch(1);
loadQueuePeon = new LoadQueuePeon(curator, LOAD_QUEUE_PATH, jsonMapper, Execs.scheduledSingleThreaded("test_load_queue_peon_scheduled-%d"), Execs.singleThreaded("test_load_queue_peon-%d"), // set time-out to 1 ms so that LoadQueuePeon will fail the assignment quickly
new TestDruidCoordinatorConfig(null, null, null, new Duration(1), null, null, 10, null, false, false, new Duration("PT1s")));
loadQueuePeon.start();
loadQueueCache.getListenable().addListener(new PathChildrenCacheListener() {
@Override
public void childEvent(CuratorFramework client, PathChildrenCacheEvent event) throws Exception {
if (event.getType() == PathChildrenCacheEvent.Type.CHILD_ADDED) {
loadRequestSignal.countDown();
}
}
});
loadQueueCache.start();
loadQueuePeon.loadSegment(segment, new LoadPeonCallback() {
@Override
public void execute() {
segmentLoadedSignal.countDown();
}
});
String loadRequestPath = ZKPaths.makePath(LOAD_QUEUE_PATH, segment.getIdentifier());
Assert.assertTrue(timing.forWaiting().awaitLatch(loadRequestSignal));
Assert.assertNotNull(curator.checkExists().forPath(loadRequestPath));
Assert.assertEquals(segment, ((SegmentChangeRequestLoad) jsonMapper.readValue(curator.getData().decompressed().forPath(loadRequestPath), DataSegmentChangeRequest.class)).getSegment());
// don't simulate completion of load request here
Assert.assertTrue(timing.forWaiting().awaitLatch(segmentLoadedSignal));
Assert.assertEquals(0, loadQueuePeon.getSegmentsToLoad().size());
Assert.assertEquals(0L, loadQueuePeon.getLoadQueueSize());
}
use of org.joda.time.Duration in project druid by druid-io.
the class DruidCoordinatorSegmentKillerTest method testFindIntervalForKillTask.
private void testFindIntervalForKillTask(List<Interval> segmentManagerResult, Interval expected) {
MetadataSegmentManager segmentManager = EasyMock.createMock(MetadataSegmentManager.class);
EasyMock.expect(segmentManager.getUnusedSegmentIntervals(EasyMock.anyString(), EasyMock.anyObject(Interval.class), EasyMock.anyInt())).andReturn(segmentManagerResult);
EasyMock.replay(segmentManager);
IndexingServiceClient indexingServiceClient = EasyMock.createMock(IndexingServiceClient.class);
DruidCoordinatorSegmentKiller coordinatorSegmentKiller = new DruidCoordinatorSegmentKiller(segmentManager, indexingServiceClient, new TestDruidCoordinatorConfig(null, null, Duration.parse("PT76400S"), new Duration(1), Duration.parse("PT86400S"), Duration.parse("PT86400S"), 1000, null, false, false, Duration.ZERO));
Assert.assertEquals(expected, coordinatorSegmentKiller.findIntervalForKillTask("test", 10000));
}
use of org.joda.time.Duration in project druid by druid-io.
the class LookupCoordinatorManagerConfigTest method testConfigsTakeOverrides.
@Test
public void testConfigsTakeOverrides() {
final Duration funnyDuration = Duration.standardDays(100);
final LookupCoordinatorManagerConfig config = new LookupCoordinatorManagerConfig();
config.setDeleteAllTimeout(funnyDuration);
config.setHostDeleteTimeout(funnyDuration);
config.setHostUpdateTimeout(funnyDuration);
config.setUpdateAllTimeout(funnyDuration);
config.setPeriod(funnyDuration.getMillis());
config.setThreadPoolSize(1200);
Assert.assertEquals(funnyDuration, config.getDeleteAllTimeout());
Assert.assertEquals(funnyDuration, config.getHostDeleteTimeout());
Assert.assertEquals(funnyDuration, config.getHostUpdateTimeout());
Assert.assertEquals(funnyDuration, config.getUpdateAllTimeout());
Assert.assertEquals(funnyDuration.getMillis(), config.getPeriod());
Assert.assertEquals(1200, config.getThreadPoolSize());
}
use of org.joda.time.Duration in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateAllOnHostException.
@Test
public void testUpdateAllOnHostException() throws Exception {
final HttpResponseHandler<InputStream, InputStream> responseHandler = EasyMock.createStrictMock(HttpResponseHandler.class);
final URL url = LookupCoordinatorManager.getLookupsURL(HostAndPort.fromString("localhost"));
final SettableFuture<InputStream> future = SettableFuture.create();
future.set(new ByteArrayInputStream(new byte[0]));
EasyMock.expect(client.go(EasyMock.<Request>anyObject(), EasyMock.<SequenceInputStreamResponseHandler>anyObject(), EasyMock.<Duration>anyObject())).andReturn(future).once();
EasyMock.replay(client, responseHandler);
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
HttpResponseHandler<InputStream, InputStream> makeResponseHandler(final AtomicInteger returnCode, final AtomicReference<String> reasonString) {
returnCode.set(500);
reasonString.set("");
return responseHandler;
}
};
expectedException.expect(new BaseMatcher<Throwable>() {
@Override
public boolean matches(Object o) {
return o instanceof IOException && ((IOException) o).getMessage().startsWith("Bad update request");
}
@Override
public void describeTo(Description description) {
}
});
try {
manager.updateAllOnHost(url, SINGLE_LOOKUP_MAP);
} finally {
EasyMock.verify(client, responseHandler);
}
}
use of org.joda.time.Duration in project druid by druid-io.
the class LookupCoordinatorManagerTest method testUpdateAllOnHostFailsWithFailedThings.
@Test
public void testUpdateAllOnHostFailsWithFailedThings() throws Exception {
final HttpResponseHandler<InputStream, InputStream> responseHandler = EasyMock.createStrictMock(HttpResponseHandler.class);
final String failedLookup = "failedLookup";
final URL url = LookupCoordinatorManager.getLookupsURL(HostAndPort.fromString("localhost"));
final SettableFuture<InputStream> future = SettableFuture.create();
future.set(new ByteArrayInputStream(StringUtils.toUtf8(mapper.writeValueAsString(ImmutableMap.of("status", "accepted", LookupModule.FAILED_UPDATES_KEY, ImmutableMap.of(failedLookup, ImmutableMap.of()))))));
EasyMock.expect(client.go(EasyMock.<Request>anyObject(), EasyMock.<SequenceInputStreamResponseHandler>anyObject(), EasyMock.<Duration>anyObject())).andReturn(future).once();
EasyMock.replay(client, responseHandler);
final LookupCoordinatorManager manager = new LookupCoordinatorManager(client, discoverer, mapper, configManager, lookupCoordinatorManagerConfig) {
@Override
HttpResponseHandler<InputStream, InputStream> makeResponseHandler(final AtomicInteger returnCode, final AtomicReference<String> reasonString) {
returnCode.set(200);
reasonString.set("");
return responseHandler;
}
};
expectedException.expectMessage("Lookups failed to update: [\"" + failedLookup + "\"]");
try {
manager.updateAllOnHost(url, SINGLE_LOOKUP_MAP);
} finally {
EasyMock.verify(client, responseHandler);
}
}
Aggregations