Class: Dynflow::Director::ExecutionPlanManager
- Inherits:
-
Object
- Object
- Dynflow::Director::ExecutionPlanManager
- Includes:
- Algebrick::Matching, Algebrick::TypeCheck
- Defined in:
- lib/dynflow/director/execution_plan_manager.rb
Instance Attribute Summary collapse
-
#execution_plan ⇒ Object
readonly
Returns the value of attribute execution_plan.
-
#future ⇒ Object
readonly
Returns the value of attribute future.
Instance Method Summary collapse
- #done? ⇒ Boolean
- #event(event) ⇒ Object
-
#initialize(world, execution_plan, future) ⇒ ExecutionPlanManager
constructor
A new instance of ExecutionPlanManager.
- #prepare_next_step(step) ⇒ Object
- #restart ⇒ Object
- #start ⇒ Object
- #terminate ⇒ Object
-
#what_is_next(work) ⇒ Array<WorkItem>
Of Work items to continue with.
Constructor Details
#initialize(world, execution_plan, future) ⇒ ExecutionPlanManager
Returns a new instance of ExecutionPlanManager.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 10 def initialize(world, execution_plan, future) @world = Type! world, World @execution_plan = Type! execution_plan, ExecutionPlan @future = Type! future, Concurrent::Promises::ResolvableFuture @running_steps_manager = RunningStepsManager.new(world) unless [:planned, :paused].include? execution_plan.state raise "execution_plan is not in pending or paused state, it's #{execution_plan.state}" end execution_plan.update_state(:running) end |
Instance Attribute Details
#execution_plan ⇒ Object (readonly)
Returns the value of attribute execution_plan.
8 9 10 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 8 def execution_plan @execution_plan end |
#future ⇒ Object (readonly)
Returns the value of attribute future.
8 9 10 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 8 def future @future end |
Instance Method Details
#done? ⇒ Boolean
73 74 75 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 73 def done? (!@run_manager || @run_manager.done?) && (!@finalize_manager || @finalize_manager.done?) end |
#event(event) ⇒ Object
65 66 67 68 69 70 71 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 65 def event(event) Type! event, Event unless event.execution_plan_id == @execution_plan.id raise "event #{event.inspect} doesn't belong to plan #{@execution_plan.id}" end @running_steps_manager.event(event) end |
#prepare_next_step(step) ⇒ Object
33 34 35 36 37 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 33 def prepare_next_step(step) StepWorkItem.new(execution_plan.id, step, step.queue, @world.id).tap do |work| @running_steps_manager.add(step, work) end end |
#restart ⇒ Object
27 28 29 30 31 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 27 def restart @run_manager = nil @finalize_manager = nil start end |
#start ⇒ Object
22 23 24 25 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 22 def start raise "The future was already set" if @future.resolved? start_run or start_finalize or finish end |
#terminate ⇒ Object
77 78 79 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 77 def terminate @running_steps_manager.terminate end |
#what_is_next(work) ⇒ Array<WorkItem>
Returns of Work items to continue with.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dynflow/director/execution_plan_manager.rb', line 40 def what_is_next(work) Type! work, WorkItem case work when StepWorkItem step = work.step update_steps([step]) suspended, work = @running_steps_manager.done(step) work = compute_next_from_step(step) unless suspended work when FinalizeWorkItem if work.finalize_steps_data steps = work.finalize_steps_data.map do |step_data| Serializable.from_hash(step_data, execution_plan.id, @world) end update_steps(steps) end raise "Finalize work item without @finalize_manager ready" unless @finalize_manager @finalize_manager.done! finish else raise "Unexpected work #{work}" end end |