use of org.apache.ignite.internal.tx.InternalTransaction in project ignite-3 by apache.
the class RecordBinaryViewImpl method getAndReplaceAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Tuple> getAndReplaceAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
Objects.requireNonNull(rec);
final Row row = marshal(rec, false);
return tbl.getAndReplace(row, (InternalTransaction) tx).thenApply(this::wrap);
}
use of org.apache.ignite.internal.tx.InternalTransaction in project ignite-3 by apache.
the class RecordBinaryViewImpl method getAndDeleteAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Tuple> getAndDeleteAsync(@Nullable Transaction tx, @NotNull Tuple keyRec) {
Objects.requireNonNull(keyRec);
final Row keyRow = marshal(keyRec, true);
return tbl.getAndDelete(keyRow, (InternalTransaction) tx).thenApply(this::wrap);
}
use of org.apache.ignite.internal.tx.InternalTransaction in project ignite-3 by apache.
the class RecordBinaryViewImpl method getAndUpsertAsync.
/**
* {@inheritDoc}
*/
@Override
@NotNull
public CompletableFuture<Tuple> getAndUpsertAsync(@Nullable Transaction tx, @NotNull Tuple rec) {
Objects.requireNonNull(rec);
final Row row = marshal(rec, false);
return tbl.getAndUpsert(row, (InternalTransaction) tx).thenApply(this::wrap);
}
use of org.apache.ignite.internal.tx.InternalTransaction in project ignite-3 by apache.
the class TxAbstractTest method testAbortWithValue.
@Test
public void testAbortWithValue() throws TransactionException {
accounts.recordView().upsert(null, makeValue(0, 100.));
assertEquals(100., accounts.recordView().get(null, makeKey(0)).doubleValue("balance"));
InternalTransaction tx = (InternalTransaction) igniteTransactions.begin();
var table = accounts.recordView();
table.upsert(tx, makeValue(0, 200.));
assertEquals(200., table.get(tx, makeKey(0)).doubleValue("balance"));
tx.rollback();
assertEquals(100., accounts.recordView().get(null, makeKey(0)).doubleValue("balance"));
}
use of org.apache.ignite.internal.tx.InternalTransaction in project ignite-3 by apache.
the class TxAbstractTest method testUpgradedLockInvalidation.
@Test
// TODO asch IGNITE-15938
@Disabled("https://issues.apache.org/jira/browse/IGNITE-15938")
public void testUpgradedLockInvalidation() throws Exception {
accounts.recordView().upsert(null, makeValue(1, 100.));
InternalTransaction tx = (InternalTransaction) igniteTransactions.begin();
InternalTransaction tx2 = (InternalTransaction) igniteTransactions.begin();
var table = accounts.recordView();
var table2 = accounts.recordView();
double v0 = table.get(tx, makeKey(1)).doubleValue("balance");
double v1 = table2.get(tx2, makeKey(1)).doubleValue("balance");
assertEquals(v0, v1);
// Try to upgrade a lock.
table2.upsertAsync(tx2, makeValue(1, v0 + 10));
// Give some time to update lock queue TODO asch IGNITE-15928
Thread.sleep(300);
table.upsert(tx, makeValue(1, v0 + 20));
tx.commit();
assertThrows(Exception.class, () -> tx2.commit());
}
Aggregations