use of org.apache.geode.distributed.TXManagerCancelledException in project geode by apache.
the class TXState method beforeCompletion.
//////////////////////////////////////////////////////////////////
// JTA Synchronization implementation //
//////////////////////////////////////////////////////////////////
/*
* (non-Javadoc)
*
* @see org.apache.geode.internal.cache.TXStateInterface#beforeCompletion()
*/
public void beforeCompletion() throws SynchronizationCommitConflictException {
if (this.closed) {
throw new TXManagerCancelledException();
}
this.proxy.getTxMgr().setTXState(null);
final long opStart = CachePerfStats.getStatTime();
this.jtaLifeTime = opStart - getBeginTime();
try {
reserveAndCheck();
/*
* If there is a TransactionWriter plugged in, we need to to give it an opportunity to abort
* the transaction.
*/
TransactionWriter writer = this.proxy.getTxMgr().getWriter();
if (writer != null) {
try {
// need to mark this so we don't fire again in commit
firedWriter = true;
TXEvent event = getEvent();
if (!event.hasOnlyInternalEvents()) {
writer.beforeCommit(event);
}
} catch (TransactionWriterException twe) {
cleanup();
throw new CommitConflictException(twe);
} catch (VirtualMachineError err) {
// cleanup(); this allocates objects so I don't think we can do it - that leaves the TX
// open, but we are poison pilling so we should be ok??
SystemFailure.initiateFailure(err);
// now, so don't let this thread continue.
throw err;
} catch (Throwable t) {
// rollback the transaction!
cleanup();
// Whenever you catch Error or Throwable, you must also
// catch VirtualMachineError (see above). However, there is
// _still_ a possibility that you are dealing with a cascading
// error condition, so you also need to check to see if the JVM
// is still usable:
SystemFailure.checkFailure();
throw new CommitConflictException(t);
}
}
} catch (CommitConflictException commitConflict) {
this.proxy.getTxMgr().noteCommitFailure(opStart, this.jtaLifeTime, this);
throw new SynchronizationCommitConflictException(LocalizedStrings.TXState_CONFLICT_DETECTED_IN_GEMFIRE_TRANSACTION_0.toLocalizedString(getTransactionId()), commitConflict);
}
}
Aggregations