OperationResponse response = controller.execute(attachmentsProxy, messageHandlerProxy, transactionControl); responseAttachmentSupport.registerStreams(context.getOperationId(), response.getInputStreams());
OperationResponse response = controller.execute(attachmentsProxy, messageHandlerProxy, transactionControl); responseAttachmentSupport.registerStreams(context.getOperationId(), response.getInputStreams());
/** * Sends the final response to the remote client after the prepare phase has been executed. * This should be called whether the outcome was successful or not. */ synchronized void completed(final OperationResponse response) { assert prepared; if (responseChannel != null) { // Normal case, where a COMPLETE_TX_REQUEST came in after the prepare() call and // established a new responseChannel so the client can correlate the response ControllerLogger.MGMT_OP_LOGGER.tracef("sending completed response %s for %d --- interrupted: %s", response.getResponseNode(), getOperationId(), Thread.currentThread().isInterrupted()); streamSupport.registerStreams(operation.getOperationId(), response.getInputStreams()); try { sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_COMPLETED, response.getResponseNode()); responseChannel = null; // we've now sent a response to the COMPLETE_TX_REQUEST, so we can't use this one further } catch (IOException e) { ControllerLogger.MGMT_OP_LOGGER.failedSendingCompletedResponse(e, response.getResponseNode(), getOperationId()); } finally { getResultHandler().done(null); } } else { // We were cancelled or somehow failed after sending our prepare() message but before we got a COMPLETE_TX_REQUEST. // The client will not be able to deal with any response until it sends a COMPLETE_TX_REQUEST // (which is why we null out responseChannel in prepare()). So, just cache this response // so we can send it in completeTx when the COMPLETE_TX_REQUEST comes in. assert postPrepareRaceResponse == null; // else we got called twice locally! ControllerLogger.MGMT_OP_LOGGER.tracef("received a post-prepare response for %d but no " + "COMPLETE_TX_REQUEST has been received; caching the response", getOperationId()); postPrepareRaceResponse = response; } }
/** * Sends the final response to the remote client after the prepare phase has been executed. * This should be called whether the outcome was successful or not. */ synchronized void completed(final OperationResponse response) { assert prepared; if (responseChannel != null) { // Normal case, where a COMPLETE_TX_REQUEST came in after the prepare() call and // established a new responseChannel so the client can correlate the response ControllerLogger.MGMT_OP_LOGGER.tracef("sending completed response %s for %d --- interrupted: %s", response.getResponseNode(), getOperationId(), Thread.currentThread().isInterrupted()); streamSupport.registerStreams(operation.getOperationId(), response.getInputStreams()); try { sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_COMPLETED, response.getResponseNode()); responseChannel = null; // we've now sent a response to the COMPLETE_TX_REQUEST, so we can't use this one further } catch (IOException e) { ControllerLogger.MGMT_OP_LOGGER.failedSendingCompletedResponse(e, response.getResponseNode(), getOperationId()); } finally { getResultHandler().done(null); } } else { // We were cancelled or somehow failed after sending our prepare() message but before we got a COMPLETE_TX_REQUEST. // The client will not be able to deal with any response until it sends a COMPLETE_TX_REQUEST // (which is why we null out responseChannel in prepare()). So, just cache this response // so we can send it in completeTx when the COMPLETE_TX_REQUEST comes in. assert postPrepareRaceResponse == null; // else we got called twice locally! ControllerLogger.MGMT_OP_LOGGER.tracef("received a post-prepare response for %d but no " + "COMPLETE_TX_REQUEST has been received; caching the response", getOperationId()); postPrepareRaceResponse = response; } }