use of org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig in project druid by druid-io.
the class KinesisSupervisorTest method testKinesisIOConfigInitAndAutoscalerConfigCreation.
@Test
public void testKinesisIOConfigInitAndAutoscalerConfigCreation() {
// create KinesisSupervisorIOConfig with autoScalerConfig null
KinesisSupervisorIOConfig kinesisSupervisorIOConfigWithNullAutoScalerConfig = new KinesisSupervisorIOConfig(STREAM, INPUT_FORMAT, "awsEndpoint", null, 1, 1, new Period("PT30M"), new Period("P1D"), new Period("PT30S"), false, new Period("PT30M"), null, null, null, 100, 1000, null, null, null, false);
AutoScalerConfig autoscalerConfigNull = kinesisSupervisorIOConfigWithNullAutoScalerConfig.getAutoscalerConfig();
Assert.assertNull(autoscalerConfigNull);
// create KinesisSupervisorIOConfig with autoScalerConfig Empty
KinesisSupervisorIOConfig kinesisSupervisorIOConfigWithEmptyAutoScalerConfig = new KinesisSupervisorIOConfig(STREAM, INPUT_FORMAT, "awsEndpoint", null, 1, 1, new Period("PT30M"), new Period("P1D"), new Period("PT30S"), false, new Period("PT30M"), null, null, null, 100, 1000, null, null, OBJECT_MAPPER.convertValue(new HashMap<>(), AutoScalerConfig.class), false);
AutoScalerConfig autoscalerConfig = kinesisSupervisorIOConfigWithEmptyAutoScalerConfig.getAutoscalerConfig();
Assert.assertNotNull(autoscalerConfig);
Assert.assertTrue(autoscalerConfig instanceof LagBasedAutoScalerConfig);
Assert.assertFalse(autoscalerConfig.getEnableTaskAutoScaler());
Assert.assertTrue(autoscalerConfig.toString().contains("autoScalerConfig"));
}
use of org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig in project druid by druid-io.
the class SeekableStreamSupervisorSpecTest method testDefaultAutoScalerConfigCreatedWithDefault.
@Test
public void testDefaultAutoScalerConfigCreatedWithDefault() {
EasyMock.expect(ingestionSchema.getIOConfig()).andReturn(seekableStreamSupervisorIOConfig).anyTimes();
EasyMock.expect(ingestionSchema.getDataSchema()).andReturn(dataSchema).anyTimes();
EasyMock.expect(ingestionSchema.getTuningConfig()).andReturn(seekableStreamSupervisorTuningConfig).anyTimes();
EasyMock.replay(ingestionSchema);
EasyMock.expect(seekableStreamSupervisorIOConfig.getAutoscalerConfig()).andReturn(mapper.convertValue(ImmutableMap.of("lagCollectionIntervalMillis", "1", "enableTaskAutoScaler", true, "taskCountMax", "4", "taskCountMin", "1"), AutoScalerConfig.class)).anyTimes();
EasyMock.replay(seekableStreamSupervisorIOConfig);
EasyMock.expect(supervisor4.getActiveTaskGroupsCount()).andReturn(0).anyTimes();
EasyMock.replay(supervisor4);
TestSeekableStreamSupervisorSpec spec = new TestSeekableStreamSupervisorSpec(ingestionSchema, null, false, taskStorage, taskMaster, indexerMetadataStorageCoordinator, indexTaskClientFactory, mapper, emitter, monitorSchedulerConfig, rowIngestionMetersFactory, supervisorStateManagerConfig, supervisor4, "id1");
SupervisorTaskAutoScaler autoscaler = spec.createAutoscaler(supervisor4);
Assert.assertTrue(autoscaler instanceof LagBasedAutoScaler);
LagBasedAutoScaler lagBasedAutoScaler = (LagBasedAutoScaler) autoscaler;
LagBasedAutoScalerConfig lagBasedAutoScalerConfig = lagBasedAutoScaler.getAutoScalerConfig();
Assert.assertEquals(lagBasedAutoScalerConfig.getLagCollectionIntervalMillis(), 1);
Assert.assertEquals(lagBasedAutoScalerConfig.getLagCollectionRangeMillis(), 600000);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleActionStartDelayMillis(), 300000);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleActionPeriodMillis(), 60000);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleOutThreshold(), 6000000);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleInThreshold(), 1000000);
Assert.assertEquals(lagBasedAutoScalerConfig.getTaskCountMax(), 4);
Assert.assertEquals(lagBasedAutoScalerConfig.getTaskCountMin(), 1);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleInStep(), 1);
Assert.assertEquals(lagBasedAutoScalerConfig.getScaleOutStep(), 2);
Assert.assertEquals(lagBasedAutoScalerConfig.getMinTriggerScaleActionFrequencyMillis(), 600000);
}
use of org.apache.druid.indexing.seekablestream.supervisor.autoscaler.LagBasedAutoScalerConfig in project druid by druid-io.
the class SeekableStreamSupervisorSpecTest method testAutoScalerConfig.
@Test
public void testAutoScalerConfig() {
AutoScalerConfig autoScalerConfigEmpty = mapper.convertValue(new HashMap<>(), AutoScalerConfig.class);
Assert.assertTrue(autoScalerConfigEmpty instanceof LagBasedAutoScalerConfig);
Assert.assertFalse(autoScalerConfigEmpty.getEnableTaskAutoScaler());
AutoScalerConfig autoScalerConfigNull = mapper.convertValue(null, AutoScalerConfig.class);
Assert.assertNull(autoScalerConfigNull);
AutoScalerConfig autoScalerConfigDefault = mapper.convertValue(ImmutableMap.of("autoScalerStrategy", "lagBased"), AutoScalerConfig.class);
Assert.assertTrue(autoScalerConfigDefault instanceof LagBasedAutoScalerConfig);
AutoScalerConfig autoScalerConfigValue = mapper.convertValue(ImmutableMap.of("lagCollectionIntervalMillis", "1"), AutoScalerConfig.class);
Assert.assertTrue(autoScalerConfigValue instanceof LagBasedAutoScalerConfig);
LagBasedAutoScalerConfig lagBasedAutoScalerConfig = (LagBasedAutoScalerConfig) autoScalerConfigValue;
Assert.assertEquals(lagBasedAutoScalerConfig.getLagCollectionIntervalMillis(), 1);
Exception e = null;
try {
AutoScalerConfig autoScalerError = mapper.convertValue(ImmutableMap.of("enableTaskAutoScaler", "true", "taskCountMax", "1", "taskCountMin", "4"), AutoScalerConfig.class);
} catch (RuntimeException ex) {
e = ex;
}
Assert.assertNotNull(e);
e = null;
try {
// taskCountMax and taskCountMin couldn't be ignored.
AutoScalerConfig autoScalerError2 = mapper.convertValue(ImmutableMap.of("enableTaskAutoScaler", "true"), AutoScalerConfig.class);
} catch (RuntimeException ex) {
e = ex;
}
Assert.assertNotNull(e);
}
Aggregations