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)


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

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

#creating?Boolean

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

Returns:

  • (Boolean)


121
122
123
# File 'lib/google/cloud/bigtable/cluster.rb', line 121

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.



261
262
263
264
265
# File 'lib/google/cloud/bigtable/cluster.rb', line 261

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)


144
145
146
# File 'lib/google/cloud/bigtable/cluster.rb', line 144

def disabled?
  state == :DISABLED
end

#instance_idString

The unique identifier for the instance to which the cluster belongs.

Returns:

  • (String)


72
73
74
# File 'lib/google/cloud/bigtable/cluster.rb', line 72

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

#locationString

Cluster location. For example, "us-east1-b"

Returns:

  • (String)


185
186
187
# File 'lib/google/cloud/bigtable/cluster.rb', line 185

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

#location_pathString

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

Returns:

  • (String)


195
196
197
# File 'lib/google/cloud/bigtable/cluster.rb', line 195

def location_path
  @grpc.location
end

#nodesInteger

The number of nodes allocated to this cluster.

Returns:

  • (Integer)


153
154
155
# File 'lib/google/cloud/bigtable/cluster.rb', line 153

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



163
164
165
# File 'lib/google/cloud/bigtable/cluster.rb', line 163

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)


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

def path
  @grpc.name
end

#project_idString

The unique identifier for the project to which the cluster belongs.

Returns:

  • (String)


63
64
65
# File 'lib/google/cloud/bigtable/cluster.rb', line 63

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

#ready?Boolean

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

Returns:

  • (Boolean)


111
112
113
# File 'lib/google/cloud/bigtable/cluster.rb', line 111

def ready?
  state == :READY
end

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

Reloads cluster data.



242
243
244
245
# File 'lib/google/cloud/bigtable/cluster.rb', line 242

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.

Returns:

  • (Boolean)


134
135
136
# File 'lib/google/cloud/bigtable/cluster.rb', line 134

def resizing?
  state == :RESIZING
end

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

Updates the cluster.

serve_nodes is the only updatable field.

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:



230
231
232
233
234
# File 'lib/google/cloud/bigtable/cluster.rb', line 230

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 state of the cluster. Possible values are :CREATING, :READY, :STATE_NOT_KNOWN, :RESIZING, :DISABLED.

Returns:

  • (Symbol)


102
103
104
# File 'lib/google/cloud/bigtable/cluster.rb', line 102

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)


175
176
177
# File 'lib/google/cloud/bigtable/cluster.rb', line 175

def storage_type
  @grpc.default_storage_type
end