클러스터 나열
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
인스턴스의 모든 클러스터 이름을 나열합니다.
코드 샘플
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 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 demonstrates how to list all cluster names within a specified Bigtable instance using code examples in C++, Java, Node.js, PHP, Python, and Ruby.\u003c/p\u003e\n"],["\u003cp\u003eEach code sample utilizes the respective Bigtable client library to connect to the instance and retrieve a list of cluster names, which are then printed to the console.\u003c/p\u003e\n"],["\u003cp\u003eThe code also shows how to handle cases where certain locations are temporarily unavailable, and displays a message about it.\u003c/p\u003e\n"],["\u003cp\u003eThe code samples also point the user to resources to learn more about the Bigtable client library and authentication setup.\u003c/p\u003e\n"]]],[],null,["List all of the cluster names in an instance.\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 cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::StatusOr;\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id, std::string const& instance_id) {\n std::string instance_name = cbt::InstanceName(project_id, instance_id);\n StatusOr\u003cgoogle::bigtable::admin::v2::ListClustersResponse\u003e clusters =\n instance_admin.ListClusters(instance_name);\n if (!clusters) throw std::move(clusters).status();\n std::cout \u003c\u003c \"Cluster Name List\\n\";\n for (auto const& cluster : clusters-\u003eclusters()) {\n std::cout \u003c\u003c \"Cluster Name:\" \u003c\u003c cluster.name() \u003c\u003c \"\\n\";\n }\n if (!clusters-\u003efailed_locations().empty()) {\n std::cout \u003c\u003c \"The Cloud Bigtable service reports that the following \"\n \"locations are temporarily unavailable and no information \"\n \"about clusters in these locations can be obtained:\\n\";\n for (auto const& failed_location : clusters-\u003efailed_locations()) {\n std::cout \u003c\u003c failed_location \u003c\u003c \"\\n\";\n }\n }\n }\n namespace cbt = ::google::cloud::bigtable;\n namespace cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::StatusOr;\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id) {\n std::string instance_name = cbt::InstanceName(project_id, \"-\");\n StatusOr\u003cgoogle::bigtable::admin::v2::ListClustersResponse\u003e clusters =\n instance_admin.ListClusters(instance_name);\n if (!clusters) throw std::move(clusters).status();\n std::cout \u003c\u003c \"Cluster Name List\\n\";\n for (auto const& cluster : clusters-\u003eclusters()) {\n std::cout \u003c\u003c \"Cluster Name:\" \u003c\u003c cluster.name() \u003c\u003c \"\\n\";\n }\n if (!clusters-\u003efailed_locations().empty()) {\n std::cout \u003c\u003c \"The Cloud Bigtable service reports that the following \"\n \"locations are temporarily unavailable and no information \"\n \"about clusters in these locations can be obtained:\\n\";\n for (auto const& failed_location : clusters-\u003efailed_locations()) {\n std::cout \u003c\u003c failed_location \u003c\u003c \"\\n\";\n }\n }\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 try {\n List\u003cCluster\u003e clusters = adminClient.listClusters(instanceId);\n for (Cluster cluster : clusters) {\n System.out.println(cluster.getId());\n }\n } catch (NotFoundException e) {\n System.err.println(\"Failed to list clusters from a non-existent instance: \" + e.getMessage());\n }\n\nNode.js\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 const instance3 = bigtable.instance(instanceID);\n const [clusters] = await instance3.getClusters();\n clusters.forEach(cluster =\u003e {\n console.log(cluster.id);\n });\n\nPHP\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 use Google\\Cloud\\Bigtable\\Admin\\V2\\Client\\BigtableInstanceAdminClient;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\ListClustersRequest;\n\n /**\n * List clusters of an instance\n *\n * @param string $projectId The Google Cloud project ID\n * @param string $instanceId The ID of the Bigtable instance\n */\n function list_instance_clusters(\n string $projectId,\n string $instanceId\n ): void {\n $instanceAdminClient = new BigtableInstanceAdminClient();\n\n $projectName = $instanceAdminClient-\u003eprojectName($projectId);\n $instanceName = $instanceAdminClient-\u003einstanceName($projectId, $instanceId);\n\n printf('Listing Clusters:' . PHP_EOL);\n $listClustersRequest = (new ListClustersRequest())\n -\u003esetParent($instanceName);\n $getClusters = $instanceAdminClient-\u003elistClusters($listClustersRequest)-\u003egetClusters();\n $clusters = $getClusters-\u003egetIterator();\n\n foreach ($clusters as $cluster) {\n print($cluster-\u003egetName() . PHP_EOL);\n }\n }\n\nPython\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 print(\"\\nListing clusters...\")\n for cluster in instance.list_clusters()[0]:\n print(cluster.cluster_id)\n\nRuby\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 # instance_id = \"my-instance\"\n bigtable.instance(instance_id).clusters.all do |cluster|\n puts \"Cluster: #{cluster.cluster_id}\"\n end\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)."]]