Skip to content
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 @@ -119,27 +119,31 @@ public static Builder newBuilderForEmulator(int port) {
* port number.
*/
public static Builder newBuilderForEmulator(String hostname, int port) {
Builder builder = new Builder();

builder
.stubSettings()
.setCredentialsProvider(NoCredentialsProvider.create())
.setEndpoint(hostname + ":" + port)
// disable channel refreshing when creating an emulator
.setRefreshingChannel(false)
.setMetricsProvider(NoopMetricsProvider.INSTANCE) // disable exporting metrics for emulator
.disableInternalMetrics()
.setTransportChannelProvider(
InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(256 * 1024 * 1024)
.setChannelPoolSettings(ChannelPoolSettings.staticallySized(1))
.setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
.setKeepAliveTimeDuration(
java.time.Duration.ofSeconds(61)) // sends ping in this interval
.setKeepAliveTimeoutDuration(
java.time.Duration.ofSeconds(
10)) // wait this long before considering the connection dead
.build());
BigtableDataSettings.Builder builder = new BigtableDataSettings.Builder();

// TODO: remove the suppression once setRefreshingChannel is no longer necessary
@SuppressWarnings({"deprecation", "VariableUnused"})
EnhancedBigtableStubSettings.Builder ignored =
builder
.stubSettings()
.setCredentialsProvider(NoCredentialsProvider.create())
.setEndpoint(hostname + ":" + port)
// disable channel refreshing when creating an emulator
.setRefreshingChannel(false)
.setMetricsProvider(
NoopMetricsProvider.INSTANCE) // disable exporting metrics for emulator
.disableInternalMetrics()
.setTransportChannelProvider(
InstantiatingGrpcChannelProvider.newBuilder()
.setMaxInboundMessageSize(256 * 1024 * 1024)
.setChannelPoolSettings(ChannelPoolSettings.staticallySized(1))
.setChannelConfigurator(ManagedChannelBuilder::usePlaintext)
.setKeepAliveTimeDuration(
java.time.Duration.ofSeconds(61)) // sends ping in this interval
.setKeepAliveTimeoutDuration(
java.time.Duration.ofSeconds(
10)) // wait this long before considering the connection dead
.build());

LOGGER.info("Connecting to the Bigtable emulator at " + hostname + ":" + port);
return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public static BigtableClientContext create(
ChannelPrimer channelPrimer = NoOpChannelPrimer.create();

// Inject channel priming if enabled
if (builder.isRefreshingChannel()) {
if (isRefreshingEnabled(builder)) {
channelPrimer =
BigtableChannelPrimer.create(
builder.getProjectId(),
Expand Down Expand Up @@ -182,6 +182,11 @@ public static BigtableClientContext create(
}
}

@SuppressWarnings("deprecation")
private static boolean isRefreshingEnabled(EnhancedBigtableStubSettings.Builder b) {
return b.isRefreshingChannel();
}

private static void configureGrpcOtel(
InstantiatingGrpcChannelProvider.Builder transportProvider, Metrics metrics) {
@SuppressWarnings("rawtypes")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ public void testCreateForInstanceWithAppProfileHasCorrectSettings() throws Excep
@Test
public void testCreateWithRefreshingChannel() throws Exception {
int poolSize = 3;
// TODO: remove the suppression when setRefreshingChannel can be removed
@SuppressWarnings("deprecation")
BigtableDataSettings.Builder builder =
BigtableDataSettings.newBuilderForEmulator(server.getPort())
.setProjectId(DEFAULT_PROJECT_ID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class BigtableDataSettingsTest {

@Test
public void testToString() {
// TODO: figure out how avoid using setRefreshingChannel
@SuppressWarnings("deprecation")
BigtableDataSettings settings =
BigtableDataSettings.newBuilder()
.setProjectId("our-project-2-12")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public class PreparedStatementImplTest {
public void setUp() throws IOException {
service = new TestBigtableSqlService();
serverRule.getServiceRegistry().addService(service);

BigtableDataSettings.Builder settings =
BigtableDataSettings.newBuilder()
.setProjectId(TestBigtableSqlService.DEFAULT_PROJECT_ID)
Expand All @@ -91,8 +92,6 @@ public void setUp() throws IOException {
.setTransportChannelProvider(
FixedTransportChannelProvider.create(
GrpcTransportChannel.create(serverRule.getChannel())))
// Refreshing channel doesn't work with FixedTransportChannelProvider
.setRefreshingChannel(false)
.build();
// Remove log noise from client side metrics
settings.setMetricsProvider(NoopMetricsProvider.INSTANCE).disableInternalMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ public void sendHeaders(Metadata headers) {
.setProjectId(PROJECT_ID)
.setInstanceId(INSTANCE_ID)
.setAppProfileId(APP_PROFILE_ID)
.setRefreshingChannel(false)
.build();
EnhancedBigtableStubSettings.Builder stubSettingsBuilder =
settings.getStubSettings().toBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ public void setUp() throws Exception {
BigtableDataSettings.newBuilderForEmulator(server.getPort())
.setProjectId(PROJECT_ID)
.setInstanceId(INSTANCE_ID)
.setCredentialsProvider(NoCredentialsProvider.create())
.setRefreshingChannel(false);
.setCredentialsProvider(NoCredentialsProvider.create());

stub = EnhancedBigtableStub.create(settingBuilder.build().getStubSettings());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.threeten.bp.Duration;

@RunWith(JUnit4.class)
@SuppressWarnings("deprecation") // TODO: remove this
public class EnhancedBigtableStubSettingsTest {
@Test
public void instanceNameIsRequiredTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ public void testBatchJwtAudience()
ManagedChannel channel =
ManagedChannelBuilder.forAddress("localhost", server.getPort()).usePlaintext().build();

// TODO: remove this suppression when setRefreshingChannel can be removed
@SuppressWarnings("deprecation")
EnhancedBigtableStubSettings settings =
EnhancedBigtableStubSettings.newBuilder()
.setProjectId("fake-project")
Expand Down Expand Up @@ -311,8 +313,9 @@ public void testFeatureFlags() throws InterruptedException, IOException, Executi
}

@Test
public void testPingAndWarmFeatureFlags()
throws InterruptedException, IOException, ExecutionException {
public void testPingAndWarmFeatureFlags() throws InterruptedException, IOException {
// TODO: remove the suppression once setRefreshingChannel can be removed
@SuppressWarnings("deprecation")
EnhancedBigtableStubSettings settings =
defaultSettings.toBuilder().setRefreshingChannel(true).build();
try (EnhancedBigtableStub ignored = EnhancedBigtableStub.create(settings)) {
Expand Down Expand Up @@ -543,6 +546,8 @@ public void testCreateReadRowsRawCallable() throws InterruptedException {

@Test
public void testChannelPrimerConfigured() throws IOException {
// TODO: remove the suppression once setRefreshingChannel can be removed
@SuppressWarnings("deprecation")
EnhancedBigtableStubSettings settings =
defaultSettings.toBuilder().setRefreshingChannel(true).build();

Expand Down Expand Up @@ -712,8 +717,7 @@ public void testBulkMutationFlowControllerConfigured() throws Exception {
@Test
public void testCallContextPropagatedInMutationBatcher()
throws IOException, InterruptedException, ExecutionException {
EnhancedBigtableStubSettings settings =
defaultSettings.toBuilder().setRefreshingChannel(true).build();
EnhancedBigtableStubSettings settings = defaultSettings.toBuilder().build();

try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings)) {
// clear the previous contexts
Expand All @@ -739,8 +743,7 @@ public void testCallContextPropagatedInMutationBatcher()
@Test
public void testCallContextPropagatedInReadBatcher()
throws IOException, InterruptedException, ExecutionException {
EnhancedBigtableStubSettings settings =
defaultSettings.toBuilder().setRefreshingChannel(true).build();
EnhancedBigtableStubSettings settings = defaultSettings.toBuilder().build();

try (EnhancedBigtableStub stub = EnhancedBigtableStub.create(settings)) {
// clear the previous contexts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ public void close(Status status, Metadata trailers) {
BigtableDataSettings.Builder settings =
BigtableDataSettings.newBuilderForEmulator(server.getPort())
.setProjectId("fake-project")
.setInstanceId("fake-instance")
.setRefreshingChannel(false);
.setInstanceId("fake-instance");

this.client = BigtableDataClient.create(settings.build());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public void setUp() throws IOException {
.setTransportChannelProvider(
FixedTransportChannelProvider.create(
GrpcTransportChannel.create(serverRule.getChannel())))
// channel priming doesn't work with FixedTransportChannelProvider. Disable it for the test
.setRefreshingChannel(false)
.build();

this.client = BigtableDataClient.create(settings.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,6 @@ public void setUp() throws IOException {
.setTransportChannelProvider(
FixedTransportChannelProvider.create(
GrpcTransportChannel.create(serverRule.getChannel())))
// Refreshing channel doesn't work with FixedTransportChannelProvider
.setRefreshingChannel(false)
.build();

client = BigtableDataClient.create(settings.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,6 @@ public static BigtableDataSettings.Builder defaultSettings(GrpcServerRule server
.setTransportChannelProvider(
FixedTransportChannelProvider.create(
GrpcTransportChannel.create(serverRule.getChannel())))
// Refreshing channel doesn't work with FixedTransportChannelProvider
.setRefreshingChannel(false)
.build();
// Remove log noise from client side metrics
settings.setMetricsProvider(NoopMetricsProvider.INSTANCE).disableInternalMetrics();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void start() throws Exception {
BigtableDataSettings.newBuilderForEmulator(emulator.getPort())
.setProjectId("fake-project")
.setInstanceId("fake-instance")
.setRefreshingChannel(false)
.setMetricsProvider(NoopMetricsProvider.INSTANCE)
.disableInternalMetrics()
.build();
Expand Down
Loading