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
@@ -57,9 +57,9 @@ module Pione
|
|
57
57
|
# save domain log
|
58
58
|
Log::DomainLog.new(self).save
|
59
59
|
|
60
|
-
# save domain
|
61
|
-
|
62
|
-
System::
|
60
|
+
# save a domain dump file
|
61
|
+
domain_dump_location = @working_directory ? @working_directory :@domain_location
|
62
|
+
System::DomainDump.new(env.dumpable).write(domain_dump_location)
|
63
63
|
|
64
64
|
# execute the rule
|
65
65
|
outputs = execute
|
@@ -67,9 +67,9 @@ module Pione
|
|
67
67
|
# publish outputs and finished
|
68
68
|
begin
|
69
69
|
outputs.flatten.compact.each {|output| write(output)}
|
70
|
-
write(TupleSpace::FinishedTuple.new(@domain_id, :succeeded, outputs))
|
70
|
+
write(TupleSpace::FinishedTuple.new(@domain_id, Util::UUID.generate, :succeeded, outputs))
|
71
71
|
rescue Rinda::RedundantTupleError
|
72
|
-
write(TupleSpace::FinishedTuple.new(@domain_id, :error, outputs))
|
72
|
+
write(TupleSpace::FinishedTuple.new(@domain_id, Util::UUID.generate, :error, outputs))
|
73
73
|
end
|
74
74
|
|
75
75
|
# show end message
|
@@ -7,17 +7,18 @@ module Pione
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def message
|
10
|
-
"Execution error when handling the rule '%s': inputs=%s, output=%s,
|
11
|
-
@handler.
|
10
|
+
"Execution error when handling the rule '%s': inputs=%s, output=%s, param_set=%s" % [
|
11
|
+
@handler.rule_name,
|
12
12
|
@handler.inputs,
|
13
13
|
@handler.outputs,
|
14
|
-
@handler.
|
14
|
+
@handler.param_set
|
15
15
|
]
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
-
class ActionError <
|
20
|
-
def initialize(digest, report)
|
19
|
+
class ActionError < RuleExecutionError
|
20
|
+
def initialize(handler, digest, report)
|
21
|
+
super(handler)
|
21
22
|
@digest = digest
|
22
23
|
@report = report
|
23
24
|
end
|
@@ -39,6 +40,6 @@ module Pione
|
|
39
40
|
end
|
40
41
|
end
|
41
42
|
|
42
|
-
class UnknownRule <
|
43
|
+
class UnknownRule < RuleExecutionError; end
|
43
44
|
end
|
44
45
|
end
|
@@ -52,7 +52,11 @@ module Pione
|
|
52
52
|
unless new_location == old_location or lifted.include?(old_location)
|
53
53
|
if old_location.exist?
|
54
54
|
# move data from old to new
|
55
|
-
|
55
|
+
begin
|
56
|
+
old_location.turn(new_location)
|
57
|
+
rescue ArgumentError
|
58
|
+
# ignore the error because this is the case that old and new is same file
|
59
|
+
end
|
56
60
|
# sync cache if the old is cached in this machine
|
57
61
|
System::FileCache.sync(old_location, new_location)
|
58
62
|
# write lift tuple
|
@@ -171,7 +175,7 @@ module Pione
|
|
171
175
|
def initialize(handler)
|
172
176
|
super(handler)
|
173
177
|
@data_finder = DataFinder.new(tuple_space_server, domain_id)
|
174
|
-
@finished =
|
178
|
+
@finished = Set.new # finished tuple cache
|
175
179
|
end
|
176
180
|
|
177
181
|
# Apply input data to rules.
|
@@ -183,7 +187,14 @@ module Pione
|
|
183
187
|
Util::Profiler.profile(Util::RuleApplicationProfileReport.new(digest)) do
|
184
188
|
# rule application loop
|
185
189
|
while tasks = find_tasks(rules) do
|
190
|
+
# save previous finished tuples's number
|
191
|
+
size = @finished.size
|
192
|
+
|
193
|
+
# distribute tasks
|
186
194
|
distribute_tasks(tasks)
|
195
|
+
|
196
|
+
# check whether tasks have been processed
|
197
|
+
break unless size < @finished.size
|
187
198
|
end
|
188
199
|
end
|
189
200
|
|
@@ -419,7 +430,9 @@ module Pione
|
|
419
430
|
return false
|
420
431
|
end
|
421
432
|
if finished = read!(template)
|
422
|
-
@finished
|
433
|
+
unless @finished.any? {|t| t.uuid == finished.uuid}
|
434
|
+
@finished << finished
|
435
|
+
end
|
423
436
|
return false
|
424
437
|
end
|
425
438
|
end
|
@@ -440,6 +453,9 @@ module Pione
|
|
440
453
|
# wait to finish the distributed task, note that finished tuple is in
|
441
454
|
# the task domain
|
442
455
|
finished = read(TupleSpace::FinishedTuple.new(domain: task.domain_id))
|
456
|
+
unless @finished.any? {|t| t.uuid == finished.uuid}
|
457
|
+
@finished << finished
|
458
|
+
end
|
443
459
|
|
444
460
|
### task completion processing ###
|
445
461
|
# copy write operation data tuple from the task domain to this domain
|
@@ -459,25 +475,18 @@ module Pione
|
|
459
475
|
def import_outputs_of_task(task, finished)
|
460
476
|
finished.outputs.each_with_index do |output, i|
|
461
477
|
data_expr = task.rule_condition.outputs[i].eval(task.env)
|
478
|
+
output = [output] unless output.kind_of?(Array)
|
479
|
+
|
462
480
|
case data_expr.operation
|
463
481
|
when :write
|
464
|
-
|
465
|
-
output.each {|o| copy_data_into_domain(o, domain_id)}
|
466
|
-
else
|
467
|
-
copy_data_into_domain(output, domain_id)
|
468
|
-
end
|
482
|
+
output.each {|o| copy_data_into_domain(o, domain_id)}
|
469
483
|
when :remove
|
470
|
-
|
471
|
-
output.each {|o| remove_data_from_domain(o, domain_id)}
|
472
|
-
else
|
473
|
-
remove_data_from_domain(output, domain_id)
|
474
|
-
end
|
484
|
+
output.each {|o| remove_data_from_domain(o, domain_id)}
|
475
485
|
when :touch
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
end
|
486
|
+
output.each {|o| touch_data_in_domain(o, domain_id)}
|
487
|
+
else
|
488
|
+
# here is unreached
|
489
|
+
raise RuleExecutionError.new(self)
|
481
490
|
end
|
482
491
|
end
|
483
492
|
end
|
data/lib/pione/system.rb
CHANGED
@@ -3,12 +3,14 @@ module Pione
|
|
3
3
|
end
|
4
4
|
end
|
5
5
|
|
6
|
+
require 'pione/system/system-exception'
|
6
7
|
require 'pione/system/object'
|
7
8
|
require 'pione/system/common'
|
8
9
|
require 'pione/system/init'
|
9
10
|
require 'pione/system/file-cache'
|
10
|
-
require 'pione/system/domain-
|
11
|
+
require 'pione/system/domain-dump'
|
11
12
|
require 'pione/system/status'
|
13
|
+
require 'pione/system/normalizer'
|
12
14
|
|
13
15
|
# export some classes to the name space of Pione
|
14
16
|
Pione.module_exec {const_set(:PioneObject, Pione::System::PioneObject)}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Pione
|
2
|
+
module System
|
3
|
+
# `DomainDump` is a class that dumps domain environment as a file for
|
4
|
+
# exporting the environment from PIONE world to externals.
|
5
|
+
class DomainDump < StructX
|
6
|
+
FILENAME = ".domain.dump"
|
7
|
+
|
8
|
+
# Load the domain dump file.
|
9
|
+
#
|
10
|
+
# @param location [Location::DataLocation]
|
11
|
+
# the domain dump file
|
12
|
+
# @return [DomainDump]
|
13
|
+
# domain dump object
|
14
|
+
def self.load(location)
|
15
|
+
if location.directory?
|
16
|
+
location = location + FILENAME
|
17
|
+
end
|
18
|
+
|
19
|
+
new(Marshal.load(location.read))
|
20
|
+
end
|
21
|
+
|
22
|
+
member :env
|
23
|
+
|
24
|
+
# Write a domain dump file.
|
25
|
+
def write(location)
|
26
|
+
if location.directory?
|
27
|
+
location = location + ".domain.dump"
|
28
|
+
end
|
29
|
+
|
30
|
+
location.write(Marshal.dump(env.dumpable))
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -10,13 +10,24 @@ module Pione
|
|
10
10
|
@klass || SimpleCacheMethod
|
11
11
|
end
|
12
12
|
|
13
|
-
# Set a file cache
|
13
|
+
# Set a file cache method.
|
14
14
|
#
|
15
15
|
# @param klass [Class]
|
16
16
|
# CacheMethod class
|
17
17
|
# @return [void]
|
18
|
-
def self.set_cache_method(
|
19
|
-
|
18
|
+
def self.set_cache_method(file_cache_method)
|
19
|
+
case file_cache_method
|
20
|
+
when Symbol
|
21
|
+
if klass = @file_cache_method[file_cache_method]
|
22
|
+
@klass = klass
|
23
|
+
else
|
24
|
+
raise ArgumentError.new(file_cache_method)
|
25
|
+
end
|
26
|
+
when Class
|
27
|
+
@klass = file_cache_method
|
28
|
+
else
|
29
|
+
raise ArgumentError.new(file_cache_method)
|
30
|
+
end
|
20
31
|
end
|
21
32
|
|
22
33
|
# Return the singleton.
|
@@ -27,12 +38,14 @@ module Pione
|
|
27
38
|
@instance ||= cache_method.new
|
28
39
|
end
|
29
40
|
|
30
|
-
# Get cached data
|
41
|
+
# Get cached data location of the location. If the location is not cached
|
42
|
+
# and needs to be cached, create the cache and return it. If not, return
|
43
|
+
# the location as is.
|
31
44
|
#
|
32
45
|
# @param location [BasicLocation]
|
33
46
|
# data location
|
34
|
-
# @return [
|
35
|
-
# cached
|
47
|
+
# @return [BasicLocation]
|
48
|
+
# cached location
|
36
49
|
def self.get(location)
|
37
50
|
instance.get(location)
|
38
51
|
end
|
@@ -74,8 +87,35 @@ module Pione
|
|
74
87
|
instance.clear
|
75
88
|
end
|
76
89
|
|
90
|
+
# Register the file cache method with the name.
|
91
|
+
#
|
92
|
+
# @param name [Symbol]
|
93
|
+
# the name of file cache method
|
94
|
+
# @param klass [FileCacheMethod]
|
95
|
+
# file cache method class
|
96
|
+
# @return [void]
|
97
|
+
def self.register_file_cache_method(name, klass)
|
98
|
+
(@file_cache_method ||= {})[name] = klass
|
99
|
+
end
|
100
|
+
|
77
101
|
# FileCache is an interface class of cache methods.
|
78
102
|
class FileCacheMethod
|
103
|
+
# Name the file cache method class.
|
104
|
+
#
|
105
|
+
# @param name [String]
|
106
|
+
# cache mtehod name
|
107
|
+
def self.set_name(name)
|
108
|
+
@name = name
|
109
|
+
FileCache.register_file_cache_method(name, self)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Return the name.
|
113
|
+
#
|
114
|
+
# @return [String] the name
|
115
|
+
def self.name
|
116
|
+
@name
|
117
|
+
end
|
118
|
+
|
79
119
|
# Get the cache path of the location.
|
80
120
|
#
|
81
121
|
# @param location [BasicLocation]
|
@@ -126,6 +166,8 @@ module Pione
|
|
126
166
|
|
127
167
|
# SimpleCacheMethod is a simple cache method implementation.
|
128
168
|
class SimpleCacheMethod < FileCacheMethod
|
169
|
+
set_name :simple
|
170
|
+
|
129
171
|
# Creates a method.
|
130
172
|
def initialize
|
131
173
|
@table = {}
|
@@ -135,9 +177,15 @@ module Pione
|
|
135
177
|
def get(location)
|
136
178
|
# cache if record doesn't exist
|
137
179
|
unless @table.has_key?(location)
|
138
|
-
|
139
|
-
|
140
|
-
|
180
|
+
if not(location.local?)
|
181
|
+
# create a cache and copy the location data to it
|
182
|
+
cache_location = Location[Global.file_cache_path_generator.create]
|
183
|
+
location.copy(cache_location)
|
184
|
+
@table[location] = cache_location
|
185
|
+
else
|
186
|
+
# refer directly if the location is in local
|
187
|
+
@table[location] = location
|
188
|
+
end
|
141
189
|
end
|
142
190
|
unless @table[location].exist?
|
143
191
|
location.turn(@table[location])
|
@@ -146,13 +194,19 @@ module Pione
|
|
146
194
|
end
|
147
195
|
|
148
196
|
def put(src, dest)
|
149
|
-
|
150
|
-
|
197
|
+
cache_location = @table[dest]
|
198
|
+
|
199
|
+
# update cache if
|
200
|
+
if cache_location.nil? or src.mtime > cache_location.mtime
|
201
|
+
cache_location = Location[Global.file_cache_path_generator.create]
|
202
|
+
src.copy(cache_location)
|
203
|
+
@table[dest] = cache_location
|
204
|
+
end
|
151
205
|
end
|
152
206
|
|
153
207
|
def sync(old_location, new_location)
|
154
|
-
if
|
155
|
-
@table[new_location] =
|
208
|
+
if cached?(old_location)
|
209
|
+
@table[new_location] = @table[old_location]
|
156
210
|
end
|
157
211
|
end
|
158
212
|
|
@@ -164,6 +218,31 @@ module Pione
|
|
164
218
|
@table.clear
|
165
219
|
end
|
166
220
|
end
|
221
|
+
|
222
|
+
# NoCacheMethod is a cache method for disabling file caching.
|
223
|
+
class NoCacheMethod < FileCacheMethod
|
224
|
+
set_name :no_cache
|
225
|
+
|
226
|
+
def get(location)
|
227
|
+
location
|
228
|
+
end
|
229
|
+
|
230
|
+
def put(src, location)
|
231
|
+
# do nothing
|
232
|
+
end
|
233
|
+
|
234
|
+
def sync(old_location, new_location)
|
235
|
+
# do nothing
|
236
|
+
end
|
237
|
+
|
238
|
+
def cached?(location)
|
239
|
+
false
|
240
|
+
end
|
241
|
+
|
242
|
+
def clear
|
243
|
+
# do nothing
|
244
|
+
end
|
245
|
+
end
|
167
246
|
end
|
168
247
|
end
|
169
248
|
end
|
data/lib/pione/system/init.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
module Pione
|
2
|
+
module System
|
3
|
+
# `Normalizer` is a utility module that normalizes values into normalization
|
4
|
+
# types. If values cannot normalize, this method raises
|
5
|
+
# `NormalizerValueError`. Normalization types are followings:
|
6
|
+
module Normalizer
|
7
|
+
class << self
|
8
|
+
def location(val)
|
9
|
+
if val.kind_of?(Location::BasicLocation)
|
10
|
+
val
|
11
|
+
else
|
12
|
+
Location[val]
|
13
|
+
end
|
14
|
+
rescue => e
|
15
|
+
raise NormalizerValueError.new(:location, val, e.message)
|
16
|
+
end
|
17
|
+
|
18
|
+
def param_set(val)
|
19
|
+
p val
|
20
|
+
Util.parse_param_set(val)
|
21
|
+
end
|
22
|
+
|
23
|
+
def nortification_address(val)
|
24
|
+
Notification::Address.target_address_to_uri(address.strip)
|
25
|
+
unless ["pnb", "pnm", "pnu"].include?(uri.scheme)
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
Rootage::Normalizer.set(:location) do |val|
|
35
|
+
Pione::System::Normalizer.location(val)
|
36
|
+
end
|
37
|
+
|
38
|
+
Rootage::Normalizer.set(:param_set) do |val|
|
39
|
+
Pione::System::Normalizer.param_set(val)
|
40
|
+
end
|
data/lib/pione/system/status.rb
CHANGED
@@ -6,16 +6,16 @@ module Pione
|
|
6
6
|
new(:success)
|
7
7
|
end
|
8
8
|
|
9
|
-
def error(
|
10
|
-
new(:error,
|
9
|
+
def error(message)
|
10
|
+
new(:error, message)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
attr_reader :
|
14
|
+
attr_reader :message
|
15
15
|
|
16
|
-
def initialize(status,
|
16
|
+
def initialize(status, message=nil)
|
17
17
|
@status = status
|
18
|
-
@
|
18
|
+
@message = message
|
19
19
|
end
|
20
20
|
|
21
21
|
def success?
|
@@ -1,5 +1,18 @@
|
|
1
1
|
module Pione
|
2
2
|
module System
|
3
|
-
class
|
3
|
+
class SystemError < StandardError; end
|
4
|
+
|
5
|
+
# PioneBug is an error that is caused by PIONE's bug.
|
6
|
+
class PioneBug < SystemError
|
7
|
+
def initialize(message)
|
8
|
+
@message = message
|
9
|
+
end
|
10
|
+
|
11
|
+
def message
|
12
|
+
"[PIONE BUG] " + @message
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class DomainDumpErro < SystemError; end
|
4
17
|
end
|
5
18
|
end
|