Class: Elasticity::JobFlowStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticity/job_flow_status.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJobFlowStatus



22
23
24
25
# File 'lib/elasticity/job_flow_status.rb', line 22

def initialize
  @steps = []
  @installed_steps = []
end

Instance Attribute Details

#created_atObject

Returns the value of attribute created_at.



9
10
11
# File 'lib/elasticity/job_flow_status.rb', line 9

def created_at
  @created_at
end

#durationObject

Returns the value of attribute duration.



13
14
15
# File 'lib/elasticity/job_flow_status.rb', line 13

def duration
  @duration
end

#ended_atObject

Returns the value of attribute ended_at.



12
13
14
# File 'lib/elasticity/job_flow_status.rb', line 12

def ended_at
  @ended_at
end

#installed_stepsObject

Returns the value of attribute installed_steps.



18
19
20
# File 'lib/elasticity/job_flow_status.rb', line 18

def installed_steps
  @installed_steps
end

#instance_countObject

Returns the value of attribute instance_count.



14
15
16
# File 'lib/elasticity/job_flow_status.rb', line 14

def instance_count
  @instance_count
end

#jobflow_idObject

Returns the value of attribute jobflow_id.



6
7
8
# File 'lib/elasticity/job_flow_status.rb', line 6

def jobflow_id
  @jobflow_id
end

#last_state_change_reasonObject

Returns the value of attribute last_state_change_reason.



17
18
19
# File 'lib/elasticity/job_flow_status.rb', line 17

def last_state_change_reason
  @last_state_change_reason
end

#master_instance_typeObject

Returns the value of attribute master_instance_type.



15
16
17
# File 'lib/elasticity/job_flow_status.rb', line 15

def master_instance_type
  @master_instance_type
end

#master_public_dns_nameObject

Returns the value of attribute master_public_dns_name.



19
20
21
# File 'lib/elasticity/job_flow_status.rb', line 19

def master_public_dns_name
  @master_public_dns_name
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/elasticity/job_flow_status.rb', line 5

def name
  @name
end

#normalized_instance_hoursObject

Returns the value of attribute normalized_instance_hours.



20
21
22
# File 'lib/elasticity/job_flow_status.rb', line 20

def normalized_instance_hours
  @normalized_instance_hours
end

#ready_atObject

Returns the value of attribute ready_at.



11
12
13
# File 'lib/elasticity/job_flow_status.rb', line 11

def ready_at
  @ready_at
end

#slave_instance_typeObject

Returns the value of attribute slave_instance_type.



16
17
18
# File 'lib/elasticity/job_flow_status.rb', line 16

def slave_instance_type
  @slave_instance_type
end

#started_atObject

Returns the value of attribute started_at.



10
11
12
# File 'lib/elasticity/job_flow_status.rb', line 10

def started_at
  @started_at
end

#stateObject

Returns the value of attribute state.



7
8
9
# File 'lib/elasticity/job_flow_status.rb', line 7

def state
  @state
end

#stepsObject

Returns the value of attribute steps.



8
9
10
# File 'lib/elasticity/job_flow_status.rb', line 8

def steps
  @steps
end

Class Method Details

.from_member_element(xml_element) ⇒ Object

Create a jobflow from an AWS <member> (Nokogiri::XML::Element):

/DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows/member


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/elasticity/job_flow_status.rb', line 29

def self.from_member_element(xml_element)
  jobflow_status = JobFlowStatus.new

  jobflow_status.name = xml_element.xpath('./Name').text.strip
  jobflow_status.jobflow_id = xml_element.xpath('./JobFlowId').text.strip
  jobflow_status.state = xml_element.xpath('./ExecutionStatusDetail/State').text.strip
  jobflow_status.last_state_change_reason = xml_element.xpath('./ExecutionStatusDetail/LastStateChangeReason').text.strip

  jobflow_status.steps = JobFlowStatusStep.from_members_nodeset(xml_element.xpath('./Steps/member'))

  step_names = jobflow_status.steps.map(&:name)
  Elasticity::JobFlowStep.steps_requiring_installation.each do |step|
    jobflow_status.installed_steps << step if step_names.include?(step.aws_installation_step_name)
  end

  jobflow_status.created_at = Time.parse(xml_element.xpath('./ExecutionStatusDetail/CreationDateTime').text.strip)

  ready_at = xml_element.xpath('./ExecutionStatusDetail/ReadyDateTime').text.strip
  jobflow_status.ready_at = (ready_at == '') ? (nil) : (Time.parse(ready_at))

  started_at = xml_element.xpath('./ExecutionStatusDetail/StartDateTime').text.strip
  jobflow_status.started_at = (started_at == '') ? (nil) : (Time.parse(started_at))

  ended_at = xml_element.xpath('./ExecutionStatusDetail/EndDateTime').text.strip
  jobflow_status.ended_at = (ended_at == '') ? (nil) : (Time.parse(ended_at))

  if jobflow_status.ended_at && jobflow_status.started_at
    jobflow_status.duration = ((jobflow_status.ended_at - jobflow_status.started_at) / 60).to_i
  end

  jobflow_status.instance_count = xml_element.xpath('./Instances/InstanceCount').text.strip
  jobflow_status.master_instance_type = xml_element.xpath('./Instances/MasterInstanceType').text.strip
  jobflow_status.slave_instance_type = xml_element.xpath('./Instances/SlaveInstanceType').text.strip

  master_public_dns_name = xml_element.xpath('./Instances/MasterPublicDnsName').text.strip
  jobflow_status.master_public_dns_name = (master_public_dns_name == '') ? (nil) : (master_public_dns_name)

  jobflow_status.normalized_instance_hours = xml_element.xpath('./Instances/NormalizedInstanceHours').text.strip

  jobflow_status
end

.from_members_nodeset(members_nodeset) ⇒ Object

Create JobFlows from a collection of AWS <member> nodes (Nokogiri::XML::NodeSet):

/DescribeJobFlowsResponse/DescribeJobFlowsResult/JobFlows


73
74
75
76
77
78
79
# File 'lib/elasticity/job_flow_status.rb', line 73

def self.from_members_nodeset(members_nodeset)
  jobflow_statuses = []
  members_nodeset.each do |member|
    jobflow_statuses << from_member_element(member)
  end
  jobflow_statuses
end