use of io.crate.execution.jobs.DummyTask in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnParticipatingNodeDisconnectedKillsJob.
@Test
public void testOnParticipatingNodeDisconnectedKillsJob() throws Exception {
TasksService tasksService = tasksInstance();
DiscoveryNode coordinator = newNode("coordinator");
DiscoveryNode dataNode = newNode("dataNode");
RootTask.Builder builder = tasksService.newBuilder(UUID.randomUUID(), "dummy-user", coordinator.getId(), Arrays.asList(coordinator.getId(), dataNode.getId()));
builder.addTask(new DummyTask());
tasksService.createTask(builder);
// add a second job that is coordinated by the other node to make sure the the broadcast logic is run
// even though there are jobs coordinated by the disconnected node
builder = tasksService.newBuilder(UUID.randomUUID(), "dummy-user", dataNode.getId(), Collections.emptySet());
builder.addTask(new DummyTask());
tasksService.createTask(builder);
AtomicInteger broadcasts = new AtomicInteger(0);
TransportKillJobsNodeAction killAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {
@Override
public void broadcast(KillJobsRequest request, ActionListener<Long> listener, Collection<String> excludedNodeIds) {
broadcasts.incrementAndGet();
}
};
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(tasksService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), mock(TransportService.class), killAction);
monitorService.onNodeDisconnected(dataNode, mock(Transport.Connection.class));
assertThat(broadcasts.get(), is(1));
monitorService.close();
}
use of io.crate.execution.jobs.DummyTask in project crate by crate.
the class NodeDisconnectJobMonitorServiceTest method testOnNodeDisconnectedKillsJobOriginatingFromThatNode.
@Test
public void testOnNodeDisconnectedKillsJobOriginatingFromThatNode() throws Exception {
TasksService tasksService = tasksInstance();
RootTask.Builder builder = tasksService.newBuilder(UUID.randomUUID());
builder.addTask(new DummyTask());
RootTask context = tasksService.createTask(builder);
NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(tasksService, new NodeLimits(new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS)), mock(TransportService.class), mock(TransportKillJobsNodeAction.class));
monitorService.onNodeDisconnected(new DiscoveryNode(NODE_ID, buildNewFakeTransportAddress(), Version.CURRENT), mock(Transport.Connection.class));
expectedException.expect(TaskMissing.class);
tasksService.getTask(context.jobId());
monitorService.close();
}
Aggregations