pione 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/History.txt +11 -0
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/bin/pione-log +5 -0
- data/example/CountChar/CountChar.pione +1 -1
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +39 -38
- data/lib/pione.rb +14 -35
- data/lib/pione/agent/input-generator.rb +38 -40
- data/lib/pione/agent/logger.rb +52 -19
- data/lib/pione/agent/rule-provider.rb +5 -8
- data/lib/pione/agent/task-worker.rb +25 -32
- data/lib/pione/agent/tuple-space-client.rb +22 -14
- data/lib/pione/command.rb +21 -0
- data/lib/pione/command/basic-command.rb +267 -84
- data/lib/pione/command/child-process.rb +21 -18
- data/lib/pione/command/daemon-process.rb +9 -8
- data/lib/pione/command/front-owner-command.rb +8 -25
- data/lib/pione/command/pione-broker.rb +27 -24
- data/lib/pione/command/pione-clean.rb +6 -6
- data/lib/pione/command/pione-client.rb +143 -128
- data/lib/pione/command/pione-log.rb +61 -0
- data/lib/pione/command/pione-relay-account-db.rb +40 -38
- data/lib/pione/command/pione-relay-client-db.rb +38 -42
- data/lib/pione/command/pione-relay.rb +19 -20
- data/lib/pione/command/pione-syntax-checker.rb +70 -45
- data/lib/pione/command/pione-task-worker.rb +56 -66
- data/lib/pione/command/pione-tuple-space-provider.rb +36 -45
- data/lib/pione/command/pione-tuple-space-receiver.rb +34 -32
- data/lib/pione/command/pione-tuple-space-viewer.rb +63 -47
- data/lib/pione/location.rb +10 -0
- data/lib/pione/location/basic-location.rb +272 -0
- data/lib/pione/location/dropbox-location.rb +139 -0
- data/lib/pione/location/ftp-location.rb +156 -0
- data/lib/pione/location/local-location.rb +116 -0
- data/lib/pione/log.rb +10 -0
- data/lib/pione/log/domain-info.rb +72 -0
- data/lib/pione/log/process-log.rb +176 -0
- data/lib/pione/log/process-record.rb +189 -0
- data/lib/pione/log/xes-log.rb +105 -0
- data/lib/pione/model/assignment.rb +88 -80
- data/lib/pione/model/binary-operator.rb +74 -68
- data/lib/pione/model/block.rb +218 -207
- data/lib/pione/model/boolean.rb +123 -112
- data/lib/pione/model/call-rule.rb +72 -65
- data/lib/pione/model/data-expr.rb +596 -290
- data/lib/pione/model/float.rb +108 -103
- data/lib/pione/model/integer.rb +133 -129
- data/lib/pione/model/message.rb +79 -72
- data/lib/pione/model/package.rb +42 -38
- data/lib/pione/model/parameters.rb +265 -236
- data/lib/pione/model/rule-expr.rb +247 -242
- data/lib/pione/model/rule-io.rb +137 -133
- data/lib/pione/model/rule.rb +307 -292
- data/lib/pione/model/string.rb +110 -99
- data/lib/pione/model/variable-table.rb +300 -271
- data/lib/pione/model/variable.rb +88 -83
- data/lib/pione/option.rb +13 -0
- data/lib/pione/option/child-process-option.rb +19 -0
- data/lib/pione/{command-option → option}/common-option.rb +6 -5
- data/lib/pione/option/option-interface.rb +73 -0
- data/lib/pione/{command-option → option}/presence-notifier-option.rb +4 -3
- data/lib/pione/option/task-worker-owner-option.rb +24 -0
- data/lib/pione/{command-option → option}/tuple-space-provider-option.rb +6 -4
- data/lib/pione/option/tuple-space-provider-owner-option.rb +18 -0
- data/lib/pione/option/tuple-space-receiver-option.rb +8 -0
- data/lib/pione/parser/common-parser.rb +3 -2
- data/lib/pione/parser/expr-parser.rb +6 -1
- data/lib/pione/patch/em-ftpd-patch.rb +21 -0
- data/lib/pione/patch/rinda-patch.rb +31 -23
- data/lib/pione/rule-handler/action-handler.rb +35 -25
- data/lib/pione/rule-handler/basic-handler.rb +92 -18
- data/lib/pione/rule-handler/flow-handler.rb +104 -98
- data/lib/pione/rule-handler/root-handler.rb +11 -0
- data/lib/pione/system/common.rb +10 -0
- data/lib/pione/system/file-cache.rb +103 -84
- data/lib/pione/system/global.rb +67 -12
- data/lib/pione/system/init.rb +20 -0
- data/lib/pione/transformer/expr-transformer.rb +6 -1
- data/lib/pione/tuple-space/data-finder.rb +33 -6
- data/lib/pione/tuple-space/tuple-space-receiver.rb +4 -3
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +58 -13
- data/lib/pione/tuple-space/tuple-space-server.rb +13 -11
- data/lib/pione/tuple-space/update-criteria.rb +8 -7
- data/lib/pione/tuple/base-location-tuple.rb +9 -0
- data/lib/pione/tuple/basic-tuple.rb +7 -7
- data/lib/pione/tuple/data-tuple.rb +5 -2
- data/lib/pione/tuple/lift-tuple.rb +14 -0
- data/lib/pione/tuple/rule-tuple.rb +1 -1
- data/lib/pione/tuple/task-tuple.rb +5 -1
- data/lib/pione/version.rb +1 -1
- data/pione.gemspec +5 -1
- data/test/location/spec_basic-location.rb +35 -0
- data/test/location/spec_ftp-location.rb +100 -0
- data/test/location/spec_local-location.rb +99 -0
- data/test/log/data/sample.log +1003 -0
- data/test/log/spec_xes-log.rb +11 -0
- data/test/model/spec_data-expr.rb +249 -6
- data/test/model/spec_data-expr.yml +45 -0
- data/test/parser/spec_expr-parser.yml +4 -0
- data/test/spec_data-finder.rb +13 -7
- data/test/spec_data-finder.yml +42 -13
- data/test/system/spec_file-cache.rb +39 -0
- data/test/test-util.rb +226 -1
- data/test/transformer/spec_expr-transformer.rb +12 -1
- metadata +107 -24
- data/bin/pione-search-log +0 -30
- data/lib/pione/command-option/basic-option.rb +0 -42
- data/lib/pione/command-option/child-process-option.rb +0 -17
- data/lib/pione/command-option/daemon-option.rb +0 -12
- data/lib/pione/command-option/task-worker-owner-option.rb +0 -17
- data/lib/pione/command-option/tuple-space-provider-owner-option.rb +0 -16
- data/lib/pione/command-option/tuple-space-receiver-option.rb +0 -12
- data/lib/pione/command/tuple-space-provider-owner.rb +0 -6
- data/lib/pione/resource/basic-resource.rb +0 -92
- data/lib/pione/resource/dropbox-resource.rb +0 -106
- data/lib/pione/resource/ftp.rb +0 -84
- data/lib/pione/resource/local.rb +0 -113
- data/lib/pione/tuple/base-uri-tuple.rb +0 -9
- data/lib/pione/tuple/shift-tuple.rb +0 -13
- data/lib/pione/util/log.rb +0 -79
- data/test/spec_resource.rb +0 -73
@@ -3,38 +3,59 @@ module Pione
|
|
3
3
|
# This is a class for +pione-task-worker+ command. +pione-task-worker+
|
4
4
|
# starts a task worker agent with tuple space server.
|
5
5
|
class PioneTaskWorker < ChildProcess
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
define_info do
|
7
|
+
set_name "pione-task-worker"
|
8
|
+
set_tail {|cmd|
|
9
|
+
"{Front: %s, ParentFront: %s}" % [
|
10
|
+
Global.front.uri, cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri
|
11
|
+
]
|
12
|
+
}
|
13
|
+
set_banner <<BANNER
|
14
|
+
Run task worker process. This command is launched by other processes like
|
15
|
+
pione-client or pione-broker.
|
16
|
+
BANNER
|
9
17
|
end
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
pione-client or pione-broker.
|
14
|
-
TXT
|
19
|
+
define_option do
|
20
|
+
use Option::ChildProcessOption
|
15
21
|
|
16
|
-
|
22
|
+
default :features, Model::Feature::EmptyFeature.new
|
17
23
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
# --connection-id
|
25
|
+
option('--connection-id=ID', 'set connection id') do |data, id|
|
26
|
+
data[:connection_id] = id
|
27
|
+
end
|
22
28
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
# --feature
|
30
|
+
option('--features=FEATURES', 'set features') do |data, features|
|
31
|
+
begin
|
32
|
+
features = DocumentTransformer.new.apply(
|
33
|
+
DocumentParser.new.feature_expr.parse(features)
|
34
|
+
)
|
35
|
+
data[:features] = features
|
36
|
+
rescue Parslet::ParseFailed => e
|
37
|
+
puts "invalid parameters: " + str
|
38
|
+
Util::ErrorReport.print(e)
|
39
|
+
abort
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
validate do |data|
|
44
|
+
# check requisite options
|
45
|
+
abort("error: no connection id") if data[:connection_id].nil?
|
46
|
+
|
47
|
+
# get the parent front server
|
48
|
+
begin
|
49
|
+
data[:parent_front].uuid
|
50
|
+
rescue => e
|
51
|
+
if Pione.debug_mode?
|
52
|
+
debug_message "pione-task-worker cannot get the parent front server: %s" % e
|
53
|
+
end
|
54
|
+
abort
|
55
|
+
end
|
34
56
|
end
|
35
57
|
end
|
36
58
|
|
37
|
-
attr_reader :connection_id
|
38
59
|
attr_reader :agent
|
39
60
|
attr_reader :tuple_space_server
|
40
61
|
|
@@ -44,50 +65,26 @@ TXT
|
|
44
65
|
Pione::Front::TaskWorkerFront.new(self)
|
45
66
|
end
|
46
67
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
# check requisite options
|
51
|
-
if @connection_id.nil?
|
52
|
-
abort("error: no connection id")
|
53
|
-
end
|
54
|
-
|
55
|
-
# get the parent front server
|
56
|
-
begin
|
57
|
-
@parent_front.uuid
|
58
|
-
rescue => e
|
59
|
-
if Pione.debug_mode?
|
60
|
-
debug_message "pione-task-worker cannot get the parent front server: %s" % e
|
61
|
-
end
|
62
|
-
abort
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
def prepare
|
67
|
-
super
|
68
|
-
|
69
|
-
@tuple_space_server = @parent_front.get_tuple_space_server(@connection_id)
|
70
|
-
@features = Model::Feature::EmptyFeature.new unless @features
|
71
|
-
@agent = Pione::Agent[:task_worker].new(@tuple_space_server, @features)
|
68
|
+
prepare do
|
69
|
+
@tuple_space_server = option[:parent_front].get_tuple_space_server(option[:connection_id])
|
70
|
+
@agent = Pione::Agent[:task_worker].new(@tuple_space_server, option[:features])
|
72
71
|
@command_listener = Pione::Agent[:command_listener].new(@tuple_space_server, self)
|
73
72
|
|
74
73
|
# connect caller front
|
75
|
-
|
74
|
+
option[:parent_front].add_task_worker_front(Global.front, option[:connection_id])
|
76
75
|
|
77
76
|
abort("pione-task-worker error: no tuple space server") unless @tuple_space_server
|
78
77
|
|
79
78
|
# get base uri
|
80
|
-
if @tuple_space_server.
|
81
|
-
|
82
|
-
unless
|
79
|
+
if @tuple_space_server.base_location.kind_of?(Location::DropboxLocation)
|
80
|
+
Location::Dropbox.init(@tuple_space_server)
|
81
|
+
unless Location::Dropbox.ready?
|
83
82
|
abort("You aren't ready to access Dropbox.")
|
84
83
|
end
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
88
|
-
|
89
|
-
super
|
90
|
-
|
87
|
+
start do
|
91
88
|
# start task worker activity
|
92
89
|
@agent.start
|
93
90
|
@command_listener.start
|
@@ -95,18 +92,12 @@ TXT
|
|
95
92
|
# wait...
|
96
93
|
begin
|
97
94
|
@agent.running_thread.join
|
98
|
-
# terminate
|
99
|
-
terminate
|
100
95
|
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
|
101
|
-
|
96
|
+
# ignore
|
102
97
|
end
|
103
98
|
end
|
104
99
|
|
105
|
-
|
106
|
-
# front.
|
107
|
-
#
|
108
|
-
# @return [void]
|
109
|
-
def terminate
|
100
|
+
terminate do
|
110
101
|
Global.monitor.synchronize do
|
111
102
|
begin
|
112
103
|
return if @terminated
|
@@ -118,7 +109,7 @@ TXT
|
|
118
109
|
end
|
119
110
|
|
120
111
|
# disconnect parent front
|
121
|
-
|
112
|
+
option[:parent_front].remove_task_worker_front(self, option[:connection_id])
|
122
113
|
|
123
114
|
# flag
|
124
115
|
@terminated = true
|
@@ -127,7 +118,6 @@ TXT
|
|
127
118
|
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
|
128
119
|
# ignore
|
129
120
|
end
|
130
|
-
super
|
131
121
|
end
|
132
122
|
end
|
133
123
|
end
|
@@ -2,86 +2,77 @@ module Pione
|
|
2
2
|
module Command
|
3
3
|
# PioneTupleSpaceProvider is for +pione-tuple-space-provider+ command.
|
4
4
|
class PioneTupleSpaceProvider < ChildProcess
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
5
|
+
define_info do
|
6
|
+
set_name "pione-tuple-space-provider"
|
7
|
+
set_tail {|cmd|
|
8
|
+
front_uri = begin Global.front.uri rescue "failed" end
|
9
|
+
parent_front = begin cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri rescue "failed" end
|
10
|
+
"{Front: %s, ParentFront: %s}" % [front_uri, parent_front]
|
11
|
+
}
|
12
|
+
set_banner <<TXT
|
13
|
+
Run tuple space provider process for sending tuple space presence notifier. This
|
14
|
+
command is launched by other processes like pione-client or pione-relay
|
15
|
+
normally, but you can force to start by calling with --no-parent option.
|
15
16
|
TXT
|
16
|
-
|
17
|
-
use_option_module CommandOption::TupleSpaceProviderOption
|
18
|
-
|
19
|
-
attr_reader :tuple_space_provider
|
20
|
-
|
21
|
-
def initialize
|
22
|
-
super
|
23
|
-
@parent_front = nil
|
24
|
-
@notifier_addresses = []
|
25
17
|
end
|
26
18
|
|
27
|
-
|
28
|
-
|
29
|
-
|
19
|
+
define_option do
|
20
|
+
use Option::TupleSpaceProviderOption
|
21
|
+
|
22
|
+
default :notifier_addresses, []
|
30
23
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
validate do |data|
|
25
|
+
# broadcast addresses
|
26
|
+
data[:notifier_addresses].each do |uri|
|
27
|
+
unless uri.scheme == "broadcast"
|
28
|
+
abort("error: invalid broadcast address '%s'" % uri.to_s)
|
29
|
+
end
|
35
30
|
end
|
36
31
|
end
|
37
32
|
end
|
38
33
|
|
34
|
+
attr_reader :tuple_space_provider
|
35
|
+
|
39
36
|
# @api private
|
40
37
|
def create_front
|
41
38
|
Pione::Front::TupleSpaceProviderFront.new(self)
|
42
39
|
end
|
43
40
|
|
44
|
-
|
45
|
-
def prepare
|
46
|
-
super
|
47
|
-
|
41
|
+
prepare do
|
48
42
|
# setup notifier addresses
|
49
|
-
unless
|
50
|
-
Global.tuple_space_provider_broadcast_addresses =
|
43
|
+
unless option[:notifier_addresses].empty?
|
44
|
+
Global.tuple_space_provider_broadcast_addresses = option[:notifier_addresses]
|
51
45
|
end
|
52
46
|
|
53
47
|
# make tuple space provider
|
54
48
|
@tuple_space_provider = TupleSpaceProvider.new
|
55
49
|
end
|
56
50
|
|
57
|
-
|
58
|
-
def start
|
59
|
-
super
|
60
|
-
|
51
|
+
start do
|
61
52
|
# start provider activity
|
62
53
|
@tuple_space_provider.start
|
63
54
|
|
64
55
|
begin
|
65
56
|
# set my URI to caller front as its provider
|
66
|
-
unless
|
67
|
-
|
57
|
+
unless option[:no_parent_mode]
|
58
|
+
option[:parent_front].set_tuple_space_provider(Global.front.uri)
|
68
59
|
end
|
69
60
|
|
70
61
|
# wait
|
71
62
|
DRb.thread.join
|
72
63
|
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
|
73
|
-
|
64
|
+
# ignore
|
74
65
|
end
|
75
66
|
end
|
76
67
|
|
77
|
-
|
78
|
-
def terminate
|
68
|
+
terminate do
|
79
69
|
Global.monitor.synchronize do
|
80
|
-
|
81
|
-
|
70
|
+
begin
|
71
|
+
@tuple_space_provider.terminate
|
72
|
+
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
|
73
|
+
abort
|
74
|
+
end
|
82
75
|
end
|
83
|
-
rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
|
84
|
-
abort
|
85
76
|
end
|
86
77
|
end
|
87
78
|
end
|
@@ -1,18 +1,29 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
+
# PioneTupleSpaceReceiver is a command that launchs tuple space receiver
|
4
|
+
# agent.
|
3
5
|
class PioneTupleSpaceReceiver < ChildProcess
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
define_info do
|
7
|
+
set_name "pione-tuple-space-receiver"
|
8
|
+
set_tail {|cmd|
|
9
|
+
front = Global.front.uri
|
10
|
+
parent_front = cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri
|
11
|
+
"{Front: %s, ParentFront: %s}" % [front, parent_front]
|
12
|
+
}
|
13
|
+
set_banner <<TXT
|
14
|
+
Run tuple space receiver process for receiving tuple space presence
|
11
15
|
notifier. This command is launched by other processes like pione-broker
|
12
16
|
normally, but you can force to start by calling with --no-parent option.
|
13
17
|
TXT
|
18
|
+
end
|
14
19
|
|
15
|
-
|
20
|
+
define_option do
|
21
|
+
use Option::PresenceNotifierOption
|
22
|
+
|
23
|
+
option("--presence-port=PORT", "set presence port number") do |data, port|
|
24
|
+
Global.presence_port = port.to_i
|
25
|
+
end
|
26
|
+
end
|
16
27
|
|
17
28
|
attr_reader :tuple_space_receiver
|
18
29
|
|
@@ -20,39 +31,30 @@ TXT
|
|
20
31
|
Front::TupleSpaceReceiverFront.new(self)
|
21
32
|
end
|
22
33
|
|
23
|
-
|
24
|
-
super
|
34
|
+
prepare do
|
25
35
|
@tuple_space_receiver = TupleSpaceReceiver.new
|
26
36
|
end
|
27
37
|
|
28
|
-
|
29
|
-
|
38
|
+
start do
|
39
|
+
begin
|
40
|
+
# start provider activity
|
41
|
+
@tuple_space_receiver.start
|
30
42
|
|
31
|
-
|
32
|
-
|
43
|
+
# set my uri to parent front as its provider
|
44
|
+
unless option[:no_parent_mode]
|
45
|
+
option[:parent_front].set_tuple_space_receiver(Global.front.uri)
|
46
|
+
end
|
33
47
|
|
34
|
-
|
35
|
-
|
36
|
-
|
48
|
+
# wait
|
49
|
+
DRb.thread.join
|
50
|
+
rescue DRb::ReplyReaderThreadError => e
|
51
|
+
# ignore reply reader error
|
37
52
|
end
|
38
|
-
|
39
|
-
# wait
|
40
|
-
DRb.thread.join
|
41
|
-
rescue DRb::ReplyReaderThreadError => e
|
42
|
-
# ignore reply reader error
|
43
53
|
end
|
44
54
|
|
45
|
-
|
46
|
-
#
|
47
|
-
# @return [void]
|
48
|
-
def terminate
|
55
|
+
terminate do
|
49
56
|
Global.monitor.synchronize do
|
50
|
-
|
51
|
-
@tuple_space_receiver.terminate
|
52
|
-
rescue DRb::DRbConnError
|
53
|
-
# ignore
|
54
|
-
end
|
55
|
-
super
|
57
|
+
@tuple_space_receiver.terminate
|
56
58
|
end
|
57
59
|
end
|
58
60
|
end
|
@@ -1,55 +1,58 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
+
# PioneTupleSpaceView is a command that shows and searchs tuples in tuple
|
4
|
+
# spaces.
|
3
5
|
class PioneTupleSpaceViewer < BasicCommand
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
@identifiers << name
|
6
|
+
define_info do
|
7
|
+
set_name "pione-tuple-space-viewer"
|
8
|
+
set_banner "Show and search tuples in tuple spaces."
|
8
9
|
end
|
9
10
|
|
10
|
-
define_option
|
11
|
-
|
12
|
-
|
11
|
+
define_option do
|
12
|
+
default :identifiers, []
|
13
|
+
default :exclusions, []
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
option('-i', '--identifier=NAME', 'show tuples that have the identifier') do |data, name|
|
16
|
+
data[:identifiers] << name
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
option('-e', '--exclude=NAME', 'exclude the tuple identifier') do |data, name|
|
20
|
+
data[:exclusions] << name
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
option('--package=NAME', 'show tuples which domain has the package name') do |data, name|
|
24
|
+
data[:package] = name
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
option('--rule=NAME', 'show tuples which domain has the rule name') do |data, name|
|
28
|
+
data[:rule] = name
|
29
|
+
end
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
31
|
+
option('--rule-path=NAME', 'show tuples which domain has the rule path') do |data, path|
|
32
|
+
data[:rule_path] = path
|
33
|
+
end
|
34
|
+
|
35
|
+
option('--data-name=NAME', 'show tuples that has the the name') do |data, name|
|
36
|
+
data[:data_name] = name
|
37
|
+
end
|
38
|
+
|
39
|
+
option(
|
40
|
+
'--type=TYPE',
|
41
|
+
'show the bag which has the type("bag", "read_waiter", or "take_waiter")'
|
42
|
+
) do |data, bag_type|
|
43
|
+
data[:bag_type] = bag_type.to_sym
|
44
|
+
end
|
36
45
|
|
37
|
-
|
38
|
-
|
46
|
+
option('--client=ADDRESS', 'druby address of target client process') do |data, address|
|
47
|
+
data[:address] = address
|
48
|
+
end
|
39
49
|
end
|
40
50
|
|
41
51
|
def initialize
|
42
|
-
@identifiers = []
|
43
|
-
@exclusions = []
|
44
|
-
@package = nil
|
45
|
-
@rule = nil
|
46
|
-
@rule_path = nil
|
47
|
-
@data_name = nil
|
48
|
-
@bag_type = nil
|
49
52
|
@tuple_space_servers = []
|
50
53
|
end
|
51
54
|
|
52
|
-
|
55
|
+
prepare do
|
53
56
|
require 'pp'
|
54
57
|
find_tuple_space_servers
|
55
58
|
|
@@ -59,20 +62,20 @@ module Pione
|
|
59
62
|
end
|
60
63
|
end
|
61
64
|
|
62
|
-
|
65
|
+
start do
|
63
66
|
# print each bags
|
64
67
|
@tuple_space_servers.each do |address, tuple_space_server|
|
65
68
|
puts "TupleSpaceServer: %s" % Terminal.red(address)
|
66
69
|
puts "-"*78
|
67
|
-
if
|
70
|
+
if option[:bag_type] == :bag or option[:bag_type].nil?
|
68
71
|
puts "*** bag ***"
|
69
72
|
show_bag(tuple_space_server, :bag)
|
70
73
|
end
|
71
|
-
if
|
74
|
+
if option[:bag_type] == :read_waiter or option[:bag_type].nil?
|
72
75
|
puts "*** read waiter ***"
|
73
76
|
show_bag(tuple_space_server, :read_waiter)
|
74
77
|
end
|
75
|
-
if
|
78
|
+
if option[:bag_type] == :take_waiter or option[:bag_type].nil?
|
76
79
|
puts "*** take waiter ***"
|
77
80
|
show_bag(tuple_space_server, :take_waiter)
|
78
81
|
end
|
@@ -88,14 +91,20 @@ module Pione
|
|
88
91
|
|
89
92
|
private
|
90
93
|
|
94
|
+
# Find tuple space servers.
|
95
|
+
#
|
96
|
+
# @return [void]
|
91
97
|
def find_tuple_space_servers
|
92
|
-
if
|
93
|
-
@tuple_space_servers << [
|
98
|
+
if option[:address]
|
99
|
+
@tuple_space_servers << [option[:address], get_tuple_space_server(option[:address])]
|
94
100
|
else
|
95
101
|
find_tuple_space_servers_in_range
|
96
102
|
end
|
97
103
|
end
|
98
104
|
|
105
|
+
# Find tuple space server in some port range. This scans ports of the address.
|
106
|
+
#
|
107
|
+
# @return [void]
|
99
108
|
def find_tuple_space_servers_in_range
|
100
109
|
Global.client_front_port_range.each do |port|
|
101
110
|
begin
|
@@ -107,31 +116,38 @@ module Pione
|
|
107
116
|
end
|
108
117
|
end
|
109
118
|
|
110
|
-
#
|
119
|
+
# Get a tuple space server from the address.
|
111
120
|
def get_tuple_space_server(address)
|
112
121
|
ref = DRbObject.new_with_uri(address)
|
113
122
|
ref.ping
|
114
123
|
ref.tuple_space_server
|
115
124
|
end
|
116
125
|
|
126
|
+
# Show tuples of the typed bag in the tuple space server.
|
127
|
+
#
|
128
|
+
# @param tuple_space_server [TupleSpaceServer]
|
129
|
+
# tuple space server
|
130
|
+
# @param type [Symbol]
|
131
|
+
# bag type
|
132
|
+
# @return [void]
|
117
133
|
def show_bag(tuple_space_server, type)
|
118
134
|
tuple_space_server.all_tuples(type).each do |tuple|
|
119
|
-
next if not(
|
120
|
-
next if
|
135
|
+
next if not(option[:identifiers].empty?) and not(option[:identifiers].include?(tuple.first.to_s))
|
136
|
+
next if option[:exclusions].include?(tuple.first.to_s)
|
121
137
|
|
122
138
|
t = Tuple.from_array(tuple)
|
123
139
|
|
124
140
|
# rule_path
|
125
|
-
if
|
141
|
+
if option[:rule_path]
|
126
142
|
if t.respond_to?(:domain)
|
127
|
-
next unless /^(#{
|
143
|
+
next unless /^(#{option[:rule_path]})/.match(t.domain)
|
128
144
|
else
|
129
145
|
next
|
130
146
|
end
|
131
147
|
end
|
132
148
|
|
133
149
|
# name
|
134
|
-
if
|
150
|
+
if option[:data_name]
|
135
151
|
if t.kind_of?(Tuple::Data) and t.respond_to?(:name)
|
136
152
|
next unless Model::DataExpr.new(@data_name).match(t.name)
|
137
153
|
else
|