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,66 @@
|
|
1
|
+
# URI extention for PIONE system.
|
2
|
+
# @api private
|
3
|
+
module URI
|
4
|
+
# Installs a new scheme.
|
5
|
+
def self.install_scheme(name, klass)
|
6
|
+
@@schemes[name] = klass
|
7
|
+
end
|
8
|
+
|
9
|
+
class Generic
|
10
|
+
# Returns true if the scheme is supportted by PIONE system.
|
11
|
+
# @return [Boolean]
|
12
|
+
# true if the scheme is supportted by PIONE system
|
13
|
+
def pione?
|
14
|
+
false
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns true if the path represents a directory.
|
18
|
+
# @return [Boolean]
|
19
|
+
# true if the path represents a directory
|
20
|
+
def directory?
|
21
|
+
path[-1] == '/'
|
22
|
+
end
|
23
|
+
|
24
|
+
# Returns true if the path represents a file.
|
25
|
+
# @return [Boolean]
|
26
|
+
# true if the path represents a file
|
27
|
+
def file?
|
28
|
+
not(directory?)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Converts the uri into directory form.
|
32
|
+
# @return [Generic]
|
33
|
+
# directory path form
|
34
|
+
def as_directory
|
35
|
+
if directory?
|
36
|
+
self
|
37
|
+
else
|
38
|
+
self.clone.tap{|s| s.path = s.path + "/"}
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class Parser
|
44
|
+
alias :orig_split :split
|
45
|
+
|
46
|
+
# Handles to split special schemes's URI.
|
47
|
+
def split(uri)
|
48
|
+
scheme = uri.split(":").first
|
49
|
+
|
50
|
+
# special schemes
|
51
|
+
case scheme
|
52
|
+
when "local"
|
53
|
+
path = uri[6..-1]
|
54
|
+
return [scheme, nil, nil, nil, nil, path, nil, nil, nil]
|
55
|
+
when "broadcast"
|
56
|
+
rest = uri[10..-1]
|
57
|
+
if rest == "//"
|
58
|
+
return [scheme, nil, nil, nil, nil, nil, nil, nil, nil]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# other case
|
63
|
+
return orig_split(uri)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Pione
|
2
|
+
module Relay
|
3
|
+
class ReceiverSocket < DRb::DRbTCPSocket
|
4
|
+
class ReceiverSocketError < StandardError; end
|
5
|
+
|
6
|
+
@@table = {}
|
7
|
+
|
8
|
+
def self.table
|
9
|
+
@@table
|
10
|
+
end
|
11
|
+
|
12
|
+
# Parses special URI for reverse scheme.
|
13
|
+
def self.parse_uri(uri)
|
14
|
+
if uri =~ /^receiver:\/\/(.*?):(\d+)(\?(.*))?$/
|
15
|
+
host = $1
|
16
|
+
port = $2.to_i
|
17
|
+
option = $4
|
18
|
+
[host, port, option]
|
19
|
+
else
|
20
|
+
raise(DRb::DRbBadScheme, uri) unless uri =~ /^receiver:/
|
21
|
+
raise(DRb::DRbBadURI, 'can\'t parse uri:' + uri)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Raises an error. You cannnot open receiver socket on caller side.
|
26
|
+
def self.open(uri, config)
|
27
|
+
raise DRb::DRbBadScheme.new(uri)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Creates a fake connection.
|
31
|
+
# @api private
|
32
|
+
def self.open_server(uri, config)
|
33
|
+
# reverse socket needs URI always
|
34
|
+
raise ArgumentError.new("You should specify receiver URI.") unless uri
|
35
|
+
|
36
|
+
# get config
|
37
|
+
host, port, option = parse_uri(uri)
|
38
|
+
|
39
|
+
# retrieve socket by rev_id
|
40
|
+
key = "%s:%s" % [host, port]
|
41
|
+
unless @@table.has_key?(key)
|
42
|
+
raise ReceiverSocketError.new("No socket for %s." % uri)
|
43
|
+
end
|
44
|
+
socket = @@table[key]
|
45
|
+
|
46
|
+
# create an instance with relay socket
|
47
|
+
return self.new(uri, socket, config)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Raises an error because the socket cannot accept.
|
51
|
+
def accept
|
52
|
+
raise ReceiverSocketError.new("ReceiverSocket cannnot accept connections.")
|
53
|
+
end
|
54
|
+
|
55
|
+
def close
|
56
|
+
end
|
57
|
+
|
58
|
+
def alive?
|
59
|
+
true
|
60
|
+
end
|
61
|
+
|
62
|
+
def set_socket(*args)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# install the protocol
|
67
|
+
DRb::DRbProtocol.add_protocol(ReceiverSocket)
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Pione
|
2
|
+
module Relay
|
3
|
+
class RelayAccountDB
|
4
|
+
extend Forwardable
|
5
|
+
|
6
|
+
Account = Struct.new(:name, :digest)
|
7
|
+
|
8
|
+
def_delegator :@table, "[]"
|
9
|
+
|
10
|
+
def initialize(path)
|
11
|
+
raise TypeError.new(path) unless path.kind_of?(Pathname)
|
12
|
+
@path = path
|
13
|
+
@table = read_database
|
14
|
+
end
|
15
|
+
|
16
|
+
def add(realm, name, password)
|
17
|
+
# stretching x 1000
|
18
|
+
digest = (1..1000).inject("") {|hash, _|
|
19
|
+
Digest::SHA512.hexdigest("%s:%s:%s" % [hash, name, password])
|
20
|
+
}
|
21
|
+
@table[realm] = Account.new(name, digest)
|
22
|
+
end
|
23
|
+
|
24
|
+
def delete(realm)
|
25
|
+
@table.delete(realm)
|
26
|
+
save
|
27
|
+
end
|
28
|
+
|
29
|
+
def realms
|
30
|
+
@table.keys
|
31
|
+
end
|
32
|
+
|
33
|
+
def save
|
34
|
+
@path.open("w+", 0600) do |f|
|
35
|
+
@table.each do |realm, account|
|
36
|
+
f.puts "%s:%s:%s" % [realm, account.name, account.digest] if realm and account
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def read_database
|
44
|
+
if @path.exist?
|
45
|
+
@path.readlines.inject({}) do |tbl, line|
|
46
|
+
realm, name, digest = line.chomp.split(":")
|
47
|
+
tbl.tap{ tbl.store(realm, Account.new(name, digest)) }
|
48
|
+
end
|
49
|
+
else
|
50
|
+
{}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module Pione
|
2
|
+
module Relay
|
3
|
+
class RelayClientDB
|
4
|
+
def initialize(path)
|
5
|
+
raise TypeError.new(path) unless path.kind_of?(Pathname)
|
6
|
+
@path = path
|
7
|
+
@table = read_database
|
8
|
+
end
|
9
|
+
|
10
|
+
def auth(uuid, name, response)
|
11
|
+
Digest::SHA512.hexdigest("%s:%s" % [uuid, @table[name]]) == response
|
12
|
+
end
|
13
|
+
|
14
|
+
def add(name, password)
|
15
|
+
# stretching x 1000
|
16
|
+
@table[name] = (1..1000).inject("") {|hash, _|
|
17
|
+
Digest::SHA512.hexdigest("%s:%s:%s" % [hash, name, password])
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def delete(name)
|
22
|
+
@table.delete(name)
|
23
|
+
save
|
24
|
+
end
|
25
|
+
|
26
|
+
def names
|
27
|
+
@table.keys
|
28
|
+
end
|
29
|
+
|
30
|
+
def save
|
31
|
+
@path.open("w+", 0600) do |f|
|
32
|
+
@table.each do |name, digest|
|
33
|
+
f.puts "%s:%s" % [name, digest] if name and digest
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def read_database
|
41
|
+
if @path.exist?
|
42
|
+
@path.readlines.inject({}) do |tbl, line|
|
43
|
+
name, digest = line.chomp.split(":")
|
44
|
+
tbl.tap{ tbl.store(name, digest) }
|
45
|
+
end
|
46
|
+
else
|
47
|
+
{}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,215 @@
|
|
1
|
+
module Pione
|
2
|
+
module Relay
|
3
|
+
# RelaySocket is connection layer between PIONE client and PIONE relay.
|
4
|
+
class RelaySocket < DRb::DRbSSLSocket
|
5
|
+
# AuthError is an error for relay authentication failure.
|
6
|
+
class AuthError < StandardError; end
|
7
|
+
|
8
|
+
# ProxyError is raised when proxy server cannot start.
|
9
|
+
class ProxyError < StandardError; end
|
10
|
+
|
11
|
+
# BadMessage is an error for protocol violation.
|
12
|
+
class BadMessage < Exception; end
|
13
|
+
|
14
|
+
def self.parse_uri(uri)
|
15
|
+
if uri =~ /^relay:\/\/(.*?)(:(\d+))?(\?(.*))?$/
|
16
|
+
host = $1
|
17
|
+
port = $3 ? $3.to_i : Global.relay_port
|
18
|
+
option = $5
|
19
|
+
return host, port, option
|
20
|
+
else
|
21
|
+
raise DRb::DRbBadScheme.new(uri) unless uri =~ /^relay:/
|
22
|
+
raise DRb::DRbBadURI.new('can\'t parse uri:' + uri)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Opens the socket on pione-client.
|
27
|
+
def self.open(uri, config)
|
28
|
+
host, port, option = parse_uri(uri)
|
29
|
+
host.untaint
|
30
|
+
port.untaint
|
31
|
+
|
32
|
+
# make tcp connection with SSL
|
33
|
+
soc = TCPSocket.open(host, port)
|
34
|
+
ssl_conf = DRb::DRbSSLSocket::SSLConfig.new(config)
|
35
|
+
ssl_conf.setup_ssl_context
|
36
|
+
ssl = ssl_conf.connect(soc)
|
37
|
+
|
38
|
+
if Global.show_communication
|
39
|
+
puts "you connected relay socket to %s" % uri
|
40
|
+
end
|
41
|
+
|
42
|
+
# auth like HTTP's digest method
|
43
|
+
begin
|
44
|
+
Timeout.timeout(Global.relay_client_auth_timeout_sec) do
|
45
|
+
realm = ssl.gets.chomp
|
46
|
+
uuid = ssl.gets.chomp
|
47
|
+
account = Global.relay_account_db[realm] || (raise AuthError.new("unknown realm: %s" % realm))
|
48
|
+
name = account.name
|
49
|
+
digest = account.digest
|
50
|
+
response = "%s:%s" % [name, Digest::SHA512.hexdigest("%s:%s" % [uuid, digest])]
|
51
|
+
ssl.puts(response)
|
52
|
+
unless ssl.read(3).chomp == "OK"
|
53
|
+
raise AuthError.new("authentication failed")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
rescue AuthError => e
|
57
|
+
raise e
|
58
|
+
rescue Timeout::Error
|
59
|
+
raise AuthError.new("authentication timeout")
|
60
|
+
end
|
61
|
+
|
62
|
+
if Global.show_communication
|
63
|
+
puts "you succeeded relay authentication: %s" % uri
|
64
|
+
end
|
65
|
+
|
66
|
+
# create receiver socket
|
67
|
+
ReceiverSocket.table["%s:%s" % [host, port]] = ssl
|
68
|
+
Global.relay_receiver = DRb::DRbServer.new(
|
69
|
+
"receiver://%s:%s" % [host, port],
|
70
|
+
Global.relay_tuple_space_server
|
71
|
+
)
|
72
|
+
|
73
|
+
# create an instance
|
74
|
+
return self.new(uri, ssl, ssl_conf, true)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Opens relay server port for clients.
|
78
|
+
# @api private
|
79
|
+
def self.open_server(uri, config)
|
80
|
+
# parse URI
|
81
|
+
uri = 'relay://:%s' % Global.relay_port unless uri
|
82
|
+
host, port, option = parse_uri(uri)
|
83
|
+
|
84
|
+
# rebuild URI
|
85
|
+
if host.size == 0
|
86
|
+
host = getservername
|
87
|
+
soc = open_server_inaddr_any(host, port)
|
88
|
+
else
|
89
|
+
soc = TCPServer.open(host, port)
|
90
|
+
end
|
91
|
+
port = soc.addr[1] if port == 0
|
92
|
+
new_uri = "relay://#{host}:#{port}"
|
93
|
+
|
94
|
+
# prepare SSL
|
95
|
+
ssl_conf = DRb::DRbSSLSocket::SSLConfig.new(config).tap do |conf|
|
96
|
+
conf.setup_certificate
|
97
|
+
conf.setup_ssl_context
|
98
|
+
end
|
99
|
+
|
100
|
+
# create instance
|
101
|
+
self.new(new_uri, soc, ssl_conf, false)
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.uri_option(uri, config)
|
105
|
+
host, port, option = parse_uri(uri)
|
106
|
+
return "relay://#{host}:#{port}", option
|
107
|
+
end
|
108
|
+
|
109
|
+
# Accepts pione-clients on server side.
|
110
|
+
# @api private
|
111
|
+
def accept
|
112
|
+
begin
|
113
|
+
# accept loop
|
114
|
+
while true
|
115
|
+
soc = @socket.accept
|
116
|
+
break if (@acl ? @acl.allow_socket?(soc) : true)
|
117
|
+
soc.close
|
118
|
+
end
|
119
|
+
|
120
|
+
if Global.show_communication
|
121
|
+
puts "someone connected to relay socket..."
|
122
|
+
end
|
123
|
+
|
124
|
+
# build ssl
|
125
|
+
ssl = @config.accept(soc)
|
126
|
+
|
127
|
+
# relay auth like HTTP's digest method
|
128
|
+
ssl.puts(Global.relay_realm)
|
129
|
+
uuid = Util.generate_uuid
|
130
|
+
ssl.puts(uuid)
|
131
|
+
if msg = ssl.gets
|
132
|
+
name, digest = msg.chomp.split(":")
|
133
|
+
unless Global.relay_client_db.auth(uuid, name, digest)
|
134
|
+
raise AuthError.new(name)
|
135
|
+
end
|
136
|
+
ssl.puts "OK"
|
137
|
+
|
138
|
+
if Global.show_communication
|
139
|
+
puts "succeeded authentication for %s" % name
|
140
|
+
end
|
141
|
+
|
142
|
+
# setup transmitter_id
|
143
|
+
transmitter_id = Util.generate_uuid
|
144
|
+
|
145
|
+
# save ssl socket as receiver side with transmitter_id
|
146
|
+
TransmitterSocket.receiver_socket[transmitter_id] = ssl
|
147
|
+
|
148
|
+
# open and save tcp socket with transmitter_id
|
149
|
+
Global.relay_transmitter_proxy_side_port_range.each do |port|
|
150
|
+
begin
|
151
|
+
tcp_socket = TCPServer.new("localhost", port)
|
152
|
+
TransmitterSocket.proxy_socket[transmitter_id] = tcp_socket
|
153
|
+
break
|
154
|
+
rescue
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# create servers
|
159
|
+
transmitter_server = create_transmitter_server(transmitter_id)
|
160
|
+
proxy_server = create_proxy_server(transmitter_id)
|
161
|
+
|
162
|
+
# start to provide the proxy server
|
163
|
+
TupleSpaceProvider.instance.add_tuple_space_server(
|
164
|
+
DRb::DRbObject.new_with_uri(proxy_server.uri)
|
165
|
+
)
|
166
|
+
|
167
|
+
# create instance
|
168
|
+
self.class.new(uri, ssl, @config, true)
|
169
|
+
else
|
170
|
+
raise BadMessage
|
171
|
+
end
|
172
|
+
rescue OpenSSL::SSL::SSLError, AuthError, BadMessage => e
|
173
|
+
soc.close
|
174
|
+
if Global.show_communication
|
175
|
+
puts "closed relay socket"
|
176
|
+
Util::ErrorReport.print(e)
|
177
|
+
end
|
178
|
+
retry
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Creates a transmitter server with the relay socket.
|
183
|
+
# @return [void]
|
184
|
+
def create_transmitter_server(transmitter_id)
|
185
|
+
uri = "transmitter://%s" % transmitter_id
|
186
|
+
server = DRb::DRbServer.new(uri, Trampoline.new(uri, @config))
|
187
|
+
if Global.show_communication
|
188
|
+
puts "relay created the transmitter: %s" % server.uri
|
189
|
+
end
|
190
|
+
return server
|
191
|
+
end
|
192
|
+
|
193
|
+
# Creates a proxy server for brokers in LAN.
|
194
|
+
def create_proxy_server(transmitter_id)
|
195
|
+
transmitter = DRb::DRbObject.new_with_uri("transmitter://%s" % transmitter_id)
|
196
|
+
Global.relay_proxy_port_range.each do |port|
|
197
|
+
begin
|
198
|
+
uri = "druby://localhost:%s" % port
|
199
|
+
server = DRb::DRbServer.new(uri, transmitter)
|
200
|
+
if Global.show_communication
|
201
|
+
puts "relay created the proxy: %s" % server.uri
|
202
|
+
end
|
203
|
+
return server
|
204
|
+
rescue
|
205
|
+
next
|
206
|
+
end
|
207
|
+
end
|
208
|
+
raise ProxyError.new("You cannot start relay proxy server.")
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
# install the protocol
|
213
|
+
DRb::DRbProtocol.add_protocol(RelaySocket)
|
214
|
+
end
|
215
|
+
end
|