public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; }
@Override public final <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute( Action<Request, Response, RequestBuilder> action, Request request) { PlainActionFuture<Response> actionFuture = PlainActionFuture.newFuture(); execute(action, request, actionFuture); return actionFuture; }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future); return future; }
/** * Closes the channels. * * @param channels to close * @param blocking indicates if we should block on channel close */ static <C extends CloseableChannel> void closeChannels(List<C> channels, boolean blocking) { try { IOUtils.close(channels); } catch (IOException e) { // The CloseableChannel#close method does not throw IOException, so this should not occur. throw new AssertionError(e); } if (blocking) { ArrayList<ActionFuture<Void>> futures = new ArrayList<>(channels.size()); for (final C channel : channels) { PlainActionFuture<Void> closeFuture = PlainActionFuture.newFuture(); channel.addCloseListener(closeFuture); futures.add(closeFuture); } blockOnFutures(futures); } }
private Transport.Connection internalOpenConnection(DiscoveryNode node, ConnectionProfile connectionProfile) { PlainActionFuture<Transport.Connection> future = PlainActionFuture.newFuture(); Releasable pendingConnection = transport.openConnection(node, connectionProfile, future); Transport.Connection connection; try { connection = future.actionGet(); } catch (IllegalStateException e) { // If the future was interrupted we must cancel the pending connection to avoid channels leaking if (e.getCause() instanceof InterruptedException) { pendingConnection.close(); } throw e; } try { connectionListener.onConnectionOpened(connection); } finally { connection.addCloseListener(ActionListener.wrap(() -> connectionListener.onConnectionClosed(connection))); } if (connection.isClosed()) { throw new ConnectTransportException(node, "a channel closed while connecting"); } return connection; }
@Override public final <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute( Action<Request, Response, RequestBuilder> action, Request request) { PlainActionFuture<Response> actionFuture = PlainActionFuture.newFuture(); execute(action, request, actionFuture); return actionFuture; }
public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; }
@Override public final <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute( Action<Request, Response, RequestBuilder> action, Request request) { PlainActionFuture<Response> actionFuture = PlainActionFuture.newFuture(); execute(action, request, actionFuture); return actionFuture; }
public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; }
@Override public final <Request extends ActionRequest, Response extends ActionResponse, RequestBuilder extends ActionRequestBuilder<Request, Response, RequestBuilder>> ActionFuture<Response> execute(Action<Request, Response, RequestBuilder> action, Request request) { PlainActionFuture<Response> actionFuture = PlainActionFuture.newFuture(); execute(action, request, actionFuture); return actionFuture; }
public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; }
public final ActionFuture<Response> execute(Request request) { PlainActionFuture<Response> future = newFuture(); execute(request, future); return future; }
public static SyncRetryHandler create(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client) { PlainActionFuture<BulkResponse> actionFuture = PlainActionFuture.newFuture(); return new SyncRetryHandler(retryOnThrowable, backoffPolicy, client, actionFuture); }
public static SyncRetryHandler create(Class<? extends Throwable> retryOnThrowable, BackoffPolicy backoffPolicy, Client client) { PlainActionFuture<BulkResponse> actionFuture = PlainActionFuture.newFuture(); return new SyncRetryHandler(retryOnThrowable, backoffPolicy, client, actionFuture); }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future); return future; }
/** * Invokes #accept(BulkRequest, ActionListener). Backs off on the provided exception. Retries will be scheduled using * the class's thread pool. * * @param consumer The consumer to which apply the request and listener * @param bulkRequest The bulk request that should be executed. * @param settings settings * @return a future representing the bulk response returned by the client. */ public PlainActionFuture<BulkResponse> withBackoff(BiConsumer<BulkRequest, ActionListener<BulkResponse>> consumer, BulkRequest bulkRequest, Settings settings) { PlainActionFuture<BulkResponse> future = PlainActionFuture.newFuture(); withBackoff(consumer, bulkRequest, future, settings); return future; }
/** * Closes the channels. * * @param channels to close * @param blocking indicates if we should block on channel close */ static <C extends TcpChannel> void closeChannels(List<C> channels, boolean blocking) { if (blocking) { ArrayList<ActionFuture<Void>> futures = new ArrayList<>(channels.size()); for (final C channel : channels) { if (channel.isOpen()) { PlainActionFuture<Void> closeFuture = PlainActionFuture.newFuture(); channel.addCloseListener(closeFuture); channel.close(); futures.add(closeFuture); } } blockOnFutures(futures); } else { Releasables.close(channels); } }
/** * Closes the channels. * * @param channels to close * @param blocking indicates if we should block on channel close */ static <C extends TcpChannel> void closeChannels(List<C> channels, boolean blocking) { if (blocking) { ArrayList<ActionFuture<Void>> futures = new ArrayList<>(channels.size()); for (final C channel : channels) { if (channel.isOpen()) { PlainActionFuture<Void> closeFuture = PlainActionFuture.newFuture(); channel.addCloseListener(closeFuture); channel.close(); futures.add(closeFuture); } } blockOnFutures(futures); } else { Releasables.close(channels); } }
for (int i = 0; i < numConnections; ++i) { try { PlainActionFuture<Void> connectFuture = PlainActionFuture.newFuture(); connectionFutures.add(connectFuture); TcpChannel channel = initiateChannel(node, connectFuture);
public final class NodeChannels implements Connection { private final Map<TransportRequestOptions.Type, ConnectionProfile.ConnectionTypeHandle> typeMapping; private final List<TcpChannel> channels; private final DiscoveryNode node; private final AtomicBoolean closed = new AtomicBoolean(false); private final Version version; NodeChannels(DiscoveryNode node, List<TcpChannel> channels, ConnectionProfile connectionProfile, Version handshakeVersion) { this.node = node; this.channels = Collections.unmodifiableList(channels); assert channels.size() == connectionProfile.getNumConnections() : "expected channels size to be == " + connectionProfile.getNumConnections() + " but was: [" + channels.size() + "]"; typeMapping = new EnumMap<>(TransportRequestOptions.Type.class); for (ConnectionProfile.ConnectionTypeHandle handle : connectionProfile.getHandles()) { for (TransportRequestOptions.Type type : handle.getTypes()) typeMapping.put(type, handle); } version = handshakeVersion; } @Override public Version getVersion() { return version; } public List<TcpChannel> getChannels() { return channels; } public TcpChannel channel(TransportRequestOptions.Type type) {