Java Code Examples for org.jboss.as.controller.ModelController#OperationTransactionControl

The following examples show how to use org.jboss.as.controller.ModelController#OperationTransactionControl . 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: ModelTestModelControllerService.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected ModelNode internalExecute(final ModelNode operation, final OperationMessageHandler handler,
                                    final ModelController.OperationTransactionControl control,
                                    final OperationAttachments attachments, final OperationStepHandler prepareStep) {
    return super.internalExecute(operation, handler, control, attachments, prepareStep);
}
 
Example 2
Source File: MasterDomainControllerOperationHandlerService.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
protected OperationResponse internalExecute(final Operation operation, final ManagementRequestContext<?> context, final OperationMessageHandler messageHandler, final ModelController.OperationTransactionControl control) {

    final ModelNode operationNode = operation.getOperation();
    final OperationStepHandler handler;
    final String operationName = operation.getOperation().require(OP).asString();
    if (operationName.equals(FetchMissingConfigurationHandler.OPERATION_NAME)) {
        handler = new FetchMissingConfigurationHandler(SlaveChannelAttachments.getHostName(context.getChannel()),
                SlaveChannelAttachments.getTransformers(context.getChannel()),
                domainController.getExtensionRegistry());
    } else {
        throw HostControllerLogger.ROOT_LOGGER.cannotExecuteTransactionalOperationFromSlave(operationName);
    }

    Integer domainControllerLockId;
    if (operationNode.get(OPERATION_HEADERS).hasDefined(DomainControllerLockIdUtils.DOMAIN_CONTROLLER_LOCK_ID)) {
        domainControllerLockId = operationNode.get(OPERATION_HEADERS, DomainControllerLockIdUtils.DOMAIN_CONTROLLER_LOCK_ID).asInt();
    } else {
        domainControllerLockId = null;
    }

    if (domainControllerLockId == null) {
        synchronized (this) {
            SlaveRequest slaveRequest = this.activeSlaveRequest;
            if (slaveRequest != null) {
                domainControllerLockId = slaveRequest.domainId;
                slaveRequest.refCount.incrementAndGet();
            }
        }
    }

    try {
        if (domainControllerLockId != null) {
            assert operation.getInputStreams().size() == 0; // we don't support associating streams with an active op
            ModelNode responseNode = executor.joinActiveOperation(operation.getOperation(), messageHandler, control, handler, domainControllerLockId);
            return OperationResponse.Factory.createSimple(responseNode);
        } else {
            return executor.executeAndAttemptLock(operation, messageHandler, control, new OperationStepHandler() {
                @Override
                public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
                    //Grab the lock id and store it
                    Integer domainControllerLockId = CurrentOperationIdHolder.getCurrentOperationID();
                    synchronized (this) {
                        activeSlaveRequest = new SlaveRequest(domainControllerLockId);
                    }
                    context.addStep(operation, handler, OperationContext.Stage.MODEL);
                }
            });
        }
    } finally {
        synchronized (this) {
            SlaveRequest slaveRequest = this.activeSlaveRequest;
            if (slaveRequest != null) {
                int refcount = slaveRequest.refCount.decrementAndGet();
                if (refcount == 0) {
                    activeSlaveRequest = null;
                }
            }
        }
    }
}
 
Example 3
Source File: TransactionalProtocolOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Subclasses can override this method to determine how to execute the method, e.g. attach to an existing operation or not
 *
 * @param operation the operation being executed
 * @param messageHandler the operation message handler proxy
 * @param control the operation transaction control
 * @return the result of the executed operation
 */
protected OperationResponse internalExecute(final Operation operation, final ManagementRequestContext<?> context, final OperationMessageHandler messageHandler, final ModelController.OperationTransactionControl control) {
    // Execute the operation
    return controller.execute(
            operation,
            messageHandler,
            control);
}
 
Example 4
Source File: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Execute the operation.
 *
 * @param operation operation
 * @param handler the message handler
 * @param control the transaction control
 * @param step the step to be executed
 * @return the result
 */
ModelNode execute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler step);
 
Example 5
Source File: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Execute an operation using the current management model.
 *
 * @param operation    the operation
 * @param handler      the operation handler to use
 * @return the operation result
 */
ModelNode executeReadOnly(ModelNode operation, OperationStepHandler handler, ModelController.OperationTransactionControl control);
 
Example 6
Source File: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Execute an operation using given resource model.
 *
 * @param operation    the operation
 * @param model        the resource model
 * @param handler      the operation handler to use
 * @return the operation result
 */
ModelNode executeReadOnly(ModelNode operation, Resource model, OperationStepHandler handler, ModelController.OperationTransactionControl control);
 
Example 7
Source File: ServerToHostProtocolHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Execute the operation.
 *
 * @param operation operation
 * @param handler the message handler
 * @param control the transaction control
 * @param step the step to be executed
 * @return the result
 */
ModelNode execute(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler step);
 
Example 8
Source File: ServerToHostProtocolHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 2 votes vote down vote up
/**
 * Join an existing operation
 *
 * @param operation the operation to execute
 * @param handler the message handler
 * @param control the transaction control
 * @param step the step to be executed
 * @param permit the permit
 * @return the result
 */
ModelNode joinActiveOperation(ModelNode operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler step, int permit);
 
Example 9
Source File: MasterDomainControllerOperationHandlerService.java    From wildfly-core with GNU Lesser General Public License v2.1 votes vote down vote up
OperationResponse executeAndAttemptLock(Operation operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler step); 
Example 10
Source File: MasterDomainControllerOperationHandlerService.java    From wildfly-core with GNU Lesser General Public License v2.1 votes vote down vote up
ModelNode joinActiveOperation(ModelNode operation, OperationMessageHandler handler, ModelController.OperationTransactionControl control, OperationStepHandler step, int permit);