Skip to content

Commit 40d8c6c

Browse files
committed
add no op channel primer
Change-Id: I343b3dc44d12638be2af32398b6aaa8529c7ebfb
1 parent 27aa944 commit 40d8c6c

5 files changed

Lines changed: 43 additions & 11 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableChannelPrimer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
/**
4343
* A channel warmer that ensures that a Bigtable channel is ready to be used before being added to
44-
* the active {@link com.google.api.gax.grpc.ChannelPool}.
44+
* the active {@link com.google.cloud.bigtable.gaxx.grpc.BigtableChannelPool}.
4545
*
4646
* <p>This implementation is subject to change in the future, but currently it will prime the
4747
* channel by sending a ReadRow request for a hardcoded, non-existent row key.

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/BigtableClientContext.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.google.api.gax.core.BackgroundResource;
2121
import com.google.api.gax.core.CredentialsProvider;
2222
import com.google.api.gax.core.FixedCredentialsProvider;
23+
import com.google.api.gax.grpc.ChannelPrimer;
2324
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
2425
import com.google.api.gax.rpc.ClientContext;
2526
import com.google.auth.Credentials;
@@ -121,7 +122,7 @@ public static BigtableClientContext create(EnhancedBigtableStubSettings settings
121122
setupCookieHolder(transportProvider);
122123
}
123124

124-
BigtableChannelPrimer channelPrimer = null;
125+
ChannelPrimer channelPrimer = NoOpChannelPrimer.create();
125126

126127
// Inject channel priming if enabled
127128
if (builder.isRefreshingChannel()) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.bigtable.data.v2.stub;
17+
18+
import com.google.api.gax.grpc.ChannelPrimer;
19+
import io.grpc.ManagedChannel;
20+
21+
public class NoOpChannelPrimer implements ChannelPrimer {
22+
static NoOpChannelPrimer create() {
23+
return new NoOpChannelPrimer();
24+
}
25+
26+
NoOpChannelPrimer() {}
27+
28+
@Override
29+
public void primeChannel(ManagedChannel managedChannel) {
30+
// No op
31+
}
32+
}

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/grpc/BigtableChannelPool.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.google.api.core.InternalApi;
1919
import com.google.api.gax.grpc.ChannelFactory;
20-
import com.google.cloud.bigtable.data.v2.stub.BigtableChannelPrimer;
20+
import com.google.api.gax.grpc.ChannelPrimer;
2121
import com.google.common.annotations.VisibleForTesting;
2222
import com.google.common.base.Preconditions;
2323
import com.google.common.collect.ImmutableList;
@@ -62,7 +62,7 @@ public class BigtableChannelPool extends ManagedChannel {
6262
private final BigtableChannelPoolSettings settings;
6363
private final ChannelFactory channelFactory;
6464

65-
@Nullable private final BigtableChannelPrimer channelPrimer;
65+
private final ChannelPrimer channelPrimer;
6666
private final ScheduledExecutorService executor;
6767

6868
private final Object entryWriteLock = new Object();
@@ -73,7 +73,7 @@ public class BigtableChannelPool extends ManagedChannel {
7373
public static BigtableChannelPool create(
7474
BigtableChannelPoolSettings settings,
7575
ChannelFactory channelFactory,
76-
BigtableChannelPrimer channelPrimer)
76+
ChannelPrimer channelPrimer)
7777
throws IOException {
7878
return new BigtableChannelPool(
7979
settings, channelFactory, channelPrimer, Executors.newSingleThreadScheduledExecutor());
@@ -90,7 +90,7 @@ public static BigtableChannelPool create(
9090
BigtableChannelPool(
9191
BigtableChannelPoolSettings settings,
9292
ChannelFactory channelFactory,
93-
BigtableChannelPrimer channelPrimer,
93+
ChannelPrimer channelPrimer,
9494
ScheduledExecutorService executor)
9595
throws IOException {
9696
this.settings = settings;

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/gaxx/grpc/BigtableTransportChannelProvider.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@
1818
import com.google.api.core.InternalApi;
1919
import com.google.api.gax.grpc.ChannelFactory;
2020
import com.google.api.gax.grpc.ChannelPoolSettings;
21+
import com.google.api.gax.grpc.ChannelPrimer;
2122
import com.google.api.gax.grpc.GrpcTransportChannel;
2223
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
2324
import com.google.api.gax.rpc.TransportChannel;
2425
import com.google.api.gax.rpc.TransportChannelProvider;
2526
import com.google.auth.Credentials;
26-
import com.google.cloud.bigtable.data.v2.stub.BigtableChannelPrimer;
2727
import com.google.common.base.Preconditions;
2828
import io.grpc.ManagedChannel;
2929
import java.io.IOException;
3030
import java.util.Map;
3131
import java.util.concurrent.Executor;
3232
import java.util.concurrent.ScheduledExecutorService;
33-
import javax.annotation.Nullable;
3433

3534
/**
3635
* An instance of TransportChannelProvider that provides a TransportChannel through a supplied
@@ -40,11 +39,11 @@
4039
public final class BigtableTransportChannelProvider implements TransportChannelProvider {
4140

4241
private final InstantiatingGrpcChannelProvider delegate;
43-
@Nullable private final BigtableChannelPrimer channelPrimer;
42+
private final ChannelPrimer channelPrimer;
4443

4544
private BigtableTransportChannelProvider(
4645
InstantiatingGrpcChannelProvider instantiatingGrpcChannelProvider,
47-
BigtableChannelPrimer channelPrimer) {
46+
ChannelPrimer channelPrimer) {
4847
delegate = Preconditions.checkNotNull(instantiatingGrpcChannelProvider);
4948
this.channelPrimer = channelPrimer;
5049
}
@@ -161,7 +160,7 @@ public TransportChannelProvider withCredentials(Credentials credentials) {
161160
/** Creates a BigtableTransportChannelProvider. */
162161
public static BigtableTransportChannelProvider create(
163162
InstantiatingGrpcChannelProvider instantiatingGrpcChannelProvider,
164-
BigtableChannelPrimer channelPrimer) {
163+
ChannelPrimer channelPrimer) {
165164
return new BigtableTransportChannelProvider(instantiatingGrpcChannelProvider, channelPrimer);
166165
}
167166
}

0 commit comments

Comments
 (0)