Search in sources :

Example 61 with Duration

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();
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 62 with Duration

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.");
}
Also used : Duration(org.joda.time.Duration) LifecycleStart(org.apache.druid.java.util.common.lifecycle.LifecycleStart)

Example 63 with Duration

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;
    }
}
Also used : Duration(org.joda.time.Duration) LifecycleStart(org.apache.druid.java.util.common.lifecycle.LifecycleStart)

Example 64 with Duration

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);
}
Also used : TestDruidCoordinatorConfig(org.apache.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 65 with Duration

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));
}
Also used : ServiceEventBuilder(org.apache.druid.java.util.emitter.service.ServiceEventBuilder) TestDruidCoordinatorConfig(org.apache.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Test(org.junit.Test)

Aggregations

Duration (org.joda.time.Duration)272 Test (org.junit.Test)148 Instant (org.joda.time.Instant)66 DateTime (org.joda.time.DateTime)32 Period (org.joda.time.Period)27 IntervalWindow (org.apache.beam.sdk.transforms.windowing.IntervalWindow)24 TestDruidCoordinatorConfig (org.apache.druid.server.coordinator.TestDruidCoordinatorConfig)22 HashMap (java.util.HashMap)18 IOException (java.io.IOException)17 Category (org.junit.experimental.categories.Category)16 ArrayList (java.util.ArrayList)15 Map (java.util.Map)15 KV (org.apache.beam.sdk.values.KV)15 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 IndexSpec (org.apache.druid.segment.IndexSpec)12 Set (java.util.Set)10 GlobalWindows (org.apache.beam.sdk.transforms.windowing.GlobalWindows)10 DynamicPartitionsSpec (org.apache.druid.indexer.partitions.DynamicPartitionsSpec)10 Interval (org.joda.time.Interval)10 Request (com.metamx.http.client.Request)9