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

The following examples show how to use org.jboss.as.controller.ModelController#OperationTransaction . 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: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Once the "read-domain-mode" operation is in operationPrepared, send the model back to registering HC.
 * When the model was applied successfully on the client, we process registering the proxy in the domain,
 * otherwise we rollback.
 *
 * @param transaction the model controller tx
 * @param result the prepared result (domain model)
 * @throws SlaveRegistrationException
 */
void registerHost(final ModelController.OperationTransaction transaction, final ModelNode result) throws SlaveRegistrationException {
    //
    if (sendResultToHost(transaction, result)) return;
    synchronized (this) {
        Long pingPongId = hostInfo.getRemoteConnectionId();
        // Register the slave
        domainController.registerRemoteHost(hostName, handler, transformers, pingPongId, registerProxyController);
        // Complete registration
        if(! failed) {
            transaction.commit();
        } else {
            transaction.rollback();
            return;
        }
    }
    if (registerProxyController) {
        DOMAIN_LOGGER.registeredRemoteSlaveHost(hostName, hostInfo.getPrettyProductName());
    }
}
 
Example 2
Source File: HostControllerRegistrationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private boolean sendResultToHost(ModelController.OperationTransaction transaction, final ModelNode result) {
    final Boolean registered = executeBlocking(new IOTask<Boolean>() {
        @Override
        void sendMessage(final FlushableDataOutput output) throws IOException {
            sendResponse(output, DomainControllerProtocol.PARAM_OK, result);
        }
    });
    if(! registered) {
        transaction.rollback();
        return true;
    }
    return false;
}
 
Example 3
Source File: TransactionalProtocolClientImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected PreparedOperationImpl(T operation, ModelNode preparedResult, AsyncFuture<OperationResponse> finalResult, ModelController.OperationTransaction transaction) {
    assert finalResult != null : "null result";
    this.operation = operation;
    this.preparedResult = preparedResult;
    this.finalResult = finalResult;
    this.transaction = transaction;
}
 
Example 4
Source File: TransactionalProtocolOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void operationPrepared(final ModelController.OperationTransaction transaction, final ModelNode result) {

    requestContext.prepare(transaction, result);
    try {
        // Wait for the commit or rollback message
        requestContext.txCompletedLatch.await();
    } catch (InterruptedException e) {
        // requestContext.getResultHandler().failed(e);
        ROOT_LOGGER.tracef("Clearing interrupted status from client request %d", requestContext.getOperationId());
        Thread.currentThread().interrupt();
    }
}
 
Example 5
Source File: TransactionalProtocolOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public synchronized void failed(Exception e) {
    if(prepared) {
        final ModelController.OperationTransaction transaction = activeTx;
        activeTx = null;
        if(transaction != null) {
            try {
                transaction.rollback();
            } finally {
                txCompletedLatch.countDown();
            }
        }
    } else if (responseChannel != null) {
        rollbackOnPrepare = true;
        // Failed in a step before prepare, send error response
        final String message = e.getMessage() != null ? e.getMessage() : "failure before rollback " + e.getClass().getName();
        final ModelNode response = new ModelNode();
        response.get(OUTCOME).set(FAILED);
        response.get(FAILURE_DESCRIPTION).set(message);
        ControllerLogger.MGMT_OP_LOGGER.tracef("sending pre-prepare failed response for %d  --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted());
        try {
            sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_FAILED, response);
            responseChannel = null;
        } catch (IOException ignored) {
            ControllerLogger.MGMT_OP_LOGGER.failedSendingFailedResponse(ignored, response, getOperationId());
        }
    }
}
 
Example 6
Source File: TransactionalProtocolOperationHandler.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
/** Signal from ProxyOperationTransactionControl that the operation is prepared */
synchronized void prepare(final ModelController.OperationTransaction tx, final ModelNode result) {
    assert !prepared;
    prepared = true;
    if(rollbackOnPrepare) {
        try {
            tx.rollback();
            ControllerLogger.MGMT_OP_LOGGER.tracef("rolled back on prepare for %d  --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted());
        } finally {
            txCompletedLatch.countDown();
        }

        // no response to remote side here; the response will go out when this thread executing
        // the now rolled-back op returns in ExecuteRequestHandler.doExecute

    } else {
        assert activeTx == null;
        assert responseChannel != null;
        activeTx = tx;
        ControllerLogger.MGMT_OP_LOGGER.tracef("sending prepared response for %d  --- interrupted: %s", getOperationId(), (Object) Thread.currentThread().isInterrupted());
        try {
            sendResponse(responseChannel, ModelControllerProtocol.PARAM_OPERATION_PREPARED, result);
            responseChannel = null; // we've now sent a response to the original request, so we can't use this one further
        } catch (IOException e) {
            getResultHandler().failed(e); // this will eventually call back into failed(e) above and roll back the tx
        }
    }
}
 
Example 7
Source File: EarlyResponseTransactionControl.java    From wildfly-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void operationPrepared(ModelController.OperationTransaction transaction, final ModelNode preparedResult, OperationContext context) {
    transaction.commit();
    if (context == null || !reload) { // TODO deal with shutdown as well, the handlers for which have some
                                      // subtleties that need thought
        sendResponse(preparedResult);
    } else {
        context.attach(EarlyResponseSendListener.ATTACHMENT_KEY, new EarlyResponseSendListener() {
            @Override
            public void sendEarlyResponse(OperationContext.ResultAction resultAction) {
                sendResponse(preparedResult);
            }
        });
    }
}
 
Example 8
Source File: TransactionalProtocolClientImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
synchronized void operationPrepared(final ModelController.OperationTransaction transaction, final ModelNode result) {
    wrapper.prepared(transaction, result);
}
 
Example 9
Source File: TransactionalProtocolClientImpl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
void prepared(final ModelController.OperationTransaction transaction, final ModelNode result) {
    final PreparedOperation<T> preparedOperation = new PreparedOperationImpl<T>(operation, result, future, transaction);
    listener.operationPrepared(preparedOperation);
}
 
Example 10
Source File: EarlyResponseTransactionControl.java    From wildfly-core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void operationPrepared(ModelController.OperationTransaction transaction, ModelNode preparedResult) {
    // Shouldn't be called but if it is, send the result immediately
    operationPrepared(transaction, preparedResult, null);
}