Class: Dag::Cluster
- Includes:
- Dag::Client::ClusterValidation
- Defined in:
- lib/dag/client/model/cluster.rb
Constant Summary
Constants included from Dag::Client::ClusterValidation
Dag::Client::ClusterValidation::VALID_WHERE_KEYS
Instance Attribute Summary collapse
-
#debug ⇒ Object
readonly
Returns the value of attribute debug.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Model
Instance Method Summary collapse
- #export_log(params = {}) ⇒ Object
-
#initialize(api, cluster) ⇒ Cluster
constructor
A new instance of Cluster.
-
#instances ⇒ Object
return instance infomation.
-
#restart(force: false, type: nil) ⇒ Object
restart cluster.
-
#statistics ⇒ Object
return statistics information.
Methods included from Dag::Client::ClusterValidation
#cluster_norm?, #cluster_norm_or_ptfailed?, #cluster_restart_status?, #cluster_status, #valid_cluster_info_list_status?, #valid_cluster_status?, #validate_cluster, #validate_cluster_param_keys
Constructor Details
#initialize(api, cluster) ⇒ Cluster
Returns a new instance of Cluster.
8 9 10 11 12 13 14 15 16 17 |
# 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 |
Instance Attribute Details
#debug ⇒ Object (readonly)
Returns the value of attribute debug.
19 20 21 |
# File 'lib/dag/client/model/cluster.rb', line 19 def debug @debug end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/dag/client/model/cluster.rb', line 19 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
19 20 21 |
# File 'lib/dag/client/model/cluster.rb', line 19 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
19 20 21 |
# File 'lib/dag/client/model/cluster.rb', line 19 def type @type end |
Instance Method Details
#export_log(params = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# 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 ⇒ Object
return instance infomation
instance detail
-
grade
-
quantity
57 58 59 |
# File 'lib/dag/client/model/cluster.rb', line 57 def instances @instances.map { |instance| os = OpenStruct.new(instance); os.freeze; os } end |
#restart(force: false, type: nil) ⇒ Object
restart cluster
Parameters
-
:force
- restart forcely. false by default -
:type
- cluster type ‘DAG5-Hive-Hadoop’
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
return statistics information
instance detail ==
-
instances
-
instance_id
-
grade
-
disk
-
dfs_used
-
non_dfs_used
-
capacity
-
-
-
disk
-
capacity
-
used
-
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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 |