From e6674ef018fe170a17bf849c4992c84dd8bcd840 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 15:39:53 -0500 Subject: [PATCH 1/6] deps: upgrade gax to 1.53.0 --- google-cloud-bigtable-deps-bom/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-bigtable-deps-bom/pom.xml b/google-cloud-bigtable-deps-bom/pom.xml index 753d501d9..b4de658d7 100644 --- a/google-cloud-bigtable-deps-bom/pom.xml +++ b/google-cloud-bigtable-deps-bom/pom.xml @@ -73,7 +73,7 @@ 1.7 - 1.52.0 + 1.53.0 1.8.1 1.17.0 1.92.1 From ab3059038b0be4ac189de26a2937fe4b58ae1ebe Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 16:05:17 -0500 Subject: [PATCH 2/6] fix compile failures --- .../MutateRowsBatchingDescriptor.java | 19 ++++----- .../MutateRowsBatchingDescriptorTest.java | 39 +++++++++++-------- 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java index 60a330795..051b4445f 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java @@ -17,6 +17,7 @@ import com.google.api.core.InternalApi; import com.google.api.core.SettableApiFuture; +import com.google.api.gax.batching.BatchEntry; import com.google.api.gax.batching.BatchingDescriptor; import com.google.api.gax.batching.BatchingRequestBuilder; import com.google.cloud.bigtable.data.v2.models.BulkMutation; @@ -45,9 +46,9 @@ public BatchingRequestBuilder newRequestBuilder( } @Override - public void splitResponse(Void response, List> batch) { - for (SettableApiFuture batchResponse : batch) { - batchResponse.set(null); + public void splitResponse(Void aVoid, List> batch) { + for (BatchEntry batchResponse : batch) { + batchResponse.getResultFuture().set(null); } } @@ -58,10 +59,10 @@ public void splitResponse(Void response, List> batch) { * entries whose index is mentioned {@link MutateRowsException#getFailedMutations()}. */ @Override - public void splitException(Throwable throwable, List> batch) { + public void splitException(Throwable throwable, List> batch) { if (!(throwable instanceof MutateRowsException)) { - for (SettableApiFuture future : batch) { - future.setException(throwable); + for (BatchEntry future : batch) { + future.getResultFuture().setException(throwable); } return; } @@ -74,12 +75,12 @@ public void splitException(Throwable throwable, List> ba } int i = 0; - for (SettableApiFuture entryResultFuture : batch) { + for (BatchEntry entryResultFuture : batch) { Throwable entryError = entryErrors.get(i++); if (entryError == null) { - entryResultFuture.set(null); + entryResultFuture.getResultFuture().set(null); } else { - entryResultFuture.setException(entryError); + entryResultFuture.getResultFuture().setException(entryError); } } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java index c43dea15f..6064b92ff 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java @@ -18,6 +18,7 @@ import static com.google.common.truth.Truth.assertThat; import com.google.api.core.SettableApiFuture; +import com.google.api.gax.batching.BatchEntry; import com.google.api.gax.batching.BatchingRequestBuilder; import com.google.api.gax.grpc.GrpcStatusCode; import com.google.api.gax.rpc.DeadlineExceededException; @@ -77,29 +78,35 @@ public void requestBuilderTest() { @Test public void splitResponseTest() { - List> batchResponse = - ImmutableList.of(SettableApiFuture.create(), SettableApiFuture.create()); - assertThat(batchResponse.get(0).isDone()).isFalse(); - assertThat(batchResponse.get(1).isDone()).isFalse(); + BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); + + List> batchResponse = + ImmutableList.of(resultFuture1, resultFuture2); + assertThat(batchResponse.get(0).getResultFuture().isDone()).isFalse(); + assertThat(batchResponse.get(1).getResultFuture().isDone()).isFalse(); MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); underTest.splitResponse(null, batchResponse); - assertThat(batchResponse.get(0).isDone()).isTrue(); - assertThat(batchResponse.get(1).isDone()).isTrue(); + assertThat(batchResponse.get(0).getResultFuture().isDone()).isTrue(); + assertThat(batchResponse.get(1).getResultFuture().isDone()).isTrue(); } @Test public void splitExceptionTest() { + BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); + MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); final RuntimeException expectedEx = new RuntimeException("Caused while batching"); - List> batchResponses = - ImmutableList.of(SettableApiFuture.create(), SettableApiFuture.create()); + List> batchResponses = + ImmutableList.of(resultFuture1, resultFuture2); underTest.splitException(expectedEx, batchResponses); - for (SettableApiFuture fu : batchResponses) { + for (BatchEntry response : batchResponses) { try { - fu.get(); + response.getResultFuture().get(); } catch (ExecutionException | InterruptedException ex) { assertThat(ex).hasCauseThat().isSameInstanceAs(expectedEx); } @@ -110,9 +117,9 @@ public void splitExceptionTest() { public void splitExceptionWithFailedMutationsTest() { MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); Throwable actualThrowable = null; - SettableApiFuture resultFuture1 = SettableApiFuture.create(); - SettableApiFuture resultFuture2 = SettableApiFuture.create(); - SettableApiFuture resultFuture3 = SettableApiFuture.create(); + BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry resultFuture3 = BatchEntry.create(null, SettableApiFuture.create()); // Threw an exception at 1st and 3rd entry MutateRowsException serverError = @@ -132,7 +139,7 @@ public void splitExceptionWithFailedMutationsTest() { serverError, ImmutableList.of(resultFuture1, resultFuture2, resultFuture3)); try { - resultFuture1.get(); + resultFuture1.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } @@ -143,7 +150,7 @@ public void splitExceptionWithFailedMutationsTest() { // As there is no exception for 2nd entry so it should not throw any exception actualThrowable = null; try { - resultFuture2.get(); + resultFuture2.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } @@ -151,7 +158,7 @@ public void splitExceptionWithFailedMutationsTest() { actualThrowable = null; try { - resultFuture3.get(); + resultFuture3.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } From 5693e6e6438b9308aa9f793e6ca12e77c3366d9c Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 16:06:42 -0500 Subject: [PATCH 3/6] rename parameter --- .../data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java index 051b4445f..c5d402b05 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java @@ -46,7 +46,7 @@ public BatchingRequestBuilder newRequestBuilder( } @Override - public void splitResponse(Void aVoid, List> batch) { + public void splitResponse(Void response, List> batch) { for (BatchEntry batchResponse : batch) { batchResponse.getResultFuture().set(null); } From ea5371624cf7e16df1187252b119b6225b537528 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 16:10:16 -0500 Subject: [PATCH 4/6] rename test variables --- .../MutateRowsBatchingDescriptorTest.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java index 6064b92ff..5e367cc14 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java @@ -78,11 +78,11 @@ public void requestBuilderTest() { @Test public void splitResponseTest() { - BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); List> batchResponse = - ImmutableList.of(resultFuture1, resultFuture2); + ImmutableList.of(batchEntry1, batchEntry2); assertThat(batchResponse.get(0).getResultFuture().isDone()).isFalse(); assertThat(batchResponse.get(1).getResultFuture().isDone()).isFalse(); @@ -94,13 +94,13 @@ public void splitResponseTest() { @Test public void splitExceptionTest() { - BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); final RuntimeException expectedEx = new RuntimeException("Caused while batching"); List> batchResponses = - ImmutableList.of(resultFuture1, resultFuture2); + ImmutableList.of(batchEntry1, batchEntry2); underTest.splitException(expectedEx, batchResponses); @@ -117,9 +117,9 @@ public void splitExceptionTest() { public void splitExceptionWithFailedMutationsTest() { MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); Throwable actualThrowable = null; - BatchEntry resultFuture1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry resultFuture2 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry resultFuture3 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry3 = BatchEntry.create(null, SettableApiFuture.create()); // Threw an exception at 1st and 3rd entry MutateRowsException serverError = @@ -136,10 +136,10 @@ public void splitExceptionWithFailedMutationsTest() { null, GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), true))), true); underTest.splitException( - serverError, ImmutableList.of(resultFuture1, resultFuture2, resultFuture3)); + serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3)); try { - resultFuture1.getResultFuture().get(); + batchEntry1.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } @@ -150,7 +150,7 @@ public void splitExceptionWithFailedMutationsTest() { // As there is no exception for 2nd entry so it should not throw any exception actualThrowable = null; try { - resultFuture2.getResultFuture().get(); + batchEntry2.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } @@ -158,7 +158,7 @@ public void splitExceptionWithFailedMutationsTest() { actualThrowable = null; try { - resultFuture3.getResultFuture().get(); + batchEntry3.getResultFuture().get(); } catch (ExecutionException | InterruptedException e) { actualThrowable = e; } From 8d5e153c2b4be0b1fb999c971fd6131991788825 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 16:19:16 -0500 Subject: [PATCH 5/6] review feedback --- .../MutateRowsBatchingDescriptor.java | 12 +++---- .../MutateRowsBatchingDescriptorTest.java | 31 +++++++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java index c5d402b05..04520bca1 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java @@ -16,7 +16,6 @@ package com.google.cloud.bigtable.data.v2.stub.mutaterows; import com.google.api.core.InternalApi; -import com.google.api.core.SettableApiFuture; import com.google.api.gax.batching.BatchEntry; import com.google.api.gax.batching.BatchingDescriptor; import com.google.api.gax.batching.BatchingRequestBuilder; @@ -46,8 +45,8 @@ public BatchingRequestBuilder newRequestBuilder( } @Override - public void splitResponse(Void response, List> batch) { - for (BatchEntry batchResponse : batch) { + public void splitResponse(Void response, List> entries) { + for (BatchEntry batchResponse : entries) { batchResponse.getResultFuture().set(null); } } @@ -59,9 +58,10 @@ public void splitResponse(Void response, List * entries whose index is mentioned {@link MutateRowsException#getFailedMutations()}. */ @Override - public void splitException(Throwable throwable, List> batch) { + public void splitException( + Throwable throwable, List> entries) { if (!(throwable instanceof MutateRowsException)) { - for (BatchEntry future : batch) { + for (BatchEntry future : entries) { future.getResultFuture().setException(throwable); } return; @@ -75,7 +75,7 @@ public void splitException(Throwable throwable, List entryResultFuture : batch) { + for (BatchEntry entryResultFuture : entries) { Throwable entryError = entryErrors.get(i++); if (entryError == null) { entryResultFuture.getResultFuture().set(null); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java index 5e367cc14..875a8e388 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptorTest.java @@ -78,8 +78,12 @@ public void requestBuilderTest() { @Test public void splitResponseTest() { - BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = + BatchEntry.create( + RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.create()); + BatchEntry batchEntry2 = + BatchEntry.create( + RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.create()); List> batchResponse = ImmutableList.of(batchEntry1, batchEntry2); @@ -94,8 +98,12 @@ public void splitResponseTest() { @Test public void splitExceptionTest() { - BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = + BatchEntry.create( + RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.create()); + BatchEntry batchEntry2 = + BatchEntry.create( + RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.create()); MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); final RuntimeException expectedEx = new RuntimeException("Caused while batching"); @@ -117,9 +125,15 @@ public void splitExceptionTest() { public void splitExceptionWithFailedMutationsTest() { MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor(); Throwable actualThrowable = null; - BatchEntry batchEntry1 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry batchEntry2 = BatchEntry.create(null, SettableApiFuture.create()); - BatchEntry batchEntry3 = BatchEntry.create(null, SettableApiFuture.create()); + BatchEntry batchEntry1 = + BatchEntry.create( + RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.create()); + BatchEntry batchEntry2 = + BatchEntry.create( + RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.create()); + BatchEntry batchEntry3 = + BatchEntry.create( + RowMutationEntry.create("key3").deleteRow(), SettableApiFuture.create()); // Threw an exception at 1st and 3rd entry MutateRowsException serverError = @@ -135,8 +149,7 @@ public void splitExceptionWithFailedMutationsTest() { new DeadlineExceededException( null, GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), true))), true); - underTest.splitException( - serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3)); + underTest.splitException(serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3)); try { batchEntry1.getResultFuture().get(); From 65a15e227bb96f7b892bb6253d23d5cd555d5a32 Mon Sep 17 00:00:00 2001 From: Kristen O'Leary Date: Thu, 9 Jan 2020 16:26:50 -0500 Subject: [PATCH 6/6] review feedback --- .../stub/mutaterows/MutateRowsBatchingDescriptor.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java index 04520bca1..a3ec50bc2 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/mutaterows/MutateRowsBatchingDescriptor.java @@ -61,8 +61,8 @@ public void splitResponse(Void response, List public void splitException( Throwable throwable, List> entries) { if (!(throwable instanceof MutateRowsException)) { - for (BatchEntry future : entries) { - future.getResultFuture().setException(throwable); + for (BatchEntry entry : entries) { + entry.getResultFuture().setException(throwable); } return; } @@ -75,12 +75,12 @@ public void splitException( } int i = 0; - for (BatchEntry entryResultFuture : entries) { + for (BatchEntry entry : entries) { Throwable entryError = entryErrors.get(i++); if (entryError == null) { - entryResultFuture.getResultFuture().set(null); + entry.getResultFuture().set(null); } else { - entryResultFuture.getResultFuture().setException(entryError); + entry.getResultFuture().setException(entryError); } } }