Recupero dei dettagli del cluster
Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Recupera i dettagli del cluster dato l'ID istanza nel progetto attuale.
Esempio di codice
Salvo quando diversamente specificato, i contenuti di questa pagina sono concessi in base alla licenza Creative Commons Attribution 4.0, mentre gli esempi di codice sono concessi in base alla licenza Apache 2.0. Per ulteriori dettagli, consulta le norme del sito di Google Developers. Java è un marchio registrato di Oracle e/o delle sue consociate.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis page provides code samples in C++ and PHP to retrieve cluster details using the Bigtable client library within the current project.\u003c/p\u003e\n"],["\u003cp\u003eThe code demonstrates how to use the \u003ccode\u003eGetCluster\u003c/code\u003e method to fetch specific information about a cluster, given the project ID, instance ID, and cluster ID.\u003c/p\u003e\n"],["\u003cp\u003eThe PHP example shows how to handle potential errors, such as a \u003ccode\u003eNOT_FOUND\u003c/code\u003e status, and prints essential cluster metadata like name, location, state, storage type, nodes, and encryption configuration.\u003c/p\u003e\n"],["\u003cp\u003eThe page provides links to the Bigtable client libraries and guides on setting up Application Default Credentials for authentication.\u003c/p\u003e\n"],["\u003cp\u003eThe page shows the user how to search and filter code samples for other google cloud products using the sample browser.\u003c/p\u003e\n"]]],[],null,["Get cluster details given the instance ID in the current project.\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 const& cluster_id) {\n std::string cluster_name =\n cbt::ClusterName(project_id, instance_id, cluster_id);\n StatusOr\u003cgoogle::bigtable::admin::v2::Cluster\u003e cluster =\n instance_admin.GetCluster(cluster_name);\n if (!cluster) throw std::move(cluster).status();\n std::cout \u003c\u003c \"GetCluster details : \" \u003c\u003c cluster-\u003eDebugString() \u003c\u003c \"\\n\";\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\\ApiCore\\ApiException;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\Client\\BigtableInstanceAdminClient;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\GetClusterRequest;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\Instance\\State;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\StorageType;\n\n /**\n * Get a Bigtable cluster\n *\n * @param string $projectId The Google Cloud project ID\n * @param string $instanceId The ID of the Bigtable instance\n * @param string $clusterId The ID of the cluster to fetch\n */\n function get_cluster(\n string $projectId,\n string $instanceId,\n string $clusterId\n ): void {\n $instanceAdminClient = new BigtableInstanceAdminClient();\n\n printf('Fetching the Cluster %s' . PHP_EOL, $clusterId);\n try {\n $clusterName = $instanceAdminClient-\u003eclusterName($projectId, $instanceId, $clusterId);\n $getClusterRequest = (new GetClusterRequest())\n -\u003esetName($clusterName);\n $cluster = $instanceAdminClient-\u003egetCluster($getClusterRequest);\n } catch (ApiException $e) {\n if ($e-\u003egetStatus() === 'NOT_FOUND') {\n printf('Cluster %s does not exists.' . PHP_EOL, $clusterId);\n return;\n }\n throw $e;\n }\n\n printf('Printing Details:' . PHP_EOL);\n\n // Fetch some commonly used metadata\n printf('Name: ' . $cluster-\u003egetName() . PHP_EOL);\n printf('Location: ' . $cluster-\u003egetLocation() . PHP_EOL);\n printf('State: ' . State::name($cluster-\u003egetState()) . PHP_EOL);\n printf('Default Storage Type: ' . StorageType::name($cluster-\u003egetDefaultStorageType()) . PHP_EOL);\n printf('Nodes: ' . $cluster-\u003egetServeNodes() . PHP_EOL);\n printf('Encryption Config: ' . ($cluster-\u003ehasEncryptionConfig() ? $cluster-\u003egetEncryptionConfig()-\u003egetKmsKeyName() : 'N/A') . PHP_EOL);\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)."]]