Search in sources :

Example 1 with FinalizeRemoteTransactionOperation

use of com.hazelcast.transaction.impl.xa.operations.FinalizeRemoteTransactionOperation in project hazelcast by hazelcast.

the class XAResourceImpl method finalizeTransactionRemotely.

private void finalizeTransactionRemotely(Xid xid, boolean isCommit) throws XAException {
    NodeEngine nodeEngine = getNodeEngine();
    IPartitionService partitionService = nodeEngine.getPartitionService();
    OperationService operationService = nodeEngine.getOperationService();
    SerializableXID serializableXID = new SerializableXID(xid.getFormatId(), xid.getGlobalTransactionId(), xid.getBranchQualifier());
    Data xidData = nodeEngine.toData(serializableXID);
    int partitionId = partitionService.getPartitionId(xidData);
    FinalizeRemoteTransactionOperation operation = new FinalizeRemoteTransactionOperation(xidData, isCommit);
    InternalCompletableFuture<Integer> future = operationService.invokeOnPartition(SERVICE_NAME, operation, partitionId);
    Integer errorCode;
    try {
        errorCode = future.get();
    } catch (Exception e) {
        throw ExceptionUtil.rethrow(e);
    }
    if (errorCode != null) {
        throw new XAException(errorCode);
    }
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) XAException(javax.transaction.xa.XAException) IPartitionService(com.hazelcast.spi.partition.IPartitionService) Data(com.hazelcast.nio.serialization.Data) OperationService(com.hazelcast.spi.OperationService) FinalizeRemoteTransactionOperation(com.hazelcast.transaction.impl.xa.operations.FinalizeRemoteTransactionOperation) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) MemberLeftException(com.hazelcast.core.MemberLeftException) TargetNotMemberException(com.hazelcast.spi.exception.TargetNotMemberException) ExecutionException(java.util.concurrent.ExecutionException) XAException(javax.transaction.xa.XAException)

Aggregations

HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 MemberLeftException (com.hazelcast.core.MemberLeftException)1 Data (com.hazelcast.nio.serialization.Data)1 NodeEngine (com.hazelcast.spi.NodeEngine)1 OperationService (com.hazelcast.spi.OperationService)1 TargetNotMemberException (com.hazelcast.spi.exception.TargetNotMemberException)1 IPartitionService (com.hazelcast.spi.partition.IPartitionService)1 FinalizeRemoteTransactionOperation (com.hazelcast.transaction.impl.xa.operations.FinalizeRemoteTransactionOperation)1 ExecutionException (java.util.concurrent.ExecutionException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 XAException (javax.transaction.xa.XAException)1