use of org.apache.ignite.internal.table.distributed.command.TransactionalCommand in project ignite-3 by apache.
the class PartitionListener method tryEnlistIntoTransaction.
/**
* Attempts to enlist a command into a transaction.
*
* @param command The command.
* @param clo The closure.
* @return {@code true} if a command is compatible with a transaction state or a command is not transactional.
*/
private boolean tryEnlistIntoTransaction(Command command, CommandClosure<?> clo) {
if (command instanceof TransactionalCommand) {
Timestamp ts = ((TransactionalCommand) command).getTimestamp();
TxState state = txManager.getOrCreateTransaction(ts);
if (state != null && state != TxState.PENDING) {
clo.result(new TransactionException(format("Failed to enlist a key into a transaction, state={}", state)));
return false;
}
}
return true;
}
Aggregations