use of io.crate.execution.jobs.kill.TransportKillJobsNodeAction in project crate by crate.
the class TransportDistributedResultActionTest method testKillIsInvokedIfContextIsNotFound.
@Test
public void testKillIsInvokedIfContextIsNotFound() throws Exception {
TasksService tasksService = new TasksService(clusterService, new JobsLogs(() -> false));
AtomicInteger numBroadcasts = new AtomicInteger(0);
TransportKillJobsNodeAction killJobsAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {
@Override
public void broadcast(KillJobsRequest request, ActionListener<Long> listener, Collection<String> excludedNodeIds) {
numBroadcasts.incrementAndGet();
}
};
TransportDistributedResultAction transportDistributedResultAction = new TransportDistributedResultAction(mock(Transports.class), tasksService, THREAD_POOL, mock(TransportService.class), clusterService, killJobsAction, BackoffPolicy.exponentialBackoff(TimeValue.ZERO, 0));
StreamBucket.Builder builder = new StreamBucket.Builder(new Streamer[0], RamAccounting.NO_ACCOUNTING);
try {
transportDistributedResultAction.nodeOperation(new DistributedResultRequest(UUID.randomUUID(), 0, (byte) 0, 0, builder.build(), true)).get(5, TimeUnit.SECONDS);
fail("nodeOperation call should fail with TaskMissing");
} catch (ExecutionException e) {
assertThat(e.getCause(), Matchers.instanceOf(TaskMissing.class));
}
assertThat(numBroadcasts.get(), is(1));
}
use of io.crate.execution.jobs.kill.TransportKillJobsNodeAction in project crate by crate.
the class RemoteCollectorTest method prepare.
@Before
public void prepare() {
MockitoAnnotations.initMocks(this);
UUID jobId = UUID.randomUUID();
RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(Map.of("remoteNode", Map.of("dummyTable", IntArrayList.from(1)))), RowGranularity.DOC, Collections.singletonList(createReference("name", DataTypes.STRING)), Collections.emptyList(), WhereClause.MATCH_ALL.queryOrFallback(), DistributionInfo.DEFAULT_BROADCAST);
transportJobAction = mock(TransportJobAction.class);
TasksService tasksService = new TasksService(clusterService, new JobsLogs(() -> true));
numBroadcastCalls = new AtomicInteger(0);
transportKillJobsNodeAction = new TransportKillJobsNodeAction(tasksService, clusterService, mock(TransportService.class)) {
@Override
public void broadcast(KillJobsRequest request, ActionListener<Long> listener) {
numBroadcastCalls.incrementAndGet();
}
};
consumer = new TestingRowConsumer();
remoteCollector = new RemoteCollector(jobId, new SessionSettings("dummyUser", SearchPath.createSearchPathFrom("dummySchema")), "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, Runnable::run, tasksService, RamAccounting.NO_ACCOUNTING, consumer, collectPhase);
}
use of io.crate.execution.jobs.kill.TransportKillJobsNodeAction 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();
}
Aggregations