lib/elasticity/job_flow.rb in elasticity-2.4 vs lib/elasticity/job_flow.rb in elasticity-2.5
- old
+ new
@@ -19,11 +19,11 @@
attr_accessor :ec2_subnet_id
attr_accessor :placement
attr_reader :access_key
attr_reader :secret_key
-
+
def initialize(access=nil, secret=nil)
@action_on_failure = 'TERMINATE_JOB_FLOW'
@hadoop_version = '1.0.3'
@name = 'Elasticity Job Flow'
@ami_version = 'latest'
@@ -71,11 +71,13 @@
@instance_groups[:core].type = type
@slave_instance_type = type
end
def add_bootstrap_action(bootstrap_action)
- raise_if is_jobflow_running?, JobFlowRunningError, 'To modify bootstrap actions, please create a new job flow.'
+ if is_jobflow_running?
+ raise JobFlowRunningError, 'To modify bootstrap actions, please create a new job flow.'
+ end
@bootstrap_actions << bootstrap_action
end
def set_master_instance_group(instance_group)
instance_group.role = 'MASTER'
@@ -104,21 +106,29 @@
@jobflow_steps << jobflow_step
end
end
def run
- raise_if @jobflow_steps.empty?, JobFlowMissingStepsError, 'Cannot run a job flow without adding steps. Please use #add_step.'
- raise_if is_jobflow_running?, JobFlowRunningError, 'Cannot run a job flow multiple times. To do more with this job flow, please use #add_step.'
+ if @jobflow_steps.empty?
+ raise JobFlowMissingStepsError, 'Cannot run a job flow without adding steps. Please use #add_step.'
+ end
+ if is_jobflow_running?
+ raise JobFlowRunningError, 'Cannot run a job flow multiple times. To do more with this job flow, please use #add_step.'
+ end
@jobflow_id = emr.run_job_flow(jobflow_config)
end
def shutdown
- raise_unless is_jobflow_running?, JobFlowNotStartedError, 'Cannot #shutdown a job flow that has not yet been #run.'
+ if !is_jobflow_running?
+ raise JobFlowNotStartedError, 'Cannot #shutdown a job flow that has not yet been #run.'
+ end
emr.terminate_jobflows(@jobflow_id)
end
def status
- raise_unless is_jobflow_running?, JobFlowNotStartedError, 'Please #run this job flow before attempting to retrieve status.'
+ if !is_jobflow_running?
+ raise JobFlowNotStartedError, 'Please #run this job flow before attempting to retrieve status.'
+ end
emr.describe_jobflow(@jobflow_id)
end
private
\ No newline at end of file