pione 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +14 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +118 -0
- data/bin/pione-broker +5 -0
- data/bin/pione-clean +5 -0
- data/bin/pione-client +5 -0
- data/bin/pione-eval +111 -0
- data/bin/pione-relay +5 -0
- data/bin/pione-relay-account-db +5 -0
- data/bin/pione-relay-client-db +5 -0
- data/bin/pione-search-log +30 -0
- data/bin/pione-syntax-checker +5 -0
- data/bin/pione-task-worker +5 -0
- data/bin/pione-tuple-space-provider +5 -0
- data/bin/pione-tuple-space-receiver +5 -0
- data/bin/pione-tuple-space-viewer +5 -0
- data/demo/demo.rb +311 -0
- data/demo/public/base.css +94 -0
- data/demo/public/demo.js +107 -0
- data/demo/public/index.html +91 -0
- data/demo/public/jquery-1.8.3.min.js +2 -0
- data/example/CountChar/CountChar.pione +64 -0
- data/example/CountChar/misc/CountChar.rb +22 -0
- data/example/CountChar/text/aidokushono_insho.txt +32 -0
- data/example/CountChar/text/aikokuka_shokan.txt +108 -0
- data/example/CountChar/text/carlyle_hakubutsukan.txt +58 -0
- data/example/CountChar/text/dark_minister.txt +2440 -0
- data/example/CountChar/text/kaikano_otto.txt +61 -0
- data/example/CountChar/text/kaikon.txt +30 -0
- data/example/CountChar/text/nagashimano_shi.txt +45 -0
- data/example/CountChar/text/saikachibuchi.txt +80 -0
- data/example/CountChar/text/saikonihonno_josei.txt +91 -0
- data/example/CountChar/text/taishojugonenno_bundan.txt +21 -0
- data/example/FeatureExample/FeatureExample.pione +7 -0
- data/example/Fib/Fib.pione +56 -0
- data/example/Fib/FibBC.pione +56 -0
- data/example/HelloWorld/HelloWorld.pione +5 -0
- data/example/LucasNumber/LucasNumber.pione +64 -0
- data/example/MakePair/MakePair.pione +14 -0
- data/example/MakePair/data/1.i +0 -0
- data/example/MakePair/data/2.i +0 -0
- data/example/MakePair/data/3.i +0 -0
- data/example/MakePair/data/4.i +0 -0
- data/example/MakePair/data/5.i +0 -0
- data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +61 -0
- data/example/SingleParticlesWithRef/Makefile +289 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.Makefile +153 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +116 -0
- data/example/SingleParticlesWithRef/SingleParticlesWithRefFull.pione +400 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-0-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-120-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-180-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-240-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-300-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-60-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-0-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-120-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-180-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-240-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-300-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-0-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-120-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-180-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-240-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-300-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift-noise-60-60-0.roi +0 -0
- data/example/SingleParticlesWithRef/data/121p-shift.pdb +3381 -0
- data/example/SingleParticlesWithRef/data/all.ref2d +0 -0
- data/example/SingleParticlesWithRef/data/all.ref3d +0 -0
- data/example/Sum/Sum.pione +52 -0
- data/example/SyntaxError/call_rule_error.pione +6 -0
- data/example/SyntaxError/feature_line_error.pione +7 -0
- data/example/SyntaxError/flow_block_error.pione +5 -0
- data/example/SyntaxError/input_line_error.pione +6 -0
- data/example/SyntaxError/invalid_rule_name.pione +6 -0
- data/example/SyntaxError/param_line_error.pione +7 -0
- data/example/SyntaxError/variable-binding-error.pione +11 -0
- data/lib/pione.rb +241 -0
- data/lib/pione/agent/basic-agent.rb +333 -0
- data/lib/pione/agent/broker.rb +274 -0
- data/lib/pione/agent/command-listener.rb +47 -0
- data/lib/pione/agent/input-generator.rb +194 -0
- data/lib/pione/agent/logger.rb +65 -0
- data/lib/pione/agent/process-manager.rb +38 -0
- data/lib/pione/agent/rule-provider.rb +64 -0
- data/lib/pione/agent/task-worker.rb +274 -0
- data/lib/pione/agent/trivial-routine-worker.rb +28 -0
- data/lib/pione/agent/tuple-space-client.rb +146 -0
- data/lib/pione/agent/tuple-space-server-client-life-checker.rb +29 -0
- data/lib/pione/command-option/basic-option.rb +42 -0
- data/lib/pione/command-option/child-process-option.rb +17 -0
- data/lib/pione/command-option/common-option.rb +29 -0
- data/lib/pione/command-option/daemon-option.rb +12 -0
- data/lib/pione/command-option/presence-notifier-option.rb +15 -0
- data/lib/pione/command-option/task-worker-owner-option.rb +17 -0
- data/lib/pione/command-option/tuple-space-provider-option.rb +26 -0
- data/lib/pione/command-option/tuple-space-provider-owner-option.rb +16 -0
- data/lib/pione/command-option/tuple-space-receiver-option.rb +12 -0
- data/lib/pione/command/basic-command.rb +126 -0
- data/lib/pione/command/child-process.rb +43 -0
- data/lib/pione/command/daemon-process.rb +18 -0
- data/lib/pione/command/front-owner-command.rb +37 -0
- data/lib/pione/command/pione-broker.rb +53 -0
- data/lib/pione/command/pione-clean.rb +16 -0
- data/lib/pione/command/pione-client.rb +273 -0
- data/lib/pione/command/pione-relay-account-db.rb +85 -0
- data/lib/pione/command/pione-relay-client-db.rb +80 -0
- data/lib/pione/command/pione-relay.rb +47 -0
- data/lib/pione/command/pione-syntax-checker.rb +103 -0
- data/lib/pione/command/pione-task-worker.rb +123 -0
- data/lib/pione/command/pione-tuple-space-provider.rb +87 -0
- data/lib/pione/command/pione-tuple-space-receiver.rb +55 -0
- data/lib/pione/command/pione-tuple-space-viewer.rb +151 -0
- data/lib/pione/command/tuple-space-provider-owner.rb +6 -0
- data/lib/pione/front/basic-front.rb +64 -0
- data/lib/pione/front/broker-front.rb +30 -0
- data/lib/pione/front/client-front.rb +28 -0
- data/lib/pione/front/relay-front.rb +19 -0
- data/lib/pione/front/task-worker-front.rb +16 -0
- data/lib/pione/front/task-worker-owner.rb +42 -0
- data/lib/pione/front/tuple-space-provider-front.rb +22 -0
- data/lib/pione/front/tuple-space-provider-owner.rb +11 -0
- data/lib/pione/front/tuple-space-receiver-front.rb +18 -0
- data/lib/pione/model/assignment.rb +89 -0
- data/lib/pione/model/basic-model.rb +395 -0
- data/lib/pione/model/binary-operator.rb +80 -0
- data/lib/pione/model/block.rb +233 -0
- data/lib/pione/model/boolean.rb +138 -0
- data/lib/pione/model/call-rule.rb +69 -0
- data/lib/pione/model/data-expr.rb +360 -0
- data/lib/pione/model/feature-expr.rb +794 -0
- data/lib/pione/model/float.rb +107 -0
- data/lib/pione/model/integer.rb +140 -0
- data/lib/pione/model/list.rb +104 -0
- data/lib/pione/model/message.rb +80 -0
- data/lib/pione/model/package.rb +48 -0
- data/lib/pione/model/parameters.rb +282 -0
- data/lib/pione/model/rule-expr.rb +120 -0
- data/lib/pione/model/rule-io.rb +166 -0
- data/lib/pione/model/rule.rb +294 -0
- data/lib/pione/model/string.rb +111 -0
- data/lib/pione/model/undefined-value.rb +24 -0
- data/lib/pione/model/variable-table.rb +315 -0
- data/lib/pione/model/variable.rb +87 -0
- data/lib/pione/parser/block-parser.rb +83 -0
- data/lib/pione/parser/common-parser.rb +145 -0
- data/lib/pione/parser/document-parser.rb +58 -0
- data/lib/pione/parser/error-message.yml +4 -0
- data/lib/pione/parser/expr-parser.rb +266 -0
- data/lib/pione/parser/feature-expr-parser.rb +105 -0
- data/lib/pione/parser/flow-element-parser.rb +181 -0
- data/lib/pione/parser/literal-parser.rb +182 -0
- data/lib/pione/parser/rule-definition-parser.rb +163 -0
- data/lib/pione/parser/syntax-error.rb +61 -0
- data/lib/pione/patch/array-patch.rb +3 -0
- data/lib/pione/patch/drb-patch.rb +467 -0
- data/lib/pione/patch/monitor-patch.rb +16 -0
- data/lib/pione/patch/rinda-patch.rb +759 -0
- data/lib/pione/patch/uri-patch.rb +66 -0
- data/lib/pione/relay/receiver-socket.rb +69 -0
- data/lib/pione/relay/relay-account-db.rb +55 -0
- data/lib/pione/relay/relay-client-db.rb +53 -0
- data/lib/pione/relay/relay-socket.rb +215 -0
- data/lib/pione/relay/trampoline.rb +22 -0
- data/lib/pione/relay/transmitter-socket.rb +167 -0
- data/lib/pione/resource/basic-resource.rb +92 -0
- data/lib/pione/resource/dropbox-resource.rb +106 -0
- data/lib/pione/resource/ftp.rb +84 -0
- data/lib/pione/resource/local.rb +113 -0
- data/lib/pione/rule-handler/action-handler.rb +184 -0
- data/lib/pione/rule-handler/basic-handler.rb +217 -0
- data/lib/pione/rule-handler/flow-handler.rb +339 -0
- data/lib/pione/rule-handler/root-handler.rb +23 -0
- data/lib/pione/rule-handler/system-handler.rb +13 -0
- data/lib/pione/system/common.rb +22 -0
- data/lib/pione/system/config.rb +20 -0
- data/lib/pione/system/document.rb +81 -0
- data/lib/pione/system/file-cache.rb +150 -0
- data/lib/pione/system/global.rb +346 -0
- data/lib/pione/system/identifier.rb +61 -0
- data/lib/pione/system/init.rb +16 -0
- data/lib/pione/system/object.rb +35 -0
- data/lib/pione/transformer/block-transformer.rb +23 -0
- data/lib/pione/transformer/document-transformer.rb +36 -0
- data/lib/pione/transformer/expr-transformer.rb +89 -0
- data/lib/pione/transformer/feature-expr-transformer.rb +56 -0
- data/lib/pione/transformer/flow-element-transformer.rb +66 -0
- data/lib/pione/transformer/literal-transformer.rb +76 -0
- data/lib/pione/transformer/rule-definition-transformer.rb +62 -0
- data/lib/pione/transformer/transformer-module.rb +37 -0
- data/lib/pione/tuple-space/data-finder.rb +165 -0
- data/lib/pione/tuple-space/presence-notifier.rb +83 -0
- data/lib/pione/tuple-space/relay.rb +9 -0
- data/lib/pione/tuple-space/tuple-space-provider.rb +85 -0
- data/lib/pione/tuple-space/tuple-space-receiver.rb +140 -0
- data/lib/pione/tuple-space/tuple-space-server-interface.rb +60 -0
- data/lib/pione/tuple-space/tuple-space-server.rb +156 -0
- data/lib/pione/tuple-space/update-criteria.rb +96 -0
- data/lib/pione/tuple/agent-tuple.rb +10 -0
- data/lib/pione/tuple/attribute-tuple.rb +7 -0
- data/lib/pione/tuple/base-uri-tuple.rb +9 -0
- data/lib/pione/tuple/basic-tuple.rb +317 -0
- data/lib/pione/tuple/bye-tuple.rb +9 -0
- data/lib/pione/tuple/command-tuple.rb +9 -0
- data/lib/pione/tuple/data-tuple.rb +18 -0
- data/lib/pione/tuple/dry-run-tuple.rb +8 -0
- data/lib/pione/tuple/exception-tuple.rb +11 -0
- data/lib/pione/tuple/finished-tuple.rb +17 -0
- data/lib/pione/tuple/foreground-tuple.rb +7 -0
- data/lib/pione/tuple/log-tuple.rb +14 -0
- data/lib/pione/tuple/process-info-tuple.rb +9 -0
- data/lib/pione/tuple/request-rule-tuple.rb +9 -0
- data/lib/pione/tuple/rule-tuple.rb +10 -0
- data/lib/pione/tuple/shift-tuple.rb +13 -0
- data/lib/pione/tuple/task-tuple.rb +36 -0
- data/lib/pione/tuple/task-worker-resource-tuple.rb +9 -0
- data/lib/pione/tuple/working-tuple.rb +13 -0
- data/lib/pione/uri-scheme/basic-scheme.rb +40 -0
- data/lib/pione/uri-scheme/broadcast-scheme.rb +11 -0
- data/lib/pione/uri-scheme/dropbox-scheme.rb +9 -0
- data/lib/pione/uri-scheme/local-scheme.rb +28 -0
- data/lib/pione/util/error-report.rb +12 -0
- data/lib/pione/util/log.rb +79 -0
- data/lib/pione/util/message.rb +155 -0
- data/lib/pione/util/misc.rb +73 -0
- data/lib/pione/util/terminal.rb +78 -0
- data/lib/pione/util/waiter-table.rb +53 -0
- data/lib/pione/version.rb +3 -0
- data/misc/env.sh +2 -0
- data/misc/test-drb-stop-service.rb +34 -0
- data/misc/test-ensure-and-thread-kill.rb +40 -0
- data/misc/test-many-waiters-client.rb +56 -0
- data/misc/test-many-waiters-server.rb +14 -0
- data/misc/write_and_take_test.png +0 -0
- data/misc/write_and_take_test.rb +36 -0
- data/pione.gemspec +49 -0
- data/test/agent/spec_basic-agent.rb +170 -0
- data/test/agent/spec_broker.rb +36 -0
- data/test/agent/spec_command-listener.rb +30 -0
- data/test/agent/spec_input-generator.rb +123 -0
- data/test/agent/spec_logger.rb +71 -0
- data/test/agent/spec_rule-provider.rb +65 -0
- data/test/agent/spec_task-worker.rb +307 -0
- data/test/agent/spec_tuple-space-client.rb +30 -0
- data/test/model/spec_assignment.rb +51 -0
- data/test/model/spec_binary-operator.rb +39 -0
- data/test/model/spec_block.rb +154 -0
- data/test/model/spec_boolean.rb +115 -0
- data/test/model/spec_call-rule.rb +23 -0
- data/test/model/spec_data-expr.rb +312 -0
- data/test/model/spec_feature-expr.rb +359 -0
- data/test/model/spec_feature-expr.yml +16 -0
- data/test/model/spec_float.rb +141 -0
- data/test/model/spec_integer.rb +141 -0
- data/test/model/spec_list.rb +26 -0
- data/test/model/spec_message.rb +42 -0
- data/test/model/spec_package.rb +15 -0
- data/test/model/spec_parameters.rb +148 -0
- data/test/model/spec_rule-expr.rb +66 -0
- data/test/model/spec_rule-io.rb +32 -0
- data/test/model/spec_rule.rb +158 -0
- data/test/model/spec_string.rb +106 -0
- data/test/model/spec_variable-table.rb +117 -0
- data/test/model/spec_variable.rb +84 -0
- data/test/parser/spec_block-parser.rb +5 -0
- data/test/parser/spec_block-parser.yml +85 -0
- data/test/parser/spec_common-parser.rb +281 -0
- data/test/parser/spec_expr-parser.rb +6 -0
- data/test/parser/spec_expr-parser.yml +82 -0
- data/test/parser/spec_feature-expr-parser.rb +32 -0
- data/test/parser/spec_feature-expr-parser.yml +25 -0
- data/test/parser/spec_flow-element-parser.rb +5 -0
- data/test/parser/spec_flow-element-parser.yml +180 -0
- data/test/parser/spec_literal-parser.rb +5 -0
- data/test/parser/spec_literal-parser.yml +123 -0
- data/test/parser/spec_rule-definition-parser.rb +5 -0
- data/test/parser/spec_rule-definition-parser.yml +93 -0
- data/test/patch/spec_rinda-patch.rb +32 -0
- data/test/patch/spec_uri-patch.rb +23 -0
- data/test/rule-handler/spec_action-handler.rb +135 -0
- data/test/rule-handler/spec_flow-handler.rb +127 -0
- data/test/spec_common.rb +14 -0
- data/test/spec_data-finder.rb +88 -0
- data/test/spec_data-finder.yml +115 -0
- data/test/spec_document.rb +76 -0
- data/test/spec_identifier.rb +29 -0
- data/test/spec_log.rb +52 -0
- data/test/spec_object.rb +20 -0
- data/test/spec_resource.rb +73 -0
- data/test/spec_update-criteria.rb +83 -0
- data/test/test-util.rb +223 -0
- data/test/transformer/spec_block-transformer.rb +26 -0
- data/test/transformer/spec_expr-transformer.rb +106 -0
- data/test/transformer/spec_feature-expr-transformer.rb +21 -0
- data/test/transformer/spec_flow-element-transformer.rb +154 -0
- data/test/transformer/spec_literal-transformer.rb +58 -0
- data/test/transformer/spec_rule-definition-transformer.rb +168 -0
- data/test/tuple-space/spec_tuple-space-provider.rb +36 -0
- data/test/tuple-space/spec_tuple-space-receiver.rb +32 -0
- data/test/tuple-space/spec_tuple-space-server.rb +49 -0
- data/test/tuple/spec_basic-tuple.rb +87 -0
- data/test/tuple/spec_data-tuple.rb +85 -0
- data/test/tuple/spec_finished-tuple.rb +61 -0
- data/test/tuple/spec_task-tuple.rb +127 -0
- data/test/tuple/spec_working-tuple.rb +58 -0
- data/test/uri-scheme/spec_broadcast-scheme.rb +40 -0
- data/test/uri-scheme/spec_dropbox-scheme.rb +31 -0
- data/test/uri-scheme/spec_local-scheme.rb +69 -0
- metadata +660 -0
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module Agent
|
|
3
|
+
module TupleSpaceClientOperation
|
|
4
|
+
# Sends a bye message to the tuple space servers and terminate myself.
|
|
5
|
+
def finalize
|
|
6
|
+
unless current_state == :terminated
|
|
7
|
+
bye
|
|
8
|
+
terminate
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Send a hello message to the tuple space server.
|
|
13
|
+
def hello
|
|
14
|
+
write(to_agent_tuple)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
# Send a bye message to the tuple space server.
|
|
18
|
+
def bye
|
|
19
|
+
Util.ignore_exception do
|
|
20
|
+
write(to_bye_tuple)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Makes the agent tuple.
|
|
25
|
+
# @return [Tuple::Agent]
|
|
26
|
+
# the agent tuple
|
|
27
|
+
def to_agent_tuple
|
|
28
|
+
Tuple[:agent].new(agent_type: agent_type, uuid: uuid)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# Makes the bye tuple.
|
|
32
|
+
# @return [Tuple::Bye]
|
|
33
|
+
# the bye tuple
|
|
34
|
+
def to_bye_tuple
|
|
35
|
+
Tuple[:bye].new(agent_type: agent_type, uuid: uuid)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Notify the agent happened a exception.
|
|
39
|
+
def notify_exception(e)
|
|
40
|
+
# ignore exception because the exception caused tuple server is down...
|
|
41
|
+
Util.ignore_exception do
|
|
42
|
+
write(Tuple[:exception].new(uuid, agent_type, e))
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Protected take.
|
|
47
|
+
def take(*args)
|
|
48
|
+
tuple = super(*args, &method(:set_current_tuple_entry))
|
|
49
|
+
set_current_tuple_entry(nil)
|
|
50
|
+
return tuple
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# Protected read.
|
|
54
|
+
def read(*args)
|
|
55
|
+
tuple = super(*args, &method(:set_current_tuple_entry))
|
|
56
|
+
set_current_tuple_entry(nil)
|
|
57
|
+
return tuple
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
private
|
|
61
|
+
|
|
62
|
+
# Return current tuple's entry.
|
|
63
|
+
def current_tuple_entry
|
|
64
|
+
@__current_tuple_entry__
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Set current operating tuple entry.
|
|
68
|
+
def set_current_tuple_entry(entry)
|
|
69
|
+
@__current_tuple_entry__ = entry
|
|
70
|
+
entry.instance_eval {if @place then def @place.to_s; ""; end; end }
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Cancel current tuple's entry.
|
|
74
|
+
def cancel_current_tuple_entry
|
|
75
|
+
current_tuple_entry.cancel if current_tuple_entry
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
class TupleSpaceClient < BasicAgent
|
|
80
|
+
include TupleSpaceServerInterface
|
|
81
|
+
include TupleSpaceClientOperation
|
|
82
|
+
|
|
83
|
+
# Initialize agent's state.
|
|
84
|
+
def initialize(tuple_space_server)
|
|
85
|
+
super()
|
|
86
|
+
set_tuple_space_server(tuple_space_server)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def start
|
|
90
|
+
super()
|
|
91
|
+
return self
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# State initialized.
|
|
95
|
+
def transit_to_initialized
|
|
96
|
+
hello
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# State terminated
|
|
100
|
+
def transit_to_terminated
|
|
101
|
+
Util.ignore_exception { bye }
|
|
102
|
+
cancel_current_tuple_entry
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# State error
|
|
106
|
+
def transit_to_error(e)
|
|
107
|
+
if e
|
|
108
|
+
$stderr.puts e
|
|
109
|
+
$stderr.puts e.backtrace
|
|
110
|
+
end
|
|
111
|
+
notify_exception(e)
|
|
112
|
+
terminate
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Redefine hello method with logging.
|
|
116
|
+
def hello
|
|
117
|
+
log do |msg|
|
|
118
|
+
msg.add_record(agent_type, "action", "hello")
|
|
119
|
+
msg.add_record(agent_type, "uuid", uuid)
|
|
120
|
+
end
|
|
121
|
+
super
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
# Redefine bye method with logging.
|
|
125
|
+
def bye
|
|
126
|
+
log do |msg|
|
|
127
|
+
msg.add_record(agent_type, "action", "bye")
|
|
128
|
+
msg.add_record(agent_type, "uuid", uuid)
|
|
129
|
+
end
|
|
130
|
+
super
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Redefine call transition method with logging.
|
|
134
|
+
def call_transition_method(*args)
|
|
135
|
+
unless [:logger, :command_listener].include?(agent_type)
|
|
136
|
+
log do |msg|
|
|
137
|
+
msg.add_record(agent_type, "action", "transit")
|
|
138
|
+
msg.add_record(agent_type, "state", args.first)
|
|
139
|
+
msg.add_record(agent_type, "uuid", uuid)
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
super
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module Agent
|
|
3
|
+
class TupleSpaceServerClientLifeChecker < BasicAgent
|
|
4
|
+
include TupleSpaceServerInterface
|
|
5
|
+
|
|
6
|
+
define_state :checking_bye
|
|
7
|
+
define_state :cleaning_agent
|
|
8
|
+
define_state :sleeping
|
|
9
|
+
|
|
10
|
+
define_state_transition :initialized => :checking_bye
|
|
11
|
+
define_state_transition :checking_bye => :cleaning_agent
|
|
12
|
+
define_state_transition :cleaning_agent => :checking_bye
|
|
13
|
+
|
|
14
|
+
def initialize(tuple_space_server)
|
|
15
|
+
super()
|
|
16
|
+
set_tuple_space_server(tuple_space_server)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def transit_to_checking_bye
|
|
20
|
+
return take(Tuple[:bye].any)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def transit_to_cleaning_agent(bye)
|
|
24
|
+
take(Tuple[:agent].new(uuid: bye.uuid))
|
|
25
|
+
return nil
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module OptionInterface
|
|
4
|
+
# @api private
|
|
5
|
+
def self.extended(klass)
|
|
6
|
+
klass.instance_variable_set(:@command_options, {})
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# Defines an option for the command.
|
|
10
|
+
# @return [void]
|
|
11
|
+
def define_option(*args, &b)
|
|
12
|
+
@command_options[args.first] = [args, b]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Removes the option.
|
|
16
|
+
# @return [void]
|
|
17
|
+
def remove_option(name)
|
|
18
|
+
@command_options.delete(name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns the command options.
|
|
22
|
+
# @return [Array]
|
|
23
|
+
def command_options
|
|
24
|
+
@command_options
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Installs the option module.
|
|
28
|
+
# @return [void]
|
|
29
|
+
def use_option_module(mod)
|
|
30
|
+
@command_options = @command_options.update(mod.command_options)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
class BasicOption
|
|
35
|
+
extend OptionInterface
|
|
36
|
+
|
|
37
|
+
def self.inherited(klass)
|
|
38
|
+
klass.instance_variable_set(:@command_options, command_options.clone)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module ChildProcessOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
|
|
6
|
+
# --parent-front
|
|
7
|
+
define_option('--parent-front=URI', 'set parent front URI') do |uri|
|
|
8
|
+
@parent_front = DRbObject.new_with_uri(uri)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# --no-parent
|
|
12
|
+
define_option('--no-parent', 'turn on no parent mode') do
|
|
13
|
+
@no_parent_mode = true
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module CommonOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
|
|
6
|
+
# --debug
|
|
7
|
+
define_option('-d', '--debug', "turn on debug mode") do |name|
|
|
8
|
+
Pione.debug_mode = true
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# --show-communication
|
|
12
|
+
define_option('--show-communication', "show object communication") do |show|
|
|
13
|
+
Global.show_communication = true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# --color
|
|
17
|
+
define_option('--[no-]color', 'turn on/off color mode') do |str|
|
|
18
|
+
bool = nil
|
|
19
|
+
bool = true if str == "true"
|
|
20
|
+
bool = false if str == "false"
|
|
21
|
+
if bool.nil?
|
|
22
|
+
puts "invalid color option: %s" % bool
|
|
23
|
+
exit
|
|
24
|
+
end
|
|
25
|
+
Terminal.color_mode = bool
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module PresenceNotifierOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
|
|
6
|
+
# --show-presence-notifier
|
|
7
|
+
define_option(
|
|
8
|
+
"--show-presence-notifier",
|
|
9
|
+
"show presence notifier informations"
|
|
10
|
+
) do
|
|
11
|
+
Global.show_presence_notifier = true
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module TaskWorkerOwnerOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
|
|
6
|
+
# --task-worker
|
|
7
|
+
define_option('-t N', '--task-worker=N', 'set task worker number that this process creates') do |n|
|
|
8
|
+
@task_worker = n.to_i
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# --features
|
|
12
|
+
define_option('--features="FEATURES"', 'set features') do |features|
|
|
13
|
+
@features = features
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module TupleSpaceProviderOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
use_option_module PresenceNotifierOption
|
|
6
|
+
|
|
7
|
+
# --presence-notification-address
|
|
8
|
+
define_option(
|
|
9
|
+
"--presence-notification-address=255.255.255.255:%s" % Global.presence_port,
|
|
10
|
+
"set the address for sending presence notifier"
|
|
11
|
+
) do |address|
|
|
12
|
+
# clear addresses at first time
|
|
13
|
+
unless @__option_notifier_address__
|
|
14
|
+
@__option_notifier_address__ = true
|
|
15
|
+
Global.presence_notification_addresses = []
|
|
16
|
+
end
|
|
17
|
+
# add the address
|
|
18
|
+
address = address =~ /^broadcast/ ? address : "broadcast://%s" % address
|
|
19
|
+
uri = URI.parse(address)
|
|
20
|
+
uri.host = "255.255.255.255" if uri.host.nil?
|
|
21
|
+
uri.port = Global.presence_port if uri.port.nil?
|
|
22
|
+
Global.presence_notification_addresses << uri
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
class TupleSpaceProviderOwnerOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
use_option_module TupleSpaceProviderOption
|
|
6
|
+
|
|
7
|
+
# --without-tuple-space-provider
|
|
8
|
+
define_option(
|
|
9
|
+
'--without-tuple-space-provider',
|
|
10
|
+
'process without tuple space provider'
|
|
11
|
+
) do
|
|
12
|
+
@without_tuple_space_provider = true
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module CommandOption
|
|
3
|
+
module TupleSpaceReceiverOption
|
|
4
|
+
extend OptionInterface
|
|
5
|
+
use_option_module PresenceNotifierOption
|
|
6
|
+
|
|
7
|
+
define_option("--presence-port=PORT", "set presence port number") do |port|
|
|
8
|
+
Global.presence_port = port.to_i
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
module Pione
|
|
2
|
+
module Command
|
|
3
|
+
# OptionInterface provides methods for defining options.
|
|
4
|
+
module ClassInterface
|
|
5
|
+
# Returns the program name.
|
|
6
|
+
def program_name
|
|
7
|
+
[@program_name, @program_name_block]
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Sets progaram name and visible options.
|
|
11
|
+
def set_program_name(program_name, &b)
|
|
12
|
+
@program_name = program_name
|
|
13
|
+
@program_name_block = block_given? ? b : Proc.new{""}
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Returns the program message.
|
|
17
|
+
def program_message
|
|
18
|
+
@program_message
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Sets program message.
|
|
22
|
+
def set_program_message(message)
|
|
23
|
+
@program_message = message
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
module InstanceInterface
|
|
28
|
+
# Returns program name.
|
|
29
|
+
# @return [String]
|
|
30
|
+
# program name
|
|
31
|
+
def program_name
|
|
32
|
+
name, b = self.class.program_name
|
|
33
|
+
tail = self.instance_exec(&b)
|
|
34
|
+
"%s %s" % [name, tail]
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Returns program message.
|
|
38
|
+
# @return [String]
|
|
39
|
+
# program message
|
|
40
|
+
def program_message
|
|
41
|
+
self.class.program_message
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# BasicCommand is a base class for PIONE commands.
|
|
46
|
+
class BasicCommand < PioneObject
|
|
47
|
+
extend ClassInterface
|
|
48
|
+
include InstanceInterface
|
|
49
|
+
extend CommandOption::OptionInterface
|
|
50
|
+
use_option_module CommandOption::CommonOption
|
|
51
|
+
|
|
52
|
+
# @api private
|
|
53
|
+
def self.inherited(subclass)
|
|
54
|
+
opts = command_options.clone
|
|
55
|
+
subclass.instance_eval { @command_options = opts }
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Runs the command.
|
|
59
|
+
def self.run(*args)
|
|
60
|
+
self.new(*args).run
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Runs the command.
|
|
64
|
+
def run
|
|
65
|
+
parse_options
|
|
66
|
+
validate_options
|
|
67
|
+
prepare
|
|
68
|
+
$PROGRAM_NAME = program_name
|
|
69
|
+
start
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private
|
|
73
|
+
|
|
74
|
+
# Parses options.
|
|
75
|
+
# @return [void]
|
|
76
|
+
def parse_options
|
|
77
|
+
parser = OptionParser.new do |opt|
|
|
78
|
+
opt.banner = "Usage: %s [options]" % opt.program_name
|
|
79
|
+
opt.banner << "\n" + program_message if program_message
|
|
80
|
+
|
|
81
|
+
self.class.command_options.values.sort.each do |args, b|
|
|
82
|
+
opt.on(*args, Proc.new{|*args| self.instance_exec(*args, &b)})
|
|
83
|
+
end
|
|
84
|
+
opt.version = Pione::VERSION
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
parser.parse!(ARGV)
|
|
88
|
+
rescue OptionParser::InvalidOption => e
|
|
89
|
+
e.args.each {|arg| $stderr.puts "Unknown option: #{arg}" }
|
|
90
|
+
abort
|
|
91
|
+
rescue OptionParser::MissingArgument => e
|
|
92
|
+
abort(e.message)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Validates options. Override this method if subclasses should check
|
|
96
|
+
# options.
|
|
97
|
+
# @return [void]
|
|
98
|
+
def validate_options
|
|
99
|
+
# do nothing
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Prepares for activity. Override this method if subclass should prepare
|
|
103
|
+
# before command activity.
|
|
104
|
+
# @return [void]
|
|
105
|
+
def prepare
|
|
106
|
+
Signal.trap(:INT) do
|
|
107
|
+
begin
|
|
108
|
+
terminate
|
|
109
|
+
rescue DRb::ReplyReaderThreadError
|
|
110
|
+
# ignore reply reader error
|
|
111
|
+
end
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Starts the command activity. This method should be overridden in subclasses.
|
|
116
|
+
# @return [void]
|
|
117
|
+
def start
|
|
118
|
+
raise NotImplementedError
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def terminate
|
|
122
|
+
exit
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|