Class: Google::Cloud::Bigtable::Cluster
- Inherits:
-
Object
- Object
- Google::Cloud::Bigtable::Cluster
- Defined in:
- lib/google/cloud/bigtable/cluster.rb,
lib/google/cloud/bigtable/cluster/job.rb,
lib/google/cloud/bigtable/cluster/list.rb
Overview
Cluster
A configuration object describing how Cloud Bigtable should treat traffic from a particular end user application.
Defined Under Namespace
Instance Method Summary collapse
-
#backup(backup_id) ⇒ Google::Cloud::Bigtable::Backup?
Gets a backup in the cluster.
-
#backups ⇒ Array<Google::Cloud::Bigtable::Backup>
Lists all backups in the cluster.
-
#cluster_id ⇒ String
The unique identifier for the cluster.
-
#create_backup(source_table, backup_id, expire_time) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a new Cloud Bigtable Backup.
-
#creating? ⇒ Boolean
The cluster is currently being created, and may be destroyed if the creation process encounters an error.
-
#delete ⇒ Boolean
Permanently deletes the cluster.
-
#disabled? ⇒ Boolean
The cluster has no backing nodes.
-
#instance_id ⇒ String
The unique identifier for the instance to which the cluster belongs.
-
#kms_key ⇒ String?
The full name of the Cloud KMS encryption key for the cluster, if it is CMEK-protected, in the format
projects/{key_project_id}/locations/{location}/keyRings/{ring_name}/cryptoKeys/{key_name}
. -
#location ⇒ String
Cluster location.
-
#location_path ⇒ String
Cluster location path in form of
projects/<project_id>/locations/<zone>
. -
#nodes ⇒ Integer
The number of nodes allocated to this cluster.
-
#nodes=(serve_nodes) ⇒ Object
The number of nodes allocated to this cluster.
-
#path ⇒ String
The unique name of the cluster.
-
#project_id ⇒ String
The unique identifier for the project to which the cluster belongs.
-
#ready? ⇒ Boolean
The cluster has been successfully created and is ready to serve requests.
-
#reload! ⇒ Google::Cloud::Bigtable::Cluster
Reloads cluster data.
-
#resizing? ⇒ Boolean
The cluster is currently being resized, and may revert to its previous node count if the process encounters an error.
-
#save ⇒ Google::Cloud::Bigtable::Cluster::Job
(also: #update)
Updates the cluster.
-
#state ⇒ Symbol
The current state of the cluster.
-
#storage_type ⇒ Symbol
The type of storage used by this cluster to serve its parent instance's tables, unless explicitly overridden.
Instance Method Details
#backup(backup_id) ⇒ Google::Cloud::Bigtable::Backup?
Gets a backup in the cluster.
289 290 291 292 293 294 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 289 def backup backup_id grpc = service.get_backup instance_id, cluster_id, backup_id Backup.from_grpc grpc, service rescue Google::Cloud::NotFoundError nil end |
#backups ⇒ Array<Google::Cloud::Bigtable::Backup>
Lists all backups in the cluster.
313 314 315 316 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 313 def backups grpc = service.list_backups instance_id, cluster_id Backup::List.from_grpc grpc, service end |
#cluster_id ⇒ String
The unique identifier for the cluster.
82 83 84 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 82 def cluster_id @grpc.name.split("/")[5] end |
#create_backup(source_table, backup_id, expire_time) ⇒ Google::Cloud::Bigtable::Backup::Job
Creates a new Cloud Bigtable Backup.
258 259 260 261 262 263 264 265 266 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 258 def create_backup source_table, backup_id, expire_time source_table_id = source_table.respond_to?(:name) ? source_table.name : source_table grpc = service.create_backup instance_id: instance_id, cluster_id: cluster_id, backup_id: backup_id, source_table_id: source_table_id, expire_time: expire_time Backup::Job.from_grpc grpc, service end |
#creating? ⇒ Boolean
The cluster is currently being created, and may be destroyed if the creation process encounters an error.
122 123 124 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 122 def creating? state == :CREATING end |
#delete ⇒ Boolean
Permanently deletes the cluster.
380 381 382 383 384 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 380 def delete ensure_service! service.delete_cluster instance_id, cluster_id true end |
#disabled? ⇒ Boolean
The cluster has no backing nodes. The data (tables) still exist, but no operations can be performed on the cluster.
145 146 147 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 145 def disabled? state == :DISABLED end |
#instance_id ⇒ String
The unique identifier for the instance to which the cluster belongs.
73 74 75 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 73 def instance_id @grpc.name.split("/")[3] end |
#kms_key ⇒ String?
The full name of the Cloud KMS encryption key for the cluster, if it is CMEK-protected, in the format
projects/{key_project_id}/locations/{location}/keyRings/{ring_name}/cryptoKeys/{key_name}
.
The requirements for this key are:
- The Cloud Bigtable service account associated with the project that contains this cluster must be granted
the
cloudkms.cryptoKeyEncrypterDecrypter
role on the CMEK key. - Only regional keys can be used and the region of the CMEK key must match the region of the cluster.
- All clusters within an instance must use the same CMEK key.
216 217 218 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 216 def kms_key @grpc.encryption_config&.kms_key_name end |
#location ⇒ String
Cluster location. For example, "us-east1-b"
188 189 190 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 188 def location @grpc.location.split("/")[3] end |
#location_path ⇒ String
Cluster location path in form of
projects/<project_id>/locations/<zone>
198 199 200 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 198 def location_path @grpc.location end |
#nodes ⇒ Integer
The number of nodes allocated to this cluster.
154 155 156 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 154 def nodes @grpc.serve_nodes end |
#nodes=(serve_nodes) ⇒ Object
The number of nodes allocated to this cluster. More nodes enable higher throughput and more consistent performance.
164 165 166 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 164 def nodes= serve_nodes @grpc.serve_nodes = serve_nodes end |
#path ⇒ String
The unique name of the cluster. Value in the form
projects/<project_id>/instances/<instance_id>/clusters/<cluster_id>
.
92 93 94 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 92 def path @grpc.name end |
#project_id ⇒ String
The unique identifier for the project to which the cluster belongs.
64 65 66 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 64 def project_id @grpc.name.split("/")[1] end |
#ready? ⇒ Boolean
The cluster has been successfully created and is ready to serve requests.
112 113 114 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 112 def ready? state == :READY end |
#reload! ⇒ Google::Cloud::Bigtable::Cluster
Reloads cluster data.
361 362 363 364 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 361 def reload! @grpc = service.get_cluster instance_id, cluster_id self end |
#resizing? ⇒ Boolean
The cluster is currently being resized, and may revert to its previous node count if the process encounters an error. A cluster is still capable of serving requests while being resized, but may perform as if its number of allocated nodes is between the starting and requested states.
135 136 137 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 135 def resizing? state == :RESIZING end |
#save ⇒ Google::Cloud::Bigtable::Cluster::Job Also known as: update
Updates the cluster.
serve_nodes
is the only updatable field.
349 350 351 352 353 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 349 def save ensure_service! grpc = service.update_cluster instance_id, cluster_id, location_path, nodes Cluster::Job.from_grpc grpc, service end |
#state ⇒ Symbol
The current state of the cluster.
Possible values are
:CREATING
, :READY
, :STATE_NOT_KNOWN
, :RESIZING
, :DISABLED
.
103 104 105 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 103 def state @grpc.state end |
#storage_type ⇒ Symbol
The type of storage used by this cluster to serve its parent instance's tables, unless explicitly overridden. Valid values are:
:SSD
- Flash (SSD) storage should be used.:HDD
- Magnetic drive (HDD) storage should be used.
178 179 180 |
# File 'lib/google/cloud/bigtable/cluster.rb', line 178 def storage_type @grpc.default_storage_type end |