@Override public void messageReceived(Request request, final TransportChannel channel) throws Exception { // we just send back a response, no need to fork a listener request.listenerThreaded(false); // we don't spawn, so if we get a request with no threading, change it to single threaded if (request.operationThreading() == BroadcastOperationThreading.NO_THREADS) { request.operationThreading(BroadcastOperationThreading.SINGLE_THREAD); } execute( request, new ActionListener<Response>() { @Override public void onResponse(Response response) { try { channel.sendResponse(response); } catch (Throwable e) { onFailure(e); } } @Override public void onFailure(Throwable e) { try { channel.sendResponse(e); } catch (Exception e1) { logger.warn("Failed to send response", e1); } } }); }
public ActionFuture<Response> execute(DiscoveryNode node, Request request) throws ElasticsearchException { PlainActionFuture<Response> future = newFuture(); request.listenerThreaded(false); execute(node, request, future); return future; }
@Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // no need to use threaded listener, since we just send a response request.listenerThreaded(false); execute( request, new ActionListener<Response>() { @Override public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Throwable e) { onFailure(e); } } @Override public void onFailure(Throwable e) { try { channel.sendResponse(e); } catch (Exception e1) { logger.warn( "Failed to send error response for action [" + actionName + "] and request [" + request + "]", e1); } } }); }
@Override public void messageReceived(Request request, final TransportChannel channel) throws Exception { // we just send back a response, no need to fork a listener request.listenerThreaded(false); execute( request, new ActionListener<Response>() { @Override public void onResponse(Response response) { try { channel.sendResponse(response); } catch (Throwable e) { onFailure(e); } } @Override public void onFailure(Throwable e) { try { channel.sendResponse(e); } catch (Exception e1) { logger.warn("Failed to send response", e1); } } }); }
@Override public void messageReceived(final Request request, final TransportChannel channel) throws Exception { // no need to have a threaded listener since we just send back a response request.listenerThreaded(false); // if we have a local operation, execute it on a thread since we don't spawn request.operationThreaded(true); execute( request, new ActionListener<Response>() { @Override public void onResponse(Response result) { try { channel.sendResponse(result); } catch (Exception e) { onFailure(e); } } @Override public void onFailure(Throwable e) { try { channel.sendResponse(e); } catch (Exception e1) { logger.warn("Failed to send response for " + transportAction, e1); } } }); }
@Override public void execute(Request request, ActionListener<Response> listener) { // since the callback is async, we typically can get called from within an event in the cluster // service // or something similar, so make sure we are threaded so we won't block it. request.listenerThreaded(true); super.execute(request, listener); }