@Override public V txGet() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { if (e.getCause() instanceof ElasticsearchException) { throw (ElasticsearchException) e.getCause(); } else { throw new TransportException("Failed execution", e); } } }
@Override public V txGet(long timeout, TimeUnit unit) { try { return get(timeout, unit); } catch (TimeoutException e) { throw new ElasticsearchTimeoutException(e); } catch (InterruptedException e) { throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { if (e.getCause() instanceof ElasticsearchException) { throw (ElasticsearchException) e.getCause(); } else { throw new TransportException("Failed execution", e); } } }
@Override public void handleResponse(T response) { try { channel.sendResponse(response); } catch (IOException e) { handleException(new TransportException(e)); } }
@Override public void doRun() { TransportException ex = new TransportException("transport stopped, action: " + holderToNotify.action()); holderToNotify.handler().handleException(ex); } });
public <T extends TransportResponse> void sendChildRequest(final Transport.Connection connection, final String action, final TransportRequest request, final Task parentTask, final TransportRequestOptions options, final TransportResponseHandler<T> handler) { request.setParentTask(localNode.getId(), parentTask.getId()); try { sendRequest(connection, action, request, options, handler); } catch (TaskCancelledException ex) { // The parent task is already cancelled - just fail the request handler.handleException(new TransportException(ex)); } catch (NodeNotConnectedException ex) { // the caller might not handle this so we invoke the handler handler.handleException(ex); } }
void sendHandshake(long requestId, DiscoveryNode node, TcpChannel channel, TimeValue timeout, ActionListener<Version> listener) { numHandshakes.inc(); final HandshakeResponseHandler handler = new HandshakeResponseHandler(requestId, version, listener); pendingHandshakes.put(requestId, handler); channel.addCloseListener(ActionListener.wrap( () -> handler.handleLocalException(new TransportException("handshake failed because connection reset")))); boolean success = false; try { // for the request we use the minCompatVersion since we don't know what's the version of the node we talk to // we also have no payload on the request but the response will contain the actual version of the node we talk // to as the payload. final Version minCompatVersion = version.minimumCompatibilityVersion(); handshakeRequestSender.sendRequest(node, channel, requestId, minCompatVersion); threadPool.schedule(timeout, ThreadPool.Names.GENERIC, () -> handler.handleLocalException(new ConnectTransportException(node, "handshake_timeout[" + timeout + "]"))); success = true; } catch (Exception e) { handler.handleLocalException(new ConnectTransportException(node, "failure to send " + HANDSHAKE_ACTION_NAME, e)); } finally { if (success == false) { TransportResponseHandler<?> removed = pendingHandshakes.remove(requestId); assert removed == null : "Handshake should not be pending if exception was thrown"; } } }
throw new TransportException("TransportService is closed stopped can't send request");
@Override public V txGet() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { if (e.getCause() instanceof ElasticsearchException) { throw (ElasticsearchException) e.getCause(); } else { throw new TransportException("Failed execution", e); } } }
@Override public V txGet() { try { return get(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw new IllegalStateException("Future got interrupted", e); } catch (ExecutionException e) { if (e.getCause() instanceof ElasticsearchException) { throw (ElasticsearchException) e.getCause(); } else { throw new TransportException("Failed execution", e); } } }
@Override public void handleResponse(T response) { try { channel.sendResponse(response); } catch (IOException e) { handleException(new TransportException(e)); } }
@Override public void doRun() { TransportException ex = new TransportException("transport stopped, action: " + holderToNotify.action()); holderToNotify.handler().handleException(ex); } });
@Override public void handleResponse(T response) { try { channel.sendResponse(response); } catch (IOException e) { handleException(new TransportException(e)); } }
@Override public void handleResponse(T response) { try { channel.sendResponse(response); } catch (IOException e) { handleException(new TransportException(e)); } }
@Override public void handleResponse(T response) { try { channel.sendResponse(response); } catch (IOException e) { handleException(new TransportException(e)); } }
@Override public void doRun() { TransportException ex = new TransportException("transport stopped, action: " + holderToNotify.action()); holderToNotify.handler().handleException(ex); } });
@Override public void doRun() { TransportException ex = new TransportException("transport stopped, action: " + holderToNotify.action()); holderToNotify.handler().handleException(ex); } });
@Override public void run() { holderToNotify.handler().handleException(new TransportException("transport stopped, action: " + holderToNotify.action())); } });
@Override public void onFailure(Exception e) { TransportException exception = new TransportException("unable to communicate with remote cluster [" + clusterName + "]", e); if (transportException.compareAndSet(null, exception) == false) { exception = transportException.accumulateAndGet(exception, (previous, current) -> { current.addSuppressed(previous); return current; }); } if (responsesCountDown.countDown()) { listener.onFailure(exception); } } });
public <T extends TransportResponse> void sendChildRequest(final Transport.Connection connection, final String action, final TransportRequest request, final Task parentTask, final TransportRequestOptions options, final TransportResponseHandler<T> handler) { request.setParentTask(localNode.getId(), parentTask.getId()); try { sendRequest(connection, action, request, options, handler); } catch (TaskCancelledException ex) { // The parent task is already cancelled - just fail the request handler.handleException(new TransportException(ex)); } catch (NodeNotConnectedException ex) { // the caller might not handle this so we invoke the handler handler.handleException(ex); } }
public <T extends TransportResponse> void sendChildRequest(final Transport.Connection connection, final String action, final TransportRequest request, final Task parentTask, final TransportRequestOptions options, final TransportResponseHandler<T> handler) { request.setParentTask(localNode.getId(), parentTask.getId()); try { sendRequest(connection, action, request, options, handler); } catch (TaskCancelledException ex) { // The parent task is already cancelled - just fail the request handler.handleException(new TransportException(ex)); } catch (NodeNotConnectedException ex) { // the caller might not handle this so we invoke the handler handler.handleException(ex); } }