use of com.hazelcast.transaction.impl.operations.BroadcastTxRollbackOperation in project hazelcast by hazelcast.
the class TransactionManagerServiceImpl method finalize.
private boolean finalize(String uuid, String txnId, TxBackupLog log) {
OperationService operationService = nodeEngine.getOperationService();
if (!uuid.equals(log.callerUuid)) {
return false;
}
if (log.state == ACTIVE) {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:ACTIVE] of endpoint " + uuid);
}
Collection<Member> memberList = nodeEngine.getClusterService().getMembers();
Collection<Future> futures = new ArrayList<Future>(memberList.size());
for (Member member : memberList) {
Operation op = new BroadcastTxRollbackOperation(txnId);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
futures.add(f);
}
long timeoutMillis = TransactionOptions.getDefault().getTimeoutMillis();
waitWithDeadline(futures, timeoutMillis, TimeUnit.MILLISECONDS, finalizeExceptionHandler);
} else {
TransactionImpl tx;
if (log.allowedDuringPassiveState) {
tx = new AllowedDuringPassiveStateTransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
} else {
tx = new TransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
}
if (log.state == COMMITTING) {
if (logger.isFinestEnabled()) {
logger.finest("Committing transaction[id:" + txnId + ", state:COMMITTING] of endpoint " + uuid);
}
try {
tx.commit();
} catch (Throwable e) {
logger.warning("Error during committing from tx backup!", e);
}
} else {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:" + log.state + "] of endpoint " + uuid);
}
try {
tx.rollback();
} catch (Throwable e) {
logger.warning("Error during rolling-back from tx backup!", e);
}
}
}
return true;
}
use of com.hazelcast.transaction.impl.operations.BroadcastTxRollbackOperation in project hazelcast by hazelcast.
the class TransactionManagerServiceImpl method finalizeTransaction.
private boolean finalizeTransaction(UUID uuid, UUID txnId, TxBackupLog log) {
OperationService operationService = nodeEngine.getOperationService();
if (!uuid.equals(log.callerUuid)) {
return false;
}
if (log.state == ACTIVE) {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:ACTIVE] of endpoint " + uuid);
}
Collection<Member> memberList = nodeEngine.getClusterService().getMembers();
Collection<Future> futures = new ArrayList<>(memberList.size());
for (Member member : memberList) {
Operation op = new BroadcastTxRollbackOperation(txnId);
Future f = operationService.invokeOnTarget(SERVICE_NAME, op, member.getAddress());
futures.add(f);
}
long timeoutMillis = TransactionOptions.getDefault().getTimeoutMillis();
waitWithDeadline(futures, timeoutMillis, TimeUnit.MILLISECONDS, finalizeExceptionHandler);
} else {
TransactionImpl tx;
if (log.allowedDuringPassiveState) {
tx = new AllowedDuringPassiveStateTransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
} else {
tx = new TransactionImpl(this, nodeEngine, txnId, log.records, log.timeoutMillis, log.startTime, log.callerUuid);
}
if (log.state == COMMITTING) {
if (logger.isFinestEnabled()) {
logger.finest("Committing transaction[id:" + txnId + ", state:COMMITTING] of endpoint " + uuid);
}
try {
tx.commit();
} catch (Throwable e) {
logger.warning("Error during committing from tx backup!", e);
}
} else {
if (logger.isFinestEnabled()) {
logger.finest("Rolling-back transaction[id:" + txnId + ", state:" + log.state + "] of endpoint " + uuid);
}
try {
tx.rollback();
} catch (Throwable e) {
logger.warning("Error during rolling-back from tx backup!", e);
}
}
}
return true;
}
Aggregations