Search in sources :

Example 6 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class PartitionedTXRegionStub method containsKey.

public boolean containsKey(KeyInfo keyInfo) {
    PartitionedRegion pr = (PartitionedRegion) region;
    try {
        boolean retVal = pr.containsKeyRemotely((InternalDistributedMember) state.getTarget(), keyInfo.getBucketId(), keyInfo.getKey());
        trackBucketForTx(keyInfo);
        return retVal;
    } catch (TransactionException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e.getCause());
        throw re;
    } catch (PrimaryBucketException e) {
        RuntimeException re = getTransactionException(keyInfo, e);
        re.initCause(e);
        throw re;
    } catch (ForceReattemptException e) {
        if (isBucketNotFoundException(e)) {
            RuntimeException re = getTransactionException(keyInfo, e);
            re.initCause(e);
            throw re;
        }
        waitToRetry();
        RuntimeException re = new TransactionDataNodeHasDepartedException(LocalizedStrings.PartitionedRegion_TRANSACTION_DATA_NODE_0_HAS_DEPARTED_TO_PROCEED_ROLLBACK_THIS_TRANSACTION_AND_BEGIN_A_NEW_ONE.toLocalizedString(state.getTarget()));
        re.initCause(e);
        throw re;
    }
}
Also used : TransactionException(org.apache.geode.cache.TransactionException) ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) PrimaryBucketException(org.apache.geode.internal.cache.PrimaryBucketException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 7 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class CommitFunction method execute.

public void execute(FunctionContext context) {
    Cache cache = CacheFactory.getAnyInstance();
    TXId txId = null;
    try {
        txId = (TXId) context.getArguments();
    } catch (ClassCastException e) {
        logger.info("CommitFunction should be invoked with a TransactionId as an argument i.e. setArguments(txId).execute(function)");
        throw e;
    }
    DistributedMember member = txId.getMemberId();
    Boolean result = false;
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (cache.getDistributedSystem().getDistributedMember().equals(member)) {
        if (isDebugEnabled) {
            logger.debug("CommitFunction: for transaction: {} committing locally", txId);
        }
        CacheTransactionManager txMgr = cache.getCacheTransactionManager();
        if (txMgr.tryResume(txId)) {
            if (isDebugEnabled) {
                logger.debug("CommitFunction: resumed transaction: {}", txId);
            }
            txMgr.commit();
            result = true;
        }
    } else {
        ArrayList args = new ArrayList();
        args.add(txId);
        args.add(NestedTransactionFunction.COMMIT);
        Execution ex = FunctionService.onMember(member).setArguments(args);
        if (isDebugEnabled) {
            logger.debug("CommitFunction: for transaction: {} executing NestedTransactionFunction on member: {}", txId, member);
        }
        try {
            List list = (List) ex.execute(new NestedTransactionFunction()).getResult();
            result = (Boolean) list.get(0);
        } catch (FunctionException fe) {
            if (fe.getCause() instanceof FunctionInvocationTargetException) {
                throw new TransactionDataNodeHasDepartedException("Could not commit on member:" + member);
            } else {
                throw fe;
            }
        }
    }
    if (isDebugEnabled) {
        logger.debug("CommitFunction: for transaction: {} returning result: {}", txId, result);
    }
    context.getResultSender().lastResult(result);
}
Also used : ArrayList(java.util.ArrayList) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException) Execution(org.apache.geode.cache.execute.Execution) TXId(org.apache.geode.internal.cache.TXId) DistributedMember(org.apache.geode.distributed.DistributedMember) FunctionInvocationTargetException(org.apache.geode.cache.execute.FunctionInvocationTargetException) ArrayList(java.util.ArrayList) List(java.util.List) Cache(org.apache.geode.cache.Cache)

Example 8 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class RollbackFunction method execute.

public void execute(FunctionContext context) {
    Cache cache = CacheFactory.getAnyInstance();
    TXId txId = null;
    try {
        txId = (TXId) context.getArguments();
    } catch (ClassCastException e) {
        logger.info("RollbackFunction should be invoked with a TransactionId as an argument i.e. setArguments(txId).execute(function)");
        throw e;
    }
    DistributedMember member = txId.getMemberId();
    Boolean result = false;
    final boolean isDebugEnabled = logger.isDebugEnabled();
    if (cache.getDistributedSystem().getDistributedMember().equals(member)) {
        if (isDebugEnabled) {
            logger.debug("RollbackFunction: for transaction: {} rolling back locally", txId);
        }
        CacheTransactionManager txMgr = cache.getCacheTransactionManager();
        if (txMgr.tryResume(txId)) {
            if (isDebugEnabled) {
                logger.debug("RollbackFunction: resumed transaction: {}", txId);
            }
            txMgr.rollback();
            result = true;
        }
    } else {
        ArrayList args = new ArrayList();
        args.add(txId);
        args.add(NestedTransactionFunction.ROLLBACK);
        Execution ex = FunctionService.onMember(member).setArguments(args);
        if (isDebugEnabled) {
            logger.debug("RollbackFunction: for transaction: {} executing NestedTransactionFunction on member: {}", txId, member);
        }
        try {
            List list = (List) ex.execute(new NestedTransactionFunction()).getResult();
            result = (Boolean) list.get(0);
        } catch (FunctionException fe) {
            throw new TransactionDataNodeHasDepartedException("Could not Rollback on member:" + member);
        }
    }
    if (isDebugEnabled) {
        logger.debug("RollbackFunction: for transaction: {} returning result: {}", txId, result);
    }
    context.getResultSender().lastResult(result);
}
Also used : ArrayList(java.util.ArrayList) FunctionException(org.apache.geode.cache.execute.FunctionException) CacheTransactionManager(org.apache.geode.cache.CacheTransactionManager) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException) Execution(org.apache.geode.cache.execute.Execution) TXId(org.apache.geode.internal.cache.TXId) DistributedMember(org.apache.geode.distributed.DistributedMember) ArrayList(java.util.ArrayList) List(java.util.List) Cache(org.apache.geode.cache.Cache)

Example 9 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class ClientTXStateStub method commit.

@Override
public void commit() throws CommitConflictException {
    obtainLocalLocks();
    try {
        TXCommitMessage txcm = firstProxy.commit(proxy.getTxId().getUniqId());
        afterServerCommit(txcm);
    } catch (TransactionDataNodeHasDepartedException e) {
        throw new TransactionInDoubtException(e);
    } finally {
        lockReq.releaseLocal();
        this.firstProxy.getPool().releaseServerAffinity();
    }
}
Also used : TXCommitMessage(org.apache.geode.internal.cache.TXCommitMessage) TransactionInDoubtException(org.apache.geode.cache.TransactionInDoubtException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Example 10 with TransactionDataNodeHasDepartedException

use of org.apache.geode.cache.TransactionDataNodeHasDepartedException in project geode by apache.

the class DistributedTXRegionStub method postPutAll.

public void postPutAll(DistributedPutAllOperation putallOp, VersionedObjectList successfulPuts, LocalRegion region) {
    try {
        RemotePutAllMessage.PutAllResponse response = RemotePutAllMessage.send(state.getTarget(), putallOp.getBaseEvent(), putallOp.getPutAllEntryData(), putallOp.getPutAllEntryData().length, true, DistributionManager.PARTITIONED_REGION_EXECUTOR, false);
        response.waitForCacheException();
    } catch (RegionDestroyedException rde) {
        throw new TransactionDataNotColocatedException(LocalizedStrings.RemoteMessage_REGION_0_NOT_COLOCATED_WITH_TRANSACTION.toLocalizedString(rde.getRegionFullPath()), rde);
    } catch (RemoteOperationException roe) {
        throw new TransactionDataNodeHasDepartedException(roe);
    }
}
Also used : RemotePutAllMessage(org.apache.geode.internal.cache.RemotePutAllMessage) RegionDestroyedException(org.apache.geode.cache.RegionDestroyedException) TransactionDataNotColocatedException(org.apache.geode.cache.TransactionDataNotColocatedException) RemoteOperationException(org.apache.geode.internal.cache.RemoteOperationException) TransactionDataNodeHasDepartedException(org.apache.geode.cache.TransactionDataNodeHasDepartedException)

Aggregations

TransactionDataNodeHasDepartedException (org.apache.geode.cache.TransactionDataNodeHasDepartedException)15 RegionDestroyedException (org.apache.geode.cache.RegionDestroyedException)6 TransactionDataNotColocatedException (org.apache.geode.cache.TransactionDataNotColocatedException)6 RemoteOperationException (org.apache.geode.internal.cache.RemoteOperationException)6 TransactionException (org.apache.geode.cache.TransactionException)5 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)5 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)5 PrimaryBucketException (org.apache.geode.internal.cache.PrimaryBucketException)5 TransactionDataRebalancedException (org.apache.geode.cache.TransactionDataRebalancedException)3 TXId (org.apache.geode.internal.cache.TXId)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Cache (org.apache.geode.cache.Cache)2 CacheException (org.apache.geode.cache.CacheException)2 CacheTransactionManager (org.apache.geode.cache.CacheTransactionManager)2 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)2 Execution (org.apache.geode.cache.execute.Execution)2 FunctionException (org.apache.geode.cache.execute.FunctionException)2 DistributedMember (org.apache.geode.distributed.DistributedMember)2 PartitionedRegionException (org.apache.geode.internal.cache.PartitionedRegionException)2