Sha256: c3715c706eab54e4c97bbe3ac0075a0fe68da7ac6587b12361c87a6de4b04547

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

module Elasticity

  class ClusterStatus

    attr_accessor :name
    attr_accessor :cluster_id
    attr_accessor :state
    attr_accessor :created_at
    attr_accessor :ready_at
    attr_accessor :ended_at
    attr_accessor :last_state_change_reason
    attr_accessor :master_public_dns_name
    attr_accessor :normalized_instance_hours

    # ClusterStatus is created via the results of the DescribeCluster API call
    def self.from_aws_data(cluster_data)
      cluster_data = cluster_data['Cluster']
      ClusterStatus.new.tap do |c|
        c.name = cluster_data['Name']
        c.cluster_id = cluster_data['Id']
        c.state = cluster_data['Status']['State']
        c.created_at = Time.at(cluster_data['Status']['Timeline']['CreationDateTime'])
        c.ready_at = Time.at(cluster_data['Status']['Timeline']['ReadyDateTime'])
        c.ended_at = Time.at(cluster_data['Status']['Timeline']['EndDateTime'])
        c.last_state_change_reason = cluster_data['Status']['StateChangeReason']['Code']
        c.master_public_dns_name = cluster_data['MasterPublicDnsName']
        c.normalized_instance_hours = cluster_data['NormalizedInstanceHours']
      end
    end

    # http://docs.aws.amazon.com/ElasticMapReduce/latest/DeveloperGuide/ProcessingCycle.html
    def active?
      %w{RUNNING STARTING BOOTSTRAPPING WAITING SHUTTING_DOWN}.include?(@state)
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elasticity-6.0.1 lib/elasticity/cluster_status.rb
elasticity-6.0 lib/elasticity/cluster_status.rb