org.elasticsearch.common.util.concurrent.CountDown Java Examples
The following examples show how to use
org.elasticsearch.common.util.concurrent.CountDown.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InternalClusterService.java From Elasticsearch with Apache License 2.0 | 6 votes |
AckCountDownListener(AckedClusterStateTaskListener ackedTaskListener, long clusterStateVersion, DiscoveryNodes nodes, ThreadPool threadPool) { this.ackedTaskListener = ackedTaskListener; this.clusterStateVersion = clusterStateVersion; this.nodes = nodes; int countDown = 0; for (DiscoveryNode node : nodes) { if (ackedTaskListener.mustAck(node)) { countDown++; } } //we always wait for at least 1 node (the master) countDown = Math.max(1, countDown); logger.trace("expecting {} acknowledgements for cluster_state update (version: {})", countDown, clusterStateVersion); this.countDown = new CountDown(countDown); this.ackTimeoutCallback = threadPool.schedule(ackedTaskListener.ackTimeout(), ThreadPool.Names.GENERIC, new Runnable() { @Override public void run() { onTimeout(); } }); }
Example #2
Source File: TransportClearScrollAction.java From Elasticsearch with Apache License 2.0 | 6 votes |
private Async(ClearScrollRequest request, ActionListener<ClearScrollResponse> listener, ClusterState clusterState) { int expectedOps = 0; this.nodes = clusterState.nodes(); if (request.getScrollIds().size() == 1 && "_all".equals(request.getScrollIds().get(0))) { expectedOps = nodes.size(); } else { for (String parsedScrollId : request.getScrollIds()) { ScrollIdForNode[] context = parseScrollId(parsedScrollId).getContext(); expectedOps += context.length; this.contexts.add(context); } } this.request = request; this.listener = listener; this.expHolder = new AtomicReference<>(); this.expectedOps = new CountDown(expectedOps); }
Example #3
Source File: MasterService.java From crate with Apache License 2.0 | 6 votes |
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 }
Example #4
Source File: SyncedFlushService.java From Elasticsearch with Apache License 2.0 | 5 votes |
private void contDownAndSendResponseIfDone(String syncId, List<ShardRouting> shards, ShardId shardId, int totalShards, ActionListener<ShardsSyncedFlushResult> listener, CountDown countDown, Map<ShardRouting, ShardSyncedFlushResponse> results) { if (countDown.countDown()) { assert results.size() == shards.size(); listener.onResponse(new ShardsSyncedFlushResult(shardId, syncId, totalShards, results)); } }
Example #5
Source File: TransportIndicesShardStoresAction.java From Elasticsearch with Apache License 2.0 | 5 votes |
AsyncShardStoresInfoFetches(DiscoveryNodes nodes, RoutingNodes routingNodes, MetaData metaData, Set<ShardId> shardIds, ActionListener<IndicesShardStoresResponse> listener) { this.nodes = nodes; this.routingNodes = routingNodes; this.metaData = metaData; this.shardIds = shardIds; this.listener = listener; this.fetchResponses = new ConcurrentLinkedQueue<>(); this.expectedOps = new CountDown(shardIds.size()); }
Example #6
Source File: SyncedFlushService.java From crate with Apache License 2.0 | 5 votes |
private void countDownAndSendResponseIfDone(String syncId, List<ShardRouting> shards, ShardId shardId, int totalShards, ActionListener<ShardsSyncedFlushResult> listener, CountDown countDown, Map<ShardRouting, ShardSyncedFlushResponse> results) { if (countDown.countDown()) { assert results.size() == shards.size(); listener.onResponse(new ShardsSyncedFlushResult(shardId, syncId, totalShards, results)); } }
Example #7
Source File: GroupedActionListener.java From crate with Apache License 2.0 | 5 votes |
/** * Creates a new listener * @param delegate the delegate listener * @param groupSize the group size */ public GroupedActionListener(ActionListener<Collection<T>> delegate, int groupSize) { if (groupSize <= 0) { throw new IllegalArgumentException("groupSize must be greater than 0 but was " + groupSize); } results = new AtomicArray<>(groupSize); countDown = new CountDown(groupSize); this.delegate = delegate; }