@Override public void onFailure(Exception e) { List<FailedNodeException> failures = new ArrayList<>(nodes.length); for (final DiscoveryNode node: nodes) { failures.add(new FailedNodeException(node.getId(), "total failure in fetching", e)); } processAsyncFetch(null, failures, fetchingRound); } });
@Override public void handleException(TransportException exp) { errors.add(new VerificationFailure(node.getId(), exp)); if (counter.decrementAndGet() == 0) { finishVerification(listener, nodes, errors); } } });
@Override public void handleResponse(PreSyncedFlushResponse response) { PreSyncedFlushResponse existing = presyncResponses.putIfAbsent(node.getId(), response); assert existing == null : "got two answers for node [" + node + "]"; // count after the assert so we won't decrement twice in handleException if (countDown.countDown()) { listener.onResponse(presyncResponses); } }
/** master nodes go before other nodes, with a secondary sort by id **/ private static int compareNodes(DiscoveryNode o1, DiscoveryNode o2) { if (o1.isMasterNode() && !o2.isMasterNode()) { return -1; } if (!o1.isMasterNode() && o2.isMasterNode()) { return 1; } return o1.getId().compareTo(o2.getId()); } }
/** * Convenience constructor for building the TaskId out of what is usually at hand. */ public ParentTaskAssigningClient(Client in, DiscoveryNode localNode, Task parentTask) { this(in, new TaskId(localNode.getId(), parentTask.getId())); }
/** * Determine if a given node exists * * @param node of the node which existence should be verified * @return <code>true</code> if the node exists. Otherwise <code>false</code> */ public boolean nodeExists(DiscoveryNode node) { DiscoveryNode existing = nodes.get(node.getId()); return existing != null && existing.equals(node); }
@Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject("nodes"); for (NodeStats nodeStats : getNodes()) { builder.startObject(nodeStats.getNode().getId()); builder.field("timestamp", nodeStats.getTimestamp()); nodeStats.toXContent(builder, params); builder.endObject(); } builder.endObject(); return builder; }
public void sendExecuteDfs(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task, final SearchActionListener<DfsSearchResult> listener) { transportService.sendChildRequest(connection, DFS_ACTION_NAME, request, task, new ConnectionCountingHandler<>(listener, DfsSearchResult::new, clientConnections, connection.getNode().getId())); }
public void sendExecuteQuery(Transport.Connection connection, final QuerySearchRequest request, SearchTask task, final SearchActionListener<QuerySearchResult> listener) { transportService.sendChildRequest(connection, QUERY_ID_ACTION_NAME, request, task, new ConnectionCountingHandler<>(listener, QuerySearchResult::new, clientConnections, connection.getNode().getId())); }
public void sendExecuteScrollQuery(Transport.Connection connection, final InternalScrollSearchRequest request, SearchTask task, final SearchActionListener<ScrollQuerySearchResult> listener) { transportService.sendChildRequest(connection, QUERY_SCROLL_ACTION_NAME, request, task, new ConnectionCountingHandler<>(listener, ScrollQuerySearchResult::new, clientConnections, connection.getNode().getId())); }
public void sendExecuteQuery(Transport.Connection connection, final ShardSearchTransportRequest request, SearchTask task, final SearchActionListener<SearchPhaseResult> listener) { // we optimize this and expect a QueryFetchSearchResult if we only have a single shard in the search request // this used to be the QUERY_AND_FETCH which doesn't exist anymore. final boolean fetchDocuments = request.numberOfShards() == 1; Writeable.Reader<SearchPhaseResult> reader = fetchDocuments ? QueryFetchSearchResult::new : QuerySearchResult::new; final ActionListener handler = responseWrapper.apply(connection, listener); transportService.sendChildRequest(connection, QUERY_ACTION_NAME, request, task, new ConnectionCountingHandler<>(handler, reader, clientConnections, connection.getNode().getId())); }
private void sendExecuteFetch(Transport.Connection connection, String action, final ShardFetchRequest request, SearchTask task, final SearchActionListener<FetchSearchResult> listener) { transportService.sendChildRequest(connection, action, request, task, new ConnectionCountingHandler<>(listener, FetchSearchResult::new, clientConnections, connection.getNode().getId())); }
@Override protected void doExecute(Task thisTask, GetTaskRequest request, ActionListener<GetTaskResponse> listener) { if (clusterService.localNode().getId().equals(request.getTaskId().getNodeId())) { getRunningTaskFromNode(thisTask, request, listener); } else { runOnNodeWithTaskIfPossible(thisTask, request, listener); } }
@Override public void clusterChanged(ClusterChangedEvent event) { if (event.nodesRemoved()) { for (DiscoveryNode removedNode : event.nodesDelta().removedNodes()) { removeNode(removedNode.getId()); } } }
protected void shardExecute(Task task, Request request, ShardId shardId, ActionListener<ShardResponse> shardActionListener) { ShardRequest shardRequest = newShardRequest(request, shardId); shardRequest.setParentTask(clusterService.localNode().getId(), task.getId()); replicatedBroadcastShardAction.execute(shardRequest, shardActionListener); }
private void setBanOnNodes(String reason, CancellableTask task, DiscoveryNodes nodes, ActionListener<Void> listener) { sendSetBanRequest(nodes, BanParentTaskRequest.createSetBanParentTaskRequest(new TaskId(clusterService.localNode().getId(), task.getId()), reason), listener); }
/** * Used by {@link TransportSearchAction} to send the expand queries (field collapsing). */ void sendExecuteMultiSearch(final MultiSearchRequest request, SearchTask task, final ActionListener<MultiSearchResponse> listener) { final Transport.Connection connection = transportService.getConnection(transportService.getLocalNode()); transportService.sendChildRequest(connection, MultiSearchAction.NAME, request, task, new ConnectionCountingHandler<>(listener, MultiSearchResponse::new, clientConnections, connection.getNode().getId())); }
protected ClusterState createInitialState(DiscoveryNode localNode) { ClusterState.Builder builder = clusterApplier.newClusterStateBuilder(); return builder.nodes(DiscoveryNodes.builder().add(localNode) .localNodeId(localNode.getId()) .masterNodeId(localNode.getId()) .build()) .blocks(ClusterBlocks.builder() .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)) .build(); }
@Override protected void doRun() throws Exception { taskManager.waitForTaskCompletion(runningTask, waitForCompletionTimeout(request.getTimeout())); waitedForCompletion(thisTask, request, runningTask.taskInfo(clusterService.localNode().getId(), true), listener); }