Search in sources :

Example 1 with TransportKillJobsNodeAction

use of io.crate.executor.transport.kill.TransportKillJobsNodeAction in project crate by crate.

the class NodeDisconnectJobMonitorServiceTest method testOnParticipatingNodeDisconnectedKillsJob.

@Test
public void testOnParticipatingNodeDisconnectedKillsJob() throws Exception {
    JobContextService jobContextService = jobContextService();
    DiscoveryNode coordinator_node = new DiscoveryNode("coordinator_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
    DiscoveryNode data_node = new DiscoveryNode("data_node_id", DummyTransportAddress.INSTANCE, Version.CURRENT);
    DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().localNodeId("coordinator_node_id").put(coordinator_node).put(data_node).build();
    JobExecutionContext.Builder builder = jobContextService.newBuilder(UUID.randomUUID(), coordinator_node.getId(), Arrays.asList(coordinator_node.getId(), data_node.getId()));
    builder.addSubContext(new DummySubContext());
    jobContextService.createContext(builder);
    TransportKillJobsNodeAction killAction = mock(TransportKillJobsNodeAction.class);
    NodeDisconnectJobMonitorService monitorService = new NodeDisconnectJobMonitorService(Settings.EMPTY, mock(ThreadPool.class), jobContextService, mock(TransportService.class), killAction);
    monitorService.onNodeDisconnected(discoveryNodes.get("data_node_id"));
    verify(killAction, times(1)).broadcast(any(KillJobsRequest.class), any(ActionListener.class), eq(Arrays.asList(discoveryNodes.get("data_node_id").getId())));
}
Also used : TransportKillJobsNodeAction(io.crate.executor.transport.kill.TransportKillJobsNodeAction) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) DummySubContext(io.crate.jobs.DummySubContext) ActionListener(org.elasticsearch.action.ActionListener) TransportService(org.elasticsearch.transport.TransportService) KillJobsRequest(io.crate.executor.transport.kill.KillJobsRequest) ThreadPool(org.elasticsearch.threadpool.ThreadPool) JobExecutionContext(io.crate.jobs.JobExecutionContext) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) JobContextService(io.crate.jobs.JobContextService) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 2 with TransportKillJobsNodeAction

use of io.crate.executor.transport.kill.TransportKillJobsNodeAction in project crate by crate.

the class RemoteCollectorTest method setUp.

@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    UUID jobId = UUID.randomUUID();
    RoutedCollectPhase collectPhase = new RoutedCollectPhase(jobId, 0, "remoteCollect", new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of("remoteNode", ImmutableMap.of("dummyTable", Collections.singletonList(1)))), RowGranularity.DOC, Collections.<Symbol>singletonList(createReference("name", DataTypes.STRING)), Collections.<Projection>emptyList(), WhereClause.MATCH_ALL, DistributionInfo.DEFAULT_BROADCAST);
    transportJobAction = mock(TransportJobAction.class);
    transportKillJobsNodeAction = mock(TransportKillJobsNodeAction.class);
    consumer = new TestingBatchConsumer();
    JobsLogs jobsLogs = new JobsLogs(() -> true);
    JobContextService jobContextService = new JobContextService(Settings.EMPTY, new NoopClusterService(), jobsLogs);
    remoteCollector = new RemoteCollector(jobId, "localNode", "remoteNode", transportJobAction, transportKillJobsNodeAction, jobContextService, mock(RamAccountingContext.class), consumer, collectPhase);
}
Also used : TransportJobAction(io.crate.action.job.TransportJobAction) TransportKillJobsNodeAction(io.crate.executor.transport.kill.TransportKillJobsNodeAction) Routing(io.crate.metadata.Routing) TestingBatchConsumer(io.crate.testing.TestingBatchConsumer) JobsLogs(io.crate.operation.collect.stats.JobsLogs) UUID(java.util.UUID) Map(java.util.Map) ImmutableMap(com.google.common.collect.ImmutableMap) NoopClusterService(org.elasticsearch.test.cluster.NoopClusterService) RoutedCollectPhase(io.crate.planner.node.dql.RoutedCollectPhase) JobContextService(io.crate.jobs.JobContextService) Before(org.junit.Before)

Aggregations

TransportKillJobsNodeAction (io.crate.executor.transport.kill.TransportKillJobsNodeAction)2 JobContextService (io.crate.jobs.JobContextService)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 TransportJobAction (io.crate.action.job.TransportJobAction)1 KillJobsRequest (io.crate.executor.transport.kill.KillJobsRequest)1 DummySubContext (io.crate.jobs.DummySubContext)1 JobExecutionContext (io.crate.jobs.JobExecutionContext)1 Routing (io.crate.metadata.Routing)1 JobsLogs (io.crate.operation.collect.stats.JobsLogs)1 RoutedCollectPhase (io.crate.planner.node.dql.RoutedCollectPhase)1 CrateUnitTest (io.crate.test.integration.CrateUnitTest)1 TestingBatchConsumer (io.crate.testing.TestingBatchConsumer)1 Map (java.util.Map)1 UUID (java.util.UUID)1 ActionListener (org.elasticsearch.action.ActionListener)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)1 NoopClusterService (org.elasticsearch.test.cluster.NoopClusterService)1 ThreadPool (org.elasticsearch.threadpool.ThreadPool)1 TransportService (org.elasticsearch.transport.TransportService)1