Class: MMS::Resource::Cluster

Inherits:
MMS::Resource show all
Defined in:
lib/mms/resource/cluster.rb

Instance Attribute Summary collapse

Attributes inherited from MMS::Resource

#client, #data, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MMS::Resource

#_load, find, #from_hash, #invalidate_cache, #set_client, #set_data, #to_hash

Constructor Details

#initializeCluster

Returns a new instance of Cluster.



14
15
16
17
# File 'lib/mms/resource/cluster.rb', line 14

def initialize
  @snapshots = []
  @restorejobs = []
end

Instance Attribute Details

#last_heartbeatObject

Returns the value of attribute last_heartbeat.



9
10
11
# File 'lib/mms/resource/cluster.rb', line 9

def last_heartbeat
  @last_heartbeat
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/mms/resource/cluster.rb', line 5

def name
  @name
end

#replicaset_nameObject

Returns the value of attribute replicaset_name.



7
8
9
# File 'lib/mms/resource/cluster.rb', line 7

def replicaset_name
  @replicaset_name
end

#restorejobs(page = 1, limit = 1000) ⇒ Object

Returns the value of attribute restorejobs.



12
13
14
# File 'lib/mms/resource/cluster.rb', line 12

def restorejobs
  @restorejobs
end

#shard_nameObject

Returns the value of attribute shard_name.



6
7
8
# File 'lib/mms/resource/cluster.rb', line 6

def shard_name
  @shard_name
end

#snapshots(page = 1, limit = 1000) ⇒ Object

Returns the value of attribute snapshots.



11
12
13
# File 'lib/mms/resource/cluster.rb', line 11

def snapshots
  @snapshots
end

#type_nameObject

Returns the value of attribute type_name.



8
9
10
# File 'lib/mms/resource/cluster.rb', line 8

def type_name
  @type_name
end

Class Method Details

._find(client, group_id, id) ⇒ Object



96
97
98
# File 'lib/mms/resource/cluster.rb', line 96

def self._find(client, group_id, id)
  client.get('/groups/' + group_id + '/clusters/' + id)
end

.table_headerObject



92
93
94
# File 'lib/mms/resource/cluster.rb', line 92

def self.table_header
  ['Group', 'Cluster', 'Shard name', 'Replica name', 'Type', 'Last heartbeat', 'Cluster Id']
end

Instance Method Details

#create_restorejob(point_in_time = nil) ⇒ Array<MMS::Resource::RestoreJob>

Parameters:

  • point_in_time (String) (defaults to: nil)

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/mms/resource/cluster.rb', line 63

def create_restorejob(point_in_time = nil)
  data = {
    'timestamp' => {
      'date' => point_in_time,
      'increment' => 0
    }
  }
  job_data_list = @client.post('/groups/' + group.id + '/clusters/' + @id + '/restoreJobs', data)

  if job_data_list.nil?
    raise MMS::ResourceError.new("Cannot create job from snapshot `#{self.id}`", self)
  end

  job_data_list.map do |job_data|
    j = MMS::Resource::RestoreJob.new
    j.set_client(@client)
    j.set_data(job_data)
    j
  end
end

#groupObject



19
20
21
# File 'lib/mms/resource/cluster.rb', line 19

def group
  MMS::Resource::Group.find(@client, @data['groupId'])
end

#snapshot(id) ⇒ Object



23
24
25
# File 'lib/mms/resource/cluster.rb', line 23

def snapshot(id)
  MMS::Resource::Snapshot.find(@client, group.id, @id, nil, id)
end

#snapshot_scheduleObject



40
41
42
# File 'lib/mms/resource/cluster.rb', line 40

def snapshot_schedule
  MMS::Resource::SnapshotSchedule.find(@client, group.id, @id)
end

#table_rowObject



84
85
86
# File 'lib/mms/resource/cluster.rb', line 84

def table_row
  [group.name, @name, @shard_name, @replicaset_name, @type_name, @last_heartbeat, @id]
end

#table_sectionObject



88
89
90
# File 'lib/mms/resource/cluster.rb', line 88

def table_section
  [table_row]
end