Search in sources :

Example 1 with KillResponse

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

the class NodeDisconnectJobMonitorService method onNodeDisconnected.

@Override
public void onNodeDisconnected(final DiscoveryNode node) {
    final Collection<UUID> contexts = jobContextService.getJobIdsByCoordinatorNode(node.getId()).collect(Collectors.toList());
    if (contexts.isEmpty()) {
        // Disconnected node is not a handler node --> kill jobs on all participated nodes
        contexts.addAll(jobContextService.getJobIdsByParticipatingNodes(node.getId()).collect(Collectors.toList()));
        KillJobsRequest killJobsRequest = new KillJobsRequest(contexts);
        if (!contexts.isEmpty()) {
            killJobsNodeAction.broadcast(killJobsRequest, new ActionListener<KillResponse>() {

                @Override
                public void onResponse(KillResponse killResponse) {
                }

                @Override
                public void onFailure(Throwable e) {
                    LOGGER.warn("failed to send kill request to nodes");
                }
            }, Arrays.asList(node.getId()));
        } else {
            return;
        }
    }
    threadPool.schedule(DELAY, ThreadPool.Names.GENERIC, () -> jobContextService.killJobs(contexts));
}
Also used : KillJobsRequest(io.crate.executor.transport.kill.KillJobsRequest) KillResponse(io.crate.executor.transport.kill.KillResponse)

Aggregations

KillJobsRequest (io.crate.executor.transport.kill.KillJobsRequest)1 KillResponse (io.crate.executor.transport.kill.KillResponse)1