use of org.joda.time.Duration in project druid by druid-io.
the class ScheduledExecutorsTest method testscheduleWithFixedDelay.
@Test
public void testscheduleWithFixedDelay() throws InterruptedException {
Duration initialDelay = new Duration(1000);
Duration delay = new Duration(1000);
ScheduledExecutorService exec = Execs.scheduledSingleThreaded("BasicAuthenticatorCacheManager-Exec--%d");
ScheduledExecutors.scheduleWithFixedDelay(exec, initialDelay, delay, () -> {
System.out.println("TEST!");
});
Thread.sleep(5 * 1000);
exec.shutdown();
}
use of org.joda.time.Duration in project druid by druid-io.
the class DerivativeDataSourceManager method start.
@LifecycleStart
public void start() {
log.info("starting derivatives manager.");
synchronized (lock) {
if (started) {
return;
}
exec = MoreExecutors.listeningDecorator(Execs.scheduledSingleThreaded("DerivativeDataSourceManager-Exec-%d"));
final Duration delay = config.getPollDuration().toStandardDuration();
future = exec.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
try {
updateDerivatives();
} catch (Exception e) {
log.makeAlert(e, "uncaught exception in derivatives manager updating thread").emit();
}
}
}, 0, delay.getMillis(), TimeUnit.MILLISECONDS);
started = true;
}
log.info("Derivatives manager started.");
}
use of org.joda.time.Duration in project druid by druid-io.
the class ConfigManager method start.
@LifecycleStart
public void start() {
synchronized (lock) {
if (started) {
return;
}
poller = new PollingCallable();
ScheduledExecutors.scheduleWithFixedDelay(exec, new Duration(0), config.get().getPollDuration().toStandardDuration(), poller);
started = true;
}
}
use of org.joda.time.Duration in project druid by druid-io.
the class KillSupervisorsTest method testConstructorFailIfInvalidPeriod.
@Test
public void testConstructorFailIfInvalidPeriod() {
TestDruidCoordinatorConfig druidCoordinatorConfig = new TestDruidCoordinatorConfig(null, null, null, new Duration("PT5S"), null, null, null, new Duration("PT3S"), new Duration("PT1S"), null, null, null, null, null, null, null, 10, null);
exception.expect(IllegalArgumentException.class);
exception.expectMessage("Coordinator supervisor kill period must be >= druid.coordinator.period.metadataStoreManagementPeriod");
killSupervisors = new KillSupervisors(druidCoordinatorConfig, mockMetadataSupervisorManager);
}
use of org.joda.time.Duration in project druid by druid-io.
the class KillDatasourceMetadataTest method testRunNotSkipIfLastRunMoreThanPeriod.
@Test
public void testRunNotSkipIfLastRunMoreThanPeriod() {
Mockito.when(mockDruidCoordinatorRuntimeParams.getEmitter()).thenReturn(mockServiceEmitter);
TestDruidCoordinatorConfig druidCoordinatorConfig = new TestDruidCoordinatorConfig(null, null, null, new Duration("PT5S"), null, null, null, null, null, null, null, null, null, null, new Duration("PT6S"), new Duration("PT1S"), 10, null);
killDatasourceMetadata = new KillDatasourceMetadata(druidCoordinatorConfig, mockIndexerMetadataStorageCoordinator, mockMetadataSupervisorManager);
killDatasourceMetadata.run(mockDruidCoordinatorRuntimeParams);
Mockito.verify(mockIndexerMetadataStorageCoordinator).removeDataSourceMetadataOlderThan(ArgumentMatchers.anyLong(), ArgumentMatchers.anySet());
Mockito.verify(mockServiceEmitter).emit(ArgumentMatchers.any(ServiceEventBuilder.class));
}
Aggregations