@Override public ManagementRequestHandler<?, ?> resolveHandler(RequestHandlerChain handlers, ManagementRequestHeader header) { final byte operationId = header.getOperationId(); switch (operationId) { case ManagementProtocol.TYPE_PING: handlers.registerActiveOperation(header.getBatchId(), null); return this; } return handlers.resolveNext(); }
public static ManagementResponseHeader create(final ManagementRequestHeader header, Exception error) { final int workingVersion = Math.min(ManagementProtocol.VERSION, header.getVersion()); return new ManagementResponseHeader(workingVersion, header.getRequestId(), error != null ? error.getMessage() : null); }
ManagementRequestHeader(final int version, final DataInput input) throws IOException { super(version); read(input); }
@Override public ManagementRequestHandler<?, ?> resolveHandler(final RequestHandlerChain handlers, final ManagementRequestHeader header) { if (header.getVersion() != 1) { final byte operationId = header.getOperationId(); switch (operationId) { case DomainControllerProtocol.REGISTER_HOST_CONTROLLER_REQUEST: { context.activeOperation = handlers.registerActiveOperation(header.getBatchId(), context, context); return new InitiateRegistrationHandler(); context.activeOperation = handlers.registerActiveOperation(header.getBatchId(), context, context); return new InitiateRegistrationHandler();
protected ModelNode doExecute(final ModelNode operation, final int attachmentsLength, final ManagementRequestContext<Void> context) { //Add a header to show that this operation comes from a user. If this is a host controller and the operation needs propagating to the //servers it will be removed by the domain ops responsible for propagation to the servers. operation.get(OPERATION_HEADERS, CALLER_TYPE).set(USER); final ManagementRequestHeader header = ManagementRequestHeader.class.cast(context.getRequestHeader()); final int batchId = header.getBatchId(); final ModelNode result = new ModelNode(); final OperationMessageHandlerProxy messageHandlerProxy = new OperationMessageHandlerProxy(channelAssociation, batchId); final OperationAttachmentsProxy attachmentsProxy = OperationAttachmentsProxy.create(channelAssociation, batchId, attachmentsLength); try { ROOT_LOGGER.tracef("Executing client request %d(%d)", batchId, header.getRequestId()); result.set(controller.execute( operation, messageHandlerProxy, ModelController.OperationTransactionControl.COMMIT, attachmentsProxy)); } catch (Exception e) { final ModelNode failure = new ModelNode(); failure.get(OUTCOME).set(FAILED); failure.get(FAILURE_DESCRIPTION).set(e.getClass().getName() + ":" + e.getMessage()); result.set(failure); attachmentsProxy.shutdown(e); } finally { ROOT_LOGGER.tracef("Executed client request %d", batchId); } return result; }
@Override public ManagementRequestHandler<?, ?> resolveHandler(RequestHandlerChain handlers, ManagementRequestHeader header) { final byte operationType = header.getOperationId(); if (operationType == ModelControllerProtocol.HANDLE_REPORT_REQUEST) { return MESSAGE_HANDLER; } else if (operationType == ModelControllerProtocol.GET_INPUTSTREAM_REQUEST) { return GET_INPUT_STREAM; } return handlers.resolveNext(); }
/** * Get an active operation. * * @param header the request header * @return the active operation, {@code null} if if there is no registered operation */ protected <T, A> ActiveOperation<T, A> getActiveOperation(final ManagementRequestHeader header) { return getActiveOperation(header.getBatchId()); }
public static ManagementResponseHeader create(final ManagementRequestHeader header) { return create(header, header.getRequestId()); }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw MESSAGES.invalidType("0x" + Integer.toHexString(type)); } } }
@Override public ManagementRequestHandler<?, ?> resolveHandler(final RequestHandlerChain handlers, final ManagementRequestHeader header) { if (header.getVersion() != 1) { final byte operationId = header.getOperationId(); switch (operationId) { case DomainControllerProtocol.REGISTER_HOST_CONTROLLER_REQUEST: { context.activeOperation = handlers.registerActiveOperation(header.getBatchId(), context, context); return new InitiateRegistrationHandler(); context.activeOperation = handlers.registerActiveOperation(header.getBatchId(), context, context); return new InitiateRegistrationHandler();
final int batchId = header.getBatchId(); final ModelNode result = new ModelNode(); final OperationAttachmentsProxy attachmentsProxy = OperationAttachmentsProxy.create(channelAssociation, batchId, attachmentsLength); try { ROOT_LOGGER.tracef("Executing client request %d(%d)", batchId, header.getRequestId()); result.set(controller.execute( operation,
@Override public ManagementRequestHandler<?, ?> resolveHandler(RequestHandlerChain handlers, ManagementRequestHeader header) { final byte operationType = header.getOperationId(); if (operationType == ModelControllerProtocol.HANDLE_REPORT_REQUEST) { return MESSAGE_HANDLER; } else if (operationType == ModelControllerProtocol.GET_INPUTSTREAM_REQUEST) { return GET_INPUT_STREAM; } return handlers.resolveNext(); }
/** * Get an active operation. * * @param header the request header * @return the active operation, {@code null} if if there is no registered operation */ protected <T, A> ActiveOperation<T, A> getActiveOperation(final ManagementRequestHeader header) { return getActiveOperation(header.getBatchId()); }
public static ManagementResponseHeader create(final ManagementRequestHeader header) { return create(header, header.getRequestId()); }
/** * Parses the input stream to read the header * * @param input data input to read from * @return the parsed protocol header * @throws IOException */ public static ManagementProtocolHeader parse(DataInput input) throws IOException { validateSignature(input); expectHeader(input, ManagementProtocol.VERSION_FIELD); int version = input.readInt(); expectHeader(input, ManagementProtocol.TYPE); byte type = input.readByte(); switch (type) { case ManagementProtocol.TYPE_REQUEST: return new ManagementRequestHeader(version, input); case ManagementProtocol.TYPE_RESPONSE: return new ManagementResponseHeader(version, input); case ManagementProtocol.TYPE_BYE_BYE: return new ManagementByeByeHeader(version); case ManagementProtocol.TYPE_PING: return new ManagementPingHeader(version); case ManagementProtocol.TYPE_PONG: return new ManagementPongHeader(version); default: throw ProtocolLogger.ROOT_LOGGER.invalidType("0x" + Integer.toHexString(type)); } } }
@Override public ManagementRequestHandler<?, ?> resolveHandler(RequestHandlerChain handlers, ManagementRequestHeader header) { final byte operationId = header.getOperationId(); switch (operationId) { case ManagementProtocol.TYPE_PING: handlers.registerActiveOperation(header.getBatchId(), null); return this; } return handlers.resolveNext(); }
final int batchId = header.getBatchId(); final ModelNode result = new ModelNode(); final OperationAttachmentsProxy attachmentsProxy = OperationAttachmentsProxy.create(operation, channelAssociation, batchId, attachmentsLength); try { ROOT_LOGGER.tracef("Executing client request %d(%d)", batchId, header.getRequestId()); OperationResponse response = controller.execute(attachmentsProxy, messageHandlerProxy, transactionControl);
/** {@inheritDoc} */ @Override public ManagementRequestHandler<?, ?> resolveHandler(RequestHandlerChain handlers, ManagementRequestHeader header) { final byte operationType = header.getOperationId(); if (operationType == ModelControllerProtocol.HANDLE_REPORT_REQUEST) { return new HandleReportRequestHandler(); } else if (operationType == ModelControllerProtocol.GET_INPUTSTREAM_REQUEST) { return ReadAttachmentInputStreamRequestHandler.INSTANCE; } return handlers.resolveNext(); }
/** * Get an active operation. * * @param header the request header * @return the active operation, {@code null} if if there is no registered operation */ protected <T, A> ActiveOperation<T, A> getActiveOperation(final ManagementRequestHeader header) { return getActiveOperation(header.getBatchId()); }
public static ManagementResponseHeader create(final ManagementRequestHeader header, Throwable error) { final int workingVersion = Math.min(ManagementProtocol.VERSION, header.getVersion()); return new ManagementResponseHeader(workingVersion, header.getRequestId(), error != null ? error.getClass().getName() + ':' + error.getMessage() : null); }