Search in sources :

Example 1 with MultiActionListener

use of io.crate.executor.MultiActionListener in project crate by crate.

the class TransportKillNodeAction method broadcast.

public void broadcast(Request request, ActionListener<KillResponse> listener, Collection<String> excludedNodeIds) {
    Stream<DiscoveryNode> nodes = StreamSupport.stream(clusterService.state().nodes().spliterator(), false);
    Collection<DiscoveryNode> filteredNodes = nodes.filter(node -> !excludedNodeIds.contains(node.getId())).collect(Collectors.toList());
    listener = new MultiActionListener<>(filteredNodes.size(), KillResponse.MERGE_FUNCTION, listener);
    DefaultTransportResponseHandler<KillResponse> responseHandler = new DefaultTransportResponseHandler<KillResponse>(listener) {

        @Override
        public KillResponse newInstance() {
            return new KillResponse(0);
        }
    };
    for (DiscoveryNode node : filteredNodes) {
        transportService.sendRequest(node, name, request, responseHandler);
    }
}
Also used : java.util(java.util) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) AbstractComponent(org.elasticsearch.common.component.AbstractComponent) TransportRequest(org.elasticsearch.transport.TransportRequest) DefaultTransportResponseHandler(io.crate.executor.transport.DefaultTransportResponseHandler) Callable(java.util.concurrent.Callable) MultiActionListener(io.crate.executor.MultiActionListener) Collectors(java.util.stream.Collectors) FutureCallback(com.google.common.util.concurrent.FutureCallback) NodeActionRequestHandler(io.crate.executor.transport.NodeActionRequestHandler) Futures(com.google.common.util.concurrent.Futures) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings) Stream(java.util.stream.Stream) NodeAction(io.crate.executor.transport.NodeAction) ClusterService(org.elasticsearch.cluster.ClusterService) JobContextService(io.crate.jobs.JobContextService) ThreadPool(org.elasticsearch.threadpool.ThreadPool) StreamSupport(java.util.stream.StreamSupport) TransportService(org.elasticsearch.transport.TransportService) Nonnull(javax.annotation.Nonnull) ActionListener(org.elasticsearch.action.ActionListener) Nullable(javax.annotation.Nullable) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) DefaultTransportResponseHandler(io.crate.executor.transport.DefaultTransportResponseHandler)

Aggregations

FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 MultiActionListener (io.crate.executor.MultiActionListener)1 DefaultTransportResponseHandler (io.crate.executor.transport.DefaultTransportResponseHandler)1 NodeAction (io.crate.executor.transport.NodeAction)1 NodeActionRequestHandler (io.crate.executor.transport.NodeActionRequestHandler)1 JobContextService (io.crate.jobs.JobContextService)1 java.util (java.util)1 Callable (java.util.concurrent.Callable)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 StreamSupport (java.util.stream.StreamSupport)1 Nonnull (javax.annotation.Nonnull)1 Nullable (javax.annotation.Nullable)1 ActionListener (org.elasticsearch.action.ActionListener)1 ClusterService (org.elasticsearch.cluster.ClusterService)1 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)1 AbstractComponent (org.elasticsearch.common.component.AbstractComponent)1 Settings (org.elasticsearch.common.settings.Settings)1