Search in sources :

Example 1 with AsyncTransactionStep

use of com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep in project java-spanner by googleapis.

the class AsyncTransactionManagerTest method asyncTransactionManagerReadRow.

@Test
public void asyncTransactionManagerReadRow() throws Exception {
    try (AsyncTransactionManager manager = client().transactionManagerAsync()) {
        TransactionContextFuture transactionContextFuture = manager.beginAsync();
        while (true) {
            try {
                AsyncTransactionStep<Struct, String> value = transactionContextFuture.then((transactionContext, ignored) -> transactionContext.readRowAsync(READ_TABLE_NAME, Key.of(1L), READ_COLUMN_NAMES), executor).then((ignored, input) -> ApiFutures.immediateFuture(input.getString("Value")), executor);
                value.commitAsync().get();
                assertThat(value.get()).isEqualTo("v1");
                break;
            } catch (AbortedException e) {
                transactionContextFuture = manager.resetForRetryAsync();
            }
        }
    }
}
Also used : Arrays(java.util.Arrays) BatchCreateSessionsRequest(com.google.spanner.v1.BatchCreateSessionsRequest) TimeoutException(java.util.concurrent.TimeoutException) StatementResult(com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_STATEMENT) TransactionSelector(com.google.spanner.v1.TransactionSelector) Status(io.grpc.Status) BeginTransactionRequest(com.google.spanner.v1.BeginTransactionRequest) Parameterized(org.junit.runners.Parameterized) CommitTimestampFuture(com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture) ApiFutures(com.google.api.core.ApiFutures) SpannerApiFutures.get(com.google.cloud.spanner.SpannerApiFutures.get) Collection(java.util.Collection) READ_COLUMN_NAMES(com.google.cloud.spanner.MockSpannerTestUtil.READ_COLUMN_NAMES) Range(com.google.common.collect.Range) ApiFutureCallback(com.google.api.core.ApiFutureCallback) Executors(java.util.concurrent.Executors) ApiFuture(com.google.api.core.ApiFuture) SettableApiFuture(com.google.api.core.SettableApiFuture) UPDATE_COUNT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_COUNT) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) INVALID_UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.INVALID_UPDATE_STATEMENT) READ_TABLE_NAME(com.google.cloud.spanner.MockSpannerTestUtil.READ_TABLE_NAME) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) CommitRequest(com.google.spanner.v1.CommitRequest) ImmutableList(com.google.common.collect.ImmutableList) SimulatedExecutionTime(com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) AbstractMessage(com.google.protobuf.AbstractMessage) Executor(java.util.concurrent.Executor) Assert.assertNotNull(org.junit.Assert.assertNotNull) Parameter(org.junit.runners.Parameterized.Parameter) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) RollbackRequest(com.google.spanner.v1.RollbackRequest) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ReadOption(com.google.cloud.spanner.Options.ReadOption) AsyncTransactionFunction(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionFunction) AsyncTransactionStep(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep) SessionPoolTransactionContext(com.google.cloud.spanner.SessionPool.SessionPoolTransactionContext) UPDATE_ABORTED_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_ABORTED_STATEMENT) TransactionContextImpl(com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl) ExecuteBatchDmlRequest(com.google.spanner.v1.ExecuteBatchDmlRequest) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) Test(org.junit.Test)

Example 2 with AsyncTransactionStep

use of com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep in project java-spanner by googleapis.

the class ITTransactionManagerAsyncTest method testAbortAndRetry.

@Ignore("Cloud Spanner now seems to return CANCELLED instead of ABORTED when a transaction is invalidated by a later transaction in the same session")
@Test
public void testAbortAndRetry() throws InterruptedException, ExecutionException {
    assumeFalse("Emulator does not support more than 1 simultaneous transaction. " + "This test would therefore loop indefinitely on the emulator.", isUsingEmulator());
    client.write(Collections.singletonList(Mutation.newInsertBuilder("T").set("K").to("Key3").set("BoolValue").to(true).build()));
    try (AsyncTransactionManager manager1 = client.transactionManagerAsync()) {
        TransactionContextFuture txn1 = manager1.beginAsync();
        AsyncTransactionManager manager2;
        TransactionContextFuture txn2;
        AsyncTransactionStep<Void, Struct> txn2Step1;
        while (true) {
            try {
                AsyncTransactionStep<Void, Struct> txn1Step1 = txn1.then((transaction, ignored) -> transaction.readRowAsync("T", Key.of("Key3"), Arrays.asList("K", "BoolValue")), executor);
                manager2 = client.transactionManagerAsync();
                txn2 = manager2.beginAsync();
                txn2Step1 = txn2.then((transaction, ignored) -> transaction.readRowAsync("T", Key.of("Key3"), Arrays.asList("K", "BoolValue")), executor);
                AsyncTransactionStep<Struct, Void> txn1Step2 = txn1Step1.then((transaction, ignored) -> {
                    transaction.buffer(Mutation.newUpdateBuilder("T").set("K").to("Key3").set("BoolValue").to(false).build());
                    return ApiFutures.immediateFuture(null);
                }, executor);
                txn2Step1.get();
                txn1Step2.commitAsync().get();
                break;
            } catch (AbortedException e) {
                Thread.sleep(e.getRetryDelayInMillis());
                // In that case we should just retry without resetting anything.
                if (manager1.getState() == TransactionState.ABORTED) {
                    txn1 = manager1.resetForRetryAsync();
                }
            }
        }
        // txn2 should have been aborted.
        try {
            txn2Step1.commitAsync().get();
            fail("Expected to abort");
        } catch (AbortedException e) {
            assertThat(manager2.getState()).isEqualTo(TransactionState.ABORTED);
            txn2 = manager2.resetForRetryAsync();
        }
        AsyncTransactionStep<Void, Void> txn2Step2 = txn2.then((transaction, ignored) -> {
            transaction.buffer(Mutation.newUpdateBuilder("T").set("K").to("Key3").set("BoolValue").to(true).build());
            return ApiFutures.immediateFuture(null);
        }, executor);
        txn2Step2.commitAsync().get();
        Struct row = client.singleUse().readRow("T", Key.of("Key3"), Arrays.asList("K", "BoolValue"));
        assertThat(row.getString(0)).isEqualTo("Key3");
        assertThat(row.getBoolean(1)).isTrue();
        manager2.close();
    }
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) Assume.assumeFalse(org.junit.Assume.assumeFalse) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) TransactionState(com.google.cloud.spanner.TransactionManager.TransactionState) DatabaseClient(com.google.cloud.spanner.DatabaseClient) Spanner(com.google.cloud.spanner.Spanner) ImmutableList(com.google.common.collect.ImmutableList) AsyncTransactionManager(com.google.cloud.spanner.AsyncTransactionManager) Key(com.google.cloud.spanner.Key) Assert.fail(org.junit.Assert.fail) ClassRule(org.junit.ClassRule) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) AbortedException(com.google.cloud.spanner.AbortedException) ParallelIntegrationTest(com.google.cloud.spanner.ParallelIntegrationTest) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) ApiFutures(com.google.api.core.ApiFutures) Database(com.google.cloud.spanner.Database) Executor(java.util.concurrent.Executor) Assert.assertNotNull(org.junit.Assert.assertNotNull) Parameter(org.junit.runners.Parameterized.Parameter) Collection(java.util.Collection) EmulatorSpannerHelper.isUsingEmulator(com.google.cloud.spanner.testing.EmulatorSpannerHelper.isUsingEmulator) Test(org.junit.Test) Mutation(com.google.cloud.spanner.Mutation) Truth.assertThat(com.google.common.truth.Truth.assertThat) Category(org.junit.experimental.categories.Category) Executors(java.util.concurrent.Executors) IntegrationTestEnv(com.google.cloud.spanner.IntegrationTestEnv) KeySet(com.google.cloud.spanner.KeySet) ErrorCode(com.google.cloud.spanner.ErrorCode) SpannerException(com.google.cloud.spanner.SpannerException) ExecutionException(java.util.concurrent.ExecutionException) Ignore(org.junit.Ignore) Struct(com.google.cloud.spanner.Struct) AsyncTransactionStep(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep) Collections(java.util.Collections) AsyncTransactionManager(com.google.cloud.spanner.AsyncTransactionManager) AbortedException(com.google.cloud.spanner.AbortedException) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) Struct(com.google.cloud.spanner.Struct) Ignore(org.junit.Ignore) ParallelIntegrationTest(com.google.cloud.spanner.ParallelIntegrationTest) Test(org.junit.Test)

Example 3 with AsyncTransactionStep

use of com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep in project java-spanner by googleapis.

the class AsyncTransactionManagerExample method asyncTransactionManager.

static void asyncTransactionManager(DatabaseClient client) throws InterruptedException, ExecutionException, TimeoutException {
    ExecutorService executor = Executors.newSingleThreadExecutor();
    AsyncTransactionStep<List<Struct>, long[]> updateCounts;
    try (AsyncTransactionManager mgr = client.transactionManagerAsync()) {
        TransactionContextFuture txn = mgr.beginAsync();
        // Loop to retry aborted errors.
        while (true) {
            try {
                updateCounts = txn.then((transaction, v) -> {
                    // Execute two reads in parallel and return the result of these as the input
                    // for the next step of the transaction.
                    ApiFuture<Struct> album1BudgetFut = transaction.readRowAsync("Albums", Key.of(1, 1), ImmutableList.of("MarketingBudget"));
                    ApiFuture<Struct> album2BudgetFut = transaction.readRowAsync("Albums", Key.of(2, 2), ImmutableList.of("MarketingBudget"));
                    return ApiFutures.allAsList(Arrays.asList(album1BudgetFut, album2BudgetFut));
                }, executor).then((transaction, budgets) -> {
                    long album1Budget = budgets.get(0).getLong(0);
                    long album2Budget = budgets.get(1).getLong(0);
                    long transfer = 200_000;
                    if (album2Budget >= transfer) {
                        album1Budget += transfer;
                        album2Budget -= transfer;
                        Statement updateStatement1 = Statement.newBuilder("UPDATE Albums " + "SET MarketingBudget = @AlbumBudget " + "WHERE SingerId = 1 and AlbumId = 1").bind("AlbumBudget").to(album1Budget).build();
                        Statement updateStatement2 = Statement.newBuilder("UPDATE Albums " + "SET MarketingBudget = @AlbumBudget " + "WHERE SingerId = 2 and AlbumId = 2").bind("AlbumBudget").to(album2Budget).build();
                        return transaction.batchUpdateAsync(ImmutableList.of(updateStatement1, updateStatement2));
                    } else {
                        return ApiFutures.immediateFuture(new long[] { 0L, 0L });
                    }
                }, executor);
                // Commit after the updates.
                CommitTimestampFuture commitTsFut = updateCounts.commitAsync();
                // Wait for the transaction to finish and execute a retry if necessary.
                commitTsFut.get();
                break;
            } catch (AbortedException e) {
                txn = mgr.resetForRetryAsync();
            }
        }
    }
    // Calculate the total update count.
    ApiFuture<Long> totalUpdateCount = ApiFutures.transform(updateCounts, new ApiFunction<long[], Long>() {

        @SuppressFBWarnings("UVA_USE_VAR_ARGS")
        @Override
        public Long apply(long[] input) {
            return Arrays.stream(input).sum();
        }
    }, MoreExecutors.directExecutor());
    System.out.printf("%d records updated.%n", totalUpdateCount.get(30L, TimeUnit.SECONDS));
    executor.shutdown();
}
Also used : MoreExecutors(com.google.common.util.concurrent.MoreExecutors) Arrays(java.util.Arrays) DatabaseId(com.google.cloud.spanner.DatabaseId) TimeoutException(java.util.concurrent.TimeoutException) DatabaseClient(com.google.cloud.spanner.DatabaseClient) Spanner(com.google.cloud.spanner.Spanner) ImmutableList(com.google.common.collect.ImmutableList) AsyncTransactionManager(com.google.cloud.spanner.AsyncTransactionManager) SpannerOptions(com.google.cloud.spanner.SpannerOptions) Key(com.google.cloud.spanner.Key) ExecutorService(java.util.concurrent.ExecutorService) CommitTimestampFuture(com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture) AbortedException(com.google.cloud.spanner.AbortedException) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) ApiFutures(com.google.api.core.ApiFutures) Executors(java.util.concurrent.Executors) ApiFuture(com.google.api.core.ApiFuture) Statement(com.google.cloud.spanner.Statement) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Struct(com.google.cloud.spanner.Struct) AsyncTransactionStep(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep) ApiFunction(com.google.api.core.ApiFunction) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) Statement(com.google.cloud.spanner.Statement) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) Struct(com.google.cloud.spanner.Struct) AsyncTransactionManager(com.google.cloud.spanner.AsyncTransactionManager) AbortedException(com.google.cloud.spanner.AbortedException) ExecutorService(java.util.concurrent.ExecutorService) ImmutableList(com.google.common.collect.ImmutableList) List(java.util.List) CommitTimestampFuture(com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture)

Example 4 with AsyncTransactionStep

use of com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep in project java-spanner by googleapis.

the class AsyncTransactionManagerTest method asyncTransactionManagerFireAndForgetInvalidBatchUpdate.

@Test
public void asyncTransactionManagerFireAndForgetInvalidBatchUpdate() throws Exception {
    try (AsyncTransactionManager manager = clientWithEmptySessionPool().transactionManagerAsync()) {
        TransactionContextFuture transactionContextFuture = manager.beginAsync();
        while (true) {
            try {
                AsyncTransactionStep<Void, long[]> updateCounts = transactionContextFuture.then((transactionContext, ignored) -> {
                    transactionContext.batchUpdateAsync(ImmutableList.of(UPDATE_STATEMENT, INVALID_UPDATE_STATEMENT));
                    return ApiFutures.<Void>immediateFuture(null);
                }, executor).then((transactionContext, ignored) -> transactionContext.batchUpdateAsync(ImmutableList.of(UPDATE_STATEMENT, UPDATE_STATEMENT)), executor);
                updateCounts.commitAsync().get();
                assertThat(updateCounts.get()).asList().containsExactly(UPDATE_COUNT, UPDATE_COUNT);
                break;
            } catch (AbortedException e) {
                transactionContextFuture = manager.resetForRetryAsync();
            }
        }
    }
    assertThat(mockSpanner.getRequestTypes()).containsExactly(BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, ExecuteBatchDmlRequest.class, CommitRequest.class);
}
Also used : Arrays(java.util.Arrays) BatchCreateSessionsRequest(com.google.spanner.v1.BatchCreateSessionsRequest) TimeoutException(java.util.concurrent.TimeoutException) StatementResult(com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_STATEMENT) TransactionSelector(com.google.spanner.v1.TransactionSelector) Status(io.grpc.Status) BeginTransactionRequest(com.google.spanner.v1.BeginTransactionRequest) Parameterized(org.junit.runners.Parameterized) CommitTimestampFuture(com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture) ApiFutures(com.google.api.core.ApiFutures) SpannerApiFutures.get(com.google.cloud.spanner.SpannerApiFutures.get) Collection(java.util.Collection) READ_COLUMN_NAMES(com.google.cloud.spanner.MockSpannerTestUtil.READ_COLUMN_NAMES) Range(com.google.common.collect.Range) ApiFutureCallback(com.google.api.core.ApiFutureCallback) Executors(java.util.concurrent.Executors) ApiFuture(com.google.api.core.ApiFuture) SettableApiFuture(com.google.api.core.SettableApiFuture) UPDATE_COUNT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_COUNT) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) INVALID_UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.INVALID_UPDATE_STATEMENT) READ_TABLE_NAME(com.google.cloud.spanner.MockSpannerTestUtil.READ_TABLE_NAME) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) CommitRequest(com.google.spanner.v1.CommitRequest) ImmutableList(com.google.common.collect.ImmutableList) SimulatedExecutionTime(com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) AbstractMessage(com.google.protobuf.AbstractMessage) Executor(java.util.concurrent.Executor) Assert.assertNotNull(org.junit.Assert.assertNotNull) Parameter(org.junit.runners.Parameterized.Parameter) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) RollbackRequest(com.google.spanner.v1.RollbackRequest) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ReadOption(com.google.cloud.spanner.Options.ReadOption) AsyncTransactionFunction(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionFunction) AsyncTransactionStep(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep) SessionPoolTransactionContext(com.google.cloud.spanner.SessionPool.SessionPoolTransactionContext) UPDATE_ABORTED_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_ABORTED_STATEMENT) TransactionContextImpl(com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl) ExecuteBatchDmlRequest(com.google.spanner.v1.ExecuteBatchDmlRequest) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) Test(org.junit.Test)

Example 5 with AsyncTransactionStep

use of com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep in project java-spanner by googleapis.

the class AsyncTransactionManagerTest method asyncTransactionManagerWithBatchUpdateCommitAborted.

@Test
public void asyncTransactionManagerWithBatchUpdateCommitAborted() throws Exception {
    try (AsyncTransactionManager manager = clientWithEmptySessionPool().transactionManagerAsync()) {
        // Temporarily set the result of the update to 2 rows.
        mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT + 1L));
        final AtomicInteger attempt = new AtomicInteger();
        TransactionContextFuture txn = manager.beginAsync();
        while (true) {
            try {
                AsyncTransactionStep<Void, long[]> updateCounts = txn.then((ignored1, ignored2) -> {
                    if (attempt.get() > 0) {
                        // Set the result of the update statement back to 1 row.
                        mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
                    }
                    return ApiFutures.<Void>immediateFuture(null);
                }, executor).then((transactionContext, ignored) -> transactionContext.batchUpdateAsync(ImmutableList.of(UPDATE_STATEMENT, UPDATE_STATEMENT)), executor);
                updateCounts.then((transaction, ignored) -> {
                    if (attempt.incrementAndGet() == 1) {
                        mockSpanner.abortTransaction(transaction);
                    }
                    return ApiFutures.immediateFuture(null);
                }, executor).commitAsync().get();
                assertThat(updateCounts.get()).asList().containsExactly(UPDATE_COUNT, UPDATE_COUNT);
                assertThat(attempt.get()).isEqualTo(2);
                break;
            } catch (AbortedException e) {
                txn = manager.resetForRetryAsync();
            }
        }
    } finally {
        mockSpanner.putStatementResult(StatementResult.update(UPDATE_STATEMENT, UPDATE_COUNT));
    }
    assertThat(mockSpanner.getRequestTypes()).containsExactly(BatchCreateSessionsRequest.class, ExecuteBatchDmlRequest.class, CommitRequest.class, BeginTransactionRequest.class, ExecuteBatchDmlRequest.class, CommitRequest.class);
}
Also used : Arrays(java.util.Arrays) BatchCreateSessionsRequest(com.google.spanner.v1.BatchCreateSessionsRequest) TimeoutException(java.util.concurrent.TimeoutException) StatementResult(com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_STATEMENT) TransactionSelector(com.google.spanner.v1.TransactionSelector) Status(io.grpc.Status) BeginTransactionRequest(com.google.spanner.v1.BeginTransactionRequest) Parameterized(org.junit.runners.Parameterized) CommitTimestampFuture(com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture) ApiFutures(com.google.api.core.ApiFutures) SpannerApiFutures.get(com.google.cloud.spanner.SpannerApiFutures.get) Collection(java.util.Collection) READ_COLUMN_NAMES(com.google.cloud.spanner.MockSpannerTestUtil.READ_COLUMN_NAMES) Range(com.google.common.collect.Range) ApiFutureCallback(com.google.api.core.ApiFutureCallback) Executors(java.util.concurrent.Executors) ApiFuture(com.google.api.core.ApiFuture) SettableApiFuture(com.google.api.core.SettableApiFuture) UPDATE_COUNT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_COUNT) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) ExecuteSqlRequest(com.google.spanner.v1.ExecuteSqlRequest) Iterables(com.google.common.collect.Iterables) MoreExecutors(com.google.common.util.concurrent.MoreExecutors) INVALID_UPDATE_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.INVALID_UPDATE_STATEMENT) READ_TABLE_NAME(com.google.cloud.spanner.MockSpannerTestUtil.READ_TABLE_NAME) Assert.assertThrows(org.junit.Assert.assertThrows) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) CommitRequest(com.google.spanner.v1.CommitRequest) ImmutableList(com.google.common.collect.ImmutableList) SimulatedExecutionTime(com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) AbstractMessage(com.google.protobuf.AbstractMessage) Executor(java.util.concurrent.Executor) Assert.assertNotNull(org.junit.Assert.assertNotNull) Parameter(org.junit.runners.Parameterized.Parameter) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) RollbackRequest(com.google.spanner.v1.RollbackRequest) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) ReadOption(com.google.cloud.spanner.Options.ReadOption) AsyncTransactionFunction(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionFunction) AsyncTransactionStep(com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep) SessionPoolTransactionContext(com.google.cloud.spanner.SessionPool.SessionPoolTransactionContext) UPDATE_ABORTED_STATEMENT(com.google.cloud.spanner.MockSpannerTestUtil.UPDATE_ABORTED_STATEMENT) TransactionContextImpl(com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl) ExecuteBatchDmlRequest(com.google.spanner.v1.ExecuteBatchDmlRequest) Collections(java.util.Collections) Assert.assertEquals(org.junit.Assert.assertEquals) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TransactionContextFuture(com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture) Test(org.junit.Test)

Aggregations

ApiFutures (com.google.api.core.ApiFutures)6 AsyncTransactionStep (com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionStep)6 TransactionContextFuture (com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture)6 ImmutableList (com.google.common.collect.ImmutableList)6 MoreExecutors (com.google.common.util.concurrent.MoreExecutors)6 Arrays (java.util.Arrays)6 ExecutionException (java.util.concurrent.ExecutionException)6 ApiFuture (com.google.api.core.ApiFuture)5 CommitTimestampFuture (com.google.cloud.spanner.AsyncTransactionManager.CommitTimestampFuture)5 Truth.assertThat (com.google.common.truth.Truth.assertThat)5 Collection (java.util.Collection)5 Collections (java.util.Collections)5 List (java.util.List)5 ApiFutureCallback (com.google.api.core.ApiFutureCallback)4 SettableApiFuture (com.google.api.core.SettableApiFuture)4 AsyncTransactionFunction (com.google.cloud.spanner.AsyncTransactionManager.AsyncTransactionFunction)4 SimulatedExecutionTime (com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime)4 StatementResult (com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult)4 INVALID_UPDATE_STATEMENT (com.google.cloud.spanner.MockSpannerTestUtil.INVALID_UPDATE_STATEMENT)3 READ_COLUMN_NAMES (com.google.cloud.spanner.MockSpannerTestUtil.READ_COLUMN_NAMES)3