protected Builder(ClientContext clientContext) { super(clientContext); readRowsSettings = ServerStreamingCallSettings.newBuilder(); sampleRowKeysSettings = ServerStreamingCallSettings.newBuilder(); mutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); mutateRowsSettings = ServerStreamingCallSettings.newBuilder(); checkAndMutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); readModifyWriteRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( mutateRowSettings, checkAndMutateRowSettings, readModifyWriteRowSettings); initDefaults(this); }
protected Builder(ClientContext clientContext) { super(clientContext); createReadSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); readRowsSettings = ServerStreamingCallSettings.newBuilder(); batchCreateReadSessionStreamsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); finalizeStreamSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); splitReadStreamSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( createReadSessionSettings, batchCreateReadSessionStreamsSettings, finalizeStreamSettings, splitReadStreamSettings); initDefaults(this); }
protected Builder(ClientContext clientContext) { super(clientContext); getDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); listDocumentsSettings = PagedCallSettings.newBuilder(LIST_DOCUMENTS_PAGE_STR_FACT); createDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); updateDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); deleteDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); batchGetDocumentsSettings = ServerStreamingCallSettings.newBuilder(); beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); runQuerySettings = ServerStreamingCallSettings.newBuilder(); writeSettings = StreamingCallSettings.newBuilder(); listenSettings = StreamingCallSettings.newBuilder(); listCollectionIdsSettings = PagedCallSettings.newBuilder(LIST_COLLECTION_IDS_PAGE_STR_FACT); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( getDocumentSettings, listDocumentsSettings, createDocumentSettings, updateDocumentSettings, deleteDocumentSettings, beginTransactionSettings, commitSettings, rollbackSettings, listCollectionIdsSettings); initDefaults(this); }
protected Builder(ClientContext clientContext) { super(clientContext); getDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); listDocumentsSettings = PagedCallSettings.newBuilder(LIST_DOCUMENTS_PAGE_STR_FACT); createDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); updateDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); deleteDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); batchGetDocumentsSettings = ServerStreamingCallSettings.newBuilder(); beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); runQuerySettings = ServerStreamingCallSettings.newBuilder(); writeSettings = StreamingCallSettings.newBuilder(); listenSettings = StreamingCallSettings.newBuilder(); listCollectionIdsSettings = PagedCallSettings.newBuilder(LIST_COLLECTION_IDS_PAGE_STR_FACT); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( getDocumentSettings, listDocumentsSettings, createDocumentSettings, updateDocumentSettings, deleteDocumentSettings, beginTransactionSettings, commitSettings, rollbackSettings, listCollectionIdsSettings); initDefaults(this); }
protected Builder(ClientContext clientContext) { super(clientContext); createSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); getSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); listSessionsSettings = PagedCallSettings.newBuilder(LIST_SESSIONS_PAGE_STR_FACT); deleteSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); executeSqlSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); executeStreamingSqlSettings = ServerStreamingCallSettings.newBuilder(); readSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); streamingReadSettings = ServerStreamingCallSettings.newBuilder(); beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); partitionQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); partitionReadSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( createSessionSettings, getSessionSettings, listSessionsSettings, deleteSessionSettings, executeSqlSettings, readSettings, beginTransactionSettings, commitSettings, rollbackSettings, partitionQuerySettings, partitionReadSettings); initDefaults(this); }
/** * Creates a callable chain to handle point ReadRows RPCs. The chain will: * * <ul> * <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest} and * dispatch the RPC. * <li>Upon receiving the response stream, it will merge the {@link * com.google.bigtable.v2.ReadRowsResponse.CellChunk}s in logical rows. The actual row * implementation can be configured in by the {@code rowAdapter} parameter. * <li>Retry/resume on failure. * <li>Filter out marker rows. * </ul> */ public <RowT> UnaryCallable<Query, RowT> createReadRowCallable(RowAdapter<RowT> rowAdapter) { return createReadRowsCallable( ServerStreamingCallSettings.<Query, Row>newBuilder() .setRetryableCodes(settings.readRowSettings().getRetryableCodes()) .setRetrySettings(settings.readRowSettings().getRetrySettings()) .setIdleTimeout(settings.readRowSettings().getRetrySettings().getTotalTimeout()) .build(), rowAdapter) .first(); }
ServerStreamingCallSettings.<ReadRowsRequest, RowT>newBuilder() .setResumptionStrategy(new ReadRowsResumptionStrategy<>(rowAdapter)) .setRetryableCodes(readRowsSettings.getRetryableCodes())
protected Builder(ClientContext clientContext) { super(clientContext); readRowsSettings = ServerStreamingCallSettings.newBuilder(); sampleRowKeysSettings = ServerStreamingCallSettings.newBuilder(); mutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); mutateRowsSettings = ServerStreamingCallSettings.newBuilder(); checkAndMutateRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); readModifyWriteRowSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( mutateRowSettings, checkAndMutateRowSettings, readModifyWriteRowSettings); initDefaults(this); }
/** * Create a server-streaming callable with grpc-specific functionality. Designed for use by * generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @deprecated Please use ServerStreamingCallSettings */ @Deprecated @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { // up convert to new settings ServerStreamingCallSettings<RequestT, ResponseT> serverStreamingCallSettings = ServerStreamingCallSettings.<RequestT, ResponseT>newBuilder().build(); return createServerStreamingCallable( grpcCallSettings, serverStreamingCallSettings, clientContext); }
/** * Create a server-streaming callable with grpc-specific functionality. Designed for use by * generated code. * * @param grpcCallSettings the gRPC call settings * @param streamingCallSettings {@link StreamingCallSettings} to configure the method-level * settings with. * @param clientContext {@link ClientContext} to use to connect to the service. * @deprecated Please use ServerStreamingCallSettings */ @Deprecated @BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT> createServerStreamingCallable( GrpcCallSettings<RequestT, ResponseT> grpcCallSettings, StreamingCallSettings<RequestT, ResponseT> streamingCallSettings, ClientContext clientContext) { // up convert to new settings ServerStreamingCallSettings<RequestT, ResponseT> serverStreamingCallSettings = ServerStreamingCallSettings.<RequestT, ResponseT>newBuilder().build(); return createServerStreamingCallable( grpcCallSettings, serverStreamingCallSettings, clientContext); }
@Test public void retryableCodesVarArgs() { ServerStreamingCallSettings.Builder<Object, Object> builder = ServerStreamingCallSettings.newBuilder().setRetryableCodes(Code.UNKNOWN, Code.ABORTED); Truth.assertThat(builder.getRetryableCodes()).containsExactly(Code.UNKNOWN, Code.ABORTED); }
protected Builder(ClientContext clientContext) { super(clientContext); getDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); listDocumentsSettings = PagedCallSettings.newBuilder(LIST_DOCUMENTS_PAGE_STR_FACT); createDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); updateDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); deleteDocumentSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); batchGetDocumentsSettings = ServerStreamingCallSettings.newBuilder(); beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); runQuerySettings = ServerStreamingCallSettings.newBuilder(); writeSettings = StreamingCallSettings.newBuilder(); listenSettings = StreamingCallSettings.newBuilder(); listCollectionIdsSettings = PagedCallSettings.newBuilder(LIST_COLLECTION_IDS_PAGE_STR_FACT); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( getDocumentSettings, listDocumentsSettings, createDocumentSettings, updateDocumentSettings, deleteDocumentSettings, beginTransactionSettings, commitSettings, rollbackSettings, listCollectionIdsSettings); initDefaults(this); }
protected Builder(ClientContext clientContext) { super(clientContext); createSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); getSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); listSessionsSettings = PagedCallSettings.newBuilder(LIST_SESSIONS_PAGE_STR_FACT); deleteSessionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); executeSqlSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); executeStreamingSqlSettings = ServerStreamingCallSettings.newBuilder(); readSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); streamingReadSettings = ServerStreamingCallSettings.newBuilder(); beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); partitionQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); partitionReadSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); unaryMethodSettingsBuilders = ImmutableList.<UnaryCallSettings.Builder<?, ?>>of( createSessionSettings, getSessionSettings, listSessionsSettings, deleteSessionSettings, executeSqlSettings, readSettings, beginTransactionSettings, commitSettings, rollbackSettings, partitionQuerySettings, partitionReadSettings); initDefaults(this); }
@Test public void retryableCodesAreNotLost() { Set<Code> codes = ImmutableSet.of(Code.UNAVAILABLE, Code.RESOURCE_EXHAUSTED); ServerStreamingCallSettings.Builder<Object, Object> builder = ServerStreamingCallSettings.newBuilder(); builder.setRetryableCodes(codes); Truth.assertThat(builder.getRetryableCodes()).containsExactlyElementsIn(codes); Truth.assertThat(builder.build().getRetryableCodes()).containsExactlyElementsIn(codes); Truth.assertThat(builder.build().toBuilder().getRetryableCodes()) .containsExactlyElementsIn(codes); }
@Test public void retryableSettingsAreNotLost() { RetrySettings retrySettings = Mockito.mock(RetrySettings.class); ServerStreamingCallSettings.Builder<Object, Object> builder = ServerStreamingCallSettings.newBuilder(); builder.setRetrySettings(retrySettings); Truth.assertThat(builder.getRetrySettings()).isSameAs(retrySettings); Truth.assertThat(builder.build().getRetrySettings()).isSameAs(retrySettings); Truth.assertThat(builder.build().toBuilder().getRetrySettings()).isSameAs(retrySettings); }
@Test public void idleTimeoutIsNotLost() { Duration idleTimeout = Duration.ofSeconds(5); ServerStreamingCallSettings.Builder<Object, Object> builder = ServerStreamingCallSettings.newBuilder(); builder.setIdleTimeout(idleTimeout); Truth.assertThat(builder.getIdleTimeout()).isEqualTo(idleTimeout); Truth.assertThat(builder.build().getIdleTimeout()).isEqualTo(idleTimeout); Truth.assertThat(builder.build().toBuilder().getIdleTimeout()).isEqualTo(idleTimeout); } }
/** * Creates a callable chain to handle point ReadRows RPCs. The chain will: * * <ul> * <li>Convert a {@link Query} into a {@link com.google.bigtable.v2.ReadRowsRequest} and * dispatch the RPC. * <li>Upon receiving the response stream, it will merge the {@link * com.google.bigtable.v2.ReadRowsResponse.CellChunk}s in logical rows. The actual row * implementation can be configured in by the {@code rowAdapter} parameter. * <li>Retry/resume on failure. * <li>Filter out marker rows. * </ul> */ public <RowT> UnaryCallable<Query, RowT> createReadRowCallable(RowAdapter<RowT> rowAdapter) { return createReadRowsCallable( ServerStreamingCallSettings.<Query, Row>newBuilder() .setRetryableCodes(settings.readRowSettings().getRetryableCodes()) .setRetrySettings(settings.readRowSettings().getRetrySettings()) .setIdleTimeout(settings.readRowSettings().getRetrySettings().getTotalTimeout()) .build(), rowAdapter) .first(); }
ServerStreamingCallSettings.<ReadRowsRequest, RowT>newBuilder() .setResumptionStrategy(new ReadRowsResumptionStrategy<>(rowAdapter)) .setRetryableCodes(readRowsSettings.getRetryableCodes())
ServerStreamingCallSettings.<Color, Money>newBuilder() .setRetrySettings( RetrySettings.newBuilder() ServerStreamingCallSettings.<Color, Money>newBuilder() .setRetryableCodes(Code.INVALID_ARGUMENT) .setRetrySettings(
@Before public void setUp() throws InstantiationException, IllegalAccessException, IOException { String serverName = "fakeservice"; FakeServiceImpl serviceImpl = new FakeServiceImpl(); inprocessServer = new InProcessServer<>(serviceImpl, serverName); inprocessServer.start(); channel = InProcessChannelBuilder.forName(serverName).directExecutor().usePlaintext().build(); clientContext = ClientContext.newBuilder() .setTransportChannel(GrpcTransportChannel.create(channel)) .setDefaultCallContext(GrpcCallContext.of(channel, CallOptions.DEFAULT)) .build(); streamingCallSettings = ServerStreamingCallSettings.<Color, Money>newBuilder().build(); streamingCallable = GrpcCallableFactory.createServerStreamingCallable( GrpcCallSettings.create(METHOD_SERVER_STREAMING_RECOGNIZE), streamingCallSettings, clientContext); }