use of org.apache.druid.indexing.overlord.supervisor.Supervisor in project druid by druid-io.
the class OverlordSecurityResourceFilterTest method setUp.
@Before
public void setUp() {
if (resourceFilter instanceof TaskResourceFilter && !mockedOnceTsqa) {
// Since we are creating the mocked tsqa object only once and getting that object from Guice here therefore
// if the mockedOnce check is not done then we will call EasyMock.expect and EasyMock.replay on the mocked object
// multiple times and it will throw exceptions
tsqa = injector.getInstance(TaskStorageQueryAdapter.class);
EasyMock.expect(tsqa.getTask(EasyMock.anyString())).andReturn(Optional.of(noopTask)).anyTimes();
EasyMock.replay(tsqa);
mockedOnceTsqa = true;
}
if (resourceFilter instanceof SupervisorResourceFilter && !mockedOnceSM) {
supervisorManager = injector.getInstance(SupervisorManager.class);
SupervisorSpec supervisorSpec = new SupervisorSpec() {
@Override
public String getId() {
return "id";
}
@Override
public Supervisor createSupervisor() {
return null;
}
@Override
public SupervisorTaskAutoScaler createAutoscaler(Supervisor supervisor) {
return new NoopTaskAutoScaler();
}
@Override
public List<String> getDataSources() {
return ImmutableList.of("test");
}
@Override
public SupervisorSpec createSuspendedSpec() {
return null;
}
@Override
public SupervisorSpec createRunningSpec() {
return null;
}
@Override
public boolean isSuspended() {
return false;
}
@Override
public String getType() {
return null;
}
@Override
public String getSource() {
return null;
}
};
EasyMock.expect(supervisorManager.getSupervisorSpec(EasyMock.anyString())).andReturn(Optional.of(supervisorSpec)).anyTimes();
EasyMock.replay(supervisorManager);
mockedOnceSM = true;
}
setUp(resourceFilter);
}
use of org.apache.druid.indexing.overlord.supervisor.Supervisor in project druid by druid-io.
the class NoopSupervisorSpecTest method testNoopSupervisorSpecWithAutoscaler.
@Test
public void testNoopSupervisorSpecWithAutoscaler() {
Exception e = null;
try {
NoopSupervisorSpec noopSupervisorSpec = new NoopSupervisorSpec(null, Collections.singletonList("datasource1"));
Supervisor supervisor = noopSupervisorSpec.createSupervisor();
SupervisorTaskAutoScaler autoscaler = noopSupervisorSpec.createAutoscaler(supervisor);
Assert.assertNull(autoscaler);
Callable<Integer> noop = new Callable<Integer>() {
@Override
public Integer call() {
return -1;
}
};
int count = supervisor.getActiveTaskGroupsCount();
Assert.assertEquals(count, -1);
LagStats lagStats = supervisor.computeLagStats();
long totalLag = lagStats.getTotalLag();
long avgLag = lagStats.getAvgLag();
long maxLag = lagStats.getMaxLag();
Assert.assertEquals(totalLag, 0);
Assert.assertEquals(avgLag, 0);
Assert.assertEquals(maxLag, 0);
} catch (Exception ex) {
e = ex;
}
Assert.assertNull(e);
}
use of org.apache.druid.indexing.overlord.supervisor.Supervisor in project druid by druid-io.
the class MaterializedViewSupervisorSpecTest method testMaterializedViewSupervisorSpecCreated.
@Test
public void testMaterializedViewSupervisorSpecCreated() {
Exception ex = null;
try {
MaterializedViewSupervisorSpec spec = new MaterializedViewSupervisorSpec("wikiticker", new DimensionsSpec(Lists.newArrayList(new StringDimensionSchema("isUnpatrolled"), new StringDimensionSchema("metroCode"), new StringDimensionSchema("namespace"), new StringDimensionSchema("page"), new StringDimensionSchema("regionIsoCode"), new StringDimensionSchema("regionName"), new StringDimensionSchema("user"))), new AggregatorFactory[] { new CountAggregatorFactory("count"), new LongSumAggregatorFactory("added", "added") }, HadoopTuningConfig.makeDefaultTuningConfig(), null, null, null, null, null, false, objectMapper, null, null, null, null, null, new MaterializedViewTaskConfig(), EasyMock.createMock(AuthorizerMapper.class), new NoopChatHandlerProvider(), new SupervisorStateManagerConfig());
Supervisor supervisor = spec.createSupervisor();
Assert.assertTrue(supervisor instanceof MaterializedViewSupervisor);
SupervisorTaskAutoScaler autoscaler = spec.createAutoscaler(supervisor);
Assert.assertNull(autoscaler);
try {
supervisor.computeLagStats();
} catch (Exception e) {
Assert.assertTrue(e instanceof UnsupportedOperationException);
}
try {
int count = supervisor.getActiveTaskGroupsCount();
} catch (Exception e) {
Assert.assertTrue(e instanceof UnsupportedOperationException);
}
Callable<Integer> noop = new Callable<Integer>() {
@Override
public Integer call() {
return -1;
}
};
} catch (Exception e) {
ex = e;
}
Assert.assertNull(ex);
}
Aggregations