pione 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +9 -0
- data/Rakefile +13 -0
- data/bin/pione +5 -0
- data/bin/pione-compiler +5 -0
- data/example/ScoreAggregation/ScoreAggregation.pione +2 -0
- data/example/ScoreAggregation/bin/apply-template.rb +1 -1
- data/example/ScoreAggregation/bin/mean-summary.rb +1 -1
- data/example/ScoreAggregation/bin/total-mean.rb +1 -1
- data/example/ScoreAggregation/bin/total-statistics.rb +3 -3
- data/example/ScoreAggregation/pione-package.json +21 -0
- data/example/ScoreAggregation/scenario/case1/Scenario.pione +1 -0
- data/example/ScoreAggregation/scenario/case1/pione-scenario.json +36 -0
- data/lib/pione.rb +15 -2
- data/lib/pione/agent/basic-agent.rb +0 -1
- data/lib/pione/agent/job-terminator.rb +8 -3
- data/lib/pione/agent/task-worker.rb +9 -2
- data/lib/pione/command.rb +2 -0
- data/lib/pione/command/basic-command.rb +4 -0
- data/lib/pione/command/option.rb +4 -1
- data/lib/pione/command/pione-clean.rb +104 -17
- data/lib/pione/command/pione-client.rb +16 -3
- data/lib/pione/command/pione-command.rb +45 -0
- data/lib/pione/command/pione-compiler.rb +39 -0
- data/lib/pione/command/pione-log.rb +1 -0
- data/lib/pione/command/pione-task-worker.rb +6 -2
- data/lib/pione/command/pione-val.rb +1 -0
- data/lib/pione/front.rb +1 -0
- data/lib/pione/front/basic-front.rb +1 -1
- data/lib/pione/front/front-exception.rb +5 -1
- data/lib/pione/global.rb +3 -118
- data/lib/pione/global/broker-variable.rb +21 -8
- data/lib/pione/global/client-variable.rb +16 -8
- data/lib/pione/{system → global}/config.rb +2 -2
- data/lib/pione/global/global-exception.rb +40 -0
- data/lib/pione/global/input-generator-variable.rb +4 -1
- data/lib/pione/global/item.rb +168 -0
- data/lib/pione/global/log-variable.rb +64 -13
- data/lib/pione/global/network-variable.rb +4 -1
- data/lib/pione/global/package-variable.rb +25 -10
- data/lib/pione/global/path-variable.rb +62 -26
- data/lib/pione/global/relay-variable.rb +101 -36
- data/lib/pione/global/system-variable.rb +26 -9
- data/lib/pione/global/task-worker-variable.rb +19 -7
- data/lib/pione/global/tuple-space-notifier-variable.rb +60 -20
- data/lib/pione/lang.rb +0 -2
- data/lib/pione/lang/data-expr.rb +8 -0
- data/lib/pione/package/package-exception.rb +1 -1
- data/lib/pione/rule-engine/action-handler.rb +14 -12
- data/lib/pione/rule-engine/engine-exception.rb +11 -0
- data/lib/pione/rule-engine/flow-handler.rb +20 -11
- data/lib/pione/system.rb +1 -1
- data/lib/pione/system/file-cache.rb +1 -1
- data/lib/pione/system/init.rb +13 -15
- data/lib/pione/system/status.rb +30 -0
- data/lib/pione/system/system-exception.rb +0 -24
- data/lib/pione/test-helper.rb +8 -1
- data/lib/pione/test-helper/command-helper.rb +42 -15
- data/lib/pione/util.rb +1 -0
- data/lib/pione/util/embeded-expr-expander.rb +5 -11
- data/lib/pione/util/pnml-compiler.rb +97 -0
- data/lib/pione/util/profiler.rb +107 -0
- data/lib/pione/version.rb +1 -1
- data/man/pione-clean.1 +76 -0
- data/pione.gemspec +5 -2
- data/test/agent/spec_job-terminator.rb +41 -3
- data/test/command/data/pione-client/ActionError.pione +5 -0
- data/test/command/data/pione-compiler/Sequence.pnml +137 -0
- data/test/command/spec_pione-clean.rb +250 -5
- data/test/command/spec_pione-client.rb +57 -46
- data/test/command/spec_pione-command.rb +18 -0
- data/test/command/spec_pione-compiler.rb +13 -0
- data/test/global/spec_item.rb +77 -0
- data/test/lang/data/data-expr.yml +5 -0
- data/test/rule-engine/{spec_action-handler.pione → data/action-handler/BasicAction.pione} +0 -0
- data/test/rule-engine/data/action-handler/UsePackageScript.pione +17 -0
- data/test/rule-engine/spec_action-handler.rb +143 -80
- data/test/system/spec_status.rb +13 -0
- data/test/{tuple → tuple-space}/spec_basic-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_data-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_finished-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_message-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_task-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_touch-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/spec_working-tuple.rb +0 -0
- data/test/{tuple → tuple-space}/tuple-behavior.rb +0 -0
- data/test/util/data/pnml/Sequence.pnml +137 -0
- data/test/util/spec_pnml-compiler.rb +21 -0
- data/test/util/spec_profiler.rb +53 -0
- metadata +75 -32
- data/example/ScoreAggregation/package.yml +0 -5
- data/example/ScoreAggregation/scenario/case1/scenario.yml +0 -29
- data/lib/pione/lang/interpolator-parser.rb +0 -44
- data/lib/pione/lang/interpolator-transformer.rb +0 -13
- data/test/lang/spec_interpolator-parser.rb +0 -5
- data/test/lang/spec_interpolator-transformer.rb +0 -15
@@ -309,8 +309,12 @@ module Pione
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def execute_job_terminator
|
312
|
-
@job_terminator = Agent::JobTerminator.start(@tuple_space) do
|
313
|
-
|
312
|
+
@job_terminator = Agent::JobTerminator.start(@tuple_space) do |status|
|
313
|
+
if status.error?
|
314
|
+
abort("pione-client catched the error: %s" % status.exception.message)
|
315
|
+
else
|
316
|
+
terminate
|
317
|
+
end
|
314
318
|
end
|
315
319
|
end
|
316
320
|
|
@@ -402,6 +406,7 @@ module Pione
|
|
402
406
|
terminate :process_job => :spawner_thread
|
403
407
|
terminate :child_process, :module => CommonCommandAction
|
404
408
|
terminate :process_job => :process_manager
|
409
|
+
terminate :process_job => :job_terminator
|
405
410
|
terminate :process_job => :task_worker
|
406
411
|
terminate :process_job => :input_generator
|
407
412
|
terminate :process_job => :logger
|
@@ -415,11 +420,19 @@ module Pione
|
|
415
420
|
@spawner_threads.list.each {|thread| thread.kill}
|
416
421
|
end
|
417
422
|
|
418
|
-
# Terminate process manager
|
423
|
+
# Terminate process manager. Be careful that pione-client main thread
|
424
|
+
# waits to stop the process manager's chain thread, so agents pione-client
|
425
|
+
# has cannot terminate maybe. You need to terminate it after process
|
426
|
+
# manager terminated.
|
419
427
|
def terminate_process_manager
|
420
428
|
@process_manager.terminate if @process_manager
|
421
429
|
end
|
422
430
|
|
431
|
+
# Terminate job terminator.
|
432
|
+
def terminate_job_terminator
|
433
|
+
@job_terminator.terminate if @job_terminator and not(@job_terminator.terminated?)
|
434
|
+
end
|
435
|
+
|
423
436
|
# Terminate task worker agents.
|
424
437
|
def terminate_task_worker
|
425
438
|
if option[:stand_alone] and @task_workers
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# PioneCommand is a facade command for PIONE's various functions.
|
4
|
+
class PioneCommand < BasicCommand
|
5
|
+
# subcommand table
|
6
|
+
@subcommand = {}
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_reader :subcommand
|
10
|
+
|
11
|
+
# Add the subcommand.
|
12
|
+
def add_subcommand(name, command)
|
13
|
+
@subcommand[name] = command
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# basic informations
|
19
|
+
#
|
20
|
+
|
21
|
+
option_parser_mode :order!
|
22
|
+
command_name "pione"
|
23
|
+
command_banner "PIONE is a rule-based workflow engine."
|
24
|
+
|
25
|
+
#
|
26
|
+
# options
|
27
|
+
#
|
28
|
+
|
29
|
+
#
|
30
|
+
# command lifecycle: execution phase
|
31
|
+
#
|
32
|
+
|
33
|
+
execute :subcommand
|
34
|
+
|
35
|
+
def execute_subcommand
|
36
|
+
name = @argv.first
|
37
|
+
if cmd = self.class.subcommand[name]
|
38
|
+
cmd.run(@argv.drop(1))
|
39
|
+
else
|
40
|
+
abort("no such subcommand: %s" % name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# PionePackage is a command body of "pione-package".
|
4
|
+
class PioneCompiler < BasicCommand
|
5
|
+
#
|
6
|
+
# basic informations
|
7
|
+
#
|
8
|
+
|
9
|
+
command_name "pione-compiler"
|
10
|
+
command_banner "pione-compiler translates from PNML to PIONE document."
|
11
|
+
|
12
|
+
#
|
13
|
+
# options
|
14
|
+
#
|
15
|
+
|
16
|
+
use_option :debug
|
17
|
+
|
18
|
+
#
|
19
|
+
# command lifecycle: execution phase
|
20
|
+
#
|
21
|
+
|
22
|
+
setup :source
|
23
|
+
|
24
|
+
def setup_source
|
25
|
+
@source = @argv.first
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# command lifecycle: execution phase
|
30
|
+
#
|
31
|
+
|
32
|
+
execute :compile_to_pnml
|
33
|
+
|
34
|
+
def execute_compile_to_pnml
|
35
|
+
print Util::PNMLCompiler.new(Location[@source]).compile
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -108,8 +108,12 @@ module Pione
|
|
108
108
|
|
109
109
|
# Create a job terminator and setup the action.
|
110
110
|
def setup_job_terminator
|
111
|
-
@job_terminator = Agent::JobTerminator.new(@tuple_space) do
|
112
|
-
|
111
|
+
@job_terminator = Agent::JobTerminator.new(@tuple_space) do |status|
|
112
|
+
if status.error?
|
113
|
+
abort("pione-task-worker catched the error: %s" % status.exception.message)
|
114
|
+
else
|
115
|
+
terminate
|
116
|
+
end
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
data/lib/pione/front.rb
CHANGED
@@ -2,9 +2,13 @@ module Pione
|
|
2
2
|
module Front
|
3
3
|
# FrontError is raised when front server cannnot start.
|
4
4
|
class FrontError < StandardError
|
5
|
+
def initialize(front, exception)
|
6
|
+
@front = front
|
7
|
+
@exception = exception
|
8
|
+
end
|
5
9
|
|
6
10
|
def message
|
7
|
-
"You couldn't start front server(%s)
|
11
|
+
"You couldn't start front server(%s): %s" % [@front.class.name, @exception.message]
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
data/lib/pione/global.rb
CHANGED
@@ -2,126 +2,11 @@ module Pione
|
|
2
2
|
# Global is a table of global variables in PIONE system. It defines variable
|
3
3
|
# names, initial values, and configuration conditions. You can set and get
|
4
4
|
# value by calling item named method.
|
5
|
-
module Global
|
6
|
-
#
|
7
|
-
# variables
|
8
|
-
#
|
9
|
-
|
10
|
-
# these variables should be with prefix and postfix because of name colloision
|
11
|
-
@__names__ = Array.new # variable names
|
12
|
-
@__configurable__ = Hash.new # variable configurability
|
13
|
-
@__lazy_initializer__ = Hash.new # variable initializers
|
14
|
-
@__dependencies__ = Hash.new {|h, k| h[k] = []} # dependency table
|
15
|
-
@__updater__ = Hash.new # updaters for computed item
|
16
|
-
|
17
|
-
class << self
|
18
|
-
# Define an internal item. The item cannot be configured by user.
|
19
|
-
def define_internal_item(name, initial_value=nil, &initializer)
|
20
|
-
define_item(name, false, initial_value, :initializer => initializer)
|
21
|
-
end
|
22
|
-
|
23
|
-
# Define an external item. The item can be configured by user.
|
24
|
-
def define_external_item(name, initial_value=nil, &initializer)
|
25
|
-
define_item(name, true, initial_value, :initializer => initializer)
|
26
|
-
end
|
27
|
-
|
28
|
-
# Define a computed item. The item cannote be configured by user.
|
29
|
-
def define_computed_item(name, dependencies, &updater)
|
30
|
-
define_item(name, false, nil, :dependencies => dependencies, :updater => updater)
|
31
|
-
end
|
32
|
-
|
33
|
-
# Get value of the variable.
|
34
|
-
def get(name)
|
35
|
-
val = instance_variable_get("@%s" % name)
|
36
|
-
if val.nil?
|
37
|
-
# call lazy initializer
|
38
|
-
if @__lazy_initializer__.has_key?(name)
|
39
|
-
set(name, @__lazy_initializer__[name].call)
|
40
|
-
end
|
41
|
-
|
42
|
-
# call initial updater
|
43
|
-
if @__updater__.has_key?(name)
|
44
|
-
update(name)
|
45
|
-
end
|
46
|
-
|
47
|
-
# get value
|
48
|
-
get(name)
|
49
|
-
else
|
50
|
-
return val
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
# Set value of the variable.
|
55
|
-
def set(name, val)
|
56
|
-
# set value
|
57
|
-
instance_variable_set("@%s" % name, val)
|
58
|
-
|
59
|
-
# update dependecies
|
60
|
-
@__dependencies__[name].each do |dependency|
|
61
|
-
update(dependency)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Update the computed item.
|
66
|
-
def update(name)
|
67
|
-
set(name, @__updater__[name].call)
|
68
|
-
end
|
69
|
-
|
70
|
-
# Return true if the variable is configurable.
|
71
|
-
def configurable?(name)
|
72
|
-
@__configurable__[name]
|
73
|
-
end
|
74
|
-
|
75
|
-
# Return all variable names.
|
76
|
-
def all_names
|
77
|
-
@__names__
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
# Define a new global variable.
|
83
|
-
def define_item(name, configurable, initial_value=nil, option)
|
84
|
-
# setup informations
|
85
|
-
@__names__ << name
|
86
|
-
@__configurable__[name]= configurable
|
87
|
-
@__lazy_initializer__[name] = option[:initializer] if option[:initializer]
|
88
|
-
@__updater__[name] = option[:updater] if option[:updater]
|
89
|
-
|
90
|
-
# build dependency table for computed items
|
91
|
-
if option[:dependencies]
|
92
|
-
option[:dependencies].each do |dependency|
|
93
|
-
@__dependencies__[dependency] << name
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
# set reader and writer
|
98
|
-
define_variable_reader(name)
|
99
|
-
define_variable_writer(name)
|
100
|
-
|
101
|
-
# set initial value
|
102
|
-
unless initial_value.nil?
|
103
|
-
set(name, initial_value)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Define reader method of the variable.
|
108
|
-
def define_variable_reader(name)
|
109
|
-
singleton_class.module_eval do |mod|
|
110
|
-
define_method(name) {get(name)}
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# Define writer method of the variable.
|
115
|
-
def define_variable_writer(name)
|
116
|
-
singleton_class.module_eval do |mod|
|
117
|
-
define_method("set_%s" % name) {|val| set(name, val)}
|
118
|
-
define_method("%s=" % name) {|val| set(name, val)}
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
5
|
+
module Global; end
|
123
6
|
end
|
124
7
|
|
8
|
+
require 'pione/global/item'
|
9
|
+
require 'pione/global/config'
|
125
10
|
require 'pione/global/system-variable'
|
126
11
|
require 'pione/global/path-variable'
|
127
12
|
require 'pione/global/network-variable'
|
@@ -1,20 +1,33 @@
|
|
1
1
|
module Pione
|
2
2
|
module Global
|
3
3
|
# broker-front port range begin
|
4
|
-
define_external_item(:broker_front_port_range_begin
|
4
|
+
define_external_item(:broker_front_port_range_begin) do |item|
|
5
|
+
item.desc = "start port number of broker front"
|
6
|
+
item.init = 41000
|
7
|
+
end
|
5
8
|
|
6
9
|
# broker-front port range end
|
7
|
-
define_external_item(:broker_front_port_range_end
|
10
|
+
define_external_item(:broker_front_port_range_end) do |item|
|
11
|
+
item.desc = "end port number of broker front"
|
12
|
+
item.init = 41099
|
13
|
+
end
|
8
14
|
|
9
15
|
# broker-front port range
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
define_computed_item(:broker_front_port_range, [:broker_front_port_range_begin, :broker_front_port_range_end]) do |item|
|
17
|
+
item.desc = "port range of broker front"
|
18
|
+
item.define_updater do
|
19
|
+
Range.new(
|
20
|
+
Global.broker_front_port_range_begin,
|
21
|
+
Global.broker_front_port_range_end
|
22
|
+
)
|
23
|
+
end
|
15
24
|
end
|
16
25
|
|
17
26
|
# balancer method
|
18
|
-
define_external_item(:broker_task_worker_balancer)
|
27
|
+
define_external_item(:broker_task_worker_balancer) do |item|
|
28
|
+
item.desc = "balancer method of task worker broker"
|
29
|
+
item.init = "Pione::Agent::EasyTaskWorkerBalancer"
|
30
|
+
item.define_updater {|val| eval(val)}
|
31
|
+
end
|
19
32
|
end
|
20
33
|
end
|
@@ -1,18 +1,26 @@
|
|
1
1
|
module Pione
|
2
2
|
module Global
|
3
3
|
# This is a begin number of port range for client's front.
|
4
|
-
define_external_item(:client_front_port_range_begin
|
4
|
+
define_external_item(:client_front_port_range_begin) do |item|
|
5
|
+
item.desc = "start port number of client front"
|
6
|
+
item.init = 40000
|
7
|
+
end
|
5
8
|
|
6
9
|
# This is an end number of port range for client's front.
|
7
|
-
define_external_item(:client_front_port_range_end
|
10
|
+
define_external_item(:client_front_port_range_end) do |item|
|
11
|
+
item.desc = "end port number of client front"
|
12
|
+
item.init = 40099
|
13
|
+
end
|
8
14
|
|
9
15
|
# This is port range for client's front.
|
10
|
-
define_computed_item(:client_front_port_range,
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
define_computed_item(:client_front_port_range, [:client_front_port_range_begin, :client_front_port_range_end]) do |item|
|
17
|
+
item.desc = "port range of broker front"
|
18
|
+
item.define_updater do
|
19
|
+
Range.new(
|
20
|
+
Global.client_front_port_range_begin,
|
21
|
+
Global.client_front_port_range_end
|
22
|
+
)
|
23
|
+
end
|
16
24
|
end
|
17
25
|
end
|
18
26
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Pione
|
2
|
-
module
|
2
|
+
module Global
|
3
3
|
# Config is a class for setting PIONE system configuration.
|
4
4
|
class Config
|
5
5
|
# Load configuration and apply it to global settings.
|
@@ -23,7 +23,7 @@ module Pione
|
|
23
23
|
def apply
|
24
24
|
@table.each do |key, val|
|
25
25
|
key = key.to_sym
|
26
|
-
if Global.
|
26
|
+
if Global.item[key] and Global.item[key].configurable?
|
27
27
|
Global.set(key, val)
|
28
28
|
else
|
29
29
|
raise UnconfigurableVariableError.new(key)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Pione
|
2
|
+
module Global
|
3
|
+
class GlobalError < StandardError; end
|
4
|
+
|
5
|
+
# UnknownItem is raised when unknown global item is referred.
|
6
|
+
class UnknownItem < GlobalError
|
7
|
+
def initialize(name)
|
8
|
+
@name = name
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
"item '%s' is unknown as global variables" % @name
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# This exception class is raised when configuration file is in invalid format.
|
17
|
+
class InvalidConfigFile < GlobalError
|
18
|
+
# config file path
|
19
|
+
attr_reader :path
|
20
|
+
|
21
|
+
def initialize(path)
|
22
|
+
@path = path
|
23
|
+
end
|
24
|
+
|
25
|
+
def message
|
26
|
+
"invalid format configuration file: %s" % @path
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class UnconfigurableVariableError < GlobalError
|
31
|
+
def initialize(name)
|
32
|
+
@name = name
|
33
|
+
end
|
34
|
+
|
35
|
+
def message
|
36
|
+
"global variable \"%s\" is unconfigurable." % @name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|