Clusterdetails abrufen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Rufen Sie Clusterdetails für die Instanz-ID im aktuellen Projekt ab.
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","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)."]]