接続プールの構成
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
接続プールの構成
もっと見る
このコードサンプルを含む詳細なドキュメントについては、以下をご覧ください。
コードサンプル
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content provides code examples in C++, Go, and Java demonstrating how to configure connection pools for Google Cloud Bigtable.\u003c/p\u003e\n"],["\u003cp\u003eConnection pool size can be set to optimize the number of channels used for communication, with a size of 10 being used in the provided examples.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples show how to set the pool size when creating a Bigtable client using each respective language.\u003c/p\u003e\n"],["\u003cp\u003eSetting up Application Default Credentials (ADC) is necessary to authenticate with Bigtable, and instructions to do so are referenced.\u003c/p\u003e\n"],["\u003cp\u003eFor more resources on managing connection pools and installing client libraries, relevant links to the Bigtable documentation and sample browser are provided.\u003c/p\u003e\n"]]],[],null,["Configure connection pools\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Configure connection pools](/bigtable/docs/configure-connection-pools)\n\nCode sample \n\nC++\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n namespace cbt = ::google::cloud::bigtable;\n namespace gc = ::google::cloud;\n [](std::string const& project_id, std::string const& instance_id,\n std::string const& table_id) {\n auto constexpr kPoolSize = 10;\n auto options = gc::Options{}.set\u003cgc::GrpcNumChannelsOption\u003e(kPoolSize);\n cbt::Table table(cbt::MakeDataConnection(options),\n cbt::TableResource(project_id, instance_id, table_id));\n std::cout \u003c\u003c \"Connected with channel pool size of \" \u003c\u003c kPoolSize \u003c\u003c \"\\n\";\n }\n\nGo\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n import (\n \t\"context\"\n \t\"fmt\"\n \t\"io\"\n\n \t\"cloud.google.com/go/bigtable\"\n \t\"google.golang.org/api/option\"\n )\n\n func configureConnectionPool(w io.Writer, projectID, instanceID string) error {\n \t// projectID := \"my-project-id\"\n \t// instanceID := \"my-instance-id\"\n \tctx := context.Background()\n\n \t// Set up Bigtable data operations client.\n \tpoolSize := 10\n \tclient, err := bigtable.https://cloud.google.com/go/docs/reference/cloud.google.com/go/bigtable/latest/index.html#cloud_google_com_go_bigtable_Client_NewClient(ctx, projectID, instanceID, option.WithGRPCConnectionPool(poolSize))\n \tdefer client.Close()\n\n \tif err != nil {\n \t\treturn fmt.Errorf(\"bigtable.NewClient: %w\", err)\n \t}\n\n \tfmt.Fprintf(w, \"Connected with pool size of %d\", poolSize)\n\n \treturn nil\n }\n\nJava\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n import com.google.api.gax.grpc.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.html;\n import com.google.cloud.bigtable.data.v2.https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient.html;\n import com.google.cloud.bigtable.data.v2.https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.html;\n import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings;\n import java.io.IOException;\n\n public class ConfigureConnectionPool {\n\n public static void configureConnectionPool(String projectId, String instanceId) {\n // String projectId = \"my-project-id\";\n // String instanceId = \"my-instance-id\";\n\n https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.html.Builder settingsBuilder =\n https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.html.newBuilder().https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.Builder.html#com_google_cloud_bigtable_data_v2_BigtableDataSettings_Builder_setProjectId_java_lang_String_(projectId).https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.Builder.html#com_google_cloud_bigtable_data_v2_BigtableDataSettings_Builder_setInstanceId_java_lang_String_(instanceId);\n\n settingsBuilder\n .https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.Builder.html#com_google_cloud_bigtable_data_v2_BigtableDataSettings_Builder_stubSettings__()\n .setTransportChannelProvider(\n EnhancedBigtableStubSettings.defaultGrpcTransportProviderBuilder()\n .https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder.html#com_google_api_gax_grpc_InstantiatingGrpcChannelProvider_Builder_setPoolSize_int_(10)\n .build());\n\n https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.html settings = settingsBuilder.build();\n try (https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient.html dataClient = https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataClient.html.create(settings)) {\n https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.html provider =\n (https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.html)\n settings.https://cloud.google.com/java/docs/reference/google-cloud-bigtable/latest/com.google.cloud.bigtable.data.v2.BigtableDataSettings.html#com_google_cloud_bigtable_data_v2_BigtableDataSettings_getStubSettings__().getTransportChannelProvider();\n\n int poolSize = provider.https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.html#com_google_api_gax_grpc_InstantiatingGrpcChannelProvider_toBuilder__().https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.Builder.html#com_google_api_gax_grpc_InstantiatingGrpcChannelProvider_Builder_getPoolSize__();\n\n System.out.println(String.format(\"Connected with pool size of %d\", poolSize));\n } catch (IOException e) {\n System.out.println(\"Error during ConfigureConnectionPool: \\n\" + e.toString());\n }\n }\n }\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigtable)."]]