class Dag::Cluster
Attributes
debug[R]
name[R]
status[R]
type[R]
Public Class Methods
new(api, cluster)
click to toggle source
Calls superclass method
Dag::Model::new
# File lib/dag/client/model/cluster.rb, line 8 def initialize(api, cluster) super(api) @name = cluster['name'] @status = cluster['status'] @cluster_status = @status @type = cluster['type'] @instances = cluster['instances'] @debug = cluster['debug'] end
Public Instance Methods
export_log(params = {})
click to toggle source
# File lib/dag/client/model/cluster.rb, line 40 def export_log(params = {}) unless cluster_norm_or_ptfailed? raise Dag::Client::StatusInvalid.new("cluster status is invalid: #{cluster_status}") end default = { compress: false } @api.cluster_export_log(@name, default.merge(params)) end
instances()
click to toggle source
restart(force: false, type: nil)
click to toggle source
restart cluster
Parameters¶ ↑
-
:force
- restart forcely. false by default -
:type
- cluster type 'DAG5-Hive-Hadoop'
# File lib/dag/client/model/cluster.rb, line 26 def restart(force: false, type: nil) unless cluster_restart_status? raise Dag::Client::StatusInvalid.new("cluster status is invalid: #{cluster_status}") end params = { force: force, type: type || @type, debug: false } @api.cluster_restart(@name, params) end
statistics()
click to toggle source
return statistics information
instance detail ==¶ ↑
-
instances
-
instance_id
-
grade
-
disk
-
dfs_used
-
non_dfs_used
-
capacity
-
-
-
disk
-
capacity
-
used
-
# File lib/dag/client/model/cluster.rb, line 74 def statistics statistics_info = if valid_cluster_status? && cluster_norm_or_ptfailed? @api.statistics(@name) end if statistics_info.present? statistics_info = { "instances" => statistics_info['instances'], "disk" => statistics_info['disk'] } end return nil unless statistics_info key_to_underscore(statistics_info) end
Private Instance Methods
key_to_underscore(hash)
click to toggle source
# File lib/dag/client/model/cluster.rb, line 92 def key_to_underscore(hash) OpenStruct.new(hash.each_with_object({}) {|(k, v), new_hash| v = v.map {|s| send(__method__, s) } if v.class == Array v = send(__method__, v) if v.class == Hash new_hash[k.underscore] = v }).freeze end