use of com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest in project java-bigtable by googleapis.
the class ReadRowsUserCallableTest method testRequestConverted.
@Test
public void testRequestConverted() {
ServerStreamingStashCallable<ReadRowsRequest, Row> innerCallable = new ServerStreamingStashCallable<>();
ReadRowsUserCallable<Row> callable = new ReadRowsUserCallable<>(innerCallable, REQUEST_CONTEXT);
Query query = Query.create("fake-table");
callable.call(query);
Truth.assertThat(innerCallable.getActualRequest()).isEqualTo(query.toProto(REQUEST_CONTEXT));
}
use of com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest in project java-bigtable by googleapis.
the class RowMergingCallableTest method invalidMarkerInCell.
@Test
public void invalidMarkerInCell() {
FakeStreamingApi.ServerStreamingStashCallable<ReadRowsRequest, ReadRowsResponse> inner = new ServerStreamingStashCallable<>(Lists.newArrayList(ReadRowsResponse.newBuilder().addChunks(CellChunk.newBuilder().setRowKey(ByteString.copyFromUtf8("key1")).setFamilyName(StringValue.newBuilder().setValue("family")).setQualifier(BytesValue.newBuilder().setValue(ByteString.EMPTY)).setTimestampMicros(1_000).setValue(ByteString.copyFromUtf8("a")).setValueSize(2)).build(), // send a scan marker
ReadRowsResponse.newBuilder().setLastScannedRowKey(ByteString.copyFromUtf8("key1")).build(), // finish the cell & row
ReadRowsResponse.newBuilder().addChunks(CellChunk.newBuilder().setValue(ByteString.copyFromUtf8("b")).setValueSize(0).setCommitRow(true)).build()));
RowMergingCallable<Row> rowMergingCallable = new RowMergingCallable<>(inner, new DefaultRowAdapter());
Throwable actualError = null;
try {
rowMergingCallable.all().call(ReadRowsRequest.getDefaultInstance());
} catch (Throwable t) {
actualError = t;
}
Truth.assertThat(actualError).isInstanceOf(IllegalStateException.class);
}
use of com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest in project java-bigtable by googleapis.
the class RowMergingCallableTest method scanMarker.
@Test
public void scanMarker() {
FakeStreamingApi.ServerStreamingStashCallable<ReadRowsRequest, ReadRowsResponse> inner = new ServerStreamingStashCallable<>(Lists.newArrayList(// send a scan marker
ReadRowsResponse.newBuilder().setLastScannedRowKey(ByteString.copyFromUtf8("key1")).build()));
RowMergingCallable<Row> rowMergingCallable = new RowMergingCallable<>(inner, new DefaultRowAdapter());
List<Row> results = rowMergingCallable.all().call(ReadRowsRequest.getDefaultInstance());
Truth.assertThat(results).containsExactly(Row.create(ByteString.copyFromUtf8("key1"), Lists.<RowCell>newArrayList()));
}
use of com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest in project java-bigtable by googleapis.
the class BigtableDataClientFactoryTest method testCreateWithRefreshingChannel.
@Test
public void testCreateWithRefreshingChannel() throws Exception {
String[] tableIds = { "fake-table1", "fake-table2" };
int poolSize = 3;
BigtableDataSettings.Builder builder = BigtableDataSettings.newBuilderForEmulator(server.getPort()).setProjectId(DEFAULT_PROJECT_ID).setInstanceId(DEFAULT_INSTANCE_ID).setAppProfileId(DEFAULT_APP_PROFILE_ID).setPrimingTableIds(tableIds).setRefreshingChannel(true);
builder.stubSettings().setCredentialsProvider(credentialsProvider).setStreamWatchdogProvider(watchdogProvider).setExecutorProvider(executorProvider);
InstantiatingGrpcChannelProvider channelProvider = (InstantiatingGrpcChannelProvider) builder.stubSettings().getTransportChannelProvider();
InstantiatingGrpcChannelProvider.Builder channelProviderBuilder = channelProvider.toBuilder();
channelProviderBuilder.setPoolSize(poolSize);
builder.stubSettings().setTransportChannelProvider(channelProviderBuilder.build());
BigtableDataClientFactory factory = BigtableDataClientFactory.create(builder.build());
factory.createDefault();
factory.createForAppProfile("other-appprofile");
factory.createForInstance("other-project", "other-instance");
// Make sure that only 1 instance is created for all clients
Mockito.verify(credentialsProvider, Mockito.times(1)).getCredentials();
Mockito.verify(executorProvider, Mockito.times(1)).getExecutor();
Mockito.verify(watchdogProvider, Mockito.times(1)).getWatchdog();
// Make sure that the clients are sharing the same ChannelPool
assertThat(setUpAttributes).hasSize(poolSize);
// Make sure that prime requests were sent only once per table per connection
assertThat(service.readRowsRequests).hasSize(poolSize * tableIds.length);
List<ReadRowsRequest> expectedRequests = new LinkedList<>();
for (String tableId : tableIds) {
for (int i = 0; i < poolSize; i++) {
expectedRequests.add(ReadRowsRequest.newBuilder().setTableName(String.format("projects/%s/instances/%s/tables/%s", DEFAULT_PROJECT_ID, DEFAULT_INSTANCE_ID, tableId)).setAppProfileId(DEFAULT_APP_PROFILE_ID).setRows(RowSet.newBuilder().addRowKeys(ByteString.copyFromUtf8("nonexistent-priming-row"))).setFilter(RowFilter.newBuilder().setBlockAllFilter(true).build()).setRowsLimit(1).build());
}
}
assertThat(service.readRowsRequests).containsExactly(expectedRequests.toArray());
// Wait for all the connections to close asynchronously
factory.close();
long sleepTimeMs = 1000;
Thread.sleep(sleepTimeMs);
// Verify that all the channels are closed
assertThat(terminateAttributes).hasSize(poolSize);
}
use of com.google.cloud.bigquery.storage.v1beta2.ReadRowsRequest in project java-bigtable-hbase by googleapis.
the class TestBigtableVeneerApi method testGetDataClient.
@Test
public void testGetDataClient() throws Exception {
assertTrue(bigtableApi.getDataClient() instanceof DataClientVeneerApi);
Query query = Query.create(TABLE_ID).rowKey(ROW_KEY);
bigtableApi.getDataClient().readRowsAsync(query);
ReadRowsRequest request = fakeDataService.popLastRequest();
assertEquals(ROW_KEY, request.getRows().getRowKeys(0).toStringUtf8());
}
Aggregations