@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("received response to CompleteTxRequest (%s) for %d", status != ModelControllerProtocol.PARAM_ROLLBACK, context.getOperationId()); // We only accept operationCompleted responses expectHeader(input, ModelControllerProtocol.PARAM_OPERATION_COMPLETED); final ModelNode responseNode = new ModelNode(); responseNode.readExternal(input); // Complete the operation resultHandler.done(createOperationResponse(responseNode, channelAssociation, context.getOperationId())); }
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("received response to CompleteTxRequest (%s) for %d", status != ModelControllerProtocol.PARAM_ROLLBACK, context.getOperationId()); // We only accept operationCompleted responses expectHeader(input, ModelControllerProtocol.PARAM_OPERATION_COMPLETED); final ModelNode responseNode = new ModelNode(); responseNode.readExternal(input); // Complete the operation resultHandler.done(createOperationResponse(responseNode, channelAssociation, context.getOperationId())); }
@Override public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("sending CompleteTxRequest for %d", context.getOperationId()); context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() { @Override public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception { sendRequestInternal(resultHandler, context); } }, false); }
@Override protected void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context, final FlushableDataOutput output) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("transmitting CompleteTxRequest (%s) for %d", status != ModelControllerProtocol.PARAM_ROLLBACK, context.getOperationId()); output.write(status); }
@Override public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("sending ExecuteRequest for %d", context.getOperationId()); // WFLY-3090 Protect the communication channel from getting closed due to administrative // cancellation of the management op by using a separate thread to send context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() { @Override public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception { sendRequestInternal(resultHandler, context); } }, false); }
@Override public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("sending CompleteTxRequest for %d", context.getOperationId()); context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() { @Override public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception { sendRequestInternal(resultHandler, context); } }, false); }
@Override protected void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context, final FlushableDataOutput output) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("transmitting CompleteTxRequest (%s) for %d", status != ModelControllerProtocol.PARAM_ROLLBACK, context.getOperationId()); output.write(status); }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException { HostControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d", context.getOperationId()); final RemoteFileRequestAndHandler.RootFileReader reader = new RemoteFileRequestAndHandler.RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { byte[] hash = HashUtil.hexStringToByteArray(filePath); return deploymentFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } }; ServerToHostRemoteFileRequestAndHandler.INSTANCE.handleRequest(input, reader, resultHandler, context); } }
@Override public void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("sending ExecuteRequest for %d", context.getOperationId()); // WFLY-3090 Protect the communication channel from getting closed due to administrative // cancellation of the management op by using a separate thread to send context.executeAsync(new ManagementRequestContext.AsyncTask<ExecuteRequestContext>() { @Override public void execute(ManagementRequestContext<ExecuteRequestContext> context) throws Exception { sendRequestInternal(resultHandler, context); } }, false); }
@Override public void handleRequest(DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException { HostControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d", context.getOperationId()); final RemoteFileRequestAndHandler.RootFileReader reader = new RemoteFileRequestAndHandler.RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { byte[] hash = HashUtil.hexStringToByteArray(filePath); return deploymentFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } }; ServerToHostRemoteFileRequestAndHandler.INSTANCE.handleRequest(input, reader, resultHandler, context); } }
private void done(boolean commit) { final byte status = commit ? ModelControllerProtocol.PARAM_COMMIT : ModelControllerProtocol.PARAM_ROLLBACK; try { // Send the CompleteTxRequest channelAssociation.executeRequest(context.getOperationId(), new CompleteTxRequest(status)); } catch (Exception e) { resultHandler.failed(e); } } }, response);
private void done(boolean commit) { final byte status = commit ? ModelControllerProtocol.PARAM_COMMIT : ModelControllerProtocol.PARAM_ROLLBACK; try { // Send the CompleteTxRequest channelAssociation.executeRequest(context.getOperationId(), new CompleteTxRequest(status)); } catch (Exception e) { resultHandler.failed(e); } } }, response);
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<OperationExecutionContext> context) throws IOException { expectHeader(input, ModelControllerProtocol.PARAM_RESPONSE); final ModelNode node = new ModelNode(); node.readExternal(input); resultHandler.done(getOperationResponse(node, context.getOperationId())); expectHeader(input, ManagementProtocol.RESPONSE_END); } }, executionContext);
@Override void handleRequest(String hostId, DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<Void> context) throws IOException { DomainControllerLogger.ROOT_LOGGER.tracef("Handling GetFileOperation with id %d from %s", context.getOperationId(), hostId); final RootFileReader reader = new RootFileReader() { public File readRootFile(byte rootId, String filePath) throws RequestProcessingException { final HostFileRepository localFileRepository = domainController.getLocalFileRepository(); switch (rootId) { case DomainControllerProtocol.PARAM_ROOT_ID_FILE: { return localFileRepository.getFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_CONFIGURATION: { return localFileRepository.getConfigurationFile(filePath); } case DomainControllerProtocol.PARAM_ROOT_ID_DEPLOYMENT: { byte[] hash = HashUtil.hexStringToByteArray(filePath); return localFileRepository.getDeploymentRoot(new ContentReference(filePath, hash)); } default: { throw HostControllerLogger.ROOT_LOGGER.invalidRootId(rootId); } } } }; remoteSupport.handleRequest(input, reader, resultHandler, context); } }
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context) throws IOException { if (forExecuteTxRequest) { try { // Read and discard the input ExecutableRequest.parse(input, channelAssociation); } finally { ControllerLogger.MGMT_OP_LOGGER.tracef("aborting (cancel received before request) for %d", context.getOperationId()); ModelNode response = new ModelNode(); response.get(OUTCOME).set(CANCELLED); context.getAttachment().initialize(context); context.getAttachment().failed(response); } } else { // This was a COMPLETE_TX_REQUEST that came in before the original EXECUTE_TX_REQUEST final byte commitOrRollback = input.readByte(); if (commitOrRollback == ModelControllerProtocol.PARAM_COMMIT) { // a cancel would not use PARAM_COMMIT; this was a request that didn't match any existing op // Likely the request was cancelled and removed but the commit message was in process throw ControllerLogger.MGMT_OP_LOGGER.responseHandlerNotFound(context.getOperationId()); } // else this was a cancel request. Do nothing and wait for the initial operation request to come in // and see the pre-existing ActiveOperation and then call this with forExecuteTxRequest=true } }
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<ModelNode> resultHandler, final ManagementRequestContext<Void> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("Cancellation of %d requested", context.getOperationId()); context.executeAsync(new ManagementRequestContext.AsyncTask<Void>() { @Override public void execute(ManagementRequestContext<Void> context) throws Exception { final ManagementResponseHeader response = ManagementResponseHeader.create(context.getRequestHeader()); final FlushableDataOutput output = context.writeMessage(response); try { output.writeByte(ManagementProtocol.RESPONSE_END); output.close(); } finally { StreamUtils.safeClose(output); } } }, false); resultHandler.cancel(); } }
@Override public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<ModelNode> resultHandler, final ManagementRequestContext<Void> context) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("Cancellation of %d requested", context.getOperationId()); context.executeAsync(new ManagementRequestContext.AsyncTask<Void>() { @Override public void execute(ManagementRequestContext<Void> context) throws Exception { final ManagementResponseHeader response = ManagementResponseHeader.create(context.getRequestHeader()); final FlushableDataOutput output = context.writeMessage(response); try { output.writeByte(ManagementProtocol.RESPONSE_END); output.close(); } finally { StreamUtils.safeClose(output); } } }, false); resultHandler.cancel(); } }
@Override public void execute(final ManagementRequestContext<ExecuteRequestContext> context) throws Exception { FlushableDataOutput output = null; try { MGMT_OP_LOGGER.tracef("Transmitting response for %d", context.getOperationId()); final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader()); output = context.writeMessage(header); // response type output.writeByte(responseType); // operation result response.writeExternal(output); // response end output.writeByte(ManagementProtocol.RESPONSE_END); output.close(); } catch (IOException toCache) { exceptionHolder.exception = toCache; } finally { StreamUtils.safeClose(output); latch.countDown(); } } }, false);
@Override public void execute(final ManagementRequestContext<ExecuteRequestContext> context) throws Exception { FlushableDataOutput output = null; try { MGMT_OP_LOGGER.tracef("Transmitting response for %d", context.getOperationId()); final ManagementResponseHeader header = ManagementResponseHeader.create(context.getRequestHeader()); output = context.writeMessage(header); // response type output.writeByte(responseType); // operation result response.writeExternal(output); // response end output.writeByte(ManagementProtocol.RESPONSE_END); output.close(); } catch (IOException toCache) { exceptionHolder.exception = toCache; } finally { StreamUtils.safeClose(output); latch.countDown(); } } }, false);
@Override protected void sendRequest(final ActiveOperation.ResultHandler<OperationResponse> resultHandler, final ManagementRequestContext<ExecuteRequestContext> context, final FlushableDataOutput output) throws IOException { ControllerLogger.MGMT_OP_LOGGER.tracef("transmitting ExecuteRequest for %d", context.getOperationId()); // Write the operation final ExecuteRequestContext executionContext = context.getAttachment(); final List<InputStream> streams = executionContext.getInputStreams(); final ModelNode operation = executionContext.getOperation(); int inputStreamLength = 0; if (streams != null) { inputStreamLength = streams.size(); } output.write(ModelControllerProtocol.PARAM_OPERATION); operation.writeExternal(output); output.write(ModelControllerProtocol.PARAM_INPUTSTREAMS_LENGTH); output.writeInt(inputStreamLength); final Boolean sendIdentity = channelAssociation.getAttachments().getAttachment(SEND_IDENTITY); if (sendIdentity != null && sendIdentity) { ExecuteRequestContext attachment = context.getAttachment(); write(output, attachment.getSecurityIdentity(), attachment.getRemoteAddress()); } final Boolean sendInVm = channelAssociation.getAttachments().getAttachment(SEND_IN_VM); if (sendInVm != null && sendInVm) { ExecuteRequestContext attachment = context.getAttachment(); output.writeByte(ModelControllerProtocol.PARAM_IN_VM_CALL); output.writeBoolean(attachment.isInVmCall()); } }