use of com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor in project java-bigtable by googleapis.
the class BigtableBatchingCallSettingsTest method testBuilderFromSettings.
@Test
public void testBuilderFromSettings() {
BigtableBatchingCallSettings.Builder builder = BigtableBatchingCallSettings.newBuilder(new MutateRowsBatchingDescriptor());
RetrySettings retrySettings = RetrySettings.newBuilder().setTotalTimeout(Duration.ofMinutes(1)).build();
builder.setBatchingSettings(BATCHING_SETTINGS).setRetryableCodes(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED).setRetrySettings(retrySettings).enableLatencyBasedThrottling(10L);
BigtableBatchingCallSettings settings = builder.build();
BigtableBatchingCallSettings.Builder newBuilder = settings.toBuilder();
assertThat(newBuilder.getBatchingSettings()).isEqualTo(BATCHING_SETTINGS);
assertThat(newBuilder.getRetryableCodes()).containsExactly(StatusCode.Code.UNAVAILABLE, StatusCode.Code.UNAUTHENTICATED);
assertThat(newBuilder.getRetrySettings()).isEqualTo(retrySettings);
assertThat(newBuilder.isLatencyBasedThrottlingEnabled()).isTrue();
assertThat(newBuilder.getTargetRpcLatencyMs()).isEqualTo(10L);
assertThat(newBuilder.getDynamicFlowControlSettings()).isNotNull();
verifyFlowControlSettingWhenLatencyBasedThrottlingEnabled(newBuilder.getDynamicFlowControlSettings());
}
use of com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptorTest method countBytesTest.
@Test
public void countBytesTest() {
RowMutationEntry request = RowMutationEntry.create(ROW_KEY).setCell(FAMILY, QUALIFIER, VALUE);
long bytes = request.toProto().getSerializedSize();
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
assertThat(underTest.countBytes(request)).isEqualTo(bytes);
}
use of com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptorTest method splitExceptionWithFailedMutationsTest.
@Test
public void splitExceptionWithFailedMutationsTest() {
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
Throwable actualThrowable = null;
BatchEntry<RowMutationEntry, Void> batchEntry1 = BatchEntry.create(RowMutationEntry.create("key1").deleteRow(), SettableApiFuture.<Void>create());
BatchEntry<RowMutationEntry, Void> batchEntry2 = BatchEntry.create(RowMutationEntry.create("key2").deleteRow(), SettableApiFuture.<Void>create());
BatchEntry<RowMutationEntry, Void> batchEntry3 = BatchEntry.create(RowMutationEntry.create("key3").deleteRow(), SettableApiFuture.<Void>create());
// Threw an exception at 1st and 3rd entry
MutateRowsException serverError = new MutateRowsException(null, ImmutableList.of(MutateRowsException.FailedMutation.create(0, new UnavailableException(null, GrpcStatusCode.of(Status.Code.UNAVAILABLE), true)), MutateRowsException.FailedMutation.create(2, new DeadlineExceededException(null, GrpcStatusCode.of(Status.Code.DEADLINE_EXCEEDED), true))), true);
underTest.splitException(serverError, ImmutableList.of(batchEntry1, batchEntry2, batchEntry3));
try {
batchEntry1.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
assertThat(actualThrowable).hasCauseThat().isEqualTo(serverError.getFailedMutations().get(0).getError());
// As there is no exception for 2nd entry so it should not throw any exception
actualThrowable = null;
try {
batchEntry2.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
assertThat(actualThrowable).isNull();
actualThrowable = null;
try {
batchEntry3.getResultFuture().get();
} catch (ExecutionException | InterruptedException e) {
actualThrowable = e;
}
// The third response should has the last found failed mutation error.
assertThat(actualThrowable).hasCauseThat().isEqualTo(serverError.getFailedMutations().get(1).getError());
}
use of com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor in project java-bigtable by googleapis.
the class MutateRowsBatchingDescriptorTest method requestBuilderTest.
@Test
public void requestBuilderTest() {
MutateRowsBatchingDescriptor underTest = new MutateRowsBatchingDescriptor();
long timestamp = 10_000L;
BulkMutation bulkMutation = BulkMutation.create("fake-table");
BatchingRequestBuilder<RowMutationEntry, BulkMutation> requestBuilder = underTest.newRequestBuilder(bulkMutation);
requestBuilder.add(RowMutationEntry.create(ROW_KEY).setCell(FAMILY, QUALIFIER, timestamp, VALUE));
requestBuilder.add(RowMutationEntry.create("rowKey-2").setCell("family-2", "q", 20_000L, "some-value"));
BulkMutation actualBulkMutation = requestBuilder.build();
assertThat(actualBulkMutation.toProto(requestContext)).isEqualTo(BulkMutation.create("fake-table").add(ROW_KEY, Mutation.create().setCell(FAMILY, QUALIFIER, timestamp, VALUE)).add("rowKey-2", Mutation.create().setCell("family-2", "q", 20_000L, "some-value")).toProto(requestContext));
}
use of com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor in project java-bigtable by googleapis.
the class BigtableBatchingCallSettingsTest method testEmptyBuilder.
@Test
public void testEmptyBuilder() {
BigtableBatchingCallSettings.Builder builder = BigtableBatchingCallSettings.newBuilder(new MutateRowsBatchingDescriptor());
assertThat(builder.getBatchingSettings()).isNull();
assertThat(builder.getRetryableCodes()).isEmpty();
assertThat(builder.getRetrySettings()).isNotNull();
assertThat(builder.isLatencyBasedThrottlingEnabled()).isFalse();
assertThat(builder.getTargetRpcLatencyMs()).isNull();
assertThat(builder.getDynamicFlowControlSettings()).isNull();
}
Aggregations