pione 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/.s3cfg +42 -0
- data/.travis.yml +18 -4
- data/.yardopts +1 -0
- data/Gemfile +3 -0
- data/History.txt +14 -0
- data/Procfile +7 -0
- data/Rakefile +25 -0
- data/bin/pione-interactive +6 -0
- data/bin/{pione-compiler → pione-notification-listener} +1 -1
- data/bin/{pione-broker → pione-task-worker-broker} +1 -1
- data/doc/man/pione-list-param.md +36 -0
- data/example/ActionError/ActionError.pione +9 -0
- data/example/ActionError/pione-package.json +15 -0
- data/example/CountChar/CountChar.pione +1 -1
- data/example/ScoreAggregation/ScoreAggregation.pione +1 -1
- data/example/Touch/pione-package.json +15 -0
- data/lib/pione.rb +12 -0
- data/lib/pione/agent.rb +3 -3
- data/lib/pione/agent/basic-agent.rb +10 -4
- data/lib/pione/agent/input-generator.rb +3 -3
- data/lib/pione/agent/{process-manager.rb → job-manager.rb} +10 -7
- data/lib/pione/agent/job-terminator.rb +2 -2
- data/lib/pione/agent/logger.rb +3 -3
- data/lib/pione/agent/messenger.rb +20 -9
- data/lib/pione/agent/notification-listener.rb +88 -0
- data/lib/pione/agent/task-worker-broker.rb +84 -0
- data/lib/pione/agent/task-worker.rb +3 -2
- data/lib/pione/agent/tuple-space-client.rb +1 -0
- data/lib/pione/agent/tuple-space-provider.rb +17 -35
- data/lib/pione/command.rb +33 -15
- data/lib/pione/command/action.rb +105 -0
- data/lib/pione/command/basic-command.rb +34 -376
- data/lib/pione/command/command-exception.rb +12 -11
- data/lib/pione/command/common.rb +198 -0
- data/lib/pione/command/option.rb +159 -204
- data/lib/pione/command/pione-action-exec.rb +85 -0
- data/lib/pione/command/pione-action-list.rb +43 -19
- data/lib/pione/command/pione-action-print.rb +79 -0
- data/lib/pione/command/pione-action.rb +8 -67
- data/lib/pione/command/pione-clean.rb +88 -68
- data/lib/pione/command/pione-client.rb +475 -332
- data/lib/pione/command/pione-command.rb +14 -31
- data/lib/pione/command/pione-compile.rb +90 -0
- data/lib/pione/command/pione-config-get.rb +53 -0
- data/lib/pione/command/pione-config-list.rb +64 -0
- data/lib/pione/command/pione-config-set.rb +59 -0
- data/lib/pione/command/pione-config-unset.rb +50 -0
- data/lib/pione/command/pione-config.rb +61 -0
- data/lib/pione/command/pione-diagnosis-notification.rb +235 -0
- data/lib/pione/command/pione-diagnosis.rb +21 -0
- data/lib/pione/command/pione-interactive.rb +188 -0
- data/lib/pione/command/pione-lang-check-syntax.rb +163 -0
- data/lib/pione/command/pione-lang-interactive.rb +146 -0
- data/lib/pione/command/pione-lang.rb +22 -0
- data/lib/pione/command/pione-log-format.rb +163 -0
- data/lib/pione/command/pione-log-list-id.rb +48 -0
- data/lib/pione/command/pione-log.rb +19 -101
- data/lib/pione/command/pione-notification-listener.rb +95 -0
- data/lib/pione/command/pione-package-add.rb +137 -0
- data/lib/pione/command/pione-package-build.rb +122 -0
- data/lib/pione/command/pione-package-show.rb +96 -0
- data/lib/pione/command/pione-package-update.rb +59 -0
- data/lib/pione/command/pione-package.rb +11 -139
- data/lib/pione/command/pione-task-worker-broker.rb +88 -0
- data/lib/pione/command/pione-task-worker.rb +148 -98
- data/lib/pione/command/pione-tuple-space-provider.rb +62 -54
- data/lib/pione/command/pione-tuple-space-viewer.rb +105 -83
- data/lib/pione/command/pione-val.rb +39 -39
- data/lib/pione/command/spawner.rb +34 -27
- data/lib/pione/front.rb +4 -2
- data/lib/pione/front/basic-front.rb +86 -23
- data/lib/pione/front/client-front.rb +2 -2
- data/lib/pione/front/diagnosis-notification-front.rb +40 -0
- data/lib/pione/front/front-exception.rb +7 -1
- data/lib/pione/front/notification-listener-front.rb +36 -0
- data/lib/pione/front/notification-recipient-interface.rb +19 -0
- data/lib/pione/front/relay-front.rb +4 -4
- data/lib/pione/front/task-worker-broker-front.rb +19 -0
- data/lib/pione/front/task-worker-front.rb +2 -2
- data/lib/pione/front/tuple-space-provider-front.rb +3 -2
- data/lib/pione/global.rb +3 -1
- data/lib/pione/global/client-variable.rb +1 -1
- data/lib/pione/global/config.rb +63 -7
- data/lib/pione/global/diagnosis-variable.rb +26 -0
- data/lib/pione/global/item.rb +28 -5
- data/lib/pione/global/log-variable.rb +6 -5
- data/lib/pione/global/network-variable.rb +75 -4
- data/lib/pione/global/path-variable.rb +1 -1
- data/lib/pione/global/system-variable.rb +12 -12
- data/lib/pione/global/task-worker-broker-variable.rb +43 -0
- data/lib/pione/global/tuple-space-notifier-variable.rb +3 -55
- data/lib/pione/lang/boolean.rb +4 -0
- data/lib/pione/lang/data-expr.rb +1 -1
- data/lib/pione/lang/integer.rb +1 -1
- data/lib/pione/lang/string.rb +4 -0
- data/lib/pione/lang/type.rb +1 -1
- data/lib/pione/location.rb +1 -0
- data/lib/pione/location/data-location.rb +41 -13
- data/lib/pione/location/dropbox-location.rb +175 -56
- data/lib/pione/location/ftp-location.rb +4 -1
- data/lib/pione/location/http-location.rb +5 -3
- data/lib/pione/location/https-location.rb +4 -2
- data/lib/pione/location/local-location.rb +6 -3
- data/lib/pione/location/location-exception.rb +12 -0
- data/lib/pione/location/notification-scheme.rb +46 -0
- data/lib/pione/log.rb +8 -7
- data/lib/pione/log/debug.rb +9 -9
- data/lib/pione/log/domain-log.rb +6 -1
- data/lib/pione/log/message-log-receiver.rb +32 -0
- data/lib/pione/log/system-log.rb +62 -141
- data/lib/pione/model.rb +7 -0
- data/lib/pione/model/notification-listener-model.rb +29 -0
- data/lib/pione/model/task-worker-broker-model.rb +129 -0
- data/lib/pione/notification.rb +13 -0
- data/lib/pione/notification/address.rb +104 -0
- data/lib/pione/notification/exception.rb +10 -0
- data/lib/pione/notification/message.rb +109 -0
- data/lib/pione/notification/receiver.rb +90 -0
- data/lib/pione/notification/recipient.rb +68 -0
- data/lib/pione/notification/task-worker-broker-recipient.rb +85 -0
- data/lib/pione/notification/transmitter.rb +84 -0
- data/lib/pione/pnml.rb +35 -0
- data/lib/pione/pnml/annotation-extractor.rb +47 -0
- data/lib/pione/pnml/compiler.rb +176 -0
- data/lib/pione/pnml/input-merge-complement.rb +78 -0
- data/lib/pione/pnml/input-parallelization-complement.rb +75 -0
- data/lib/pione/pnml/input-reduction.rb +80 -0
- data/lib/pione/pnml/invalid-arc-elimination.rb +41 -0
- data/lib/pione/pnml/io-expansion.rb +88 -0
- data/lib/pione/pnml/isolated-element-elimination.rb +32 -0
- data/lib/pione/pnml/net-rewriter.rb +44 -0
- data/lib/pione/pnml/output-decomposition-complement.rb +77 -0
- data/lib/pione/pnml/output-reduction.rb +86 -0
- data/lib/pione/pnml/output-synchronization-complement.rb +77 -0
- data/lib/pione/pnml/pione-model.rb +417 -0
- data/lib/pione/pnml/pnml-exception.rb +23 -0
- data/lib/pione/pnml/pnml-model.rb +368 -0
- data/lib/pione/pnml/reader.rb +51 -0
- data/lib/pione/rule-engine/action-handler.rb +8 -6
- data/lib/pione/rule-engine/basic-handler.rb +5 -5
- data/lib/pione/rule-engine/engine-exception.rb +7 -6
- data/lib/pione/rule-engine/flow-handler.rb +27 -18
- data/lib/pione/system.rb +3 -1
- data/lib/pione/system/domain-dump.rb +34 -0
- data/lib/pione/system/file-cache.rb +92 -13
- data/lib/pione/system/init.rb +3 -0
- data/lib/pione/system/normalizer.rb +40 -0
- data/lib/pione/system/status.rb +5 -5
- data/lib/pione/system/system-exception.rb +14 -1
- data/lib/pione/task-worker-broker.rb +7 -0
- data/lib/pione/task-worker-broker/basic-provider.rb +20 -0
- data/lib/pione/task-worker-broker/easy-provider.rb +65 -0
- data/lib/pione/test-helper.rb +27 -0
- data/lib/pione/test-helper/command-helper.rb +9 -101
- data/lib/pione/tuple-space/basic-tuple.rb +1 -1
- data/lib/pione/tuple-space/tuple-definition.yml +4 -6
- data/lib/pione/tuple-space/tuple-space-interface.rb +3 -45
- data/lib/pione/tuple-space/tuple-space-server.rb +45 -0
- data/lib/pione/util.rb +1 -2
- data/lib/pione/util/boolean-value.rb +62 -0
- data/lib/pione/util/completion.rb +111 -0
- data/lib/pione/util/evaluatable.rb +13 -27
- data/lib/pione/util/package-parameters-list.rb +15 -27
- data/lib/pione/util/zip.rb +8 -3
- data/lib/pione/version.rb +1 -1
- data/lib/rootage.rb +20 -0
- data/lib/rootage/action.rb +114 -0
- data/lib/rootage/argument.rb +46 -0
- data/lib/rootage/command.rb +218 -0
- data/lib/rootage/core.rb +532 -0
- data/lib/rootage/exception.rb +107 -0
- data/lib/rootage/help.rb +148 -0
- data/lib/rootage/help.txt.erb +31 -0
- data/lib/rootage/log.rb +226 -0
- data/lib/rootage/normalizer.rb +184 -0
- data/lib/rootage/option.rb +152 -0
- data/lib/rootage/scenario-test-result.erb +39 -0
- data/lib/rootage/scenario.rb +362 -0
- data/lib/rootage/test-helper.rb +115 -0
- data/man/pione-list-param.1 +44 -0
- data/misc/clock.rb +9 -0
- data/misc/machine-info.sh +21 -0
- data/misc/pione-completion.bash +238 -0
- data/misc/pione-completion.erb +53 -0
- data/misc/pione-completion.zsh +238 -0
- data/misc/pione.god +22 -0
- data/misc/ui.xml +23 -0
- data/pione.gemspec +3 -1
- data/test/agent/spec_basic-agent.rb +1 -1
- data/test/agent/spec_input-generator.rb +2 -2
- data/test/agent/spec_messenger.rb +6 -9
- data/test/agent/spec_notification-listener.rb +80 -0
- data/test/agent/{spec_broker.rb → spec_task-worker-broker.rb} +13 -10
- data/test/agent/spec_tuple-space-provider.rb +10 -6
- data/test/command/command-behavior.rb +3 -11
- data/test/command/data/pione-list-param/AdvancedParameters.pione +12 -0
- data/test/command/data/pione-list-param/BasicParameters.pione +12 -0
- data/test/command/spec_pione-action-exec.rb +16 -0
- data/test/command/spec_pione-action-list.rb +15 -10
- data/test/command/spec_pione-action-print.rb +14 -0
- data/test/command/spec_pione-action.rb +6 -19
- data/test/command/spec_pione-clean.rb +29 -46
- data/test/command/spec_pione-client.rb +29 -36
- data/test/command/spec_pione-command.rb +6 -6
- data/test/command/{spec_pione-compiler.rb → spec_pione-compile.rb} +11 -13
- data/test/command/spec_pione-config-get.rb +47 -0
- data/test/command/spec_pione-config-list.rb +42 -0
- data/test/command/spec_pione-config-set.rb +38 -0
- data/test/command/spec_pione-config-unset.rb +44 -0
- data/test/command/spec_pione-config.rb +11 -0
- data/test/command/spec_pione-diagnosis-notification.rb +23 -0
- data/test/command/spec_pione-diagnosis.rb +11 -0
- data/test/command/spec_pione-lang-check-syntax.rb +12 -0
- data/test/command/spec_pione-lang.rb +11 -0
- data/test/command/spec_pione-log-format.rb +29 -0
- data/test/command/spec_pione-log-list-id.rb +17 -0
- data/test/command/spec_pione-log.rb +6 -20
- data/test/command/spec_pione-package-add.rb +55 -0
- data/test/command/spec_pione-package-build.rb +57 -0
- data/test/command/spec_pione-package-show.rb +72 -0
- data/test/command/{spec_pione-update-package-info.rb → spec_pione-package-update.rb} +12 -13
- data/test/command/spec_pione-package.rb +4 -104
- data/test/command/spec_pione-val.rb +10 -7
- data/test/global/spec_config.rb +50 -0
- data/test/global/spec_item.rb +1 -1
- data/test/literate-action/data/HelloWorld.md +1 -1
- data/test/location/location-behavior.rb +1 -1
- data/test/location/spec_dropbox-location.rb +39 -0
- data/test/location/spec_notification-scheme.rb +37 -0
- data/test/log/spec_debug.rb +5 -4
- data/test/log/spec_message-log-receiver.rb +13 -0
- data/test/log/spec_message-log.rb +6 -9
- data/test/log/spec_system-log.rb +5 -3
- data/test/notification/spec_address.rb +229 -0
- data/test/notification/spec_message.rb +30 -0
- data/test/notification/spec_receiver.rb +36 -0
- data/test/notification/spec_transmitter.rb +37 -0
- data/test/pnml/data/ConditionalBranchIf.pnml +270 -0
- data/test/pnml/data/ConditionalBranchIfElse.pnml +309 -0
- data/test/pnml/data/IOExpansionComplex.pnml +363 -0
- data/test/pnml/data/IOExpansionSimple.pnml +140 -0
- data/test/pnml/data/InputMergeComplementComplex.pnml +381 -0
- data/test/pnml/data/InputMergeComplementSimple.pnml +248 -0
- data/test/pnml/data/InputParallelizationComplementComplex.pnml +433 -0
- data/test/pnml/data/InputParallelizationComplementSimple.pnml +288 -0
- data/test/pnml/data/InputReductionComplex.pnml +192 -0
- data/test/pnml/data/InputReductionLong.pnml +344 -0
- data/test/pnml/data/InputReductionSimple.pnml +140 -0
- data/test/pnml/data/IsolatedElementElimination.pnml +171 -0
- data/test/pnml/data/OutputDecompositionComplementComplex.pnml +381 -0
- data/test/pnml/data/OutputDecompositionComplementSimple.pnml +242 -0
- data/test/pnml/data/OutputReductionComplex.pnml +186 -0
- data/test/pnml/data/OutputReductionLong.pnml +344 -0
- data/test/pnml/data/OutputReductionSimple.pnml +140 -0
- data/test/pnml/data/OutputSynchronizationComplementComplex.pnml +498 -0
- data/test/pnml/data/OutputSynchronizationComplementSimple.pnml +347 -0
- data/test/pnml/data/SampleNet.pnml +238 -0
- data/test/pnml/spec_input-merge-complement.rb +40 -0
- data/test/pnml/spec_input-parallelization-complement.rb +50 -0
- data/test/pnml/spec_input-reduction.rb +113 -0
- data/test/pnml/spec_invalid-arc-elimination.rb +33 -0
- data/test/pnml/spec_io-expansion.rb +126 -0
- data/test/pnml/spec_isolated-element-elimination.rb +25 -0
- data/test/pnml/spec_output-decomposition-complement.rb +40 -0
- data/test/pnml/spec_output-reduction.rb +114 -0
- data/test/pnml/spec_output-synchronization-complement.rb +62 -0
- data/test/pnml/spec_pione-element.rb +144 -0
- data/test/pnml/spec_pnml-element.rb +373 -0
- data/test/pnml/spec_reader.rb +16 -0
- data/test/rootage/spec_argument.rb +18 -0
- data/test/rootage/spec_command.rb +239 -0
- data/test/rootage/spec_core.rb +198 -0
- data/test/rootage/spec_scenario.rb +149 -0
- data/test/system/{spec_domain-info.rb → spec_domain-dump.rb} +6 -6
- data/test/system/spec_file-cache.rb +6 -9
- data/test/tuple-space/spec_finished-tuple.rb +1 -1
- data/test/util/{spec_package-parameters-list_1.pione → data/package-parameters-list/Param1.pione} +0 -0
- data/test/util/{spec_package-parameters-list_2.pione → data/package-parameters-list/Param2.pione} +0 -0
- data/test/util/{spec_package-parameters-list_3.pione → data/package-parameters-list/Param3.pione} +0 -0
- data/test/util/{spec_package-parameters-list_4.pione → data/package-parameters-list/Param4.pione} +0 -0
- data/test/util/spec_boolean-value.rb +32 -0
- data/test/util/spec_completion.rb +22 -0
- data/test/util/spec_package-parameters-list.rb +39 -52
- data/test/util/spec_zip.rb +28 -1
- metadata +288 -47
- data/bin/pione-tuple-space-receiver +0 -5
- data/lib/pione/agent/broker.rb +0 -304
- data/lib/pione/agent/tuple-space-receiver.rb +0 -137
- data/lib/pione/command/pione-broker.rb +0 -104
- data/lib/pione/command/pione-compiler.rb +0 -57
- data/lib/pione/command/pione-relay-account-db.rb +0 -141
- data/lib/pione/command/pione-relay-client-db.rb +0 -118
- data/lib/pione/command/pione-relay.rb +0 -59
- data/lib/pione/command/pione-syntax-checker.rb +0 -214
- data/lib/pione/command/pione-tuple-space-receiver.rb +0 -111
- data/lib/pione/command/pione-update-package-info.rb +0 -53
- data/lib/pione/front/broker-front.rb +0 -22
- data/lib/pione/front/tuple-space-receiver-front.rb +0 -11
- data/lib/pione/global/broker-variable.rb +0 -33
- data/lib/pione/system/domain-info.rb +0 -25
- data/lib/pione/util/pnml-compiler.rb +0 -168
- data/test/agent/spec_tuple-space-receiver.rb +0 -47
- data/test/util/spec_pnml-compiler.rb +0 -32
@@ -0,0 +1,88 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneTaskWorkerBroker` is a command that starts activity of task worker
|
4
|
+
# broker agent. This command will spawn `pione-task-worker`.
|
5
|
+
class PioneTaskWorkerBroker < BasicCommand
|
6
|
+
#
|
7
|
+
# informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:toplevel, true)
|
11
|
+
define(:name, "pione-task-worker-broker")
|
12
|
+
define(:desc, "run task worker broker agent to launch task workers")
|
13
|
+
define(:front, Front::TaskWorkerBrokerFront)
|
14
|
+
define(:model, Model::TaskWorkerBrokerModel)
|
15
|
+
define(:notification_recipient, Notification::TaskWorkerBrokerRecipient) {|cmd, model|
|
16
|
+
[model, Global.notification_listener]
|
17
|
+
}
|
18
|
+
|
19
|
+
#
|
20
|
+
# options
|
21
|
+
#
|
22
|
+
|
23
|
+
option(CommonOption.color)
|
24
|
+
option(CommonOption.debug)
|
25
|
+
option(CommonOption.features)
|
26
|
+
option(CommonOption.communication_address)
|
27
|
+
option(CommonOption.task_worker_size) do |item|
|
28
|
+
item.type = :positive_integer
|
29
|
+
end
|
30
|
+
option CommonOption.file_cache_method
|
31
|
+
option CommonOption.file_sliding
|
32
|
+
|
33
|
+
#
|
34
|
+
# command lifecycle: setup phase
|
35
|
+
#
|
36
|
+
|
37
|
+
phase(:setup) do |item|
|
38
|
+
item.configure(:timeout => 10)
|
39
|
+
item << :task_worker_broker_agent
|
40
|
+
end
|
41
|
+
|
42
|
+
setup(:task_worker_broker_agent) do |item|
|
43
|
+
item.desc = "Create a task worker broker agent"
|
44
|
+
|
45
|
+
item.assign(:task_worker_broker_agent) do
|
46
|
+
Agent::TaskWorkerBroker.new(model)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# command lifecycle: execution phase
|
52
|
+
#
|
53
|
+
|
54
|
+
phase(:execution) do |item|
|
55
|
+
item << :task_worker_broker_agent
|
56
|
+
end
|
57
|
+
|
58
|
+
execution(:task_worker_broker_agent) do |item|
|
59
|
+
item.desc = "Start agent activity of task worker broker"
|
60
|
+
|
61
|
+
item.process do
|
62
|
+
model[:task_worker_broker_agent].start!
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# command lifecycle: termination phase
|
68
|
+
#
|
69
|
+
|
70
|
+
phase(:termination) do |item|
|
71
|
+
item.configure(:timeout => 15)
|
72
|
+
item << ProcessAction.terminate_children
|
73
|
+
item << :task_worker_broker_agent
|
74
|
+
end
|
75
|
+
|
76
|
+
termination(:task_worker_broker_agent) do |item|
|
77
|
+
item.desc = "Terminate the agent"
|
78
|
+
|
79
|
+
item.process do
|
80
|
+
test(model[:task_worker_broker_agent])
|
81
|
+
test(not(model[:task_worker_broker_agent].terminated?))
|
82
|
+
|
83
|
+
model[:task_worker_broker_agent].terminate
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -1,65 +1,64 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
-
#
|
3
|
+
# `PioneTaskWorker` is a command that runs pione task worker agents.
|
4
4
|
class PioneTaskWorker < BasicCommand
|
5
|
-
#
|
6
|
-
# basic informations
|
7
|
-
#
|
8
|
-
|
9
|
-
command_name "pione-task-worker" do |cmd|
|
10
|
-
"front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
|
11
|
-
end
|
12
|
-
|
13
|
-
command_banner(Util::Indentation.cut(<<-TEXT))
|
14
|
-
Run a task worker process. This command assumes to be launched by
|
15
|
-
pione-client or pione-broker, so you should not execute this by hand.
|
16
|
-
TEXT
|
17
|
-
|
18
|
-
command_front Front::TaskWorkerFront
|
19
|
-
|
20
|
-
#
|
21
|
-
# options
|
22
|
-
#
|
23
|
-
|
24
|
-
use_option :color
|
25
|
-
use_option :debug
|
26
|
-
use_option :my_ip_address
|
27
|
-
use_option :parent_front
|
28
|
-
use_option :features
|
29
|
-
|
30
|
-
define_option(:tuple_space_id) do |item|
|
31
|
-
item.long = '--tuple-space-id=UUID'
|
32
|
-
item.desc = 'tuple space id that the worker joins'
|
33
|
-
item.requisite = true
|
34
|
-
item.value = proc {|id| id}
|
35
|
-
end
|
36
|
-
|
37
5
|
#
|
38
6
|
# class methods
|
39
7
|
#
|
40
8
|
|
41
|
-
# Create a new process of
|
42
|
-
def self.spawn(features, tuple_space_id)
|
43
|
-
spawner = Spawner.new("pione-task-worker")
|
9
|
+
# Create a new process of `pione-task-worker` command.
|
10
|
+
def self.spawn(model, features, tuple_space_id)
|
11
|
+
spawner = Spawner.new(model, "pione-task-worker")
|
44
12
|
|
45
13
|
# debug options
|
46
14
|
spawner.option("--debug=system") if Global.debug_system
|
47
15
|
spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
|
48
16
|
spawner.option("--debug=rule_engine") if Global.debug_rule_engine
|
49
17
|
spawner.option("--debug=communication") if Global.debug_communication
|
50
|
-
spawner.option("--debug=
|
18
|
+
spawner.option("--debug=notification") if Global.debug_notification
|
51
19
|
|
52
20
|
# requisite options
|
53
|
-
spawner.option("--parent-front",
|
21
|
+
spawner.option("--parent-front", model[:front].uri.to_s)
|
54
22
|
spawner.option("--tuple-space-id", tuple_space_id)
|
55
23
|
spawner.option("--features", features) if features
|
56
24
|
|
57
|
-
#
|
58
|
-
spawner.option("--color"
|
25
|
+
# others
|
26
|
+
spawner.option("--color", Global.color_enabled)
|
27
|
+
spawner.option("--file-cache-method", System::FileCache.cache_method.name.to_s)
|
28
|
+
spawner.option("--file-sliding", Global.file_sliding)
|
59
29
|
|
60
30
|
spawner.spawn # this method returns child front
|
61
31
|
end
|
62
32
|
|
33
|
+
#
|
34
|
+
# informations
|
35
|
+
#
|
36
|
+
|
37
|
+
define(:toplevel, true)
|
38
|
+
define(:name, "pione-task-worker")
|
39
|
+
define(:desc, "process tasks")
|
40
|
+
define(:front, Front::TaskWorkerFront)
|
41
|
+
|
42
|
+
#
|
43
|
+
# options
|
44
|
+
#
|
45
|
+
|
46
|
+
option CommonOption.color
|
47
|
+
option CommonOption.debug
|
48
|
+
option CommonOption.communication_address
|
49
|
+
option CommonOption.parent_front
|
50
|
+
option CommonOption.features
|
51
|
+
option CommonOption.file_cache_method
|
52
|
+
option CommonOption.file_sliding
|
53
|
+
|
54
|
+
option(:tuple_space_id) do |item|
|
55
|
+
item.type = :string
|
56
|
+
item.long = '--tuple-space-id'
|
57
|
+
item.arg = 'UUID'
|
58
|
+
item.desc = 'Tuple space ID that the worker joins'
|
59
|
+
item.requisite = true
|
60
|
+
end
|
61
|
+
|
63
62
|
#
|
64
63
|
# instance methods
|
65
64
|
#
|
@@ -71,50 +70,79 @@ module Pione
|
|
71
70
|
# command lifecycle: setup phase
|
72
71
|
#
|
73
72
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
73
|
+
phase(:setup) do |item|
|
74
|
+
item.configure(:timeout => 15)
|
75
|
+
|
76
|
+
item << ProcessAction.connect_parent
|
77
|
+
item << :tuple_space
|
78
|
+
item << :task_worker_agent
|
79
|
+
item << :job_terminator
|
80
|
+
item << :base_location
|
81
|
+
end
|
80
82
|
|
81
|
-
|
82
|
-
|
83
|
-
@tuple_space = option[:parent_front].get_tuple_space(option[:tuple_space_id])
|
83
|
+
setup(:tuple_space) do |item|
|
84
|
+
item.desc = "Get a tuple space from parent"
|
84
85
|
|
85
|
-
|
86
|
-
|
86
|
+
item.assign(:tuple_space) do
|
87
|
+
model[:parent_front].get_tuple_space(model[:tuple_space_id])
|
87
88
|
end
|
88
89
|
|
89
|
-
|
90
|
-
|
90
|
+
item.process do
|
91
|
+
test(not(model[:tuple_space]))
|
92
|
+
|
93
|
+
arg = {name: cmd.name, id: option[:tuple_space_id]}
|
94
|
+
cmd.abort('"%{name}" cannot get the tuple space "%{id}".' % arg)
|
95
|
+
end
|
96
|
+
|
97
|
+
item.process do
|
98
|
+
if Util.error?(:timeout => 3) {model[:tuple_space].uuid}
|
99
|
+
cmd.abort('"%{name}" cannot connect to tuple space.' % {name: cmd.name})
|
100
|
+
end
|
91
101
|
end
|
92
102
|
end
|
93
103
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
104
|
+
setup(:task_worker_agent) do |item|
|
105
|
+
item.desc = "Create a task worker agent"
|
106
|
+
|
107
|
+
item.assign(:task_worker_agent) do
|
108
|
+
Agent::TaskWorker.new(model[:tuple_space], Global.expressional_features)
|
109
|
+
end
|
110
|
+
|
111
|
+
item.exception(Agent::TupleSpaceError) do |e|
|
112
|
+
cmd.abort(e)
|
113
|
+
end
|
99
114
|
end
|
100
115
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
116
|
+
setup(:base_location) do |item|
|
117
|
+
item.desc = "Get a base location"
|
118
|
+
|
119
|
+
item.assign(:base_location) do
|
120
|
+
model[:tuple_space].base_location
|
121
|
+
end
|
122
|
+
|
123
|
+
item.process do
|
124
|
+
# enable Dropbox location
|
125
|
+
if model[:base_location].is_a?(Location::DropboxLocation)
|
126
|
+
begin
|
127
|
+
Location::DropboxLocation.enable(model[:tuple_space])
|
128
|
+
rescue Location::DropboxLocationUnavailable => e
|
129
|
+
arg = {addr: model[:base_location].address}
|
130
|
+
cmd.abort('Base location "%{addr}" is on Dropbox, but it is not ready.' % arg)
|
131
|
+
end
|
107
132
|
end
|
108
133
|
end
|
109
134
|
end
|
110
135
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
136
|
+
setup(:job_terminator) do |item|
|
137
|
+
item.desc = "Create a job terminator and setup the action"
|
138
|
+
|
139
|
+
item.assign(:job_terminator) do
|
140
|
+
Agent::JobTerminator.new(model[:tuple_space]) do |status|
|
141
|
+
if status.error?
|
142
|
+
cmd.abort('"%s" catched the error: %s' % [cmd.name, status.message])
|
143
|
+
else
|
144
|
+
cmd.terminate
|
145
|
+
end
|
118
146
|
end
|
119
147
|
end
|
120
148
|
end
|
@@ -123,50 +151,72 @@ module Pione
|
|
123
151
|
# command lifecycle: execution phase
|
124
152
|
#
|
125
153
|
|
126
|
-
|
127
|
-
|
128
|
-
|
154
|
+
phase(:execution) do |item|
|
155
|
+
item << :job_terminator
|
156
|
+
item << :task_worker_agent
|
157
|
+
|
158
|
+
item.exception(DRb::DRbConnError) do |e|
|
159
|
+
Log::Debug.system do
|
160
|
+
"%s goes termination phase because the exception was catched: %s" % [cmd.name, e.message]
|
161
|
+
end
|
162
|
+
cmd.terminate
|
129
163
|
end
|
130
|
-
cmd.terminate
|
131
164
|
end
|
132
|
-
execute :job_terminator
|
133
|
-
execute :agent
|
134
165
|
|
135
|
-
|
136
|
-
|
137
|
-
|
166
|
+
execution(:job_terminator) do |item|
|
167
|
+
item.desc = "Start the job terminator"
|
168
|
+
|
169
|
+
item.process do
|
170
|
+
model[:job_terminator].start
|
171
|
+
end
|
138
172
|
end
|
139
173
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
174
|
+
execution(:task_worker_agent) do |item|
|
175
|
+
item.desc = "Start task worker activity and wait the termination"
|
176
|
+
|
177
|
+
item.process do
|
178
|
+
model[:task_worker_agent].start
|
179
|
+
model[:task_worker_agent].wait_until_terminated(nil)
|
180
|
+
end
|
144
181
|
end
|
145
182
|
|
146
183
|
#
|
147
184
|
# command lifecycle: termination phase
|
148
185
|
#
|
149
186
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
187
|
+
phase(:termination) do |item|
|
188
|
+
item.configure(:timeout => 10)
|
189
|
+
item << ProcessAction.disconnect_parent
|
190
|
+
item << :job_terminator
|
191
|
+
item << :task_worker_agent
|
192
|
+
end
|
193
|
+
|
194
|
+
termination(:job_terminator) do |item|
|
195
|
+
item.desc = "Terminate job terminator agent"
|
154
196
|
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
197
|
+
item.condition do
|
198
|
+
test(model[:job_terminator])
|
199
|
+
test(not(model[:job_terminator].terminated?))
|
200
|
+
end
|
201
|
+
|
202
|
+
item.process do
|
203
|
+
model[:job_terminator].terminate
|
159
204
|
end
|
160
205
|
end
|
161
206
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
207
|
+
termination(:task_worker_agent) do |item|
|
208
|
+
item.desc = "Terminate task worker agent"
|
209
|
+
|
210
|
+
item.condition do
|
211
|
+
test(model[:task_worker_agent])
|
212
|
+
test(not(model[:task_worker_agent].terminated?))
|
213
|
+
end
|
214
|
+
|
215
|
+
item.process do
|
216
|
+
model[:task_worker_agent].terminate
|
217
|
+
model[:task_worker_agent].wait_until_terminated(nil)
|
167
218
|
end
|
168
219
|
end
|
169
220
|
end
|
170
221
|
end
|
171
222
|
end
|
172
|
-
|
@@ -1,101 +1,109 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
-
# PioneTupleSpaceProvider is for
|
3
|
+
# `PioneTupleSpaceProvider` is for `pione-tuple-space-provider` command.
|
4
4
|
class PioneTupleSpaceProvider < BasicCommand
|
5
|
-
#
|
6
|
-
# command info
|
7
|
-
#
|
8
|
-
|
9
|
-
command_name "pione-tuple-space-provider" do |cmd|
|
10
|
-
"front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
|
11
|
-
end
|
12
|
-
|
13
|
-
command_banner(Util::Indentation.cut(<<-TXT))
|
14
|
-
Run tuple space provider process for sending tuple space presence
|
15
|
-
notifier. This command assumes to be launched by other processes like
|
16
|
-
pione-client or pione-relay.
|
17
|
-
TXT
|
18
|
-
|
19
|
-
command_front Pione::Front::TupleSpaceProviderFront do |cmd|
|
20
|
-
[cmd.option[:parent_front].get_tuple_space(nil)]
|
21
|
-
end
|
22
|
-
|
23
|
-
#
|
24
|
-
# options
|
25
|
-
#
|
26
|
-
|
27
|
-
use_option :color
|
28
|
-
use_option :debug
|
29
|
-
use_option :my_ip_address
|
30
|
-
use_option :parent_front
|
31
|
-
use_option :presence_notification_address
|
32
|
-
|
33
5
|
#
|
34
6
|
# class methods
|
35
7
|
#
|
36
8
|
|
37
9
|
# Create a new process of tuple space provider command.
|
38
|
-
def self.spawn
|
39
|
-
spawner = Spawner.new(
|
10
|
+
def self.spawn(cmd)
|
11
|
+
spawner = Spawner.new(cmd.model, "pione-tuple-space-provider")
|
40
12
|
|
41
13
|
# debug options
|
42
14
|
spawner.option("--debug=system") if Global.debug_system
|
43
15
|
spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
|
44
16
|
spawner.option("--debug=rule_engine") if Global.debug_rule_engine
|
45
17
|
spawner.option("--debug=communication") if Global.debug_communication
|
46
|
-
spawner.option("--debug=
|
18
|
+
spawner.option("--debug=notification") if Global.debug_notification
|
47
19
|
|
48
20
|
# requisite options
|
49
|
-
spawner.option("--parent-front",
|
50
|
-
spawner.option("--
|
51
|
-
Global.
|
52
|
-
spawner.option("--
|
21
|
+
spawner.option("--parent-front", cmd.model[:front].uri.to_s)
|
22
|
+
spawner.option("--communication-address", Global.communication_address.to_s)
|
23
|
+
Global.notification_targets.each do |address|
|
24
|
+
spawner.option("--notification-target", address.to_s)
|
53
25
|
end
|
54
26
|
|
55
27
|
# optionals
|
56
|
-
spawner.option("--color"
|
28
|
+
spawner.option("--color", Global.color_enabled)
|
57
29
|
|
58
30
|
spawner.spawn
|
59
31
|
end
|
60
32
|
|
61
33
|
#
|
62
|
-
#
|
34
|
+
# informations
|
63
35
|
#
|
64
36
|
|
65
|
-
|
37
|
+
define(:toplevel, true)
|
38
|
+
define(:name, "pione-tuple-space-provider")
|
39
|
+
define(:desc, "run tuple space provider agent")
|
40
|
+
define(:front, Pione::Front::TupleSpaceProviderFront)
|
41
|
+
|
42
|
+
#
|
43
|
+
# options
|
44
|
+
#
|
45
|
+
|
46
|
+
option CommonOption.color
|
47
|
+
option CommonOption.debug
|
48
|
+
option CommonOption.communication_address
|
49
|
+
option CommonOption.parent_front
|
50
|
+
option NotificationOption.notification_targets
|
66
51
|
|
67
52
|
#
|
68
53
|
# command lifecycle: setup phase
|
69
54
|
#
|
70
55
|
|
71
|
-
|
72
|
-
|
56
|
+
phase(:setup) do |item|
|
57
|
+
item.configure(:timeout => 5)
|
58
|
+
|
59
|
+
item << ProcessAction.connect_parent
|
60
|
+
end
|
73
61
|
|
74
62
|
#
|
75
63
|
# command lifecycle: execution phase
|
76
64
|
#
|
77
65
|
|
78
|
-
|
66
|
+
phase(:execution) do |item|
|
67
|
+
item << :start_agent
|
68
|
+
item << :wait_agent
|
69
|
+
end
|
70
|
+
|
71
|
+
execution(:start_agent) do |item|
|
72
|
+
item.desc = "Start an agent activity"
|
79
73
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
74
|
+
item.assign(:agent) do
|
75
|
+
Agent::TupleSpaceProvider.start(model[:front].uri)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
execution(:wait_agent) do |item|
|
80
|
+
item.desc = "Wait agent to terminate"
|
81
|
+
|
82
|
+
item.process do
|
83
|
+
model[:agent].wait_until_terminated(nil)
|
84
|
+
end
|
84
85
|
end
|
85
86
|
|
86
87
|
#
|
87
88
|
# command lifecycle: termination phase
|
88
89
|
#
|
89
90
|
|
90
|
-
|
91
|
-
|
92
|
-
|
91
|
+
phase(:termination) do |seq|
|
92
|
+
seq.configure(:timeout => 5)
|
93
|
+
|
94
|
+
seq << :agent
|
95
|
+
seq << ProcessAction.disconnect_parent
|
96
|
+
end
|
97
|
+
|
98
|
+
termination(:agent) do |item|
|
99
|
+
item.desc = "Terminate the agent"
|
100
|
+
|
101
|
+
item.process do
|
102
|
+
test(model[:agent])
|
103
|
+
test(model[:agent].terminated?)
|
93
104
|
|
94
|
-
|
95
|
-
|
96
|
-
if @agent and not(@agent.terminated?)
|
97
|
-
@agent.terminate
|
98
|
-
@agent.wait_until_terminated(nil)
|
105
|
+
model[:agent].terminate
|
106
|
+
model[:agent].wait_until_terminated(nil)
|
99
107
|
end
|
100
108
|
end
|
101
109
|
end
|