CountedCollector(Consumer<R> resultConsumer, int expectedOps, Runnable onFinish, SearchPhaseContext context) { this.resultConsumer = resultConsumer; this.counter = new CountDown(expectedOps); this.onFinish = onFinish; this.context = context; }
private ChannelsConnectedListener(DiscoveryNode node, ConnectionProfile connectionProfile, List<TcpChannel> channels, ActionListener<Transport.Connection> listener) { this.node = node; this.connectionProfile = connectionProfile; this.channels = channels; this.listener = listener; this.countDown = new CountDown(channels.size()); }
AsyncShardStoresInfoFetches(DiscoveryNodes nodes, RoutingNodes routingNodes, Set<ShardId> shardIds, ActionListener<IndicesShardStoresResponse> listener) { this.nodes = nodes; this.routingNodes = routingNodes; this.shardIds = shardIds; this.listener = listener; this.fetchResponses = new ConcurrentLinkedQueue<>(); this.expectedOps = new CountDown(shardIds.size()); }
/** * Creates a new listener * @param delegate the delegate listener * @param groupSize the group size */ public GroupedActionListener(ActionListener<Collection<T>> delegate, int groupSize, Collection<T> defaults) { results = new AtomicArray<>(groupSize); countDown = new CountDown(groupSize); this.delegate = delegate; this.defaults = defaults; }
listener.onResponse(null); } else { CountDown countDown = new CountDown(asyncActions.size()); ActionListener<?> internalListener = new ActionListener() { @Override
CountDown countDown = new CountDown(clusters.size()); Function<String, DiscoveryNode> nullFunction = s -> null; for (final String cluster : clusters) {
AckCountDownListener(AckedClusterStateTaskListener ackedTaskListener, long clusterStateVersion, DiscoveryNodes nodes, ThreadPool threadPool) { this.ackedTaskListener = ackedTaskListener; this.clusterStateVersion = clusterStateVersion; this.threadPool = threadPool; this.masterNode = nodes.getMasterNode(); int countDown = 0; for (DiscoveryNode node : nodes) { //we always wait for at least the master node if (node.equals(masterNode) || ackedTaskListener.mustAck(node)) { countDown++; } } logger.trace("expecting {} acknowledgements for cluster_state update (version: {})", countDown, clusterStateVersion); this.countDown = new CountDown(countDown + 1); // we also wait for onCommit to be called }
ClearScrollController(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener, DiscoveryNodes nodes, Logger logger, SearchTransportService searchTransportService) { this.nodes = nodes; this.logger = logger; this.searchTransportService = searchTransportService; this.listener = listener; List<String> scrollIds = request.getScrollIds(); final int expectedOps; if (scrollIds.size() == 1 && "_all".equals(scrollIds.get(0))) { expectedOps = nodes.getSize(); runner = this::cleanAllScrolls; } else { List<ScrollIdForNode> parsedScrollIds = new ArrayList<>(); for (String parsedScrollId : request.getScrollIds()) { ScrollIdForNode[] context = parseScrollId(parsedScrollId).getContext(); for (ScrollIdForNode id : context) { parsedScrollIds.add(id); } } if (parsedScrollIds.isEmpty()) { expectedOps = 0; runner = () -> listener.onResponse(new ClearScrollResponse(true, 0)); } else { expectedOps = parsedScrollIds.size(); runner = () -> cleanScrollIds(parsedScrollIds); } } this.expectedOps = new CountDown(expectedOps); }
finishAndNotifyListener(listener, shardsResponses); final CountDown responsesCountDown = new CountDown(shards.size()); for (final ShardId shardId : shards) { ActionListener<ShardResponse> shardActionListener = new ActionListener<ShardResponse>() {
connectionListener.onResponse(null); } else { CountDown countDown = new CountDown(seeds.size()); remoteClusters.putAll(this.remoteClusters); for (Map.Entry<String, Tuple<String, List<Tuple<String, Supplier<DiscoveryNode>>>>> entry : seeds.entrySet()) {
public void collectSearchShards(IndicesOptions indicesOptions, String preference, String routing, Map<String, OriginalIndices> remoteIndicesByCluster, ActionListener<Map<String, ClusterSearchShardsResponse>> listener) { final CountDown responsesCountDown = new CountDown(remoteIndicesByCluster.size()); final Map<String, ClusterSearchShardsResponse> searchShardsResponses = new ConcurrentHashMap<>(); final AtomicReference<RemoteTransportException> transportException = new AtomicReference<>();
final int totalShards, final ActionListener<ShardsSyncedFlushResult> listener) { final CountDown countDown = new CountDown(shards.size()); final Map<ShardRouting, ShardSyncedFlushResponse> results = ConcurrentCollections.newConcurrentMap(); final int numDocsOnPrimary = numDocsOnPrimary(shards, preSyncResponses);
final ShardId shardId, final ActionListener<Map<String, PreSyncedFlushResponse>> listener) { final CountDown countDown = new CountDown(shards.size()); final ConcurrentMap<String, PreSyncedFlushResponse> presyncResponses = ConcurrentCollections.newConcurrentMap(); for (final ShardRouting shard : shards) {
final CountDown completionCounter = new CountDown(totalNumRequest); final List<FieldCapabilitiesIndexResponse> indexResponses = Collections.synchronizedList(new ArrayList<>()); final Runnable onResponse = () -> {
private void run(BiFunction<String, String, DiscoveryNode> clusterNodeLookup, final ScrollIdForNode[] context) { final CountDown counter = new CountDown(scrollId.getContext().length); for (int i = 0; i < context.length; i++) { ScrollIdForNode target = context[i];
return; final CountDown countDown = new CountDown(numberOfShards);
AsyncShardStoresInfoFetches(DiscoveryNodes nodes, RoutingNodes routingNodes, Set<ShardId> shardIds, ActionListener<IndicesShardStoresResponse> listener) { this.nodes = nodes; this.routingNodes = routingNodes; this.shardIds = shardIds; this.listener = listener; this.fetchResponses = new ConcurrentLinkedQueue<>(); this.expectedOps = new CountDown(shardIds.size()); }
AsyncShardStoresInfoFetches(DiscoveryNodes nodes, RoutingNodes routingNodes, Set<ShardId> shardIds, ActionListener<IndicesShardStoresResponse> listener) { this.nodes = nodes; this.routingNodes = routingNodes; this.shardIds = shardIds; this.listener = listener; this.fetchResponses = new ConcurrentLinkedQueue<>(); this.expectedOps = new CountDown(shardIds.size()); }
/** * Creates a new listener * @param delegate the delegate listener * @param groupSize the group size */ public GroupedActionListener(ActionListener<Collection<T>> delegate, int groupSize, Collection<T> defaults) { results = new AtomicArray<>(groupSize); countDown = new CountDown(groupSize); this.delegate = delegate; this.defaults = defaults; }
final ScoreDoc[] lastEmittedDocPerShard = searchPhaseController.getLastEmittedDocPerShard(reducedQueryPhase, queryResults.length()); final CountDown counter = new CountDown(docIdsToLoad.length); for (int i = 0; i < docIdsToLoad.length; i++) { final int index = i;