use of org.apache.ignite.internal.tx.Timestamp in project ignite-3 by apache.
the class PartitionListener method handleFinishTxCommand.
/**
* Handler for the {@link FinishTxCommand}.
*
* @param cmd Command.
* @return Result.
*/
private boolean handleFinishTxCommand(FinishTxCommand cmd) {
Timestamp ts = cmd.timestamp();
boolean commit = cmd.finish();
return txManager.changeState(ts, TxState.PENDING, commit ? TxState.COMMITED : TxState.ABORTED);
}
use of org.apache.ignite.internal.tx.Timestamp in project ignite-3 by apache.
the class PartitionCommandListenerTest method upsert.
/**
* Upserts rows.
*/
private void upsert() {
Timestamp ts = Timestamp.nextVersion();
commandListener.onWrite(iterator((i, clo) -> {
when(clo.command()).thenReturn(new UpsertCommand(getTestRow(i, i), ts));
doAnswer(invocation -> {
assertNull(invocation.getArgument(0));
return null;
}).when(clo).result(any());
}));
}
use of org.apache.ignite.internal.tx.Timestamp in project ignite-3 by apache.
the class TxManagerImpl method begin.
/**
* {@inheritDoc}
*/
@Override
public InternalTransaction begin() {
Timestamp ts = Timestamp.nextVersion();
states.put(ts, TxState.PENDING);
return new TransactionImpl(this, ts, clusterService.topologyService().localMember().address());
}
use of org.apache.ignite.internal.tx.Timestamp in project ignite-3 by apache.
the class ItTxDistributedTestThreeNodesThreeReplicasCollocated method testTxStateReplication.
@Test
public void testTxStateReplication() {
TransactionImpl tx = (TransactionImpl) igniteTransactions.begin();
Timestamp txTimestamp = tx.timestamp();
accounts.recordView().upsert(tx, makeValue(1, 200.));
tx.commit();
assertTrue(TestUtils.waitForCondition(() -> txManagers.values().stream().filter(txManager -> txManager.state(txTimestamp) != null && txManager.state(txTimestamp).equals(TxState.COMMITED)).collect(Collectors.toList()).size() >= 2, 5_000));
}
Aggregations