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;
}
}
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);
}
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);
}
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();
}
}
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);
}
}
Aggregations