Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.INSTANCE_ID_KEY;

import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.gax.batching.Batcher;
Expand Down Expand Up @@ -112,7 +111,6 @@
import com.google.cloud.bigtable.data.v2.stub.readrows.FilterMarkerRowsCallable;
import com.google.cloud.bigtable.data.v2.stub.readrows.LargeReadRowsResumptionStrategy;
import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsBatchingDescriptor;
import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsFirstCallable;
import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsResumptionStrategy;
import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsRetryCompletedCallable;
import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsUserCallable;
Expand All @@ -131,7 +129,6 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.protobuf.ByteString;
import io.grpc.MethodDescriptor;
import io.opencensus.stats.Stats;
Expand Down Expand Up @@ -404,52 +401,31 @@ public <RowT> ServerStreamingCallable<Query, RowT> createReadRowsCallable(
*/
public <RowT> UnaryCallable<Query, RowT> createReadRowCallable(RowAdapter<RowT> rowAdapter) {
ClientContext clientContext = bigtableClientContext.getClientContext();
if (!settings.getEnableSkipTrailers()) {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable =
createReadRowsBaseCallable(
ServerStreamingCallSettings.<ReadRowsRequest, Row>newBuilder()
.setRetryableCodes(settings.readRowSettings().getRetryableCodes())
.setRetrySettings(settings.readRowSettings().getRetrySettings())
.setIdleTimeout(settings.readRowSettings().getRetrySettings().getTotalTimeout())
.build(),
rowAdapter);

ReadRowsUserCallable<RowT> readRowCallable =
new ReadRowsUserCallable<>(readRowsCallable, requestContext);
ReadRowsFirstCallable<RowT> firstRow = new ReadRowsFirstCallable<>(readRowCallable);
UnaryCallable<Query, RowT> traced =
new TracedUnaryCallable<>(
firstRow, clientContext.getTracerFactory(), getSpanName("ReadRow"));
return traced.withDefaultCallContext(
clientContext
.getDefaultCallContext()
.withRetrySettings(settings.readRowSettings().getRetrySettings()));
} else {
ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable =
createReadRowsBaseCallable(
ServerStreamingCallSettings.<ReadRowsRequest, Row>newBuilder()
.setRetryableCodes(settings.readRowSettings().getRetryableCodes())
.setRetrySettings(settings.readRowSettings().getRetrySettings())
.setIdleTimeoutDuration(Duration.ZERO)
.setWaitTimeoutDuration(Duration.ZERO)
.build(),
rowAdapter,
new SimpleStreamResumptionStrategy<>());
ServerStreamingCallable<Query, RowT> readRowCallable =
new TransformingServerStreamingCallable<>(
readRowsCallable,
(query) -> query.limit(1).toProto(requestContext),
Functions.identity());

return new BigtableUnaryOperationCallable<>(
readRowCallable,
clientContext
.getDefaultCallContext()
.withRetrySettings(settings.readRowSettings().getRetrySettings()),
clientContext.getTracerFactory(),
getSpanName("ReadRow"),
/* allowNoResponses= */ true);
}

ServerStreamingCallable<ReadRowsRequest, RowT> readRowsCallable =
createReadRowsBaseCallable(
ServerStreamingCallSettings.<ReadRowsRequest, Row>newBuilder()
.setRetryableCodes(settings.readRowSettings().getRetryableCodes())
.setRetrySettings(settings.readRowSettings().getRetrySettings())
.setIdleTimeoutDuration(Duration.ZERO)
.setWaitTimeoutDuration(Duration.ZERO)
.build(),
rowAdapter,
new SimpleStreamResumptionStrategy<>());
ServerStreamingCallable<Query, RowT> readRowCallable =
new TransformingServerStreamingCallable<>(
readRowsCallable,
(query) -> query.limit(1).toProto(requestContext),
Functions.identity());

return new BigtableUnaryOperationCallable<>(
readRowCallable,
clientContext
.getDefaultCallContext()
.withRetrySettings(settings.readRowSettings().getRetrySettings()),
clientContext.getTracerFactory(),
getSpanName("ReadRow"),
/* allowNoResponses= */ true);
}

private <ReqT, RowT> ServerStreamingCallable<ReadRowsRequest, RowT> createReadRowsBaseCallable(
Expand Down Expand Up @@ -1292,67 +1268,6 @@ private <BaseReqT, BaseRespT, ReqT, RespT> UnaryCallable<ReqT, RespT> createUnar
UnaryCallSettings<ReqT, RespT> callSettings,
Function<ReqT, BaseReqT> requestTransformer,
Function<BaseRespT, RespT> responseTranformer) {
if (settings.getEnableSkipTrailers()) {
return createUnaryCallableNew(
methodDescriptor, headerParamsFn, callSettings, requestTransformer, responseTranformer);
} else {
return createUnaryCallableOld(
methodDescriptor, headerParamsFn, callSettings, requestTransformer, responseTranformer);
}
}

private <BaseReqT, BaseRespT, ReqT, RespT> UnaryCallable<ReqT, RespT> createUnaryCallableOld(
MethodDescriptor<BaseReqT, BaseRespT> methodDescriptor,
RequestParamsExtractor<BaseReqT> headerParamsFn,
UnaryCallSettings<ReqT, RespT> callSettings,
Function<ReqT, BaseReqT> requestTransformer,
Function<BaseRespT, RespT> responseTranformer) {

UnaryCallable<BaseReqT, BaseRespT> base =
GrpcRawCallableFactory.createUnaryCallable(
GrpcCallSettings.<BaseReqT, BaseRespT>newBuilder()
.setMethodDescriptor(methodDescriptor)
.setParamsExtractor(headerParamsFn)
.build(),
callSettings.getRetryableCodes());

UnaryCallable<BaseReqT, BaseRespT> withStatsHeaders = new StatsHeadersUnaryCallable<>(base);

UnaryCallable<BaseReqT, BaseRespT> withBigtableTracer =
new BigtableTracerUnaryCallable<>(withStatsHeaders);

UnaryCallable<BaseReqT, BaseRespT> retrying = withRetries(withBigtableTracer, callSettings);

UnaryCallable<ReqT, RespT> transformed =
new UnaryCallable<ReqT, RespT>() {
@Override
public ApiFuture<RespT> futureCall(ReqT reqT, ApiCallContext apiCallContext) {
ApiFuture<BaseRespT> f =
retrying.futureCall(requestTransformer.apply(reqT), apiCallContext);
return ApiFutures.transform(
f, responseTranformer::apply, MoreExecutors.directExecutor());
}
};

UnaryCallable<ReqT, RespT> traced =
new TracedUnaryCallable<>(
transformed,
bigtableClientContext.getClientContext().getTracerFactory(),
getSpanName(methodDescriptor.getBareMethodName()));

return traced.withDefaultCallContext(
bigtableClientContext
.getClientContext()
.getDefaultCallContext()
.withRetrySettings(callSettings.getRetrySettings()));
}

private <BaseReqT, BaseRespT, ReqT, RespT> UnaryCallable<ReqT, RespT> createUnaryCallableNew(
MethodDescriptor<BaseReqT, BaseRespT> methodDescriptor,
RequestParamsExtractor<BaseReqT> headerParamsFn,
UnaryCallSettings<ReqT, RespT> callSettings,
Function<ReqT, BaseReqT> requestTransformer,
Function<BaseRespT, RespT> responseTranformer) {

ServerStreamingCallable<BaseReqT, BaseRespT> base =
GrpcRawCallableFactory.createServerStreamingCallable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Logger;
Expand Down Expand Up @@ -119,11 +118,6 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
private static final boolean DIRECT_PATH_BOUND_TOKEN_DISABLED =
Boolean.parseBoolean(System.getenv("CBT_DISABLE_DIRECTPATH_BOUND_TOKEN"));

private static final boolean SKIP_TRAILERS =
Optional.ofNullable(System.getenv("CBT_SKIP_HEADERS"))
.map(Boolean::parseBoolean)
.orElse(true);

private static final Set<Code> IDEMPOTENT_RETRY_CODES =
ImmutableSet.of(Code.DEADLINE_EXCEEDED, Code.UNAVAILABLE);

Expand Down Expand Up @@ -268,7 +262,6 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
private ImmutableList<String> primedTableIds;
private final boolean enableRoutingCookie;
private final boolean enableRetryInfo;
private final boolean enableSkipTrailers;

private final ServerStreamingCallSettings<Query, Row> readRowsSettings;
private final UnaryCallSettings<Query, Row> readRowSettings;
Expand Down Expand Up @@ -318,7 +311,6 @@ private EnhancedBigtableStubSettings(Builder builder) {
primedTableIds = builder.primedTableIds;
enableRoutingCookie = builder.enableRoutingCookie;
enableRetryInfo = builder.enableRetryInfo;
enableSkipTrailers = builder.enableSkipTrailers;
metricsProvider = builder.metricsProvider;
metricsEndpoint = builder.metricsEndpoint;
internalMetricsProvider = builder.internalMetricsProvider;
Expand Down Expand Up @@ -413,10 +405,6 @@ public boolean getEnableRetryInfo() {
return enableRetryInfo;
}

boolean getEnableSkipTrailers() {
return enableSkipTrailers;
}

/**
* Gets the Google Cloud Monitoring endpoint for publishing client side metrics. If it's null,
* client will publish metrics to the default monitoring endpoint.
Expand Down Expand Up @@ -769,7 +757,6 @@ public static class Builder extends StubSettings.Builder<EnhancedBigtableStubSet
private String jwtAudience;
private boolean enableRoutingCookie;
private boolean enableRetryInfo;
private boolean enableSkipTrailers;

private final ServerStreamingCallSettings.Builder<Query, Row> readRowsSettings;
private final UnaryCallSettings.Builder<Query, Row> readRowSettings;
Expand Down Expand Up @@ -810,7 +797,6 @@ private Builder() {
setCredentialsProvider(defaultCredentialsProviderBuilder().build());
this.enableRoutingCookie = true;
this.enableRetryInfo = true;
this.enableSkipTrailers = SKIP_TRAILERS;
metricsProvider = DefaultMetricsProvider.INSTANCE;
this.internalMetricsProvider = DEFAULT_INTERNAL_OTEL_PROVIDER;
this.jwtAudience = DEFAULT_DATA_JWT_AUDIENCE;
Expand Down Expand Up @@ -1223,11 +1209,6 @@ public boolean getEnableRetryInfo() {
return enableRetryInfo;
}

Builder setEnableSkipTrailers(boolean enabled) {
this.enableSkipTrailers = enabled;
return this;
}

/** Returns the builder for the settings used for calls to readRows. */
public ServerStreamingCallSettings.Builder<Query, Row> readRowsSettings() {
return readRowsSettings;
Expand Down Expand Up @@ -1360,7 +1341,6 @@ public String toString() {
.add("primedTableIds", primedTableIds)
.add("enableRoutingCookie", enableRoutingCookie)
.add("enableRetryInfo", enableRetryInfo)
.add("enableSkipTrailers", enableSkipTrailers)
.add("readRowsSettings", readRowsSettings)
.add("readRowSettings", readRowSettings)
.add("sampleRowKeysSettings", sampleRowKeysSettings)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,6 @@ public void enableRetryInfoFalseValueTest() throws IOException {
"primedTableIds",
"enableRoutingCookie",
"enableRetryInfo",
"enableSkipTrailers",
"readRowsSettings",
"readRowSettings",
"sampleRowKeysSettings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public void setUp() throws Exception {
.setInstanceId(INSTANCE_ID)
.setMetricsProvider(NoopMetricsProvider.INSTANCE)
.setCredentialsProvider(NoCredentialsProvider.create());
clientBuilder.stubSettings().setEnableSkipTrailers(true).setTracerFactory(tracerFactory);
clientBuilder.stubSettings().setTracerFactory(tracerFactory);

client = BigtableDataClient.create(clientBuilder.build());
}
Expand Down
Loading
Loading