Class: Fog::Parsers::AWS::EMR::DescribeJobFlows

Inherits:
Base
  • Object
show all
Defined in:
lib/fog/aws/parsers/emr/describe_job_flows.rb

Instance Method Summary collapse

Instance Method Details

#end_element(name) ⇒ Object



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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/fog/aws/parsers/emr/describe_job_flows.rb', line 34

def end_element(name)
  if @context.last == 'BootstrapActions'
    case name
    when 'Name'
      @bootstrap_actions[name] = value
    when 'Path'
      @bootstrap_actions['ScriptBootstrapActionConfig'][name] = value
    when 'BootstrapActions'
      @flow['BootstrapActions'] = @bootstrap_actions
      @bootstrap_actions = {'ScriptBootstrapActionConfig' => {'Args' => []}}
    end
  end

  if @context.last == 'ExecutionStatusDetail'
    case name
    when 'CreationDateTime', 'EndDateTime', 'LastStateChangeReason',
        'ReadyDateTime', 'StartDateTime', 'State'
      @execution_status_detail[name] = value
    when 'ExecutionStatusDetail'
      if @context.include?('Steps')
        @step['ExecutionStatusDetail'] = @execution_status_detail
      else
        @flow['ExecutionStatusDetail'] = @execution_status_detail
      end
      @execution_status_detail = {}
    end
  end

  if @context.last == 'Instances'
    case name
    when 'AvailabilityZone'
      @instance['Placement'][name] = value
    when 'Ec2KeyName', 'HadoopVersion', 'InstanceCount', 'KeepJobFlowAliveWhenNoSteps',
          'MasterInstanceId', 'MasterInstanceType', 'MasterPublicDnsName', 'NormalizedInstanceHours',
          'SlaveInstanceType', 'TerminationProtected'
      @instance[name] = value
    when 'member'
      @instance['InstanceGroups'] << @instance_group_detail
      @instance_group_detail = {}
    when 'Instances'
      @flow['Instances'] = @instance
      @instance = { 'InstanceGroups' => [], 'Placement' => {}}
    end
  end

  if @context.last == 'InstanceGroups'
    case name
    when 'member'
      @instance['InstanceGroups'] << @instance_group_detail
      @instance_group_detail = {}
    else
      @instance_group_detail[name] = value
    end
  end

  if @context.last == 'Args'
    if name == 'member'
      if @context.include?('Steps')
        @step['StepConfig']['HadoopJarStepConfig']['Args'] << value.strip
      else
        @bootstrap_actions['ScriptBootstrapActionConfig']['Args'] << value
      end
    end
  end

  if @context.last == 'Steps'
    case name
    when 'ActionOnFailure', 'Name'
      @step[name] = value
    when 'Jar', 'MainClass'
      @step['StepConfig']['HadoopJarStepConfig'][name] = value
    when 'member'
      @flow['Steps'] << @step
      @step = {
        'ExecutionStatusDetail' => {},
        'StepConfig' => {
          'HadoopJarStepConfig' =>  {
            'Args' => [],
            'Properties' => []
          }
        }
      }
    end
  end

  if @context.empty?
    case name
    when 'AmiVersion', 'JobFlowId', 'LogUri', 'Name'
      @flow[name] = value
    when 'member'
      @response['JobFlows'] << @flow
      @flow = {'Instances' => [], 'ExecutionStatusDetail' => {}, 'BootstrapActions' => [], 'Steps' => []}
    end
  end

  if @context.last == name
    @context.pop
  end
end

#resetObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/aws/parsers/emr/describe_job_flows.rb', line 6

def reset
  @context = []
  @contexts = ['BootstrapActions', 'ExecutionStatusDetail', 'Instances', 'Steps', 'InstanceGroups', 'Args']

  @response = { 'JobFlows' => [] }
  @bootstrap_actions = {'ScriptBootstrapActionConfig' => {'Args' => []}}
  @instance = { 'InstanceGroups' => [], 'Placement' => {}}
  @step = {
    'ExecutionStatusDetail' => {},
    'StepConfig' => {
      'HadoopJarStepConfig' =>  {
        'Args' => [],
        'Properties' => []
      }
    }
  }
  @flow = {'Instances' => [], 'ExecutionStatusDetail' => {}, 'BootstrapActions' => [], 'Steps' => []}
  @instance_group_detail = {}
  @execution_status_detail = {}
end

#start_element(name, attrs = []) ⇒ Object



27
28
29
30
31
32
# File 'lib/fog/aws/parsers/emr/describe_job_flows.rb', line 27

def start_element(name, attrs = [])
  super
  if @contexts.include?(name)
    @context.push(name)
  end
end