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
@@ -1,45 +1,28 @@
|
|
1
1
|
module Pione
|
2
2
|
module Command
|
3
|
-
# PioneCommand is a facade command for PIONE's various functions.
|
3
|
+
# `PioneCommand` is a facade command for PIONE's various functions.
|
4
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
5
|
#
|
18
6
|
# basic informations
|
19
7
|
#
|
20
8
|
|
21
|
-
|
22
|
-
|
23
|
-
|
9
|
+
define(:toplevel, true)
|
10
|
+
define(:name, "pione")
|
11
|
+
define(:desc, "PIONE's utility command set")
|
24
12
|
|
25
13
|
#
|
26
|
-
#
|
14
|
+
# requirements
|
27
15
|
#
|
28
16
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
cmd.run(@argv.drop(1))
|
39
|
-
else
|
40
|
-
abort("no such subcommand: %s" % name)
|
41
|
-
end
|
42
|
-
end
|
17
|
+
require 'pione/command/pione-action'
|
18
|
+
require 'pione/command/pione-clean'
|
19
|
+
require 'pione/command/pione-config'
|
20
|
+
require 'pione/command/pione-diagnosis'
|
21
|
+
require 'pione/command/pione-lang'
|
22
|
+
require 'pione/command/pione-log'
|
23
|
+
require 'pione/command/pione-package'
|
24
|
+
require 'pione/command/pione-val'
|
25
|
+
require 'pione/command/pione-compile'
|
43
26
|
end
|
44
27
|
end
|
45
28
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# PioneCompile is a subcommand body of "pione compile".
|
4
|
+
class PioneCompile < BasicCommand
|
5
|
+
#
|
6
|
+
# basic informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "pione compile")
|
10
|
+
define(:desc, "translate from PNML to PIONE document")
|
11
|
+
|
12
|
+
#
|
13
|
+
# arguments
|
14
|
+
#
|
15
|
+
|
16
|
+
argument(:source) do |item|
|
17
|
+
item.type = :location
|
18
|
+
item.desc = "source PNML file"
|
19
|
+
end
|
20
|
+
|
21
|
+
#
|
22
|
+
# options
|
23
|
+
#
|
24
|
+
|
25
|
+
option(CommonOption.debug)
|
26
|
+
|
27
|
+
option(:flow_name) do |item|
|
28
|
+
item.type = :string
|
29
|
+
item.long = '--flow-name'
|
30
|
+
item.arg = 'NAME'
|
31
|
+
item.desc = 'Set flow name'
|
32
|
+
end
|
33
|
+
|
34
|
+
option(:package_name) do |item|
|
35
|
+
item.type = :string
|
36
|
+
item.long = '--package-name'
|
37
|
+
item.arg = 'NAME'
|
38
|
+
item.desc = 'Set package name'
|
39
|
+
end
|
40
|
+
|
41
|
+
option(:editor) do |item|
|
42
|
+
item.type = :string
|
43
|
+
item.long = '--editor'
|
44
|
+
item.arg = 'NAME'
|
45
|
+
item.desc = 'Set package editor'
|
46
|
+
end
|
47
|
+
|
48
|
+
option(:tag) do |item|
|
49
|
+
item.type = :string
|
50
|
+
item.long = '--tag'
|
51
|
+
item.arg = 'NAME'
|
52
|
+
item.desc = 'Set package tag'
|
53
|
+
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# command lifecycle: execution phase
|
57
|
+
#
|
58
|
+
|
59
|
+
phase(:execution) do |item|
|
60
|
+
item << :compile_pnml
|
61
|
+
item << :print
|
62
|
+
end
|
63
|
+
|
64
|
+
execution(:compile_pnml) do |item|
|
65
|
+
item.desc = "Compile from PNML to PIONE"
|
66
|
+
|
67
|
+
item.assign(:result) do
|
68
|
+
net = PNML::Reader.read(model[:source])
|
69
|
+
option = {
|
70
|
+
:flow_name => model[:flow_name],
|
71
|
+
:package_name => model[:package_name],
|
72
|
+
:editor => model[:editor],
|
73
|
+
:tag => model[:tag]
|
74
|
+
}
|
75
|
+
PNML::Compiler.new(net, option).compile
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
execution(:print) do |item|
|
80
|
+
item.desc = "Print the PIONE document"
|
81
|
+
|
82
|
+
item.process do
|
83
|
+
print model[:result]
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
PioneCommand.define_subcommand("compile", PioneCompile)
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneConfigGet` is a command for getting a value of PIONE global
|
4
|
+
# variable.
|
5
|
+
class PioneConfigGet < BasicCommand
|
6
|
+
#
|
7
|
+
# basic informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:name, "get")
|
11
|
+
define(:desc, "Get a value of PIONE global variable")
|
12
|
+
|
13
|
+
#
|
14
|
+
# arguments
|
15
|
+
#
|
16
|
+
|
17
|
+
argument(:name) do |item|
|
18
|
+
item.type = :string
|
19
|
+
item.desc = "Variable name"
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# options
|
24
|
+
#
|
25
|
+
|
26
|
+
option CommonOption.debug
|
27
|
+
option PioneConfigOption.file
|
28
|
+
|
29
|
+
#
|
30
|
+
# command lifecycle: execution phase
|
31
|
+
#
|
32
|
+
|
33
|
+
phase(:execution) do |item|
|
34
|
+
item << PioneConfigAction.load_config
|
35
|
+
item << :get
|
36
|
+
end
|
37
|
+
|
38
|
+
execution(:get) do |item|
|
39
|
+
desc = "Get the value"
|
40
|
+
|
41
|
+
item.process do
|
42
|
+
puts model[:config].get(model[:name])
|
43
|
+
end
|
44
|
+
|
45
|
+
item.exception(Global::UnconfigurableVariableError) do |e|
|
46
|
+
cmd.abort("'%s' is not a configurable item name." % model[:name])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
PioneConfig.define_subcommand("get", PioneConfigGet)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneConfigList` is a command that lists PIONE global variables.
|
4
|
+
class PioneConfigList < BasicCommand
|
5
|
+
#
|
6
|
+
# informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "list")
|
10
|
+
define(:desc, "List PIONE global variables")
|
11
|
+
|
12
|
+
#
|
13
|
+
# options
|
14
|
+
#
|
15
|
+
|
16
|
+
option CommonOption.debug
|
17
|
+
option PioneConfigOption.file
|
18
|
+
|
19
|
+
#
|
20
|
+
# command lifecycle: execution phase
|
21
|
+
#
|
22
|
+
|
23
|
+
phase(:execution) do |item|
|
24
|
+
item << :collect_items
|
25
|
+
item << :print
|
26
|
+
end
|
27
|
+
|
28
|
+
execution(:collect_items) do |item|
|
29
|
+
item.desc = "List"
|
30
|
+
|
31
|
+
# make items table
|
32
|
+
item.assign(:table) {Hash.new}
|
33
|
+
|
34
|
+
# push configurable global items
|
35
|
+
item.process do
|
36
|
+
Global.item.each do |key, item|
|
37
|
+
if item.configurable?
|
38
|
+
model[:table][key] = item.init
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# push items in config file
|
44
|
+
item.process do
|
45
|
+
Global::Config.new(model[:file]).each do |name, value|
|
46
|
+
model[:table][name] = value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
execution(:print) do |item|
|
52
|
+
item.desc = "Print a list of configurable items"
|
53
|
+
|
54
|
+
item.process do
|
55
|
+
model[:table].keys.sort.each do |name|
|
56
|
+
puts "%s: %s" % [name, model[:table][name]]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
PioneConfig.define_subcommand("list", PioneConfigList)
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneConfigSet` is a command for setting a value of PIONE global
|
4
|
+
# variable.
|
5
|
+
class PioneConfigSet < BasicCommand
|
6
|
+
#
|
7
|
+
# informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:name, "set")
|
11
|
+
define(:desc, "Set a value of PIONE global variable")
|
12
|
+
|
13
|
+
#
|
14
|
+
# arguments
|
15
|
+
#
|
16
|
+
|
17
|
+
argument(:name) do |item|
|
18
|
+
item.type = :string
|
19
|
+
item.desc = "variable name"
|
20
|
+
end
|
21
|
+
|
22
|
+
argument(:value) do |item|
|
23
|
+
item.type = :string
|
24
|
+
item.desc = "variable value"
|
25
|
+
end
|
26
|
+
|
27
|
+
#
|
28
|
+
# options
|
29
|
+
#
|
30
|
+
|
31
|
+
option CommonOption.debug
|
32
|
+
option PioneConfigOption.file
|
33
|
+
|
34
|
+
#
|
35
|
+
# command lifecycle: execution phase
|
36
|
+
#
|
37
|
+
|
38
|
+
phase(:execution) do |item|
|
39
|
+
item << PioneConfigAction.load_config
|
40
|
+
item << :set
|
41
|
+
item << PioneConfigAction.save_config
|
42
|
+
end
|
43
|
+
|
44
|
+
execution(:set) do |item|
|
45
|
+
item.desc = "Set the value"
|
46
|
+
|
47
|
+
item.process do
|
48
|
+
model[:config].set(model[:name], model[:value])
|
49
|
+
end
|
50
|
+
|
51
|
+
item.exception(Global::UnconfigurableVariableError) do |e|
|
52
|
+
cmd.abort("'%s' is not a configurable item name." % cmd.name)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
PioneConfig.define_subcommand("set", PioneConfigSet)
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneConfigUnset` is a command for unsetting a value of PIONE global
|
4
|
+
# variable.
|
5
|
+
class PioneConfigUnset < BasicCommand
|
6
|
+
#
|
7
|
+
# informations
|
8
|
+
#
|
9
|
+
|
10
|
+
define(:name, "unset")
|
11
|
+
define(:desc, "Unset a value of PIONE global variable")
|
12
|
+
|
13
|
+
#
|
14
|
+
# arguments
|
15
|
+
#
|
16
|
+
|
17
|
+
argument(:name) do |item|
|
18
|
+
item.type = :string
|
19
|
+
item.desc = "variable name"
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# options
|
24
|
+
#
|
25
|
+
|
26
|
+
option CommonOption.debug
|
27
|
+
option PioneConfigOption.file
|
28
|
+
|
29
|
+
#
|
30
|
+
# command lifecycle: execution phase
|
31
|
+
#
|
32
|
+
|
33
|
+
phase(:execution) do |item|
|
34
|
+
item << PioneConfigAction.load_config
|
35
|
+
item << :unset
|
36
|
+
item << PioneConfigAction.save_config
|
37
|
+
end
|
38
|
+
|
39
|
+
execution(:unset) do |item|
|
40
|
+
item.desc = "Unset the item"
|
41
|
+
|
42
|
+
item.process do
|
43
|
+
model[:config].unset(model[:name])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
PioneConfig.define_subcommand("unset", PioneConfigUnset)
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
# `PioneConfig` is a utility set for PIONE global variables.
|
4
|
+
class PioneConfig < BasicCommand
|
5
|
+
#
|
6
|
+
# informations
|
7
|
+
#
|
8
|
+
|
9
|
+
define(:name, "config")
|
10
|
+
define(:desc, "Configure PIONE global variables")
|
11
|
+
|
12
|
+
#
|
13
|
+
# requirements
|
14
|
+
#
|
15
|
+
|
16
|
+
require 'pione/command/pione-config-get'
|
17
|
+
require 'pione/command/pione-config-list'
|
18
|
+
require 'pione/command/pione-config-set'
|
19
|
+
require 'pione/command/pione-config-unset'
|
20
|
+
end
|
21
|
+
|
22
|
+
# `PioneConfigOption` is a set of common options for `pione config`
|
23
|
+
# subcommands.
|
24
|
+
module PioneConfigOption
|
25
|
+
extend Rootage::OptionCollection
|
26
|
+
|
27
|
+
define(:file) do |item|
|
28
|
+
item.short = "-f"
|
29
|
+
item.long = "--file"
|
30
|
+
item.arg = "PATH"
|
31
|
+
item.desc = "path of config file"
|
32
|
+
item.type = :path
|
33
|
+
item.default = Global.config_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
# `PioneConfigAction` is a set of common actions for `pione config`
|
38
|
+
# subcommands.
|
39
|
+
module PioneConfigAction
|
40
|
+
extend Rootage::ActionCollection
|
41
|
+
|
42
|
+
define(:load_config) do |item|
|
43
|
+
item.desc = "Load PIONE configuration"
|
44
|
+
|
45
|
+
item.assign(:config) do
|
46
|
+
Global::Config.new(model[:file])
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
define(:save_config) do |item|
|
51
|
+
item.desc = "Save the configuration"
|
52
|
+
|
53
|
+
item.process do
|
54
|
+
model[:config].save(model[:file])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
PioneCommand.define_subcommand("config", PioneConfig)
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,235 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PioneDiagnosisNotification < BasicCommand
|
4
|
+
#
|
5
|
+
# command definitions
|
6
|
+
#
|
7
|
+
|
8
|
+
define(:name, "notification")
|
9
|
+
define(:desc, "Diagnose notification settings")
|
10
|
+
define(:front, Front::DiagnosisNotificationFront)
|
11
|
+
|
12
|
+
#
|
13
|
+
# options
|
14
|
+
#
|
15
|
+
|
16
|
+
option CommonOption.debug
|
17
|
+
option CommonOption.color
|
18
|
+
option NotificationOption.notification_targets
|
19
|
+
option NotificationOption.notification_receivers
|
20
|
+
|
21
|
+
option(:type) do |item|
|
22
|
+
item.type = :string
|
23
|
+
item.range = ["transmitter", "receiver", "both"]
|
24
|
+
item.long = "--type"
|
25
|
+
item.arg = "NAME"
|
26
|
+
item.desc = "transmitter, receiver, or both"
|
27
|
+
item.init = "both"
|
28
|
+
end
|
29
|
+
|
30
|
+
option(:timeout) do |item|
|
31
|
+
item.type = :positive_integer
|
32
|
+
item.long = "--timeout"
|
33
|
+
item.arg = "N"
|
34
|
+
item.desc = "timeout after N second"
|
35
|
+
item.init = 10
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# command lifecycle: setup phase
|
40
|
+
#
|
41
|
+
|
42
|
+
phase(:setup) do |item|
|
43
|
+
item << :thread_groups
|
44
|
+
item << :message
|
45
|
+
end
|
46
|
+
|
47
|
+
setup(:thread_groups) do |item|
|
48
|
+
item.desc = "Make thread groups"
|
49
|
+
|
50
|
+
item.assign(:transmitting_threads) {ThreadGroup.new}
|
51
|
+
item.assign(:receiver_threads) {ThreadGroup.new}
|
52
|
+
end
|
53
|
+
|
54
|
+
setup(:message) do |item|
|
55
|
+
item.assign(:message) do
|
56
|
+
test(transmitter?)
|
57
|
+
"The notification target address seems %s: %s"
|
58
|
+
end
|
59
|
+
|
60
|
+
item.assign(:message) do
|
61
|
+
test(receiver?)
|
62
|
+
"The notification receiver address seems %s: %s"
|
63
|
+
end
|
64
|
+
|
65
|
+
item.assign(:message) do
|
66
|
+
test(both?)
|
67
|
+
"The notification target and receiver address seem %s: %s and %s"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# command lifecycle: execution phase
|
73
|
+
#
|
74
|
+
|
75
|
+
phase(:execution) do |item|
|
76
|
+
item << :diagnosis
|
77
|
+
end
|
78
|
+
|
79
|
+
execution(:diagnosis) do |item|
|
80
|
+
item.desc = "Diagnose notification address settings"
|
81
|
+
|
82
|
+
item.assign(:target_addrs) do
|
83
|
+
Global.notification_targets.map{|uri| uri.to_s}
|
84
|
+
end
|
85
|
+
|
86
|
+
item.assign(:receiver_addrs) do
|
87
|
+
Global.notification_receivers.map{|uri| uri.to_s}
|
88
|
+
end
|
89
|
+
|
90
|
+
item.process do
|
91
|
+
test(transmitter?)
|
92
|
+
|
93
|
+
Timeout.timeout(model[:timeout]) {transmit_notification}
|
94
|
+
Log::SystemLog.info(model[:message] % ["fine", model[:target_addrs]])
|
95
|
+
end
|
96
|
+
|
97
|
+
item.process do
|
98
|
+
test(receiver?)
|
99
|
+
|
100
|
+
Timeout.timeout(model[:timeout]) {receive_notification}
|
101
|
+
Log::SystemLog.info(model[:message] % ["fine", model[:receiver_addrs]])
|
102
|
+
end
|
103
|
+
|
104
|
+
item.process do
|
105
|
+
test(both?)
|
106
|
+
|
107
|
+
g = ThreadsWait.new
|
108
|
+
g.join_nowait(Thread.new {transmit_notification})
|
109
|
+
g.join_nowait(Thread.new {receive_notification})
|
110
|
+
Timeout.timeout(model[:timeout]) {g.all_waits}
|
111
|
+
Log::SystemLog.info(model[:message] % ["fine", model[:target_addrs], model[:receive_addrs]])
|
112
|
+
end
|
113
|
+
|
114
|
+
item.exception(Timeout::Error) do
|
115
|
+
test(transmitter?)
|
116
|
+
cmd.abort(model[:message] % ["bad", model[:target_addrs]])
|
117
|
+
end
|
118
|
+
|
119
|
+
item.exception(Timeout::Error) do
|
120
|
+
test(receiver?)
|
121
|
+
cmd.abort(model[:message] % ["bad", model[:receiver_addrs]])
|
122
|
+
end
|
123
|
+
|
124
|
+
item.exception(Timeout::Error) do
|
125
|
+
test(both?)
|
126
|
+
cmd.abort(msg % ["bad", model[:target_addrs], model[:receive_addrs]])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
#
|
131
|
+
# command lifecycle: termination phase
|
132
|
+
#
|
133
|
+
|
134
|
+
phase(:termination) do |item|
|
135
|
+
item << :thread_groups
|
136
|
+
end
|
137
|
+
|
138
|
+
termination(:thread_groups) do |item|
|
139
|
+
item.desc = "Terminate all threads"
|
140
|
+
|
141
|
+
item.process do
|
142
|
+
model[:transmitting_threads].list.each {|thread| thread.terminate}
|
143
|
+
model[:receiver_threads].list.each {|thread| thread.terminate}
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
class PioneDiagnosisNotificationContext < Rootage::CommandContext
|
149
|
+
NOTIFIER = "PIONE_DIAGNOSIS_NOTIFICATION"
|
150
|
+
|
151
|
+
def transmitter?
|
152
|
+
model[:type] == "transmitter"
|
153
|
+
end
|
154
|
+
|
155
|
+
def receiver?
|
156
|
+
model[:type] == "receiver"
|
157
|
+
end
|
158
|
+
|
159
|
+
def both?
|
160
|
+
model[:type] == "both"
|
161
|
+
end
|
162
|
+
|
163
|
+
# Transmit test notification messages to targets repeatedly.
|
164
|
+
def transmit_notification
|
165
|
+
Global.notification_targets.each do |uri|
|
166
|
+
transmitter_id = uri.to_s
|
167
|
+
|
168
|
+
thread = Thread.new do
|
169
|
+
# register the current thread to front server
|
170
|
+
Thread.current[:transmitter_id] = transmitter_id
|
171
|
+
model[:front].register_transmitting_thread(Thread.current)
|
172
|
+
|
173
|
+
# build a notification message
|
174
|
+
message = Notification::Message.new(
|
175
|
+
NOTIFIER, "TEST", {"front" => model[:front].uri, "transmitter_id" => transmitter_id}
|
176
|
+
)
|
177
|
+
|
178
|
+
# create a transmitter
|
179
|
+
transmitter = Notification::Transmitter.new(uri)
|
180
|
+
|
181
|
+
# trasmitting loop for "TEST" notifications
|
182
|
+
begin
|
183
|
+
loop do
|
184
|
+
transmitter.transmit(message)
|
185
|
+
Log::SystemLog.info('Notification message has been sent to "%s".' % uri)
|
186
|
+
|
187
|
+
sleep 1
|
188
|
+
end
|
189
|
+
ensure
|
190
|
+
transmitter.close
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
model[:transmitting_threads].add(thread)
|
195
|
+
end
|
196
|
+
|
197
|
+
model[:transmitting_threads].list.each {|thread| thread.join}
|
198
|
+
end
|
199
|
+
|
200
|
+
def receive_notification
|
201
|
+
Global.notification_receivers.each do |uri|
|
202
|
+
thread = Thread.new do
|
203
|
+
receiver = Notification::Receiver.new(uri)
|
204
|
+
|
205
|
+
begin
|
206
|
+
loop do
|
207
|
+
Log::SystemLog.info('Notification receiver is waiting at "%s".' % uri.to_s)
|
208
|
+
transmitter_host, message = receiver.receive
|
209
|
+
Log::SystemLog.info('Notification has been received from "%s".' % transmitter_host)
|
210
|
+
|
211
|
+
begin
|
212
|
+
DRbObject.new_with_uri(message["front"]).touch(message["transmitter_id"])
|
213
|
+
Log::SystemLog.info('Receiver has touched transmitter at "%s".' % message["front"])
|
214
|
+
break
|
215
|
+
rescue Object => e
|
216
|
+
Log::SystemLog.warn(e.message)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
ensure
|
220
|
+
receiver.close
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
model[:receiver_threads].add(thread)
|
225
|
+
end
|
226
|
+
|
227
|
+
model[:receiver_threads].list.each {|thread| thread.join}
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
PioneDiagnosisNotification.define(:process_context_class, PioneDiagnosisNotificationContext)
|
232
|
+
|
233
|
+
PioneDiagnosis.define_subcommand("notification", PioneDiagnosisNotification)
|
234
|
+
end
|
235
|
+
end
|