Class: Google::Cloud::Bigtable::Cluster

Inherits:
Object
  • Object
show all
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.

Examples:

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance("my-instance")
cluster = instance.cluster("my-cluster")

# Update
cluster.nodes = 3
cluster.save

# Delete
cluster.delete

Defined Under Namespace

Classes: Job, List

Instance Method Summary collapse

Instance Method Details

#cluster_idString

The unique identifier for the cluster.

Returns:

  • (String)


74
75
76
# File 'lib/google/cloud/bigtable/cluster.rb', line 74

def cluster_id
  @grpc.name.split("/")[5]
end

#creating?Boolean

The instance is currently being created, and may be destroyed if the creation process encounters an error.

Returns:

  • (Boolean)


106
107
108
# File 'lib/google/cloud/bigtable/cluster.rb', line 106

def creating?
  state == :CREATING
end

#deleteBoolean

Permanently deletes the cluster

Examples:

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance("my-instance")
cluster = instance.cluster("my-cluster")
cluster.delete

Returns:

  • (Boolean)

    Returns true if the cluster was deleted.



234
235
236
237
238
# File 'lib/google/cloud/bigtable/cluster.rb', line 234

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.

Returns:

  • (Boolean)


125
126
127
# File 'lib/google/cloud/bigtable/cluster.rb', line 125

def disabled?
  state == :DISABLED
end

#instance_idString

The unique identifier for the instance.

Returns:

  • (String)


67
68
69
# File 'lib/google/cloud/bigtable/cluster.rb', line 67

def instance_id
  @grpc.name.split("/")[3]
end

#locationString

Cluster location. i.e "us-east-1b"

Returns:

  • (String)


158
159
160
# File 'lib/google/cloud/bigtable/cluster.rb', line 158

def location
  @grpc.location.split("/")[3]
end

#location_pathString

Cluster location path in form of projects/<project_id>/locations/<zone>

Returns:

  • (String)


166
167
168
# File 'lib/google/cloud/bigtable/cluster.rb', line 166

def location_path
  @grpc.location
end

#nodesInteger

The number of nodes allocated to this cluster.

Returns:

  • (Integer)


132
133
134
# File 'lib/google/cloud/bigtable/cluster.rb', line 132

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.

Parameters:

  • serve_nodes (Integer)

    Number of nodes



140
141
142
# File 'lib/google/cloud/bigtable/cluster.rb', line 140

def nodes= serve_nodes
  @grpc.serve_nodes = serve_nodes
end

#pathString

The unique name of the cluster. Value in the form projects/<project_id>/instances/<instance_id>/clusters/<cluster_id>.

Returns:

  • (String)


82
83
84
# File 'lib/google/cloud/bigtable/cluster.rb', line 82

def path
  @grpc.name
end

#project_idString

The unique identifier for the project.

Returns:

  • (String)


60
61
62
# File 'lib/google/cloud/bigtable/cluster.rb', line 60

def project_id
  @grpc.name.split("/")[1]
end

#ready?Boolean

The cluster has been successfully created and is ready to serve requests.

Returns:

  • (Boolean)


98
99
100
# File 'lib/google/cloud/bigtable/cluster.rb', line 98

def ready?
  state == :READY
end

#reload!Google::Cloud::Bigtable::Cluster

Reload cluster information.



216
217
218
219
# File 'lib/google/cloud/bigtable/cluster.rb', line 216

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 exhibit performance as if its number of allocated nodes is between the starting and requested states.

Returns:

  • (Boolean)


117
118
119
# File 'lib/google/cloud/bigtable/cluster.rb', line 117

def resizing?
  state == :RESIZING
end

#saveGoogle::Cloud::Bigtable::Cluster::Job Also known as: update

Update cluster.

Updatable fields are no of nodes.

Examples:

require "google/cloud/bigtable"

bigtable = Google::Cloud::Bigtable.new

instance = bigtable.instance("my-instance")
cluster = instance.cluster("my-cluster")
cluster.nodes = 3
job = cluster.save

job.done? #=> false

# To block until the operation completes.
job.wait_until_done!
job.done? #=> true

if job.error?
  status = job.error
else
  cluster = job.cluster
end

Returns:



200
201
202
203
204
205
206
207
208
209
# File 'lib/google/cloud/bigtable/cluster.rb', line 200

def save
  ensure_service!
  grpc = service.update_cluster(
    instance_id,
    cluster_id,
    location_path,
    nodes
  )
  Cluster::Job.from_grpc(grpc, service)
end

#stateSymbol

The current instance state. Possible values are :CREATING, :READY, :STATE_NOT_KNOWN, :RESIZING, :DISABLED.

Returns:

  • (Symbol)


91
92
93
# File 'lib/google/cloud/bigtable/cluster.rb', line 91

def state
  @grpc.state
end

#storage_typeSymbol

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)

Returns:

  • (Symbol)


150
151
152
# File 'lib/google/cloud/bigtable/cluster.rb', line 150

def storage_type
  @grpc.default_storage_type
end