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,20 @@
|
|
1
|
+
module Pione
|
2
|
+
module TaskWorkerBroker
|
3
|
+
# `BasicProvider` is an abstract class for task worker providers.
|
4
|
+
class BasicProvider
|
5
|
+
# @param model [Model::TaskWorkerBrokerModel]
|
6
|
+
# model of task worker broker
|
7
|
+
def initialize(model)
|
8
|
+
@model = model
|
9
|
+
end
|
10
|
+
|
11
|
+
# Execute task worker provisioning. If this method returned true, broker
|
12
|
+
# executes retry provision transition with no span. If false, broker
|
13
|
+
# sleeps a little.
|
14
|
+
def provide
|
15
|
+
raise NotImplementedError
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Pione
|
2
|
+
module TaskWorkerBroker
|
3
|
+
# `EasyProvider` is a task worker provider by blancing ratios of tuple space
|
4
|
+
# and task worker.
|
5
|
+
class EasyProvider < BasicProvider
|
6
|
+
# Balance task worker ratio by creating a new task worker in minimum
|
7
|
+
# tuple space or killing a task worker in maximum.
|
8
|
+
def provide
|
9
|
+
ratios = calc_resource_ratios
|
10
|
+
min = ratios.values.min
|
11
|
+
max = ratios.values.max
|
12
|
+
min_server = ratios.key(min)
|
13
|
+
max_server = ratios.key(max)
|
14
|
+
|
15
|
+
return false unless min_server
|
16
|
+
return false unless max_server
|
17
|
+
|
18
|
+
if @model.excess_task_workers > 0 and min_server
|
19
|
+
return @model.create_task_worker(min_server)
|
20
|
+
else
|
21
|
+
return adjust_task_worker(min_server, max_server)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Calculate resource ratios of tuple space servers.
|
26
|
+
def calc_resource_ratios(revision={})
|
27
|
+
ratio = {}
|
28
|
+
# make ratio table
|
29
|
+
@model.tuple_space_lock.synchronize do
|
30
|
+
@model.tuple_spaces.each do |tuple_space|
|
31
|
+
rev = revision.has_key?(tuple_space) ? revision[tuple_space] : 0
|
32
|
+
current = timeout(1){tuple_space.current_task_worker_size} + rev
|
33
|
+
resource = tuple_space.task_worker_resource
|
34
|
+
# minimum resource is 1
|
35
|
+
resource = 1 unless resource > 0
|
36
|
+
ratio[tuple_space] = current / resource.to_f
|
37
|
+
end
|
38
|
+
end
|
39
|
+
return ratio
|
40
|
+
end
|
41
|
+
|
42
|
+
# Adjusts task worker size between tuple space servers.
|
43
|
+
def adjust_task_worker(min_server, max_server)
|
44
|
+
revision = {min_server => 1, max_server => -1}
|
45
|
+
new_ratios = calc_resource_ratios(revision)
|
46
|
+
|
47
|
+
# failed to calculate tuple space ratio
|
48
|
+
return unless new_ratios.has_key?(min_server)
|
49
|
+
return unless new_ratios.has_key?(max_server)
|
50
|
+
|
51
|
+
# kill a task worker for moving worker from max server to min server
|
52
|
+
if new_ratios[min_server] < new_ratios[max_server]
|
53
|
+
if @model.terminate_task_worker_if do |worker|
|
54
|
+
worker.tuple_space == max_server && worker.states.any?{|s| s.current?(:take_task)}
|
55
|
+
end
|
56
|
+
return true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# failed to adjust task workers
|
61
|
+
return false
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
data/lib/pione/test-helper.rb
CHANGED
@@ -1,10 +1,29 @@
|
|
1
1
|
# This file should be loaded in spec files only.
|
2
2
|
|
3
3
|
require 'bacon'
|
4
|
+
require 'erb'
|
4
5
|
require 'pione'
|
6
|
+
require 'rootage/test-helper'
|
7
|
+
|
8
|
+
Pione::Command.load_all
|
5
9
|
|
6
10
|
Pione::Global.git_package_directory = Pione::Location[Temppath.mkdir]
|
7
11
|
|
12
|
+
Pione::Global.define_internal_item(:project_root) do |item|
|
13
|
+
item.init = Pione::Location[File.dirname(__FILE__)] + ".." + ".."
|
14
|
+
end
|
15
|
+
|
16
|
+
Pione::Global.define_internal_item(:test_start_time) do |item|
|
17
|
+
item.init = Time.now
|
18
|
+
end
|
19
|
+
|
20
|
+
Pione::Global.define_internal_item(:test_report) do |item|
|
21
|
+
item.define_updater do
|
22
|
+
filename = Pione::Global.test_start_time.strftime("test-report.txt")
|
23
|
+
Pione::Global.project_root + filename
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
8
27
|
module Pione
|
9
28
|
module TestHelper
|
10
29
|
DIR = Location[File.dirname(__FILE__)]
|
@@ -45,6 +64,14 @@ class Bacon::Context
|
|
45
64
|
include Pione
|
46
65
|
include Pione::TestHelper::TransformerInterface
|
47
66
|
include Pione::TupleSpace::TupleSpaceInterface
|
67
|
+
|
68
|
+
alias :orig_it :it
|
69
|
+
def it(desc, &b)
|
70
|
+
time = Time.now
|
71
|
+
orig_it(desc, &b)
|
72
|
+
line = "[%s] %s: %s\n" % [@name, desc, (Time.now - time).round(3)]
|
73
|
+
Pione::Global.test_report.append(line)
|
74
|
+
end
|
48
75
|
end
|
49
76
|
|
50
77
|
# init
|
@@ -1,94 +1,5 @@
|
|
1
1
|
module Pione
|
2
2
|
module TestHelper
|
3
|
-
# CommandResult is a result of command execution. This has result status,
|
4
|
-
# stdout, stdin, and etc, so you can analyze and check it.
|
5
|
-
class CommandResult < StructX
|
6
|
-
member :exception
|
7
|
-
member :stdout
|
8
|
-
member :stderr
|
9
|
-
|
10
|
-
# Return true if the command succeeded.
|
11
|
-
def success?
|
12
|
-
exception.kind_of?(SystemExit) and exception.success?
|
13
|
-
end
|
14
|
-
|
15
|
-
# Print the command result report.
|
16
|
-
def report
|
17
|
-
unless success?
|
18
|
-
puts "[FAIL]"
|
19
|
-
puts "ERROR: %s" % exception.message
|
20
|
-
exception.backtrace.each do |line|
|
21
|
-
puts "TRACE: %s" % line
|
22
|
-
end
|
23
|
-
if stdout.string.size > 0
|
24
|
-
puts "STDOUT:"
|
25
|
-
puts stdout.string
|
26
|
-
end
|
27
|
-
if stderr.string.size > 0
|
28
|
-
puts "STDERR:"
|
29
|
-
puts stderr.string[0..100]
|
30
|
-
end
|
31
|
-
else
|
32
|
-
puts "[SUCCESS]"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
# This module helps tests of command execution.
|
38
|
-
module Command
|
39
|
-
class << self
|
40
|
-
# Run the action with expectation command execution succeeds.
|
41
|
-
def succeed(*options, &b)
|
42
|
-
res = execute(options, &b)
|
43
|
-
res.should.success
|
44
|
-
return res
|
45
|
-
end
|
46
|
-
|
47
|
-
# Run the action with expectation command execution fails.
|
48
|
-
def fail(*options, &b)
|
49
|
-
res = execute(options, &b)
|
50
|
-
res.should.not.success
|
51
|
-
return res
|
52
|
-
end
|
53
|
-
|
54
|
-
private
|
55
|
-
|
56
|
-
# Run the command execution action.
|
57
|
-
def execute(*options, &b)
|
58
|
-
# initialize exit status
|
59
|
-
Global.exit_status = true
|
60
|
-
|
61
|
-
# make result
|
62
|
-
res = CommandResult.new(stdout: StringIO.new("", "w"), stderr: StringIO.new("", "w"))
|
63
|
-
|
64
|
-
# setup stdout and stderr
|
65
|
-
$stdout = res.stdout unless options.include?(:show) or options.include?(:show_stdout)
|
66
|
-
$stderr = res.stderr unless options.include?(:show) or options.include?(:show_stderr)
|
67
|
-
|
68
|
-
# run the action
|
69
|
-
begin
|
70
|
-
b.call
|
71
|
-
rescue Object => e
|
72
|
-
unless options.include?(:show_exception)
|
73
|
-
res.exception = e
|
74
|
-
else
|
75
|
-
raise
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
# revert stdout and stderr
|
80
|
-
$stdout = STDOUT
|
81
|
-
$stderr = STDERR
|
82
|
-
|
83
|
-
if options.include?(:report)
|
84
|
-
res.report
|
85
|
-
end
|
86
|
-
|
87
|
-
return res
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
3
|
class PioneClientRunner < StructX
|
93
4
|
member :title
|
94
5
|
member :template, default: "%s"
|
@@ -103,31 +14,28 @@ module Pione
|
|
103
14
|
runner.default_arguments = ["-o", runner.base.path.to_s]
|
104
15
|
b.call(runner)
|
105
16
|
end
|
106
|
-
|
107
|
-
# with stand alone mode
|
108
|
-
new(context: context, template: "%s with stand alone mode").tap do |runner|
|
109
|
-
runner.default_arguments = ["-o", runner.base.path.to_s, "--stand-alone"]
|
110
|
-
b.call(runner)
|
111
|
-
end
|
112
17
|
end
|
113
18
|
|
114
19
|
def run(&b)
|
115
20
|
_args = args
|
116
21
|
_base = base
|
117
22
|
context.it(template % title) do
|
118
|
-
|
119
|
-
Pione::Command::PioneClient.run(_args)
|
120
|
-
end
|
23
|
+
Rootage::ScenarioTest.succeed(Pione::Command::PioneClient, _args)
|
121
24
|
b.call(_base)
|
122
25
|
end
|
123
26
|
end
|
124
27
|
|
28
|
+
def fail
|
29
|
+
_args = args
|
30
|
+
context.it(template % title) do
|
31
|
+
Rootage::ScenarioTest.fail(Pione::Command::PioneClient, _args)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
125
35
|
def timeout(sec)
|
126
36
|
_args = args + ["--timeout", sec.to_s]
|
127
37
|
context.it(template % title) do
|
128
|
-
|
129
|
-
Pione::Command::PioneClient.run(_args)
|
130
|
-
end
|
38
|
+
Rootage::ScenarioTest.fail(Pione::Command::PioneClient, _args)
|
131
39
|
end
|
132
40
|
end
|
133
41
|
end
|
@@ -284,7 +284,7 @@ module Pione
|
|
284
284
|
# tuple object
|
285
285
|
def from_array(ary)
|
286
286
|
raise TupleFormatError.new(ary) unless ary.size > 0
|
287
|
-
raise TupleFormatError.new(ary) unless ary.
|
287
|
+
raise TupleFormatError.new(ary) unless ary.respond_to?(:to_a)
|
288
288
|
_ary = ary.to_a
|
289
289
|
identifier = _ary.first
|
290
290
|
raise TupleFormatError.new(identifier) unless TUPLE.has_key?(identifier)
|
@@ -68,12 +68,10 @@ ExceptionTuple:
|
|
68
68
|
# FinishedTuple represents task finished notifier.
|
69
69
|
FinishedTuple:
|
70
70
|
- finished
|
71
|
-
- domain:
|
72
|
-
|
73
|
-
- status:
|
74
|
-
|
75
|
-
- outputs: # outputs
|
76
|
-
Array
|
71
|
+
- domain : String # task domain
|
72
|
+
- uuid : String # UUID
|
73
|
+
- status : Symbol # status of the task processing
|
74
|
+
- outputs: Array # outputs
|
77
75
|
|
78
76
|
# ForegroundTuple represents the task is active (rule engine is processing it now).
|
79
77
|
ForegroundTuple:
|
@@ -11,9 +11,12 @@ module Pione
|
|
11
11
|
|
12
12
|
# define tuple space operations
|
13
13
|
tuple_space_operation :read
|
14
|
+
tuple_space_operation :read!
|
14
15
|
tuple_space_operation :read_all
|
15
16
|
tuple_space_operation :take
|
17
|
+
tuple_space_operation :take!
|
16
18
|
tuple_space_operation :take_all
|
19
|
+
tuple_space_operation :take_all!
|
17
20
|
tuple_space_operation :write
|
18
21
|
tuple_space_operation :count_tuple
|
19
22
|
tuple_space_operation :notify
|
@@ -23,51 +26,6 @@ module Pione
|
|
23
26
|
@__tuple_space__
|
24
27
|
end
|
25
28
|
|
26
|
-
# Read a tuple with no waiting time. If there are no matched tuples, return
|
27
|
-
# +nil+.
|
28
|
-
#
|
29
|
-
# @param tuple [BasicTuple]
|
30
|
-
# template tuple for query
|
31
|
-
# @return [BasicTuple, nil]
|
32
|
-
# query result
|
33
|
-
def read!(tuple)
|
34
|
-
begin
|
35
|
-
read(tuple, 0)
|
36
|
-
rescue Rinda::RequestExpiredError
|
37
|
-
nil
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# Take a tuple with no waiting time. If there are no matched tuples, return
|
42
|
-
# +nil+.
|
43
|
-
#
|
44
|
-
# @param tuple [BasicTuple]
|
45
|
-
# template tuple for query
|
46
|
-
# @return [BasicTuple, nil]
|
47
|
-
# query result
|
48
|
-
def take!(tuple)
|
49
|
-
begin
|
50
|
-
take(tuple, 0)
|
51
|
-
rescue Rinda::RequestExpiredError
|
52
|
-
nil
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
# Take all tuples with no waiting time. If there are no matched tuples, return
|
57
|
-
# empty array.
|
58
|
-
#
|
59
|
-
# @param tuple [BasicTuple]
|
60
|
-
# template tuple for query
|
61
|
-
# @return [Array<BasicTuple>]
|
62
|
-
# query result
|
63
|
-
def take_all!(tuple)
|
64
|
-
begin
|
65
|
-
take_all(tuple, 0)
|
66
|
-
rescue Rinda::RequestExpiredError
|
67
|
-
[]
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
29
|
# Put a log tuple with the data as a process record into tuple space. The
|
72
30
|
# record's value of transition is "complete" by default and the timestamp
|
73
31
|
# set automatically.
|
@@ -146,6 +146,51 @@ module Pione
|
|
146
146
|
@terminated = true
|
147
147
|
end
|
148
148
|
|
149
|
+
# Read a tuple with no waiting time. If there are no matched tuples, return
|
150
|
+
# `nil`.
|
151
|
+
#
|
152
|
+
# @param tuple [BasicTuple]
|
153
|
+
# template tuple for query
|
154
|
+
# @return [BasicTuple, nil]
|
155
|
+
# query result
|
156
|
+
def read!(tuple)
|
157
|
+
begin
|
158
|
+
read(tuple, 0)
|
159
|
+
rescue Rinda::RequestExpiredError
|
160
|
+
nil
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Take a tuple with no waiting time. If there are no matched tuples, return
|
165
|
+
# `nil`.
|
166
|
+
#
|
167
|
+
# @param tuple [BasicTuple]
|
168
|
+
# template tuple for query
|
169
|
+
# @return [BasicTuple, nil]
|
170
|
+
# query result
|
171
|
+
def take!(tuple)
|
172
|
+
begin
|
173
|
+
take(tuple, 0)
|
174
|
+
rescue Rinda::RequestExpiredError
|
175
|
+
nil
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
# Take all tuples with no waiting time. If there are no matched tuples, return
|
180
|
+
# empty array.
|
181
|
+
#
|
182
|
+
# @param tuple [BasicTuple]
|
183
|
+
# template tuple for query
|
184
|
+
# @return [Array<BasicTuple>]
|
185
|
+
# query result
|
186
|
+
def take_all!(tuple)
|
187
|
+
begin
|
188
|
+
take_all(tuple, 0)
|
189
|
+
rescue Rinda::RequestExpiredError
|
190
|
+
[]
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
149
194
|
def inspect
|
150
195
|
"#<Pione::TupleSpace::TupleSpaceServer:%s>" % object_id
|
151
196
|
end
|
data/lib/pione/util.rb
CHANGED
@@ -23,6 +23,5 @@ require 'pione/util/positionable' # source position handler
|
|
23
23
|
require 'pione/util/embeded-expr-expander' # expand text embeded PIONE expression
|
24
24
|
require 'pione/util/free-thread-generator' # generate threads free from thread group
|
25
25
|
require 'pione/util/parslet-extension' # parslet extension
|
26
|
-
require 'pione/util/pnml-compiler' # toy compiler from PNML to PIONE
|
27
26
|
require 'pione/util/last-time' # get last time of locations
|
28
|
-
|
27
|
+
require 'pione/util/boolean-value' # object -> boolean
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Pione
|
2
|
+
module Util
|
3
|
+
module BooleanValue
|
4
|
+
class << self
|
5
|
+
# Return boolean value of the object.
|
6
|
+
#
|
7
|
+
# @param val [Object]
|
8
|
+
# target object
|
9
|
+
# @return [Boolean]
|
10
|
+
# boolean of the object
|
11
|
+
def of(val)
|
12
|
+
case val
|
13
|
+
when NilClass
|
14
|
+
false
|
15
|
+
when TrueClass
|
16
|
+
true
|
17
|
+
when FalseClass
|
18
|
+
false
|
19
|
+
when String
|
20
|
+
of_string(val)
|
21
|
+
when Numeric
|
22
|
+
of_number(val)
|
23
|
+
else
|
24
|
+
raise ArgumentError.new(val)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
# Return boolean value of the string. Ignoring letter cases, "true",
|
31
|
+
# "t", "yes", and "y" are true, and "false", "f", "no", and "n" are
|
32
|
+
# false. Ohterwise raise `ArgumentError`.
|
33
|
+
#
|
34
|
+
# @param val [String]
|
35
|
+
# the string
|
36
|
+
# @return [Boolean]
|
37
|
+
# boolean of the string
|
38
|
+
def of_string(val)
|
39
|
+
case val.downcase
|
40
|
+
when "true", "t", "yes", "y"
|
41
|
+
true
|
42
|
+
when "false", "f", "no", "n"
|
43
|
+
false
|
44
|
+
else
|
45
|
+
raise ArgumentError.new(val)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# Return boolean value of the number. Return true if the number is
|
50
|
+
# greater than 0.
|
51
|
+
#
|
52
|
+
# @param val [Numeric]
|
53
|
+
# the number
|
54
|
+
# @return [Boolean]
|
55
|
+
# boolean of the number
|
56
|
+
def of_number(val)
|
57
|
+
val > 0
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|