use of com.google.cloud.bigtable.test_helpers.env.AbstractTestEnv.ConnectionMode in project java-bigtable by googleapis.
the class DirectPathFallbackIT method setup.
@Before
public void setup() throws IOException {
Set<ConnectionMode> validModes = ImmutableSet.of(ConnectionMode.REQUIRE_DIRECT_PATH, ConnectionMode.REQUIRE_DIRECT_PATH_IPV4);
assume().withMessage("DirectPathFallbackIT can only return when explicitly requested").that(validModes.contains(testEnvRule.env().getConnectionMode())).isTrue();
BigtableDataSettings defaultSettings = testEnvRule.env().getDataClientSettings();
InstantiatingGrpcChannelProvider defaultTransportProvider = (InstantiatingGrpcChannelProvider) defaultSettings.getStubSettings().getTransportChannelProvider();
InstantiatingGrpcChannelProvider instrumentedTransportChannelProvider = defaultTransportProvider.toBuilder().setAttemptDirectPath(true).setPoolSize(1).setChannelConfigurator(new ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder>() {
@Override
public ManagedChannelBuilder apply(ManagedChannelBuilder builder) {
injectNettyChannelHandler(builder);
// Fail fast when blackhole is active
builder.keepAliveTime(1, TimeUnit.SECONDS);
builder.keepAliveTimeout(1, TimeUnit.SECONDS);
return builder;
}
}).build();
// Inject the instrumented transport provider into a new client
BigtableDataSettings.Builder settingsBuilder = testEnvRule.env().getDataClientSettings().toBuilder();
settingsBuilder.stubSettings().setTransportChannelProvider(instrumentedTransportChannelProvider).setCredentialsProvider(FixedCredentialsProvider.create(ComputeEngineCredentials.create()));
instrumentedClient = BigtableDataClient.create(settingsBuilder.build());
}
Aggregations