Skip to content

Instantly share code, notes, and snippets.

@djaquels
Last active May 31, 2022 21:38
Show Gist options
  • Save djaquels/0667d5007e3ebf84561468c1c343a28f to your computer and use it in GitHub Desktop.
Save djaquels/0667d5007e3ebf84561468c1c343a28f to your computer and use it in GitHub Desktop.
Bgitable Custom GRPC Channel
val settingsBuilder = BigtableDataSettings.newBuilder()
settingsBuilder.setProjectId("projectId")
settingsBuilder.setInstanceId("instanceId")
settingsBuilder.setAppProfileId("default")
val grpcSettings = EnhancedBigtableStubSettings.defaultGrpcTransportProviderBuilder()
grpcSettings.setMaxInboundMessageSize(550000000)
println("Before Building Client Settings: ")
println(grpcSettings.getMaxInboundMessageSize().toString)
settingsBuilder.stubSettings().setTransportChannelProvider(grpcSettings.build())
val settings = settingsBuilder.build()
println("Buffer Size After Building Settings: ")
val provider = settings.getStubSettings().getTransportChannelProvider().asInstanceOf[InstantiatingGrpcChannelProvider]
val bufferSize = provider.toBuilder().getMaxInboundMessageSize()
println(bufferSize)
val client = BigtableDataClient.create(settings)
println("Buffer Size After Creating Client: ")
val providerAfter = settings.getStubSettings().getTransportChannelProvider().asInstanceOf[InstantiatingGrpcChannelProvider]
val bufferSizeAfter = provider.toBuilder().getMaxInboundMessageSize()
println(bufferSizeAfter)
@djaquels
Copy link
Author

Java Version

import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
import com.google.cloud.bigtable.data.v2.models.BulkMutation, Mutation;
import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings;
import com.google.cloud.bigtable.data.v2.models.RowMutation;
import com.google.protobuf.ByteString;

//class definitions...
BigtableDataSettings.Builder settingsBuilder =
        BigtableDataSettings.newBuilder().setProjectId(projectId).setInstanceId(instanceId);
EnhancedBigtableStubSettings grpcSettins = EnhancedBigtableStubSettings.defaultGrpcTransportProviderBuilder();
grpcSettings.setMaxInboundMessageSize(550000000);
settingsBuilder.stubSettings().setTransportChannelProvider(grpcSettings.build());
BigtableDataSettings  settings = settingsBuilder.build();
BigtableDataClient client = BigtableDataClient.create(settings);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment