Java Code Examples for org.jboss.dmr.ModelNode#readExternal()

The following examples show how to use org.jboss.dmr.ModelNode#readExternal() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteDomainConnection.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<Void> context) throws IOException {
    byte param = input.readByte();
    // If it failed
    if(param != DomainControllerProtocol.PARAM_OK) {
        final byte errorCode = input.readByte();
        final String message =  input.readUTF();
        resultHandler.failed(new SlaveRegistrationException(SlaveRegistrationException.ErrorCode.parseCode(errorCode), message));
        return;
    }
    final ModelNode extensions = new ModelNode();
    extensions.readExternal(input);
    // Enable the send subject
    if (context.getRequestHeader().getVersion() != 1) {
        channelHandler.getAttachments().attach(TransactionalProtocolClient.SEND_IDENTITY, Boolean.TRUE);
    }
    context.executeAsync(new ManagementRequestContext.AsyncTask<Void>() {
        @Override
        public void execute(ManagementRequestContext<Void> voidManagementRequestContext) throws Exception {
            //
            final ModelNode subsystems = resolveSubsystemVersions(extensions);
            channelHandler.executeRequest(context.getOperationId(),
                    new RegisterSubsystemsRequest(subsystems));
        }
    });
}
 
Example 2
Source File: RemoteDomainConnection.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public void handleRequest(final DataInput input, final ActiveOperation.ResultHandler<Void> resultHandler, final ManagementRequestContext<Void> context) throws IOException {
    byte param = input.readByte();
    // If it failed
    if(param != DomainControllerProtocol.PARAM_OK) {
        final byte errorCode = input.readByte();
        final String message =  input.readUTF();
        resultHandler.failed(new SlaveRegistrationException(SlaveRegistrationException.ErrorCode.parseCode(errorCode), message));
        return;
    }
    final ModelNode domainModel = new ModelNode();
    domainModel.readExternal(input);
    context.executeAsync(new ManagementRequestContext.AsyncTask<Void>() {
        @Override
        public void execute(ManagementRequestContext<Void> voidManagementRequestContext) throws Exception {
            // Apply the domain model
            if (applyDomainModel(domainModel)) {
                channelHandler.executeRequest(context.getOperationId(), new CompleteRegistrationRequest(DomainControllerProtocol.PARAM_OK));
            } else {
                channelHandler.executeRequest(context.getOperationId(), new CompleteRegistrationRequest(DomainControllerProtocol.PARAM_ERROR));
                resultHandler.failed(new SlaveRegistrationException(SlaveRegistrationException.ErrorCode.UNKNOWN, ""));
            }
        }
    });
}
 
Example 3
Source File: TransactionalProtocolOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static ExecutableRequest parse(DataInput input, ManagementChannelAssociation channelAssociation) throws IOException {
    final ModelNode operation = new ModelNode();
    ProtocolUtils.expectHeader(input, ModelControllerProtocol.PARAM_OPERATION);
    operation.readExternal(input);
    ProtocolUtils.expectHeader(input, ModelControllerProtocol.PARAM_INPUTSTREAMS_LENGTH);
    final int attachmentsLength = input.readInt();

    final PropagatedIdentity propagatedIdentity;
    final Boolean readIdentity = channelAssociation.getAttachments().getAttachment(TransactionalProtocolClient.SEND_IDENTITY);
    propagatedIdentity = (readIdentity != null && readIdentity) ? read(input) : null;

    final Boolean readSendInVm = channelAssociation.getAttachments().getAttachment(TransactionalProtocolClient.SEND_IN_VM);
    boolean inVmCall = false;
    if (readSendInVm != null && readSendInVm) {
        ProtocolUtils.expectHeader(input, ModelControllerProtocol.PARAM_IN_VM_CALL);
        inVmCall = input.readBoolean();
    }

    return new ExecutableRequest(operation, attachmentsLength, propagatedIdentity, inVmCall);
}
 
Example 4
Source File: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void handleRequest(DataInput input, ActiveOperation.ResultHandler<Void> resultHandler, ManagementRequestContext<RegistrationContext> context) throws IOException {
    final byte status = input.readByte();
    final ModelNode subsystems = new ModelNode();
    subsystems.readExternal(input);

    final RegistrationContext registration = context.getAttachment();
    if(status == DomainControllerProtocol.PARAM_OK) {
        registration.setSubsystems(subsystems, context);
    } else {
        registration.setSubsystems(null, context);
    }
}
 
Example 5
Source File: TransactionalProtocolClientImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@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()));
}
 
Example 6
Source File: HostControllerConnection.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void handleRequest(DataInput input, ActiveOperation.ResultHandler<ModelNode> resultHandler, ManagementRequestContext<Void> voidManagementRequestContext) throws IOException {
    final byte param = input.readByte();
    if(param == DomainServerProtocol.PARAM_OK) {
        final ModelNode operations = new ModelNode();
        operations.readExternal(input);
        resultHandler.done(operations);
    } else {
        resultHandler.failed(new IOException());
    }
}
 
Example 7
Source File: ObjectSerializerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Object deserializeModelNode(byte[] object) throws IOException {
    //Happens in the child classloader
    InputStream in = new ByteArrayInputStream(object);
    try {
        ModelNode modelNode = new ModelNode();
        modelNode.readExternal(in);
        return modelNode;
    } finally {
        IoUtils.safeClose(in);
    }
}
 
Example 8
Source File: ObjectSerializerImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public Object deserializeModelNode(byte[] object) throws IOException {
    //Happens in the child classloader
    InputStream in = new ByteArrayInputStream(object);
    try {
        ModelNode modelNode = new ModelNode();
        modelNode.readExternal(in);
        return modelNode;
    } finally {
        safeClose(in);
    }
}