Sha256: 754f1ea7eefde4f7d66511e640d1c8a91b0270b631dcc964084d3733d9c23be5

Contents?: true

Size: 1.97 KB

Versions: 2

Compression:

Stored size: 1.97 KB

Contents

module Elasticity

  class JobFlow

    attr_accessor :name
    attr_accessor :jobflow_id
    attr_accessor :state
    attr_accessor :steps
    attr_accessor :created_at
    attr_accessor :started_at
    attr_accessor :ready_at
    attr_accessor :instance_count
    attr_accessor :master_instance_type
    attr_accessor :slave_instance_type

    def initialize
      @steps = []
    end

    # Create a jobflow from an AWS <member> (Nokogiri::XML::Element):
    #   /DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows/member
    def self.from_member_element(xml_element)
      jobflow = JobFlow.new
      jobflow.name = xml_element.xpath("./Name").text.strip
      jobflow.jobflow_id = xml_element.xpath("./JobFlowId").text.strip
      jobflow.state = xml_element.xpath("./ExecutionStatusDetail/State").text.strip
      jobflow.steps = JobFlowStep.from_members_nodeset(xml_element.xpath("./Steps/member"))
      jobflow.created_at = Time.parse(xml_element.xpath("./ExecutionStatusDetail/CreationDateTime").text.strip)
      started_at = xml_element.xpath("./ExecutionStatusDetail/StartDateTime").text.strip
      jobflow.started_at = (started_at == "") ? (nil) : (Time.parse(started_at))
      ready_at = xml_element.xpath("./ExecutionStatusDetail/ReadyDateTime").text.strip
      jobflow.ready_at = (ready_at == "") ? (nil) : (Time.parse(ready_at))
      jobflow.instance_count = xml_element.xpath("./Instances/InstanceCount").text.strip
      jobflow.master_instance_type = xml_element.xpath("./Instances/MasterInstanceType").text.strip
      jobflow.slave_instance_type = xml_element.xpath("./Instances/SlaveInstanceType").text.strip
      jobflow
    end

    # Create JobFlows from a collection of AWS <member> nodes (Nokogiri::XML::NodeSet):
    #   /DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows
    def self.from_members_nodeset(members_nodeset)
      jobflows = []
      members_nodeset.each do |member|
        jobflows << from_member_element(member)
      end
      jobflows
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
elasticity-1.3 lib/elasticity/job_flow.rb
elasticity-1.2.3 lib/elasticity/job_flow.rb