use of org.apache.druid.indexing.overlord.TaskRunnerListener in project druid by druid-io.
the class HttpRemoteTaskRunnerTest method createTaskRunnerForTestTaskAddedOrUpdated.
private HttpRemoteTaskRunner createTaskRunnerForTestTaskAddedOrUpdated(TaskStorage taskStorage, List<Object> listenerNotificationsAccumulator) {
TestDruidNodeDiscovery druidNodeDiscovery = new TestDruidNodeDiscovery();
DruidNodeDiscoveryProvider druidNodeDiscoveryProvider = EasyMock.createMock(DruidNodeDiscoveryProvider.class);
EasyMock.expect(druidNodeDiscoveryProvider.getForService(WorkerNodeService.DISCOVERY_SERVICE_KEY)).andReturn(druidNodeDiscovery);
EasyMock.replay(druidNodeDiscoveryProvider);
HttpRemoteTaskRunner taskRunner = new HttpRemoteTaskRunner(TestHelper.makeJsonMapper(), new HttpRemoteTaskRunnerConfig() {
@Override
public int getPendingTasksRunnerNumThreads() {
return 3;
}
}, EasyMock.createNiceMock(HttpClient.class), DSuppliers.of(new AtomicReference<>(DefaultWorkerBehaviorConfig.defaultConfig())), new NoopProvisioningStrategy<>(), druidNodeDiscoveryProvider, taskStorage, EasyMock.createNiceMock(CuratorFramework.class), new IndexerZkConfig(new ZkPathsConfig(), null, null, null, null));
taskRunner.start();
if (listenerNotificationsAccumulator != null) {
taskRunner.registerListener(new TaskRunnerListener() {
@Override
public String getListenerId() {
return "test-listener";
}
@Override
public void locationChanged(String taskId, TaskLocation newLocation) {
listenerNotificationsAccumulator.add(ImmutableList.of(taskId, newLocation));
}
@Override
public void statusChanged(String taskId, TaskStatus status) {
listenerNotificationsAccumulator.add(ImmutableList.of(taskId, status));
}
}, Execs.directExecutor());
}
return taskRunner;
}
use of org.apache.druid.indexing.overlord.TaskRunnerListener in project druid by druid-io.
the class SeekableStreamSupervisor method possiblyRegisterListener.
private void possiblyRegisterListener() {
if (listenerRegistered) {
return;
}
Optional<TaskRunner> taskRunner = taskMaster.getTaskRunner();
if (taskRunner.isPresent()) {
taskRunner.get().registerListener(new TaskRunnerListener() {
@Override
public String getListenerId() {
return supervisorId;
}
@Override
public void locationChanged(final String taskId, final TaskLocation newLocation) {
// do nothing
}
@Override
public void statusChanged(String taskId, TaskStatus status) {
addNotice(new RunNotice());
}
}, Execs.directExecutor());
listenerRegistered = true;
}
}
Aggregations