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
@@ -2,8 +2,10 @@ module Pione
|
|
2
2
|
module Location
|
3
3
|
class HTTPSLocation < HTTPLocation
|
4
4
|
set_scheme "https"
|
5
|
-
|
6
|
-
|
5
|
+
|
6
|
+
define(:need_caching, true)
|
7
|
+
define(:real_appendable, false)
|
8
|
+
define(:writable, false)
|
7
9
|
|
8
10
|
# Send a request HTTPS Get and evaluate the block with the response.
|
9
11
|
def http_get(&b)
|
@@ -3,7 +3,10 @@ module Pione
|
|
3
3
|
# LocalLocation represents local disk locations.
|
4
4
|
class LocalLocation < DataLocation
|
5
5
|
set_scheme "local"
|
6
|
-
|
6
|
+
|
7
|
+
define(:need_caching, false)
|
8
|
+
define(:real_appendable, true)
|
9
|
+
define(:writable, true)
|
7
10
|
|
8
11
|
def initialize(uri)
|
9
12
|
super(uri.absolute)
|
@@ -174,7 +177,7 @@ module Pione
|
|
174
177
|
# modify mtime
|
175
178
|
begin
|
176
179
|
dest.mtime = self.mtime if option[:keep_mtime]
|
177
|
-
rescue
|
180
|
+
rescue NotImplementedError
|
178
181
|
msg = "the location operation faild to keep mtime: copy from %s to %s"
|
179
182
|
Log::SystemLog.debug(msg % [address, dest.address])
|
180
183
|
end
|
@@ -189,7 +192,7 @@ module Pione
|
|
189
192
|
end
|
190
193
|
|
191
194
|
def turn(dest)
|
192
|
-
if dest.kind_of?(LocalLocation)
|
195
|
+
if Global.file_sliding and dest.kind_of?(LocalLocation)
|
193
196
|
move(dest)
|
194
197
|
link(dest)
|
195
198
|
else
|
@@ -46,5 +46,17 @@ module Pione
|
|
46
46
|
"the location \"%s\" should local location" % @location.address
|
47
47
|
end
|
48
48
|
end
|
49
|
+
|
50
|
+
# `DropboxLocationUnavailable` is raised when Dropbox location isn't
|
51
|
+
# unavailable.
|
52
|
+
class DropboxLocationUnavailable < LocationError
|
53
|
+
def initialize(message)
|
54
|
+
@message = message
|
55
|
+
end
|
56
|
+
|
57
|
+
def message
|
58
|
+
@message
|
59
|
+
end
|
60
|
+
end
|
49
61
|
end
|
50
62
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Pione
|
2
|
+
module Location
|
3
|
+
# `NotificationBroadcastScheme` is a scheme for PIONE notification protocol
|
4
|
+
# using UDP broadcast.
|
5
|
+
#
|
6
|
+
# @example
|
7
|
+
# URI.parse("pnb://255.255.255.255:56000")
|
8
|
+
class NotificationBroadcastScheme < LocationScheme('pnb')
|
9
|
+
COMPONENT = [:scheme, :host, :port]
|
10
|
+
end
|
11
|
+
|
12
|
+
# `NotificationUnicastScheme` is a scheme for PIONE notification protocol
|
13
|
+
# using UDP unicast.
|
14
|
+
#
|
15
|
+
# @example
|
16
|
+
# URI.parse("pnu://192.168.100.10:56000")
|
17
|
+
class NotificationUnicastScheme < LocationScheme('pnu')
|
18
|
+
COMPONENT = [:scheme, :host, :port]
|
19
|
+
end
|
20
|
+
|
21
|
+
# `NotificationMulticastScheme` is a scheme for PIONE notification protocol
|
22
|
+
# using UDP multicast.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
# URI.parse("pnm://239.1.2.3:56000")
|
26
|
+
# URI.parse("pnm://239.1.2.4.56000?if=192.168.100.100")
|
27
|
+
class NotificationMulticastScheme < LocationScheme('pnm')
|
28
|
+
COMPONENT = [:scheme, :host, :port, :query] # path is fake
|
29
|
+
|
30
|
+
def interface
|
31
|
+
query_table["if"] if query
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def query_table
|
37
|
+
if query
|
38
|
+
query.split("&").each_with_object({}) do |part, table|
|
39
|
+
key, val = part.split("=")
|
40
|
+
table[key] = val
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/pione/log.rb
CHANGED
@@ -4,11 +4,12 @@ module Pione
|
|
4
4
|
end
|
5
5
|
end
|
6
6
|
|
7
|
-
require 'pione/log/system-log'
|
8
|
-
require 'pione/log/debug'
|
9
|
-
require 'pione/log/message-log'
|
10
|
-
require 'pione/log/
|
11
|
-
require 'pione/log/process-
|
12
|
-
require 'pione/log/
|
13
|
-
require 'pione/log/
|
7
|
+
require 'pione/log/system-log' # system log framwork
|
8
|
+
require 'pione/log/debug' # debug message utility
|
9
|
+
require 'pione/log/message-log' # user messages from rule engine
|
10
|
+
require 'pione/log/message-log-receiver' # message log receiver
|
11
|
+
require 'pione/log/process-record' # record of event log
|
12
|
+
require 'pione/log/process-log' # event log of processing
|
13
|
+
require 'pione/log/xes-log' # XES format
|
14
|
+
require 'pione/log/domain-log' # domain informations in tuple space
|
14
15
|
|
data/lib/pione/log/debug.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module Pione
|
2
2
|
module Log
|
3
3
|
# Debug is a log utility module for showing debug messages. Messages are
|
4
|
-
# shown when according debug flags (system, rule_engine,
|
5
|
-
#
|
4
|
+
# shown when according debug flags (system, rule_engine, notification,
|
5
|
+
# communication, ignored_exception) are available.
|
6
6
|
module Debug
|
7
7
|
# Show a debug message about PIONE system activity. This message is
|
8
|
-
# visible when
|
8
|
+
# visible when `Global.debug_system` is true.
|
9
9
|
def self.system(msg_or_exc=nil, pos=caller(1).first, &b)
|
10
10
|
if Global.debug_system
|
11
11
|
print(:system, msg_or_exc, pos, &b)
|
@@ -13,18 +13,18 @@ module Pione
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# Show a debug message about rule engine activity. This message is visible
|
16
|
-
# when
|
16
|
+
# when `Global.debug_rule_engine` is true in client side.
|
17
17
|
def self.rule_engine(msg_or_exc=nil, pos=caller(1).first, &b)
|
18
18
|
if Global.debug_rule_engine
|
19
19
|
print(:rule_engine, msg_or_exc, pos, &b)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
# Show a debug message about
|
24
|
-
#
|
25
|
-
def self.
|
26
|
-
if Global.
|
27
|
-
print(:
|
23
|
+
# Show a debug message about notification. This message is visible when
|
24
|
+
# `Global.debug_notification` is true.
|
25
|
+
def self.notification(msg_or_exc=nil, pos=caller(1).first, &b)
|
26
|
+
if Global.debug_notification
|
27
|
+
print(:notification, msg_or_exc, pos, &b)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
data/lib/pione/log/domain-log.rb
CHANGED
@@ -41,10 +41,15 @@ module Pione
|
|
41
41
|
#
|
42
42
|
# @return [void]
|
43
43
|
def save
|
44
|
+
domain_info_location = @domain_location + FILENAME
|
44
45
|
text = "== %s\n\n" % Time.now
|
45
46
|
text << @record.map{|key, val| "- %s: %s" % [key,val]}.join("\n")
|
46
47
|
text << "\n\n"
|
47
|
-
|
48
|
+
if domain_info_location.exist?
|
49
|
+
domain_info_location.append(text)
|
50
|
+
else
|
51
|
+
domain_info_location.create(text)
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
private
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Pione
|
2
|
+
module Log
|
3
|
+
# MessageLogReceiver is an abstract class for message log receivers.
|
4
|
+
class MessageLogReceiver
|
5
|
+
# Receive the message with attributes.
|
6
|
+
#
|
7
|
+
# @param message [String]
|
8
|
+
# the message
|
9
|
+
# @param level [Integer]
|
10
|
+
# message depth level
|
11
|
+
# @param header [String]
|
12
|
+
# message header
|
13
|
+
# @param color [String]
|
14
|
+
# message color
|
15
|
+
def receiver(message, level, header, color)
|
16
|
+
raise NotImplementedError.new
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# `CUIMessageLogReceiver` is a message log receiver for CUI
|
21
|
+
# environment. This receiver prints messages to stdout.
|
22
|
+
class CUIMessageLogReceiver < MessageLogReceiver
|
23
|
+
def initialize(out=$stdout)
|
24
|
+
@out = out
|
25
|
+
end
|
26
|
+
|
27
|
+
def receive(message, level, header, color)
|
28
|
+
@out.puts "%s%s %s" % [" "*level, ("%5s" % header).color(color), message]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/pione/log/system-log.rb
CHANGED
@@ -1,118 +1,33 @@
|
|
1
1
|
module Pione
|
2
2
|
module Log
|
3
|
-
|
4
|
-
|
5
|
-
def self.fatal(msg, pos=caller(1).first)
|
6
|
-
Global.system_logger.fatal(msg, pos)
|
7
|
-
end
|
8
|
-
|
9
|
-
# Log the error message.
|
10
|
-
def self.error(msg, pos=caller(1).first)
|
11
|
-
Global.system_logger.error(msg, pos)
|
12
|
-
end
|
13
|
-
|
14
|
-
# Log the warn message.
|
15
|
-
def self.warn(msg, pos=caller(1).first)
|
16
|
-
Global.system_logger.warn(msg, pos)
|
17
|
-
end
|
18
|
-
|
19
|
-
# Log the info message.
|
20
|
-
def self.info(msg, pos=caller(1).first)
|
21
|
-
Global.system_logger.info(msg, pos)
|
22
|
-
end
|
23
|
-
|
24
|
-
# Log the debug message.
|
25
|
-
def self.debug(msg, pos=caller(1).first)
|
26
|
-
Global.system_logger.debug(msg, pos)
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.terminate
|
30
|
-
Global.system_logger.terminate
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# SystemLogger is a interface for system logger implementations.
|
35
|
-
class SystemLogger
|
36
|
-
@logger = {} # logger class table
|
3
|
+
SystemLog = Rootage::Log
|
4
|
+
SystemLog.set_logger_block {Global.system_logger}
|
37
5
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
# Register the logger class with the type.
|
44
|
-
def self.register(type, logger_class)
|
45
|
-
@logger[type] = logger_class
|
46
|
-
end
|
47
|
-
|
48
|
-
# Return the log level.
|
49
|
-
def level
|
50
|
-
raise NotImplementedError
|
51
|
-
end
|
52
|
-
|
53
|
-
# Set the log level.
|
54
|
-
def level=(level)
|
55
|
-
raise NotImplementedError
|
56
|
-
end
|
57
|
-
|
58
|
-
# Log the fatal message.
|
59
|
-
def fatal(msg, pos=caller(1).first)
|
60
|
-
raise NotImplementedError
|
61
|
-
end
|
62
|
-
|
63
|
-
# Log the error message.
|
64
|
-
def error(msg, pos=caller(1).first)
|
65
|
-
raise NotImplementedError
|
66
|
-
end
|
67
|
-
|
68
|
-
# Log the warn message.
|
69
|
-
def warn(msg, pos=caller(1).first)
|
70
|
-
raise NotImplementedError
|
71
|
-
end
|
6
|
+
# `Log::PioneSystemLogger` is a PIONE original logger. This generates very
|
7
|
+
# colorful message for identifiability and detailed informations.
|
8
|
+
class PioneSystemLogger < Rootage::Logger
|
9
|
+
include DRbUndumped
|
72
10
|
|
73
|
-
# Log the info message.
|
74
|
-
def info(msg, pos=caller(1).first)
|
75
|
-
raise NotImplementedError
|
76
|
-
end
|
77
|
-
|
78
|
-
# Log the debug message.
|
79
|
-
def debug(msg, pos=caller(1).first)
|
80
|
-
raise NotImplementedError
|
81
|
-
end
|
82
|
-
|
83
|
-
# Terminate the logger.
|
84
|
-
def terminate
|
85
|
-
raise NotImplementedError
|
86
|
-
end
|
87
|
-
|
88
|
-
# Return true if some messages are queued.
|
89
|
-
def queued?
|
90
|
-
raise NotImplementedError
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
# PioneSystemLogger is a PIONE original logger. This generates very colorful
|
95
|
-
# message for identifiability and detailed informations.
|
96
|
-
class PioneSystemLogger < SystemLogger
|
97
11
|
attr_accessor :level
|
98
12
|
|
99
|
-
def initialize(out =
|
13
|
+
def initialize(out = nil)
|
100
14
|
@queue = Queue.new
|
101
15
|
@thread = make_writer_thread
|
102
16
|
@level = :info
|
17
|
+
@lock = Mutex.new
|
103
18
|
@out = out
|
104
19
|
end
|
105
20
|
|
106
|
-
def fatal(msg, pos=caller(1).first); push(:fatal, msg, pos); end
|
107
|
-
def error(msg, pos=caller(1).first); push(:error, msg, pos); end
|
108
|
-
def warn (msg, pos=caller(1).first); push(:warn , msg, pos); end
|
109
|
-
def info (msg, pos=caller(1).first); push(:info , msg, pos); end
|
110
|
-
def debug(msg, pos=caller(1).first); push(:debug, msg, pos); end
|
21
|
+
def fatal(msg, pos=caller(1).first, pid=Process.pid); push(:fatal, msg, pos, pid); end
|
22
|
+
def error(msg, pos=caller(1).first, pid=Process.pid); push(:error, msg, pos, pid); end
|
23
|
+
def warn (msg, pos=caller(1).first, pid=Process.pid); push(:warn , msg, pos, pid); end
|
24
|
+
def info (msg, pos=caller(1).first, pid=Process.pid); push(:info , msg, pos, pid); end
|
25
|
+
def debug(msg, pos=caller(1).first, pid=Process.pid); push(:debug, msg, pos, pid); end
|
111
26
|
|
112
27
|
def terminate
|
113
28
|
timeout(3) do
|
114
29
|
while @thread.alive?
|
115
|
-
if @queue.empty?
|
30
|
+
if @queue.empty? and not(@lock.locked?)
|
116
31
|
@thread.kill.join
|
117
32
|
break
|
118
33
|
else
|
@@ -121,11 +36,11 @@ module Pione
|
|
121
36
|
end
|
122
37
|
end
|
123
38
|
rescue Timeout::Error
|
39
|
+
# don't use logger here because it is dead at this time
|
40
|
+
$stdout.puts("*** system logger has been terminated unsafety, some messages maybe lost ***")
|
41
|
+
ensure
|
124
42
|
# kill writer thread
|
125
43
|
@thread.kill if @thread.alive?
|
126
|
-
|
127
|
-
# don't use logger because it is dead at this time
|
128
|
-
@out.puts("*** system logger has been terminated unsafety, some messages maybe lost ***")
|
129
44
|
end
|
130
45
|
|
131
46
|
def queued?
|
@@ -134,75 +49,83 @@ module Pione
|
|
134
49
|
|
135
50
|
private
|
136
51
|
|
52
|
+
def level_to_i(level)
|
53
|
+
case level
|
54
|
+
when :fatal; 0
|
55
|
+
when :error; 1
|
56
|
+
when :warn ; 2
|
57
|
+
when :info ; 3
|
58
|
+
when :debug; 4
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
137
62
|
def make_writer_thread
|
138
63
|
Thread.new do
|
139
64
|
while true do
|
140
|
-
level, msg, pos, time = @queue.pop
|
141
|
-
print(level, msg, pos, time)
|
65
|
+
level, msg, pos, pid, time = @queue.pop
|
66
|
+
@lock.synchronize {print(level, msg, pos, pid, time)}
|
142
67
|
end
|
143
68
|
end
|
144
69
|
end
|
145
70
|
|
146
|
-
def push(level, msg, pos)
|
147
|
-
@
|
71
|
+
def push(level, msg, pos, pid)
|
72
|
+
if level_to_i(@level) >= level_to_i(level)
|
73
|
+
@queue.push([level, msg, pos, pid, Time.now])
|
74
|
+
end
|
148
75
|
end
|
149
76
|
|
150
77
|
def color_of(level)
|
151
78
|
Global.send("pione_system_logger_%s" % level)
|
152
79
|
end
|
153
80
|
|
154
|
-
def print(level, msg, pos, time)
|
81
|
+
def print(level, msg, pos, pid, time)
|
82
|
+
out = @out || $stdout
|
155
83
|
if level == :info
|
156
|
-
|
84
|
+
out.puts "%s: %s" % [level.to_s.color(color_of(level)), msg]
|
157
85
|
else
|
158
|
-
|
86
|
+
out.puts "%s: %s [%s] (%s, #%s)" % [level.to_s.color(color_of(level)), msg, pos, time.iso8601(3), pid]
|
159
87
|
end
|
160
88
|
end
|
161
89
|
end
|
162
90
|
|
163
|
-
|
164
|
-
|
165
|
-
forward! :@logger, :level, :level=
|
91
|
+
class DelegatableLogger < Rootage::Logger
|
92
|
+
include DRbUndumped
|
166
93
|
|
167
|
-
def initialize(
|
168
|
-
@logger =
|
94
|
+
def initialize(logger)
|
95
|
+
@logger = logger
|
169
96
|
end
|
170
97
|
|
171
|
-
def fatal(msg, pos=caller(1).first
|
172
|
-
|
173
|
-
def warn (msg, pos=caller(1).first); @logger.warn(msg) ; end
|
174
|
-
def info (msg, pos=caller(1).first); @logger.info(msg) ; end
|
175
|
-
def debug(msg, pos=caller(1).first); @logger.debug(msg); end
|
176
|
-
|
177
|
-
def terminate
|
178
|
-
# ignore
|
98
|
+
def fatal(msg, pos=caller(1).first, pid=Process.pid)
|
99
|
+
send_message(msg, pos, pid) {@logger.fatal(msg, pos, pid)}
|
179
100
|
end
|
180
101
|
|
181
|
-
def
|
182
|
-
|
102
|
+
def error(msg, pos=caller(1).first, pid=Process.pid)
|
103
|
+
send_message(msg, pos, pid) {@logger.error(msg, pos, pid)}
|
183
104
|
end
|
184
|
-
end
|
185
105
|
|
186
|
-
|
187
|
-
|
188
|
-
|
106
|
+
def warn(msg, pos=caller(1).first, pid=Process.pid)
|
107
|
+
send_message(msg, pos, pid) {@logger.warn(msg, pos, pid)}
|
108
|
+
end
|
189
109
|
|
190
|
-
def
|
191
|
-
@logger
|
110
|
+
def info(msg, pos=caller(1).first, pid=Process.pid)
|
111
|
+
send_message(msg, pos, pid) {@logger.info(msg, pos, pid)}
|
192
112
|
end
|
193
113
|
|
194
|
-
def
|
195
|
-
|
196
|
-
|
197
|
-
def info (msg, pos=caller(1).first); @logger.info(msg) ; end
|
198
|
-
def debug(msg, pos=caller(1).first); @logger.debug(msg); end
|
114
|
+
def debug(msg, pos=caller(1).first, pid=Process.pid)
|
115
|
+
send_message(msg, pos, pid) {@logger.debug(msg, pos, pid)}
|
116
|
+
end
|
199
117
|
|
200
118
|
def terminate
|
201
|
-
|
119
|
+
@logger = nil
|
202
120
|
end
|
203
121
|
|
204
|
-
|
205
|
-
|
122
|
+
private
|
123
|
+
|
124
|
+
def send_message(msg, pos, pid, &block)
|
125
|
+
block.call
|
126
|
+
rescue Exception
|
127
|
+
# print stdout directly if the logger fails
|
128
|
+
$stdout.puts("%s (%s) #%s" % [msg, pos, pid])
|
206
129
|
end
|
207
130
|
end
|
208
131
|
|
@@ -210,8 +133,6 @@ module Pione
|
|
210
133
|
# register loggers
|
211
134
|
#
|
212
135
|
|
213
|
-
|
214
|
-
SystemLogger.register(:ruby, RubyStandardSystemLogger)
|
215
|
-
SystemLogger.register(:syslog, SyslogSystemLogger)
|
136
|
+
Rootage::Logger.register(:pione, PioneSystemLogger)
|
216
137
|
end
|
217
138
|
end
|