try {
simulateLocking(ctx, command, clusteringDependentLogic);
if (ctx.isOriginLocal()) {
return invokeNextInterceptor(ctx, command);
} else {
TotalOrderRemoteTransactionState state = getTransactionState(ctx);
try {
state.preparing();
if (state.isRollbackReceived()) {
//this means that rollback has already been received
transactionTable.removeRemoteTransaction(command.getGlobalTransaction());
throw new CacheException("Cannot prepare transaction" + command.getGlobalTransaction().globalId() +
". it was already marked as rollback");
}
if (state.isCommitReceived()) {
log.tracef("Transaction %s marked for commit, skipping the write skew check and forcing 1PC",
command.getGlobalTransaction().globalId());
((TotalOrderPrepareCommand) command).markSkipWriteSkewCheck();
((TotalOrderPrepareCommand) command).markAsOnePhaseCommit();
}
if (log.isTraceEnabled()) {
log.tracef("Validating transaction %s ", command.getGlobalTransaction().globalId());
}
//invoke next interceptor in the chain
Object result = invokeNextInterceptor(ctx, command);
if (command.isOnePhaseCommit()) {
totalOrderManager.release(state);
}
return result;
} finally {
state.prepared();
}
}
} catch (Throwable exception) {
if (log.isDebugEnabled()) {