Search in sources :

Example 6 with DefaultWorkerBehaviorConfig

use of org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig in project druid by druid-io.

the class PendingTaskBasedProvisioningStrategyTest method testFailIfMinWorkerIsZeroAndWorkerHintNotSet.

@Test
public void testFailIfMinWorkerIsZeroAndWorkerHintNotSet() {
    EmittingLogger mockLogger = EasyMock.createMock(EmittingLogger.class);
    Capture<String> capturedArgument = Capture.newInstance();
    mockLogger.error(EasyMock.capture(capturedArgument), EasyMock.anyInt());
    PendingTaskBasedWorkerProvisioningConfig config = new PendingTaskBasedWorkerProvisioningConfig().setMaxScalingDuration(new Period(1000)).setNumEventsToTrack(10).setPendingTaskTimeout(new Period(0)).setWorkerVersion(MIN_VERSION).setMaxScalingStep(2);
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
    EasyMock.replay(autoScaler, mockLogger);
    DefaultWorkerBehaviorConfig defaultWorkerBehaviorConfig = PendingTaskBasedWorkerProvisioningStrategy.getDefaultWorkerBehaviorConfig(DSuppliers.of(workerConfig), config, "test", mockLogger);
    Assert.assertNull(defaultWorkerBehaviorConfig);
    Assert.assertEquals(PendingTaskBasedWorkerProvisioningStrategy.ERROR_MESSAGE_MIN_WORKER_ZERO_HINT_UNSET, capturedArgument.getValue());
}
Also used : EmittingLogger(org.apache.druid.java.util.emitter.EmittingLogger) DefaultWorkerBehaviorConfig(org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig) Period(org.joda.time.Period) Test(org.junit.Test)

Example 7 with DefaultWorkerBehaviorConfig

use of org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig in project druid by druid-io.

the class PendingTaskBasedProvisioningStrategyTest method setUp.

@Before
public void setUp() {
    autoScaler = EasyMock.createMock(AutoScaler.class);
    testTask = TestTasks.immediateSuccess("task1");
    config = new PendingTaskBasedWorkerProvisioningConfig().setMaxScalingDuration(new Period(1000)).setNumEventsToTrack(10).setPendingTaskTimeout(new Period(0)).setWorkerVersion(MIN_VERSION).setMaxScalingStep(2);
    workerConfig = new AtomicReference<>(new DefaultWorkerBehaviorConfig(new FillCapacityWorkerSelectStrategy(null), autoScaler));
    strategy = new PendingTaskBasedWorkerProvisioningStrategy(config, DSuppliers.of(workerConfig), new ProvisioningSchedulerConfig(), new Supplier<ScheduledExecutorService>() {

        @Override
        public ScheduledExecutorService get() {
            return executorService;
        }
    });
}
Also used : FillCapacityWorkerSelectStrategy(org.apache.druid.indexing.overlord.setup.FillCapacityWorkerSelectStrategy) DefaultWorkerBehaviorConfig(org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig) Period(org.joda.time.Period) Supplier(com.google.common.base.Supplier) Before(org.junit.Before)

Example 8 with DefaultWorkerBehaviorConfig

use of org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig in project druid by druid-io.

the class OverlordResourceTest method testGetTotalWorkerCapacityWithAutoScaleConfiguredAndProvisioningStrategyNotSupportExpectedWorkerCapacity.

@Test
public void testGetTotalWorkerCapacityWithAutoScaleConfiguredAndProvisioningStrategyNotSupportExpectedWorkerCapacity() {
    int invalidExpectedCapacity = -1;
    int maxNumWorkers = 2;
    WorkerTaskRunner workerTaskRunner = EasyMock.createMock(WorkerTaskRunner.class);
    Collection<ImmutableWorkerInfo> workerInfos = ImmutableList.of(new ImmutableWorkerInfo(new Worker("http", "testWorker", "192.0.0.1", 3, "v1", WorkerConfig.DEFAULT_CATEGORY), 2, ImmutableSet.of("grp1", "grp2"), ImmutableSet.of("task1", "task2"), DateTimes.of("2015-01-01T01:01:01Z")));
    EasyMock.expect(workerTaskRunner.getWorkers()).andReturn(workerInfos);
    EasyMock.reset(taskMaster);
    EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.of(workerTaskRunner)).anyTimes();
    EasyMock.expect(provisioningStrategy.getExpectedWorkerCapacity(workerInfos)).andReturn(invalidExpectedCapacity).anyTimes();
    AutoScaler autoScaler = EasyMock.createMock(AutoScaler.class);
    EasyMock.expect(autoScaler.getMinNumWorkers()).andReturn(0);
    EasyMock.expect(autoScaler.getMaxNumWorkers()).andReturn(maxNumWorkers);
    DefaultWorkerBehaviorConfig workerBehaviorConfig = new DefaultWorkerBehaviorConfig(null, autoScaler);
    AtomicReference<WorkerBehaviorConfig> workerBehaviorConfigAtomicReference = new AtomicReference<>(workerBehaviorConfig);
    EasyMock.expect(configManager.watch(WorkerBehaviorConfig.CONFIG_KEY, WorkerBehaviorConfig.class)).andReturn(workerBehaviorConfigAtomicReference);
    EasyMock.replay(workerTaskRunner, autoScaler, taskRunner, taskMaster, taskStorageQueryAdapter, indexerMetadataStorageAdapter, req, workerTaskRunnerQueryAdapter, configManager, provisioningStrategy);
    final Response response = overlordResource.getTotalWorkerCapacity();
    Assert.assertEquals(HttpResponseStatus.OK.getCode(), response.getStatus());
    Assert.assertEquals(workerInfos.stream().findFirst().get().getWorker().getCapacity(), ((TotalWorkerCapacityResponse) response.getEntity()).getCurrentClusterCapacity());
    Assert.assertEquals(invalidExpectedCapacity, ((TotalWorkerCapacityResponse) response.getEntity()).getMaximumCapacityWithAutoScale());
}
Also used : Response(javax.ws.rs.core.Response) WorkerBehaviorConfig(org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig) DefaultWorkerBehaviorConfig(org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig) WorkerTaskRunner(org.apache.druid.indexing.overlord.WorkerTaskRunner) DefaultWorkerBehaviorConfig(org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig) Worker(org.apache.druid.indexing.worker.Worker) AtomicReference(java.util.concurrent.atomic.AtomicReference) AutoScaler(org.apache.druid.indexing.overlord.autoscaling.AutoScaler) ImmutableWorkerInfo(org.apache.druid.indexing.overlord.ImmutableWorkerInfo) Test(org.junit.Test)

Aggregations

DefaultWorkerBehaviorConfig (org.apache.druid.indexing.overlord.setup.DefaultWorkerBehaviorConfig)8 WorkerBehaviorConfig (org.apache.druid.indexing.overlord.setup.WorkerBehaviorConfig)5 Test (org.junit.Test)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3 Response (javax.ws.rs.core.Response)3 ImmutableWorkerInfo (org.apache.druid.indexing.overlord.ImmutableWorkerInfo)3 WorkerTaskRunner (org.apache.druid.indexing.overlord.WorkerTaskRunner)3 Period (org.joda.time.Period)3 Supplier (com.google.common.base.Supplier)2 AutoScaler (org.apache.druid.indexing.overlord.autoscaling.AutoScaler)2 Worker (org.apache.druid.indexing.worker.Worker)2 Before (org.junit.Before)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ResourceFilters (com.sun.jersey.spi.container.ResourceFilters)1 Nullable (javax.annotation.Nullable)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 TaskRunner (org.apache.druid.indexing.overlord.TaskRunner)1 FillCapacityWorkerSelectStrategy (org.apache.druid.indexing.overlord.setup.FillCapacityWorkerSelectStrategy)1