Search in sources :

Example 1 with ConnectionMode

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());
}
Also used : InstantiatingGrpcChannelProvider(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider) ConnectionMode(com.google.cloud.bigtable.test_helpers.env.AbstractTestEnv.ConnectionMode) ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) ApiFunction(com.google.api.core.ApiFunction) BigtableDataSettings(com.google.cloud.bigtable.data.v2.BigtableDataSettings) Before(org.junit.Before)

Aggregations

ApiFunction (com.google.api.core.ApiFunction)1 InstantiatingGrpcChannelProvider (com.google.api.gax.grpc.InstantiatingGrpcChannelProvider)1 BigtableDataSettings (com.google.cloud.bigtable.data.v2.BigtableDataSettings)1 ConnectionMode (com.google.cloud.bigtable.test_helpers.env.AbstractTestEnv.ConnectionMode)1 ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)1 Before (org.junit.Before)1