pione 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,43 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class ChildProcess < FrontOwnerCommand
|
4
|
+
use_option_module CommandOption::ChildProcessOption
|
5
|
+
attr_reader :parent_front
|
6
|
+
|
7
|
+
# @api private
|
8
|
+
def validate_options
|
9
|
+
if not(@no_parent_mode) and @parent_front.nil?
|
10
|
+
abort("option error: no caller front address")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# @api private
|
15
|
+
def prepare
|
16
|
+
super
|
17
|
+
|
18
|
+
# "ppid == 1" means the parent is dead
|
19
|
+
terminater = Proc.new do
|
20
|
+
if Process.ppid == 1
|
21
|
+
abort
|
22
|
+
terminate
|
23
|
+
end
|
24
|
+
sleep 3
|
25
|
+
end
|
26
|
+
|
27
|
+
# watch that the parent process exists
|
28
|
+
@watchdog = Agent::TrivialRoutineWorker.new(terminater)
|
29
|
+
end
|
30
|
+
|
31
|
+
# @api private
|
32
|
+
def start
|
33
|
+
@watchdog.start
|
34
|
+
end
|
35
|
+
|
36
|
+
def terminate
|
37
|
+
@watchdog.terminate
|
38
|
+
super
|
39
|
+
abort
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class DaemonProcess < FrontOwnerCommand
|
4
|
+
use_option_module CommandOption::DaemonOption
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
@daemon = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def prepare
|
12
|
+
super
|
13
|
+
puts Global.front.uri
|
14
|
+
Process.daemon(true, true) if @daemon
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class FrontOwnerCommand < BasicCommand
|
4
|
+
define_option("--my-ip-address=ADDRESS", "set my IP address") do |address|
|
5
|
+
Global.my_ip_address = address
|
6
|
+
end
|
7
|
+
|
8
|
+
# Runs the command.
|
9
|
+
def run
|
10
|
+
parse_options
|
11
|
+
validate_options
|
12
|
+
setup_front
|
13
|
+
prepare
|
14
|
+
$PROGRAM_NAME = program_name
|
15
|
+
start
|
16
|
+
end
|
17
|
+
|
18
|
+
# Setups font server.
|
19
|
+
# @return [void]
|
20
|
+
def setup_front
|
21
|
+
Global.front = create_front
|
22
|
+
end
|
23
|
+
|
24
|
+
# Creates a front server. This method should be overridden in subclasses.
|
25
|
+
# @return [BasicFront]
|
26
|
+
# front server
|
27
|
+
def create_front
|
28
|
+
raise NotImplementedError
|
29
|
+
end
|
30
|
+
|
31
|
+
def terminate
|
32
|
+
super
|
33
|
+
DRb.stop_service
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PioneBroker < DaemonProcess
|
4
|
+
set_program_name "pione-broker" do
|
5
|
+
"--task-worker %s" % @task_worker
|
6
|
+
end
|
7
|
+
|
8
|
+
set_program_message <<TXT
|
9
|
+
Runs the broker to launch task workers.
|
10
|
+
TXT
|
11
|
+
|
12
|
+
use_option_module CommandOption::TupleSpaceReceiverOption
|
13
|
+
use_option_module CommandOption::TaskWorkerOwnerOption
|
14
|
+
|
15
|
+
attr_reader :broker
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@task_worker = [Util.core_number - 1, 1].max
|
19
|
+
end
|
20
|
+
|
21
|
+
def create_front
|
22
|
+
Front::BrokerFront.new(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
def validate_options
|
26
|
+
unless @task_worker > 0
|
27
|
+
abort("error: no task worker resources")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def prepare
|
32
|
+
super
|
33
|
+
@broker = Pione::Agent[:broker].new(task_worker_resource: @task_worker)
|
34
|
+
@tuple_space_receiver = Pione::TupleSpaceReceiver.instance
|
35
|
+
end
|
36
|
+
|
37
|
+
def start
|
38
|
+
# start broker
|
39
|
+
@broker.start
|
40
|
+
|
41
|
+
# start tuple space receiver
|
42
|
+
@tuple_space_receiver.register(@broker)
|
43
|
+
|
44
|
+
# wait
|
45
|
+
begin
|
46
|
+
DRb.thread.join
|
47
|
+
rescue DRb::ReplyReaderThreadError
|
48
|
+
retry
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PioneClean < BasicCommand
|
4
|
+
set_program_name("pione-clean")
|
5
|
+
|
6
|
+
set_program_message <<TXT
|
7
|
+
Cleans working directories and file cache directories.
|
8
|
+
TXT
|
9
|
+
|
10
|
+
def start
|
11
|
+
FileUtils.remove_entry_secure(Global.working_directory_root)
|
12
|
+
FileUtils.remove_entry_secure(Global.file_cache_directory_root)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,273 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PioneClient < FrontOwnerCommand
|
4
|
+
use_option_module CommandOption::TaskWorkerOwnerOption
|
5
|
+
use_option_module CommandOption::TupleSpaceProviderOwnerOption
|
6
|
+
|
7
|
+
set_program_name("pione-client") do
|
8
|
+
[@filename, "-o %s" % @output_uri, @stream ? "--stream" : ""].join(" ")
|
9
|
+
end
|
10
|
+
|
11
|
+
set_program_message "Requests to process PIONE document."
|
12
|
+
|
13
|
+
# --input-uri
|
14
|
+
define_option('-i URI', '--input=URI', 'set input directory URI') do |uri|
|
15
|
+
parsed = URI.parse(uri)
|
16
|
+
unless parsed.scheme
|
17
|
+
parsed = URI.parse("local:%s" % Pathname.new(uri).expand_path)
|
18
|
+
end
|
19
|
+
@input_uri = parsed.as_directory
|
20
|
+
end
|
21
|
+
|
22
|
+
# --output-uri
|
23
|
+
define_option('-o URI', '--output=URI', 'set output directory URI') do |uri|
|
24
|
+
@output_uri = URI.parse(uri)
|
25
|
+
end
|
26
|
+
|
27
|
+
# --log
|
28
|
+
define_option('--log=PATH', 'set log path') do |path|
|
29
|
+
@log_path = path
|
30
|
+
end
|
31
|
+
|
32
|
+
# --stream
|
33
|
+
define_option('--stream', 'turn on stream mode') do
|
34
|
+
@stream = true
|
35
|
+
end
|
36
|
+
|
37
|
+
# --request-task-worker
|
38
|
+
define_option('--request-task-worker=N', 'set request number of task workers') do |n|
|
39
|
+
@request_task_worker = n.to_i
|
40
|
+
end
|
41
|
+
|
42
|
+
# --params
|
43
|
+
define_option('--params="{Var:1,...}"', "set &main:Main rule's parameters") do |str|
|
44
|
+
begin
|
45
|
+
params = DocumentTransformer.new.apply(
|
46
|
+
DocumentParser.new.parameters.parse(str)
|
47
|
+
)
|
48
|
+
@params.merge!(params)
|
49
|
+
rescue Parslet::ParseFailed => e
|
50
|
+
puts "invalid parameters: " + str
|
51
|
+
Util::ErrorReport.print(e)
|
52
|
+
abort
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# --stand-alone
|
57
|
+
define_option('--stand-alone', 'turn on stand alone mode') do
|
58
|
+
@stand_alone = true
|
59
|
+
@without_tuple_space_provider = true
|
60
|
+
end
|
61
|
+
|
62
|
+
# --dry-run
|
63
|
+
define_option('--dry-run', 'turn on dry run mode') do |b|
|
64
|
+
@dry_run = true
|
65
|
+
end
|
66
|
+
|
67
|
+
# --relay
|
68
|
+
define_option('--relay=URI', 'turn on relay mode and set relay address') do |uri|
|
69
|
+
@relay = uri
|
70
|
+
end
|
71
|
+
|
72
|
+
define_option('--name=NAME') do |name|
|
73
|
+
@name = name
|
74
|
+
end
|
75
|
+
|
76
|
+
attr_reader :tuple_space_server
|
77
|
+
attr_reader :name
|
78
|
+
|
79
|
+
def initialize
|
80
|
+
super()
|
81
|
+
@input_uri = nil
|
82
|
+
@output_uri = URI.parse("local:./output/")
|
83
|
+
@log_path = "log.txt"
|
84
|
+
@stream = false
|
85
|
+
@params = Parameters.empty
|
86
|
+
@dry_run = false
|
87
|
+
@task_worker = [Util.core_number - 1, 1].max
|
88
|
+
@request_task_worker = 1
|
89
|
+
@worker_threads = []
|
90
|
+
@stand_alone = false
|
91
|
+
@relay = nil
|
92
|
+
@filename = "-"
|
93
|
+
@without_tuple_space_provider = false
|
94
|
+
end
|
95
|
+
|
96
|
+
private
|
97
|
+
|
98
|
+
def validate_options
|
99
|
+
unless @task_worker > 0 or (not(@stand_alone) and @task_worker == 0)
|
100
|
+
abort("option error: invalid resource size '%s'" % @task_worker)
|
101
|
+
end
|
102
|
+
|
103
|
+
if @stream and @input_uri.nil?
|
104
|
+
abort("option error: no input URI on stream mode")
|
105
|
+
end
|
106
|
+
|
107
|
+
if not(@input_uri.nil?)
|
108
|
+
unless @input_uri.pione? and @input_uri.storage?
|
109
|
+
abort("opiton error: bad URI scheme '%s'" % @input_uri)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_front
|
115
|
+
Front::ClientFront.new(self)
|
116
|
+
end
|
117
|
+
|
118
|
+
def prepare
|
119
|
+
super
|
120
|
+
|
121
|
+
@filename = ARGF.filename
|
122
|
+
|
123
|
+
@tuple_space_server = TupleSpaceServer.new(
|
124
|
+
task_worker_resource: @request_task_worker
|
125
|
+
)
|
126
|
+
|
127
|
+
# setup base uri
|
128
|
+
case @output_uri.scheme
|
129
|
+
when "local"
|
130
|
+
FileUtils.makedirs(@output_uri.path)
|
131
|
+
@output_uri = @output_uri.absolute
|
132
|
+
when "dropbox"
|
133
|
+
# start session
|
134
|
+
session = nil
|
135
|
+
consumer_key = nil
|
136
|
+
consumer_secret = nil
|
137
|
+
|
138
|
+
cache = Pathname.new("~/.pione/dropbox_api.cache").expand_path
|
139
|
+
if cache.exist?
|
140
|
+
session = DropboxSession.deserialize(cache.read)
|
141
|
+
Resource::Dropbox.set_session(session)
|
142
|
+
consumer_key = session.instance_variable_get(:@consumer_key)
|
143
|
+
consumer_secret = session.instance_variable_get(:@consumer_secret)
|
144
|
+
else
|
145
|
+
api = YAML.load(Pathname.new("~/.pione/dropbox_api.yml").expand_path.read)
|
146
|
+
consumer_key = api["key"]
|
147
|
+
consumer_secret = api["secret"]
|
148
|
+
session = DropboxSession.new(consumer_key, consumer_secret)
|
149
|
+
Resource::Dropbox.set_session(session)
|
150
|
+
authorize_url = session.get_authorize_url
|
151
|
+
puts "AUTHORIZING", authorize_url
|
152
|
+
puts "Please visit that web page and hit 'Allow', then hit Enter here."
|
153
|
+
STDIN.gets
|
154
|
+
session.get_access_token
|
155
|
+
|
156
|
+
# cache session
|
157
|
+
cache.open("w+") {|c| c.write session.serialize}
|
158
|
+
end
|
159
|
+
|
160
|
+
# check session state
|
161
|
+
unless session.authorized?
|
162
|
+
abort("We cannot authorize dropbox access to PIONE.")
|
163
|
+
end
|
164
|
+
|
165
|
+
# share access token in tuple space
|
166
|
+
Resource::Dropbox.share_access_token(tuple_space_server, consumer_key, consumer_secret)
|
167
|
+
end
|
168
|
+
|
169
|
+
@output_uri = @output_uri.as_directory.to_s
|
170
|
+
@tuple_space_server.set_base_uri(@output_uri)
|
171
|
+
end
|
172
|
+
|
173
|
+
def start
|
174
|
+
read_process_document
|
175
|
+
write_tuples
|
176
|
+
connect_relay if @relay
|
177
|
+
start_agents
|
178
|
+
start_tuple_space_provider unless @without_tuple_space_provider
|
179
|
+
start_workers
|
180
|
+
@agent = Agent[:process_manager].start(@tuple_space_server, @document, @params, @stream)
|
181
|
+
@agent.running_thread.join
|
182
|
+
terminate
|
183
|
+
end
|
184
|
+
|
185
|
+
def terminate
|
186
|
+
if @tuple_space_provider
|
187
|
+
@tuple_space_provider.terminate
|
188
|
+
end
|
189
|
+
super
|
190
|
+
end
|
191
|
+
|
192
|
+
private
|
193
|
+
|
194
|
+
def read_process_document
|
195
|
+
# process definition document is not found.
|
196
|
+
if ARGF.filename == "-"
|
197
|
+
abort("There are no process definition documents.")
|
198
|
+
end
|
199
|
+
|
200
|
+
# get script dirname
|
201
|
+
@dir = File.dirname(File.expand_path(__FILE__))
|
202
|
+
|
203
|
+
# read process document
|
204
|
+
begin
|
205
|
+
@document = Document.parse(ARGF.read)
|
206
|
+
rescue Pione::Parser::ParserError => e
|
207
|
+
abort("Pione syntax error: " + e.message)
|
208
|
+
rescue Pione::Model::PioneModelTypeError, Pione::Model::VariableBindingError => e
|
209
|
+
abort("Pione model error: " + e.message)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def write_tuples
|
214
|
+
[ Tuple[:process_info].new('standalone', 'Standalone'),
|
215
|
+
Tuple[:dry_run].new(@dry_run)
|
216
|
+
].each {|tuple| @tuple_space_server.write(tuple) }
|
217
|
+
end
|
218
|
+
|
219
|
+
def start_agents
|
220
|
+
# logger
|
221
|
+
Agent[:logger].start(@tuple_space_server, File.open(@log_path, "w+"))
|
222
|
+
|
223
|
+
# rule provider
|
224
|
+
@rule_loader = Agent[:rule_provider].start(@tuple_space_server)
|
225
|
+
@rule_loader.read_document(@document)
|
226
|
+
@rule_loader.wait_till(:request_waiting)
|
227
|
+
|
228
|
+
# input generators
|
229
|
+
generator_method = @stream ? :start_by_stream : :start_by_dir
|
230
|
+
gen = Agent[:input_generator].send(
|
231
|
+
generator_method, @tuple_space_server, @input_uri
|
232
|
+
)
|
233
|
+
|
234
|
+
# command listener
|
235
|
+
@command_listener = Agent[:command_listener].start(@tuple_space_server, self)
|
236
|
+
end
|
237
|
+
|
238
|
+
# Wakes up tuple space provider process and push my tuple space server to
|
239
|
+
# it.
|
240
|
+
def start_tuple_space_provider
|
241
|
+
@tuple_space_provider = Pione::TupleSpaceProvider.instance
|
242
|
+
@tuple_space_provider.add_tuple_space_server(@tuple_space_server)
|
243
|
+
end
|
244
|
+
|
245
|
+
def start_workers
|
246
|
+
@task_worker.times do
|
247
|
+
Agent[:task_worker].spawn(Global.front, Util.generate_uuid, @features)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def connect_relay
|
252
|
+
Global.relay_tuple_space_server = @tuple_space_server
|
253
|
+
@relay_ref = DRbObject.new_with_uri(@relay)
|
254
|
+
@relay_ref.__connect
|
255
|
+
if Global.show_communication
|
256
|
+
puts "you connected the relay: %s" % @relay
|
257
|
+
end
|
258
|
+
# watchdog for the relay server
|
259
|
+
Thread.start do
|
260
|
+
Global.relay_receiver.thread.join
|
261
|
+
abort("relay server disconnected: %s" % @relay_ref.__drburi)
|
262
|
+
end
|
263
|
+
rescue DRb::DRbConnError => e
|
264
|
+
puts "You couldn't connect the relay server: %s" % @relay_ref.__drburi
|
265
|
+
puts "%s: %s" % [e.class, e.message]
|
266
|
+
caller.each {|line| puts " %s" % line}
|
267
|
+
abort
|
268
|
+
rescue Relay::RelaySocket::AuthError
|
269
|
+
abort("You failed authentication to connect the relay server: %s" % @relay_ref.__drburi)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Pione
|
2
|
+
module Command
|
3
|
+
class PioneRelayAccountDB < BasicCommand
|
4
|
+
set_program_name("pione-relay-account-db")
|
5
|
+
|
6
|
+
set_program_message <<TXT
|
7
|
+
Add, delete, or show your accounts of relay servers.
|
8
|
+
TXT
|
9
|
+
|
10
|
+
define_option("-a", "--add", "add an account") do
|
11
|
+
@action = :add
|
12
|
+
end
|
13
|
+
|
14
|
+
define_option("-d", "--delete", "delete an account") do
|
15
|
+
@action = :delete
|
16
|
+
end
|
17
|
+
|
18
|
+
define_option("-l", "--list", "list accounts") do
|
19
|
+
@action = :list
|
20
|
+
end
|
21
|
+
|
22
|
+
define_option("-r realm", "--realm realm", "realm name") do |realm|
|
23
|
+
@realm = realm
|
24
|
+
end
|
25
|
+
|
26
|
+
define_option("-u name", "--user name", "user name") do |name|
|
27
|
+
@name = name
|
28
|
+
end
|
29
|
+
|
30
|
+
define_option("-p password", "--password password", "password") do |password|
|
31
|
+
@password = password
|
32
|
+
end
|
33
|
+
|
34
|
+
define_option("-f path", "--file path", "account db path") do |path|
|
35
|
+
Global.relay_account_db_path = path
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize
|
39
|
+
@action = nil
|
40
|
+
@name = nil
|
41
|
+
@password = nil
|
42
|
+
end
|
43
|
+
|
44
|
+
def validate_options
|
45
|
+
abort("error: -a, -d, or -l") unless @action
|
46
|
+
end
|
47
|
+
|
48
|
+
def prepare
|
49
|
+
# set account db
|
50
|
+
Global.relay_account_db = RelayAccountDB.new(Global.relay_account_db_path)
|
51
|
+
|
52
|
+
# set realm
|
53
|
+
if [:add, :delete].include?(@action)
|
54
|
+
@realm = HighLine.new.ask("Realm: ") unless @realm
|
55
|
+
end
|
56
|
+
|
57
|
+
# set name and password
|
58
|
+
if @action == :add
|
59
|
+
@name = HighLine.new.ask("Name: ") unless @name
|
60
|
+
unless @password
|
61
|
+
@password = HighLine.new.ask("Password: "){|q| q.echo = "*"}
|
62
|
+
password = HighLine.new.ask("Re-enter password: "){|q| q.echo = "*"}
|
63
|
+
abort("error: password mismatch") unless @password == password
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def start
|
69
|
+
db = Global.relay_account_db
|
70
|
+
case @action
|
71
|
+
when :add
|
72
|
+
db.add(@realm, @name, @password)
|
73
|
+
db.save
|
74
|
+
when :delete
|
75
|
+
db.delete(@realm)
|
76
|
+
db.save
|
77
|
+
when :list
|
78
|
+
puts "%s accounts in %s" % [db.realms.size, Global.relay_account_db_path]
|
79
|
+
db.realms.each {|realm| puts "%s:%s" % [realm, db[realm].name]}
|
80
|
+
end
|
81
|
+
terminate
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|