Search in sources :

Example 66 with Duration

use of org.joda.time.Duration in project druid by druid-io.

the class DruidCoordinatorConfigTest method testDeserialization.

@Test
public void testDeserialization() {
    ConfigurationObjectFactory factory = Config.createFactory(new Properties());
    // with defaults
    DruidCoordinatorConfig config = factory.build(DruidCoordinatorConfig.class);
    Assert.assertEquals(new Duration("PT300s"), config.getCoordinatorStartDelay());
    Assert.assertEquals(new Duration("PT60s"), config.getCoordinatorPeriod());
    Assert.assertEquals(new Duration("PT1800s"), config.getCoordinatorIndexingPeriod());
    Assert.assertEquals(86400000, config.getCoordinatorKillPeriod().getMillis());
    Assert.assertEquals(7776000000L, config.getCoordinatorKillDurationToRetain().getMillis());
    Assert.assertEquals(100, config.getCoordinatorKillMaxSegments());
    Assert.assertEquals(new Duration(15 * 60 * 1000), config.getLoadTimeoutDelay());
    Assert.assertEquals(Duration.millis(50), config.getLoadQueuePeonRepeatDelay());
    Assert.assertTrue(config.getCompactionSkipLockedIntervals());
    // with non-defaults
    Properties props = new Properties();
    props.setProperty("druid.coordinator.startDelay", "PT1s");
    props.setProperty("druid.coordinator.period", "PT1s");
    props.setProperty("druid.coordinator.period.indexingPeriod", "PT1s");
    props.setProperty("druid.coordinator.kill.on", "true");
    props.setProperty("druid.coordinator.kill.period", "PT1s");
    props.setProperty("druid.coordinator.kill.durationToRetain", "PT1s");
    props.setProperty("druid.coordinator.kill.maxSegments", "10000");
    props.setProperty("druid.coordinator.kill.pendingSegments.on", "true");
    props.setProperty("druid.coordinator.load.timeout", "PT1s");
    props.setProperty("druid.coordinator.loadqueuepeon.repeatDelay", "PT0.100s");
    props.setProperty("druid.coordinator.compaction.skipLockedIntervals", "false");
    factory = Config.createFactory(props);
    config = factory.build(DruidCoordinatorConfig.class);
    Assert.assertEquals(new Duration("PT1s"), config.getCoordinatorStartDelay());
    Assert.assertEquals(new Duration("PT1s"), config.getCoordinatorPeriod());
    Assert.assertEquals(new Duration("PT1s"), config.getCoordinatorIndexingPeriod());
    Assert.assertEquals(new Duration("PT1s"), config.getCoordinatorKillPeriod());
    Assert.assertEquals(new Duration("PT1s"), config.getCoordinatorKillDurationToRetain());
    Assert.assertEquals(10000, config.getCoordinatorKillMaxSegments());
    Assert.assertEquals(new Duration("PT1s"), config.getLoadTimeoutDelay());
    Assert.assertEquals(Duration.millis(100), config.getLoadQueuePeonRepeatDelay());
    Assert.assertFalse(config.getCompactionSkipLockedIntervals());
}
Also used : ConfigurationObjectFactory(org.skife.config.ConfigurationObjectFactory) Duration(org.joda.time.Duration) Properties(java.util.Properties) Test(org.junit.Test)

Example 67 with Duration

use of org.joda.time.Duration in project druid by druid-io.

the class KillAuditLogTest method testConstructorFailIfInvalidPeriod.

@Test
public void testConstructorFailIfInvalidPeriod() {
    TestDruidCoordinatorConfig druidCoordinatorConfig = new TestDruidCoordinatorConfig(null, null, null, new Duration("PT5S"), null, null, null, null, null, new Duration("PT3S"), new Duration("PT1S"), null, null, null, null, null, 10, null);
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("coordinator audit kill period must be >= druid.coordinator.period.metadataStoreManagementPeriod");
    killAuditLog = new KillAuditLog(mockAuditManager, druidCoordinatorConfig);
}
Also used : TestDruidCoordinatorConfig(org.apache.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 68 with Duration

use of org.joda.time.Duration in project druid by druid-io.

the class KillAuditLogTest method testRunSkipIfLastRunLessThanPeriod.

@Test
public void testRunSkipIfLastRunLessThanPeriod() {
    TestDruidCoordinatorConfig druidCoordinatorConfig = new TestDruidCoordinatorConfig(null, null, null, new Duration("PT5S"), null, null, null, null, null, new Duration(Long.MAX_VALUE), new Duration("PT1S"), null, null, null, null, null, 10, null);
    killAuditLog = new KillAuditLog(mockAuditManager, druidCoordinatorConfig);
    killAuditLog.run(mockDruidCoordinatorRuntimeParams);
    Mockito.verifyNoInteractions(mockAuditManager);
}
Also used : TestDruidCoordinatorConfig(org.apache.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 69 with Duration

use of org.joda.time.Duration in project druid by druid-io.

the class KillDatasourceMetadataTest method testRunSkipIfLastRunLessThanPeriod.

@Test
public void testRunSkipIfLastRunLessThanPeriod() {
    TestDruidCoordinatorConfig druidCoordinatorConfig = new TestDruidCoordinatorConfig(null, null, null, new Duration("PT5S"), null, null, null, null, null, null, null, null, null, null, new Duration(Long.MAX_VALUE), new Duration("PT1S"), 10, null);
    killDatasourceMetadata = new KillDatasourceMetadata(druidCoordinatorConfig, mockIndexerMetadataStorageCoordinator, mockMetadataSupervisorManager);
    killDatasourceMetadata.run(mockDruidCoordinatorRuntimeParams);
    Mockito.verifyNoInteractions(mockIndexerMetadataStorageCoordinator);
    Mockito.verifyNoInteractions(mockMetadataSupervisorManager);
}
Also used : TestDruidCoordinatorConfig(org.apache.druid.server.coordinator.TestDruidCoordinatorConfig) Duration(org.joda.time.Duration) Test(org.junit.Test)

Example 70 with Duration

use of org.joda.time.Duration in project druid by druid-io.

the class KillDatasourceMetadataTest method testConstructorFailIfInvalidRetainDuration.

@Test
public void testConstructorFailIfInvalidRetainDuration() {
    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("PT-1S"), 10, null);
    exception.expect(IllegalArgumentException.class);
    exception.expectMessage("Coordinator datasource metadata kill retainDuration must be >= 0");
    killDatasourceMetadata = new KillDatasourceMetadata(druidCoordinatorConfig, mockIndexerMetadataStorageCoordinator, mockMetadataSupervisorManager);
}
Also used : 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