ActiveOperation.ResultHandler<Void> getResultHandler() { return operation.getResultHandler(); }
ActiveOperation.ResultHandler<Void> getResultHandler() { return operation.getResultHandler(); }
ActiveOperation.ResultHandler<Void> getResultHandler() { return operation.getResultHandler(); }
ActiveOperation.ResultHandler<Void> getResultHandler() { return operation.getResultHandler(); }
protected void handleFailed(final ManagementResponseHeader header) { handler.handleFailed(header, context.getResultHandler()); }
protected void handleFailed(final ManagementResponseHeader header) { handler.handleFailed(header, context.getResultHandler()); }
protected void handleFailed(final ManagementResponseHeader header) { handler.handleFailed(header, context.getResultHandler()); }
/** * Receive a notification that the channel was closed. * * This is used for the {@link ManagementClientChannelStrategy.Establishing} since it might use multiple channels. * * @param closed the closed resource * @param e the exception which occurred during close, if any */ public void handleChannelClosed(final Channel closed, final IOException e) { for(final Map.Entry<Integer, ActiveRequest<?, ?>> requestEntry : requests.entrySet()) { final ActiveRequest<?, ?> request = requestEntry.getValue(); if(request.channel == closed) { final IOException failure = e == null ? new IOException("Channel closed") : e; request.context.getResultHandler().failed(failure); requests.remove(requestEntry.getKey()); } } }
void sendCompletedMessage() { if(completed.compareAndSet(false, true)) { try { sendResponse(responseChannel, DomainControllerProtocol.PARAM_OK, null); } catch (IOException e) { DOMAIN_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); } }
@Override public boolean executeAsync(final AsyncTask<A> task, boolean cancellable, final Executor executor) { try { executor.execute(createAsyncTaskRunner(task, cancellable)); return true; } catch (RejectedExecutionException e) { if(support.getResultHandler().failed(e)) { AbstractMessageHandler.safeWriteErrorResponse(channel, header, e); } } return false; }
void sendCompletedMessage() { if(completed.compareAndSet(false, true)) { try { sendResponse(responseChannel, DomainControllerProtocol.PARAM_OK, null); } catch (IOException e) { ProtocolLogger.ROOT_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); } }
void sendCompletedMessage() { if(completed.compareAndSet(false, true)) { try { sendResponse(responseChannel, DomainControllerProtocol.PARAM_OK, null); } catch (IOException e) { DOMAIN_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); } }
@Override public boolean executeAsync(final AsyncTask<A> task, boolean cancellable, final Executor executor) { try { executor.execute(createAsyncTaskRunner(task, cancellable)); return true; } catch (RejectedExecutionException e) { if(support.getResultHandler().failed(e)) { AbstractMessageHandler.safeWriteErrorResponse(channel, header, e); } } return false; }
void failed(byte errorCode, String message) { if(completed.compareAndSet(false, true)) { failed = true; final IOTask<?> task = this.task; if(task != null) { task.setFailed(); } try { sendFailedResponse(responseChannel, errorCode, message); } catch (IOException e) { ProtocolLogger.ROOT_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); } }
void failed(SlaveRegistrationException.ErrorCode error, String message) { byte errorCode = error.getCode(); if(completed.compareAndSet(false, true)) { failed = true; final IOTask<?> task = this.task; if(task != null) { task.setFailed(); } try { sendFailedResponse(responseChannel, errorCode, message); } catch (IOException e) { DOMAIN_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); addFailureEvent(error); } }
void failed(SlaveRegistrationException.ErrorCode error, String message) { byte errorCode = error.getCode(); if(completed.compareAndSet(false, true)) { failed = true; final IOTask<?> task = this.task; if(task != null) { task.setFailed(); } try { sendFailedResponse(responseChannel, errorCode, message); } catch (IOException e) { DOMAIN_LOGGER.debugf(e, "failed to process message"); } activeOperation.getResultHandler().done(null); addFailureEvent(error); } }
@Override protected void doExecute() { try { task.execute(context); } catch (Throwable t) { if(support.getResultHandler().failed(t)) { ManagementProtocolHeader requestHeader; if (task instanceof MultipleResponseAsyncTask) { requestHeader = ((MultipleResponseAsyncTask) task).getCurrentRequestHeader(); requestHeader = requestHeader == null ? header : requestHeader; } else { requestHeader = header; } AbstractMessageHandler.safeWriteErrorResponse(channel, requestHeader, t); } ProtocolLogger.ROOT_LOGGER.debugf(t, " failed to process async request for %s on channel %s", task, channel); } } };
/** * Execute a request. * * @param request the request * @param channel the channel * @param support the request support * @return the future result */ protected <T, A> AsyncFuture<T> executeRequest(final ManagementRequest<T, A> request, final Channel channel, final ActiveOperation<T, A> support) { assert support != null; updateChannelRef(support, channel); final Integer requestId = this.requestID.incrementAndGet(); final ActiveRequest<T, A> ar = new ActiveRequest<T, A>(support, request); requests.put(requestId, ar); final ManagementRequestHeader header = new ManagementRequestHeader(ManagementProtocol.VERSION, requestId, support.getOperationId(), request.getOperationType()); final ActiveOperation.ResultHandler<T> resultHandler = support.getResultHandler(); try { request.sendRequest(resultHandler, new ManagementRequestContextImpl<T, A>(support, channel, header, getExecutor())); } catch (Exception e) { resultHandler.failed(e); requests.remove(requestId); } return support.getResult(); }
@Override protected void doExecute() { try { task.execute(context); } catch (Throwable t) { if(support.getResultHandler().failed(t)) { ManagementProtocolHeader requestHeader; if (task instanceof MultipleResponseAsyncTask) { requestHeader = ((MultipleResponseAsyncTask) task).getCurrentRequestHeader(); requestHeader = requestHeader == null ? header : requestHeader; } else { requestHeader = header; } AbstractMessageHandler.safeWriteErrorResponse(channel, requestHeader, t); } ProtocolLogger.ROOT_LOGGER.debugf(t, " failed to process async request for %s on channel %s", task, channel); } } };
/** * Handle a message. * * @param channel the channel * @param message the message * @param header the protocol header * @param support the request support * @param handler the request handler */ protected <T, A> void handleMessage(final Channel channel, final DataInput message, final ManagementProtocolHeader header, final ActiveOperation<T, A> support, final ManagementRequestHandler<T, A> handler) { assert support != null; updateChannelRef(support, channel); final ActiveOperation.ResultHandler<T> resultHandler = support.getResultHandler(); try { handler.handleRequest(message, resultHandler, new ManagementRequestContextImpl<T, A>(support, channel, header, getExecutor())); } catch (Exception e) { resultHandler.failed(e); safeWriteErrorResponse(channel, header, e); } }