Class: Wakame::ClusterManager

Inherits:
Object
  • Object
show all
Includes:
Manager
Defined in:
lib/wakame/master.rb

Defined Under Namespace

Classes: ClusterConfigLoader, ServiceClusterPool

Instance Attribute Summary

Attributes included from Manager

#master

Instance Method Summary collapse

Methods included from Manager

#start, #stop

Instance Method Details

#clustersObject



241
242
243
# File 'lib/wakame/master.rb', line 241

def clusters
  ServiceClusterPool.all.map{|r| r.service_cluster_id }
end

#initObject



207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/wakame/master.rb', line 207

def init
  # Periodical cluster status updater
  @status_check_timer = EM::PeriodicTimer.new(5) {
    StatusDB.pass {
      clusters.each { |cluster_id|
        Service::ServiceCluster.find(cluster_id).update_cluster_status
      }
    }
  }
  
  # Event based cluster status updater
  @check_event_tickets = []
  [Event::ServiceOnline, Event::ServiceOffline, Event::ServiceFailed].each { |evclass|
    @check_event_tickets << EventDispatcher.subscribe(evclass) { |event|
      StatusDB.pass {
        clusters.each { |cluster_id|
          Service::ServiceCluster.find(cluster_id).update_cluster_status
        }
      }
    }
  }

end

#load_config_clusterObject



254
255
256
257
258
259
# File 'lib/wakame/master.rb', line 254

def load_config_cluster
  ClusterConfigLoader.new.load.each { |name, id|
    ServiceClusterPool.register_cluster(name)
  }
  resolve_template_vm_attr
end

#register(cluster) ⇒ Object

Raises:

  • (ArgumentError)


245
246
247
248
# File 'lib/wakame/master.rb', line 245

def register(cluster)
  raise ArgumentError unless cluster.is_a?(Service::ServiceCluster)
  ServiceClusterPool.register_cluster(cluster.name)
end

#reloadObject



231
232
# File 'lib/wakame/master.rb', line 231

def reload
end

#terminateObject



234
235
236
237
238
239
# File 'lib/wakame/master.rb', line 234

def terminate
  @status_check_timer.cancel
  @check_event_tickets.each { |t|
    EventDispatcher.unsubscribe(t)
  }
end

#unregister(cluster_id) ⇒ Object



250
251
252
# File 'lib/wakame/master.rb', line 250

def unregister(cluster_id)
  @clusters.delete(cluster_id)
end