Class: Pione::Agent::JobManager
- Inherits:
-
TupleSpaceClient
- Object
- PioneObject
- BasicAgent
- TupleSpaceClient
- Pione::Agent::JobManager
- Includes:
- Log::MessageLog
- Defined in:
- lib/pione/agent/job-manager.rb
Constant Summary
Constants included from Log::MessageLog
Log::MessageLog::MESSAGE_QUEUE
Instance Attribute Summary collapse
-
#package ⇒ Object
readonly
instance method.
Attributes inherited from BasicAgent
Instance Method Summary collapse
-
#initialize(tuple_space, env, package, param_set, stream) ⇒ JobManager
constructor
A new instance of JobManager.
-
#transit_to_init ⇒ Object
transitions.
- #transit_to_run ⇒ Object
- #transit_to_sleep ⇒ Object
Methods included from Log::MessageLog
#debug_message, #debug_message_begin, #debug_message_end, debug_mode, debug_mode=, debug_mode?, message, quiet_mode, quiet_mode=, quiet_mode?, #show, #user_message, #user_message_begin, #user_message_end
Methods inherited from TupleSpaceClient
#bye, #call_transition_method, #hello, #transit_to_terminate
Methods included from TupleSpaceClientOperation
#base_location, #bye, #finalize, #hello, #notify_exception, #read, #take
Methods included from TupleSpace::TupleSpaceInterface
#process_log, #processing_error, #set_tuple_space, tuple_space_operation, #tuple_space_server, #with_process_log
Methods inherited from BasicAgent
agent_type, inherited, set_agent_type, #start, #start!, #states, #terminate, #terminated?, #transit, #wait_until, #wait_until_after, #wait_until_before, #wait_until_terminated
Methods included from StateTransitionSingletonMethod
#chain, #define_exception_handler, #define_transition, #exception_handler, #start, #transition_chain
Constructor Details
#initialize(tuple_space, env, package, param_set, stream) ⇒ JobManager
Returns a new instance of JobManager.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/pione/agent/job-manager.rb', line 13 def initialize(tuple_space, env, package, param_set, stream) unless env.entrance_rule name = env.entrance_rule_name raise JobError.new("Entrance rule `%s` not found in the package." % name) end super(tuple_space) @tuple_space = tuple_space @env = env @package = package @param_set = param_set @stream = stream @package_id = @env.current_package_id end |
Instance Attribute Details
#package ⇒ Object (readonly)
instance method
11 12 13 |
# File 'lib/pione/agent/job-manager.rb', line 11 def package @package end |
Instance Method Details
#transit_to_init ⇒ Object
transitions
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/pione/agent/job-manager.rb', line 43 def transit_to_init # split parameter set as package toplvel's and main's toplevel_variable_names = @env.variable_table.select_names_by(@env, @env.current_package_id) toplevel_param_set = @param_set.filter(toplevel_variable_names) main_param_set = @param_set.delete_all(toplevel_variable_names) # merge the toplevel parameter set @env.merge_param_set(toplevel_param_set, force: true) # setup root rule root_definition = @env.make_root_rule(main_param_set) @rule_condition = root_definition.rule_condition_context.eval(@env) # share my environment write(TupleSpace::EnvTuple.new(@env.dumpable)) # need to be dumpable # collect tuple space attributes @request_from = @tuple_space.attribute("request_from") @session_id = @tuple_space.attribute("session_id") @client_ui = @tuple_space.attribute("client_ui") end |
#transit_to_run ⇒ Object
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 |
# File 'lib/pione/agent/job-manager.rb', line 69 def transit_to_run finder = RuleEngine::DataFinder.new(@tuple_space, 'root') list = finder.to_enum(:find, :input, @rule_condition.inputs, @env).to_a if list.empty? "error: no inputs" terminate else # call root rule of the current package list.each do |env, inputs| engine_param = { :tuple_space => @tuple_space, :env => @env, :package_id => @env.current_package_id, :rule_name => "Root", :inputs => inputs, :param_set => Lang::ParameterSet.new, :domain_id => 'root', :caller_id => nil, :request_from => @request_from, :session_id => @session_id, :client_ui => @client_ui } RuleEngine.make(engine_param).handle || terminate end end # terminate if the agent is not stream mode terminate unless @stream return end |
#transit_to_sleep ⇒ Object
65 66 67 |
# File 'lib/pione/agent/job-manager.rb', line 65 def transit_to_sleep take(TupleSpace::CommandTuple.new("start-root-rule", nil)) end |