Search in sources :

Example 1 with TransportKillAllNodeAction

use of io.crate.execution.jobs.kill.TransportKillAllNodeAction in project crate by crate.

the class KillPlanTest method testKillTaskCallsBroadcastOnTransportKillAllNodeAction.

@Test
public void testKillTaskCallsBroadcastOnTransportKillAllNodeAction() {
    AtomicInteger broadcastCalls = new AtomicInteger(0);
    AtomicInteger nodeOperationCalls = new AtomicInteger(0);
    TransportKillAllNodeAction killAllNodeAction = new TransportKillAllNodeAction(new TasksService(clusterService, new JobsLogs(() -> false)), clusterService, mock(TransportService.class)) {

        @Override
        public void broadcast(KillAllRequest request, ActionListener<Long> listener) {
            broadcastCalls.incrementAndGet();
        }

        @Override
        public CompletableFuture<KillResponse> nodeOperation(KillAllRequest request) {
            nodeOperationCalls.incrementAndGet();
            return super.nodeOperation(request);
        }
    };
    KillPlan killPlan = new KillPlan(null);
    killPlan.execute(null, "dummy-user", killAllNodeAction, mock(TransportKillJobsNodeAction.class), new TestingRowConsumer());
    assertThat(broadcastCalls.get(), is(1));
    assertThat(nodeOperationCalls.get(), is(0));
}
Also used : TransportKillJobsNodeAction(io.crate.execution.jobs.kill.TransportKillJobsNodeAction) KillAllRequest(io.crate.execution.jobs.kill.KillAllRequest) ActionListener(org.elasticsearch.action.ActionListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TransportService(org.elasticsearch.transport.TransportService) TransportKillAllNodeAction(io.crate.execution.jobs.kill.TransportKillAllNodeAction) TasksService(io.crate.execution.jobs.TasksService) JobsLogs(io.crate.execution.engine.collect.stats.JobsLogs) KillResponse(io.crate.execution.jobs.kill.KillResponse) TestingRowConsumer(io.crate.testing.TestingRowConsumer) Test(org.junit.Test) CrateDummyClusterServiceUnitTest(io.crate.test.integration.CrateDummyClusterServiceUnitTest)

Aggregations

JobsLogs (io.crate.execution.engine.collect.stats.JobsLogs)1 TasksService (io.crate.execution.jobs.TasksService)1 KillAllRequest (io.crate.execution.jobs.kill.KillAllRequest)1 KillResponse (io.crate.execution.jobs.kill.KillResponse)1 TransportKillAllNodeAction (io.crate.execution.jobs.kill.TransportKillAllNodeAction)1 TransportKillJobsNodeAction (io.crate.execution.jobs.kill.TransportKillJobsNodeAction)1 CrateDummyClusterServiceUnitTest (io.crate.test.integration.CrateDummyClusterServiceUnitTest)1 TestingRowConsumer (io.crate.testing.TestingRowConsumer)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ActionListener (org.elasticsearch.action.ActionListener)1 TransportService (org.elasticsearch.transport.TransportService)1 Test (org.junit.Test)1