pione 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (366) hide show
  1. data/.gitignore +14 -0
  2. data/Gemfile +5 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +94 -0
  5. data/Rakefile +118 -0
  6. data/bin/pione-broker +5 -0
  7. data/bin/pione-clean +5 -0
  8. data/bin/pione-client +5 -0
  9. data/bin/pione-eval +111 -0
  10. data/bin/pione-relay +5 -0
  11. data/bin/pione-relay-account-db +5 -0
  12. data/bin/pione-relay-client-db +5 -0
  13. data/bin/pione-search-log +30 -0
  14. data/bin/pione-syntax-checker +5 -0
  15. data/bin/pione-task-worker +5 -0
  16. data/bin/pione-tuple-space-provider +5 -0
  17. data/bin/pione-tuple-space-receiver +5 -0
  18. data/bin/pione-tuple-space-viewer +5 -0
  19. data/demo/demo.rb +311 -0
  20. data/demo/public/base.css +94 -0
  21. data/demo/public/demo.js +107 -0
  22. data/demo/public/index.html +91 -0
  23. data/demo/public/jquery-1.8.3.min.js +2 -0
  24. data/example/CountChar/CountChar.pione +64 -0
  25. data/example/CountChar/misc/CountChar.rb +22 -0
  26. data/example/CountChar/text/aidokushono_insho.txt +32 -0
  27. data/example/CountChar/text/aikokuka_shokan.txt +108 -0
  28. data/example/CountChar/text/carlyle_hakubutsukan.txt +58 -0
  29. data/example/CountChar/text/dark_minister.txt +2440 -0
  30. data/example/CountChar/text/kaikano_otto.txt +61 -0
  31. data/example/CountChar/text/kaikon.txt +30 -0
  32. data/example/CountChar/text/nagashimano_shi.txt +45 -0
  33. data/example/CountChar/text/saikachibuchi.txt +80 -0
  34. data/example/CountChar/text/saikonihonno_josei.txt +91 -0
  35. data/example/CountChar/text/taishojugonenno_bundan.txt +21 -0
  36. data/example/FeatureExample/FeatureExample.pione +7 -0
  37. data/example/Fib/Fib.pione +56 -0
  38. data/example/Fib/FibBC.pione +56 -0
  39. data/example/HelloWorld/HelloWorld.pione +5 -0
  40. data/example/LucasNumber/LucasNumber.pione +64 -0
  41. data/example/MakePair/MakePair.pione +14 -0
  42. data/example/MakePair/data/1.i +0 -0
  43. data/example/MakePair/data/2.i +0 -0
  44. data/example/MakePair/data/3.i +0 -0
  45. data/example/MakePair/data/4.i +0 -0
  46. data/example/MakePair/data/5.i +0 -0
  47. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +61 -0
  48. data/example/SingleParticlesWithRef/Makefile +289 -0
  49. data/example/SingleParticlesWithRef/SingleParticlesWithRef.Makefile +153 -0
  50. data/example/SingleParticlesWithRef/SingleParticlesWithRef.pione +116 -0
  51. data/example/SingleParticlesWithRef/SingleParticlesWithRefFull.pione +400 -0
  52. data/example/SingleParticlesWithRef/data/121p-shift-0-0-0.roi +0 -0
  53. data/example/SingleParticlesWithRef/data/121p-shift-0-120-0.roi +0 -0
  54. data/example/SingleParticlesWithRef/data/121p-shift-0-180-0.roi +0 -0
  55. data/example/SingleParticlesWithRef/data/121p-shift-0-240-0.roi +0 -0
  56. data/example/SingleParticlesWithRef/data/121p-shift-0-300-0.roi +0 -0
  57. data/example/SingleParticlesWithRef/data/121p-shift-0-60-0.roi +0 -0
  58. data/example/SingleParticlesWithRef/data/121p-shift-120-0-0.roi +0 -0
  59. data/example/SingleParticlesWithRef/data/121p-shift-120-120-0.roi +0 -0
  60. data/example/SingleParticlesWithRef/data/121p-shift-120-180-0.roi +0 -0
  61. data/example/SingleParticlesWithRef/data/121p-shift-120-240-0.roi +0 -0
  62. data/example/SingleParticlesWithRef/data/121p-shift-120-300-0.roi +0 -0
  63. data/example/SingleParticlesWithRef/data/121p-shift-120-60-0.roi +0 -0
  64. data/example/SingleParticlesWithRef/data/121p-shift-180-0-0.roi +0 -0
  65. data/example/SingleParticlesWithRef/data/121p-shift-180-120-0.roi +0 -0
  66. data/example/SingleParticlesWithRef/data/121p-shift-180-180-0.roi +0 -0
  67. data/example/SingleParticlesWithRef/data/121p-shift-180-240-0.roi +0 -0
  68. data/example/SingleParticlesWithRef/data/121p-shift-180-300-0.roi +0 -0
  69. data/example/SingleParticlesWithRef/data/121p-shift-180-60-0.roi +0 -0
  70. data/example/SingleParticlesWithRef/data/121p-shift-240-0-0.roi +0 -0
  71. data/example/SingleParticlesWithRef/data/121p-shift-240-120-0.roi +0 -0
  72. data/example/SingleParticlesWithRef/data/121p-shift-240-180-0.roi +0 -0
  73. data/example/SingleParticlesWithRef/data/121p-shift-240-240-0.roi +0 -0
  74. data/example/SingleParticlesWithRef/data/121p-shift-240-300-0.roi +0 -0
  75. data/example/SingleParticlesWithRef/data/121p-shift-240-60-0.roi +0 -0
  76. data/example/SingleParticlesWithRef/data/121p-shift-300-0-0.roi +0 -0
  77. data/example/SingleParticlesWithRef/data/121p-shift-300-120-0.roi +0 -0
  78. data/example/SingleParticlesWithRef/data/121p-shift-300-180-0.roi +0 -0
  79. data/example/SingleParticlesWithRef/data/121p-shift-300-240-0.roi +0 -0
  80. data/example/SingleParticlesWithRef/data/121p-shift-300-300-0.roi +0 -0
  81. data/example/SingleParticlesWithRef/data/121p-shift-300-60-0.roi +0 -0
  82. data/example/SingleParticlesWithRef/data/121p-shift-60-0-0.roi +0 -0
  83. data/example/SingleParticlesWithRef/data/121p-shift-60-120-0.roi +0 -0
  84. data/example/SingleParticlesWithRef/data/121p-shift-60-180-0.roi +0 -0
  85. data/example/SingleParticlesWithRef/data/121p-shift-60-240-0.roi +0 -0
  86. data/example/SingleParticlesWithRef/data/121p-shift-60-300-0.roi +0 -0
  87. data/example/SingleParticlesWithRef/data/121p-shift-60-60-0.roi +0 -0
  88. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-0-0.roi +0 -0
  89. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-120-0.roi +0 -0
  90. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-180-0.roi +0 -0
  91. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-240-0.roi +0 -0
  92. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-300-0.roi +0 -0
  93. data/example/SingleParticlesWithRef/data/121p-shift-noise-0-60-0.roi +0 -0
  94. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-0-0.roi +0 -0
  95. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-120-0.roi +0 -0
  96. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-180-0.roi +0 -0
  97. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-240-0.roi +0 -0
  98. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-300-0.roi +0 -0
  99. data/example/SingleParticlesWithRef/data/121p-shift-noise-120-60-0.roi +0 -0
  100. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-0-0.roi +0 -0
  101. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-120-0.roi +0 -0
  102. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-180-0.roi +0 -0
  103. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-240-0.roi +0 -0
  104. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-300-0.roi +0 -0
  105. data/example/SingleParticlesWithRef/data/121p-shift-noise-180-60-0.roi +0 -0
  106. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-0-0.roi +0 -0
  107. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-120-0.roi +0 -0
  108. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-180-0.roi +0 -0
  109. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-240-0.roi +0 -0
  110. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-300-0.roi +0 -0
  111. data/example/SingleParticlesWithRef/data/121p-shift-noise-240-60-0.roi +0 -0
  112. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-0-0.roi +0 -0
  113. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-120-0.roi +0 -0
  114. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-180-0.roi +0 -0
  115. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-240-0.roi +0 -0
  116. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-300-0.roi +0 -0
  117. data/example/SingleParticlesWithRef/data/121p-shift-noise-300-60-0.roi +0 -0
  118. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-0-0.roi +0 -0
  119. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-120-0.roi +0 -0
  120. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-180-0.roi +0 -0
  121. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-240-0.roi +0 -0
  122. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-300-0.roi +0 -0
  123. data/example/SingleParticlesWithRef/data/121p-shift-noise-60-60-0.roi +0 -0
  124. data/example/SingleParticlesWithRef/data/121p-shift.pdb +3381 -0
  125. data/example/SingleParticlesWithRef/data/all.ref2d +0 -0
  126. data/example/SingleParticlesWithRef/data/all.ref3d +0 -0
  127. data/example/Sum/Sum.pione +52 -0
  128. data/example/SyntaxError/call_rule_error.pione +6 -0
  129. data/example/SyntaxError/feature_line_error.pione +7 -0
  130. data/example/SyntaxError/flow_block_error.pione +5 -0
  131. data/example/SyntaxError/input_line_error.pione +6 -0
  132. data/example/SyntaxError/invalid_rule_name.pione +6 -0
  133. data/example/SyntaxError/param_line_error.pione +7 -0
  134. data/example/SyntaxError/variable-binding-error.pione +11 -0
  135. data/lib/pione.rb +241 -0
  136. data/lib/pione/agent/basic-agent.rb +333 -0
  137. data/lib/pione/agent/broker.rb +274 -0
  138. data/lib/pione/agent/command-listener.rb +47 -0
  139. data/lib/pione/agent/input-generator.rb +194 -0
  140. data/lib/pione/agent/logger.rb +65 -0
  141. data/lib/pione/agent/process-manager.rb +38 -0
  142. data/lib/pione/agent/rule-provider.rb +64 -0
  143. data/lib/pione/agent/task-worker.rb +274 -0
  144. data/lib/pione/agent/trivial-routine-worker.rb +28 -0
  145. data/lib/pione/agent/tuple-space-client.rb +146 -0
  146. data/lib/pione/agent/tuple-space-server-client-life-checker.rb +29 -0
  147. data/lib/pione/command-option/basic-option.rb +42 -0
  148. data/lib/pione/command-option/child-process-option.rb +17 -0
  149. data/lib/pione/command-option/common-option.rb +29 -0
  150. data/lib/pione/command-option/daemon-option.rb +12 -0
  151. data/lib/pione/command-option/presence-notifier-option.rb +15 -0
  152. data/lib/pione/command-option/task-worker-owner-option.rb +17 -0
  153. data/lib/pione/command-option/tuple-space-provider-option.rb +26 -0
  154. data/lib/pione/command-option/tuple-space-provider-owner-option.rb +16 -0
  155. data/lib/pione/command-option/tuple-space-receiver-option.rb +12 -0
  156. data/lib/pione/command/basic-command.rb +126 -0
  157. data/lib/pione/command/child-process.rb +43 -0
  158. data/lib/pione/command/daemon-process.rb +18 -0
  159. data/lib/pione/command/front-owner-command.rb +37 -0
  160. data/lib/pione/command/pione-broker.rb +53 -0
  161. data/lib/pione/command/pione-clean.rb +16 -0
  162. data/lib/pione/command/pione-client.rb +273 -0
  163. data/lib/pione/command/pione-relay-account-db.rb +85 -0
  164. data/lib/pione/command/pione-relay-client-db.rb +80 -0
  165. data/lib/pione/command/pione-relay.rb +47 -0
  166. data/lib/pione/command/pione-syntax-checker.rb +103 -0
  167. data/lib/pione/command/pione-task-worker.rb +123 -0
  168. data/lib/pione/command/pione-tuple-space-provider.rb +87 -0
  169. data/lib/pione/command/pione-tuple-space-receiver.rb +55 -0
  170. data/lib/pione/command/pione-tuple-space-viewer.rb +151 -0
  171. data/lib/pione/command/tuple-space-provider-owner.rb +6 -0
  172. data/lib/pione/front/basic-front.rb +64 -0
  173. data/lib/pione/front/broker-front.rb +30 -0
  174. data/lib/pione/front/client-front.rb +28 -0
  175. data/lib/pione/front/relay-front.rb +19 -0
  176. data/lib/pione/front/task-worker-front.rb +16 -0
  177. data/lib/pione/front/task-worker-owner.rb +42 -0
  178. data/lib/pione/front/tuple-space-provider-front.rb +22 -0
  179. data/lib/pione/front/tuple-space-provider-owner.rb +11 -0
  180. data/lib/pione/front/tuple-space-receiver-front.rb +18 -0
  181. data/lib/pione/model/assignment.rb +89 -0
  182. data/lib/pione/model/basic-model.rb +395 -0
  183. data/lib/pione/model/binary-operator.rb +80 -0
  184. data/lib/pione/model/block.rb +233 -0
  185. data/lib/pione/model/boolean.rb +138 -0
  186. data/lib/pione/model/call-rule.rb +69 -0
  187. data/lib/pione/model/data-expr.rb +360 -0
  188. data/lib/pione/model/feature-expr.rb +794 -0
  189. data/lib/pione/model/float.rb +107 -0
  190. data/lib/pione/model/integer.rb +140 -0
  191. data/lib/pione/model/list.rb +104 -0
  192. data/lib/pione/model/message.rb +80 -0
  193. data/lib/pione/model/package.rb +48 -0
  194. data/lib/pione/model/parameters.rb +282 -0
  195. data/lib/pione/model/rule-expr.rb +120 -0
  196. data/lib/pione/model/rule-io.rb +166 -0
  197. data/lib/pione/model/rule.rb +294 -0
  198. data/lib/pione/model/string.rb +111 -0
  199. data/lib/pione/model/undefined-value.rb +24 -0
  200. data/lib/pione/model/variable-table.rb +315 -0
  201. data/lib/pione/model/variable.rb +87 -0
  202. data/lib/pione/parser/block-parser.rb +83 -0
  203. data/lib/pione/parser/common-parser.rb +145 -0
  204. data/lib/pione/parser/document-parser.rb +58 -0
  205. data/lib/pione/parser/error-message.yml +4 -0
  206. data/lib/pione/parser/expr-parser.rb +266 -0
  207. data/lib/pione/parser/feature-expr-parser.rb +105 -0
  208. data/lib/pione/parser/flow-element-parser.rb +181 -0
  209. data/lib/pione/parser/literal-parser.rb +182 -0
  210. data/lib/pione/parser/rule-definition-parser.rb +163 -0
  211. data/lib/pione/parser/syntax-error.rb +61 -0
  212. data/lib/pione/patch/array-patch.rb +3 -0
  213. data/lib/pione/patch/drb-patch.rb +467 -0
  214. data/lib/pione/patch/monitor-patch.rb +16 -0
  215. data/lib/pione/patch/rinda-patch.rb +759 -0
  216. data/lib/pione/patch/uri-patch.rb +66 -0
  217. data/lib/pione/relay/receiver-socket.rb +69 -0
  218. data/lib/pione/relay/relay-account-db.rb +55 -0
  219. data/lib/pione/relay/relay-client-db.rb +53 -0
  220. data/lib/pione/relay/relay-socket.rb +215 -0
  221. data/lib/pione/relay/trampoline.rb +22 -0
  222. data/lib/pione/relay/transmitter-socket.rb +167 -0
  223. data/lib/pione/resource/basic-resource.rb +92 -0
  224. data/lib/pione/resource/dropbox-resource.rb +106 -0
  225. data/lib/pione/resource/ftp.rb +84 -0
  226. data/lib/pione/resource/local.rb +113 -0
  227. data/lib/pione/rule-handler/action-handler.rb +184 -0
  228. data/lib/pione/rule-handler/basic-handler.rb +217 -0
  229. data/lib/pione/rule-handler/flow-handler.rb +339 -0
  230. data/lib/pione/rule-handler/root-handler.rb +23 -0
  231. data/lib/pione/rule-handler/system-handler.rb +13 -0
  232. data/lib/pione/system/common.rb +22 -0
  233. data/lib/pione/system/config.rb +20 -0
  234. data/lib/pione/system/document.rb +81 -0
  235. data/lib/pione/system/file-cache.rb +150 -0
  236. data/lib/pione/system/global.rb +346 -0
  237. data/lib/pione/system/identifier.rb +61 -0
  238. data/lib/pione/system/init.rb +16 -0
  239. data/lib/pione/system/object.rb +35 -0
  240. data/lib/pione/transformer/block-transformer.rb +23 -0
  241. data/lib/pione/transformer/document-transformer.rb +36 -0
  242. data/lib/pione/transformer/expr-transformer.rb +89 -0
  243. data/lib/pione/transformer/feature-expr-transformer.rb +56 -0
  244. data/lib/pione/transformer/flow-element-transformer.rb +66 -0
  245. data/lib/pione/transformer/literal-transformer.rb +76 -0
  246. data/lib/pione/transformer/rule-definition-transformer.rb +62 -0
  247. data/lib/pione/transformer/transformer-module.rb +37 -0
  248. data/lib/pione/tuple-space/data-finder.rb +165 -0
  249. data/lib/pione/tuple-space/presence-notifier.rb +83 -0
  250. data/lib/pione/tuple-space/relay.rb +9 -0
  251. data/lib/pione/tuple-space/tuple-space-provider.rb +85 -0
  252. data/lib/pione/tuple-space/tuple-space-receiver.rb +140 -0
  253. data/lib/pione/tuple-space/tuple-space-server-interface.rb +60 -0
  254. data/lib/pione/tuple-space/tuple-space-server.rb +156 -0
  255. data/lib/pione/tuple-space/update-criteria.rb +96 -0
  256. data/lib/pione/tuple/agent-tuple.rb +10 -0
  257. data/lib/pione/tuple/attribute-tuple.rb +7 -0
  258. data/lib/pione/tuple/base-uri-tuple.rb +9 -0
  259. data/lib/pione/tuple/basic-tuple.rb +317 -0
  260. data/lib/pione/tuple/bye-tuple.rb +9 -0
  261. data/lib/pione/tuple/command-tuple.rb +9 -0
  262. data/lib/pione/tuple/data-tuple.rb +18 -0
  263. data/lib/pione/tuple/dry-run-tuple.rb +8 -0
  264. data/lib/pione/tuple/exception-tuple.rb +11 -0
  265. data/lib/pione/tuple/finished-tuple.rb +17 -0
  266. data/lib/pione/tuple/foreground-tuple.rb +7 -0
  267. data/lib/pione/tuple/log-tuple.rb +14 -0
  268. data/lib/pione/tuple/process-info-tuple.rb +9 -0
  269. data/lib/pione/tuple/request-rule-tuple.rb +9 -0
  270. data/lib/pione/tuple/rule-tuple.rb +10 -0
  271. data/lib/pione/tuple/shift-tuple.rb +13 -0
  272. data/lib/pione/tuple/task-tuple.rb +36 -0
  273. data/lib/pione/tuple/task-worker-resource-tuple.rb +9 -0
  274. data/lib/pione/tuple/working-tuple.rb +13 -0
  275. data/lib/pione/uri-scheme/basic-scheme.rb +40 -0
  276. data/lib/pione/uri-scheme/broadcast-scheme.rb +11 -0
  277. data/lib/pione/uri-scheme/dropbox-scheme.rb +9 -0
  278. data/lib/pione/uri-scheme/local-scheme.rb +28 -0
  279. data/lib/pione/util/error-report.rb +12 -0
  280. data/lib/pione/util/log.rb +79 -0
  281. data/lib/pione/util/message.rb +155 -0
  282. data/lib/pione/util/misc.rb +73 -0
  283. data/lib/pione/util/terminal.rb +78 -0
  284. data/lib/pione/util/waiter-table.rb +53 -0
  285. data/lib/pione/version.rb +3 -0
  286. data/misc/env.sh +2 -0
  287. data/misc/test-drb-stop-service.rb +34 -0
  288. data/misc/test-ensure-and-thread-kill.rb +40 -0
  289. data/misc/test-many-waiters-client.rb +56 -0
  290. data/misc/test-many-waiters-server.rb +14 -0
  291. data/misc/write_and_take_test.png +0 -0
  292. data/misc/write_and_take_test.rb +36 -0
  293. data/pione.gemspec +49 -0
  294. data/test/agent/spec_basic-agent.rb +170 -0
  295. data/test/agent/spec_broker.rb +36 -0
  296. data/test/agent/spec_command-listener.rb +30 -0
  297. data/test/agent/spec_input-generator.rb +123 -0
  298. data/test/agent/spec_logger.rb +71 -0
  299. data/test/agent/spec_rule-provider.rb +65 -0
  300. data/test/agent/spec_task-worker.rb +307 -0
  301. data/test/agent/spec_tuple-space-client.rb +30 -0
  302. data/test/model/spec_assignment.rb +51 -0
  303. data/test/model/spec_binary-operator.rb +39 -0
  304. data/test/model/spec_block.rb +154 -0
  305. data/test/model/spec_boolean.rb +115 -0
  306. data/test/model/spec_call-rule.rb +23 -0
  307. data/test/model/spec_data-expr.rb +312 -0
  308. data/test/model/spec_feature-expr.rb +359 -0
  309. data/test/model/spec_feature-expr.yml +16 -0
  310. data/test/model/spec_float.rb +141 -0
  311. data/test/model/spec_integer.rb +141 -0
  312. data/test/model/spec_list.rb +26 -0
  313. data/test/model/spec_message.rb +42 -0
  314. data/test/model/spec_package.rb +15 -0
  315. data/test/model/spec_parameters.rb +148 -0
  316. data/test/model/spec_rule-expr.rb +66 -0
  317. data/test/model/spec_rule-io.rb +32 -0
  318. data/test/model/spec_rule.rb +158 -0
  319. data/test/model/spec_string.rb +106 -0
  320. data/test/model/spec_variable-table.rb +117 -0
  321. data/test/model/spec_variable.rb +84 -0
  322. data/test/parser/spec_block-parser.rb +5 -0
  323. data/test/parser/spec_block-parser.yml +85 -0
  324. data/test/parser/spec_common-parser.rb +281 -0
  325. data/test/parser/spec_expr-parser.rb +6 -0
  326. data/test/parser/spec_expr-parser.yml +82 -0
  327. data/test/parser/spec_feature-expr-parser.rb +32 -0
  328. data/test/parser/spec_feature-expr-parser.yml +25 -0
  329. data/test/parser/spec_flow-element-parser.rb +5 -0
  330. data/test/parser/spec_flow-element-parser.yml +180 -0
  331. data/test/parser/spec_literal-parser.rb +5 -0
  332. data/test/parser/spec_literal-parser.yml +123 -0
  333. data/test/parser/spec_rule-definition-parser.rb +5 -0
  334. data/test/parser/spec_rule-definition-parser.yml +93 -0
  335. data/test/patch/spec_rinda-patch.rb +32 -0
  336. data/test/patch/spec_uri-patch.rb +23 -0
  337. data/test/rule-handler/spec_action-handler.rb +135 -0
  338. data/test/rule-handler/spec_flow-handler.rb +127 -0
  339. data/test/spec_common.rb +14 -0
  340. data/test/spec_data-finder.rb +88 -0
  341. data/test/spec_data-finder.yml +115 -0
  342. data/test/spec_document.rb +76 -0
  343. data/test/spec_identifier.rb +29 -0
  344. data/test/spec_log.rb +52 -0
  345. data/test/spec_object.rb +20 -0
  346. data/test/spec_resource.rb +73 -0
  347. data/test/spec_update-criteria.rb +83 -0
  348. data/test/test-util.rb +223 -0
  349. data/test/transformer/spec_block-transformer.rb +26 -0
  350. data/test/transformer/spec_expr-transformer.rb +106 -0
  351. data/test/transformer/spec_feature-expr-transformer.rb +21 -0
  352. data/test/transformer/spec_flow-element-transformer.rb +154 -0
  353. data/test/transformer/spec_literal-transformer.rb +58 -0
  354. data/test/transformer/spec_rule-definition-transformer.rb +168 -0
  355. data/test/tuple-space/spec_tuple-space-provider.rb +36 -0
  356. data/test/tuple-space/spec_tuple-space-receiver.rb +32 -0
  357. data/test/tuple-space/spec_tuple-space-server.rb +49 -0
  358. data/test/tuple/spec_basic-tuple.rb +87 -0
  359. data/test/tuple/spec_data-tuple.rb +85 -0
  360. data/test/tuple/spec_finished-tuple.rb +61 -0
  361. data/test/tuple/spec_task-tuple.rb +127 -0
  362. data/test/tuple/spec_working-tuple.rb +58 -0
  363. data/test/uri-scheme/spec_broadcast-scheme.rb +40 -0
  364. data/test/uri-scheme/spec_dropbox-scheme.rb +31 -0
  365. data/test/uri-scheme/spec_local-scheme.rb +69 -0
  366. metadata +660 -0
@@ -0,0 +1,163 @@
1
+ module Pione
2
+ module Parser
3
+ # RuleDefinitionParser is a set of parser atom for defining rule.
4
+ module RuleDefinitionParser
5
+ include Parslet
6
+ include SyntaxError
7
+ include CommonParser
8
+ include LiteralParser
9
+ include ExprParser
10
+ include FlowElementParser
11
+ include BlockParser
12
+
13
+ # @!attribute [r] rule_definitions
14
+ # @return [Parslet::Atoms::Entity] toplevel element list
15
+ rule(:rule_definitions) {
16
+ (empty_lines? >> space? >> toplevel_element >> empty_lines?).repeat
17
+ }
18
+
19
+ # @!attribute [r] toplevel_element
20
+ # @return [Parslet::Atoms::Entity] toplevel element
21
+ # @example
22
+ # # document toplevel assignment
23
+ # $X := 1
24
+ # @example
25
+ # # define rule
26
+ # Rule Main
27
+ # input '*.txt'
28
+ # ...
29
+ # Flow
30
+ # rule SubRule
31
+ # ...
32
+ # End
33
+ # @example
34
+ # # you can write any expressions in toplevel but it is ignored
35
+ # 1 + 1
36
+ rule(:toplevel_element) {
37
+ rule_definition |
38
+ assignment |
39
+ expr
40
+ }
41
+
42
+ # @!attribute [r] rule_definition
43
+ # @return [Parslet::Atoms::Entity] rule definition
44
+ # @example
45
+ # Rule Main
46
+ # input '*.txt'
47
+ # ...
48
+ # Flow
49
+ # rule SubRule
50
+ # ...
51
+ # End
52
+ rule(:rule_definition) {
53
+ ( rule_header >>
54
+ rule_conditions >>
55
+ block.as(:block)
56
+ ).as(:rule_definition)
57
+ }
58
+
59
+ # @!attribute [r] rule_header
60
+ # @return [Parslet::Atoms::Entity] rule header
61
+ # @example
62
+ # Rule Main
63
+ rule(:rule_header) {
64
+ ( keyword_Rule >>
65
+ space >>
66
+ ( rule_name | syntax_error("it should be rule name", :rule_name)) >>
67
+ line_end
68
+ ).as(:rule_header)
69
+ }
70
+
71
+ # @!attribute [r] rule_conditions
72
+ # @return [Parslet::Atoms::Entity] rule condition list
73
+ rule(:rule_conditions) {
74
+ rule_condition.repeat.as(:rule_conditions)
75
+ }
76
+
77
+ # @!attribute [r] rule_condition
78
+ # @return [Parslet::Atoms::Entity] rule condition
79
+ # @example
80
+ # # input condition
81
+ # input '*.in'
82
+ # @example
83
+ # # output condition
84
+ # output '*.out'
85
+ # @example
86
+ # # param line
87
+ # param $VAR := "abc"
88
+ # @example
89
+ # # feature condition
90
+ # feature *
91
+ rule(:rule_condition) {
92
+ input_line |
93
+ output_line |
94
+ param_line |
95
+ feature_line
96
+ }
97
+
98
+ #
99
+ # rule conditions
100
+ #
101
+
102
+ # @!attribute [r] input_line
103
+ # @return [Parslet::Atoms::Entity] input line
104
+ # @example
105
+ # input '*.in'
106
+ rule(:input_line) {
107
+ ( space? >>
108
+ keyword_input >>
109
+ space >>
110
+ ( expr.as(:expr) |
111
+ syntax_error("it should be data_expr", :data_expr)
112
+ ) >>
113
+ line_end
114
+ ).as(:input_line)
115
+ }
116
+
117
+ # @!attribute [r] output_line
118
+ # @return [Parslet::Atoms::Entity] output line
119
+ # @example
120
+ # output '*.out'
121
+ rule(:output_line) {
122
+ ( space? >>
123
+ keyword_output >>
124
+ space >>
125
+ ( expr.as(:expr) |
126
+ syntax_error("it should be data_expr", :data_expr)
127
+ ) >>
128
+ line_end
129
+ ).as(:output_line)
130
+ }
131
+
132
+ # @!attribute [r] param_line
133
+ # @return [Parslet::Atoms::Entity] parameter line
134
+ # @example
135
+ # param $VAR := "abc"
136
+ rule(:param_line) {
137
+ ( space? >>
138
+ keyword_param >>
139
+ space >>
140
+ ( expr.as(:expr) |
141
+ syntax_error("it should be expr", :expr)
142
+ ) >>
143
+ line_end
144
+ ).as(:param_line)
145
+ }
146
+
147
+ # @!attribute [r] feature_line
148
+ # @return [Parslet::Atoms::Entity] feature line
149
+ # @example
150
+ # feature *
151
+ rule(:feature_line) {
152
+ ( space? >>
153
+ keyword_feature >>
154
+ space >>
155
+ ( expr.as(:expr) |
156
+ syntax_error("it should be feature_expr", :feature_expr)
157
+ ) >>
158
+ line_end
159
+ ).as(:feature_line)
160
+ }
161
+ end
162
+ end
163
+ end
@@ -0,0 +1,61 @@
1
+ module Pione
2
+ module Parser
3
+ # ParserError is raised when the parser finds syntax error.
4
+ class ParserError < Parslet::ParseFailed
5
+ # Creates an error.
6
+ # @param [String] str
7
+ # target string
8
+ # @param [Array<String>] expected
9
+ # expected names
10
+ # @param [Parslet::Source] source
11
+ # parser source
12
+ def initialize(str, expected, source)
13
+ @str = str
14
+ @expected = expected
15
+ @source = source
16
+ super(str)
17
+ end
18
+
19
+ # @api private
20
+ def message
21
+ line, column = @source.line_and_column
22
+ expected = @expected.join(", ")
23
+ left = @source.consume(@source.chars_left)
24
+ "%s(expected: %s, line: %s, column: %s):\n%s" % [
25
+ @str, expected, line, column, left
26
+ ]
27
+ end
28
+ end
29
+
30
+ # @api private
31
+ class SyntaxErrorAtom < Parslet::Atoms::Base
32
+ def initialize(msg, expected_elements=[])
33
+ @msg = msg
34
+ @expected_elements = expected_elements
35
+ end
36
+
37
+ def try(source, context)
38
+ raise ParserError.new(@msg, @expected_elements, source)
39
+ end
40
+
41
+ def to_s_inner(prec)
42
+ "SYNTAX_ERROR"
43
+ end
44
+ end
45
+
46
+ # SyntaxError provides notification methods for syntax error.
47
+ module SyntaxError
48
+ # Raises syntax error. This method returns a dummy atom and the parser
49
+ # evaluates it as error.
50
+ # @param [String] msg
51
+ # error message
52
+ # @param [Array<String>] expected_elements
53
+ # expected name list
54
+ # @return [SyntaxErrorAtom]
55
+ # dummy atom for parser
56
+ def syntax_error(msg, *expected_elements)
57
+ SyntaxErrorAtom.new(msg, expected_elements)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ class Array
2
+ attr_accessor :timestamp
3
+ end
@@ -0,0 +1,467 @@
1
+ # @api private
2
+ module DRb
3
+ def waiter_table
4
+ @waiter_table ||= Pione::Util::WaiterTable.new
5
+ end
6
+ module_function :waiter_table
7
+
8
+ class DRbConnError
9
+ attr_reader :args
10
+
11
+ def initialize(*args)
12
+ super
13
+ @args = args
14
+ end
15
+ end
16
+
17
+ class DRbObject
18
+ # Creates fake connection for relay.
19
+ def __connect
20
+ DRbConn.open(@uri) {}
21
+ end
22
+ end
23
+
24
+ class DRbMessage
25
+ alias :orig_initialize :initialize
26
+
27
+ def initialize(*args)
28
+ @send_request_lock = Mutex.new
29
+ @recv_request_lock = Mutex.new
30
+ @send_reply_lock = Mutex.new
31
+ @recv_reply_lock = Mutex.new
32
+ orig_initialize(*args)
33
+ end
34
+
35
+ def send_request(stream, ref, msg_id, arg, b)
36
+ req_id = Util.generate_uuid_int
37
+ if Global.show_communication
38
+ puts "send_request[%s] %s#%s(%s) on PID %s" % [req_id, ref.__drburi, msg_id, arg, Process.pid]
39
+ end
40
+ data = [
41
+ dump(req_id),
42
+ dump(ref.__drbref),
43
+ dump(msg_id.id2name),
44
+ dump(arg.length),
45
+ arg.map{|e|dump(e)}.join(''),
46
+ dump(b)
47
+ ].join('')
48
+ @send_request_lock.synchronize {stream.write(data)}
49
+ return req_id
50
+ rescue => e
51
+ if Global.show_communication
52
+ ErrorReport.print(e)
53
+ end
54
+ raise(DRbConnError, $!.message, $!.backtrace)
55
+ end
56
+
57
+ def recv_request(stream)
58
+ if Global.show_communication
59
+ puts "start recv_request on PID %s" % Process.pid
60
+ end
61
+ @recv_request_lock.synchronize do
62
+ req_id = load(stream)
63
+ ref = load(stream)
64
+ msg_id = load(stream)
65
+ argc = load(stream)
66
+ # puts "req_id %s, ref %s, msg_id %s, argc %s" % [req_id, ref, msg_id, argc]
67
+ ro = DRb.to_obj(ref)
68
+ raise(DRbConnError, "too many arguments") if @argc_limit < argc
69
+ argv = Array.new(argc, nil)
70
+ argc.times do |n|
71
+ argv[n] = load(stream)
72
+ end
73
+ block = load(stream)
74
+ if Global.show_communication
75
+ # puts "end recv_request[%s] %s#%s(%s) on %s" % [req_id, ref ? ref.__drburi : "", msg_id, argv, Process.pid]
76
+ end
77
+ return req_id, ro, msg_id, argv, block
78
+ end
79
+ end
80
+
81
+ def send_reply(req_id, stream, succ, result)
82
+ if Global.show_communication
83
+ puts "start send_reply[%s] %s on PID %s" % [req_id, result, Process.pid]
84
+ unless succ
85
+ p result
86
+ result.backtrace.each do |line|
87
+ puts line
88
+ end
89
+ p result.args
90
+ end
91
+ end
92
+ @send_reply_lock.synchronize do
93
+ stream.write(dump(req_id) + dump(succ) + dump(result, !succ))
94
+ end
95
+ if Global.show_communication
96
+ puts "end send_reply[%s] %s on PID %s" % [req_id, result, Process.pid]
97
+ end
98
+ rescue
99
+ raise(DRbConnError, $!.message, $!.backtrace)
100
+ end
101
+
102
+ def recv_reply(stream)
103
+ if Global.show_communication
104
+ puts "start recv_reply on PID %s" % Process.pid
105
+ end
106
+ @recv_reply_lock.synchronize do
107
+ req_id = load(stream)
108
+ succ = load(stream)
109
+ result = load(stream)
110
+ if Global.show_communication
111
+ puts "end recv_reply[%s] on PID %s" % [req_id, Process.pid]
112
+ end
113
+ return req_id, succ, result
114
+ end
115
+ end
116
+ end
117
+
118
+ class ReplyReaderThreadError < RuntimeError
119
+ attr_reader :inner_exception
120
+
121
+ def initialize(exception)
122
+ @inner_exception = exception
123
+ end
124
+ end
125
+
126
+ class DRbTCPSocket
127
+ # Makes reader thread for receiving unordered replies.
128
+ def reader_thread(watcher)
129
+ @watcher_mutex ||= Mutex.new
130
+ @watchers ||= Set.new
131
+ @watchers << watcher
132
+ @thread ||= Thread.new do
133
+ begin
134
+ # loop for receiving reply and waiting the result
135
+ while true
136
+ req_id, succ, result = recv_reply
137
+ DRb.waiter_table.push(req_id, [succ, result])
138
+ end
139
+ rescue Exception => e
140
+ @watcher_mutex.synchronize do
141
+ @watchers.each do |watcher|
142
+ if watcher.alive?
143
+ watcher.raise(ReplyReaderThreadError.new(e))
144
+ end
145
+ end
146
+ @watchers.delete_if {|watcher| not(watcher.alive?)}
147
+ end
148
+ end
149
+ end
150
+ end
151
+
152
+ def remove_reader_thread_watcher(watcher)
153
+ @watcher_mutex ||= Mutex.new
154
+ @watcher_mutex.synchronize do
155
+ @watchers.delete_if {|th| th == watcher}
156
+ end
157
+ end
158
+
159
+ # req_id
160
+ def send_reply(req_id, succ, result)
161
+ @msg.send_reply(req_id, stream, succ, result)
162
+ end
163
+
164
+ def alive?
165
+ return @socket ? true : false
166
+ end
167
+ end
168
+
169
+ class DRbConn
170
+ @table = {}
171
+ @retry = {}
172
+
173
+ def self.table
174
+ @table
175
+ end
176
+
177
+ def self.clear_table
178
+ @table.values do |val|
179
+ val.close rescue nil
180
+ end
181
+ @table.clear
182
+ end
183
+
184
+ # @api private
185
+ def self.open(remote_uri)
186
+ conn = nil
187
+
188
+ @mutex.synchronize do
189
+ cache = @table[remote_uri]
190
+ if not(cache.nil?) and cache.alive?
191
+ conn = cache
192
+ else
193
+ if Global.show_communication
194
+ puts "new connection to %s on %s" % [remote_uri, Process.pid] if remote_uri
195
+ end
196
+ conn = self.new(remote_uri) unless conn
197
+ end
198
+ @table[remote_uri] = conn
199
+ end
200
+
201
+ succ, result = yield(conn)
202
+ @retry[remote_uri] = 0
203
+ return succ, result
204
+ rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
205
+ @table.delete(remote_uri)
206
+ @retry[remote_uri] ||= 0
207
+ @retry[remote_uri] += 1
208
+ if @retry[remote_uri] < 5
209
+ retry
210
+ else
211
+ raise
212
+ end
213
+ end
214
+
215
+ alias :orig_close :close
216
+
217
+ def close
218
+ if Global.show_communication
219
+ puts "socket closed on %s" % Process.pid
220
+ end
221
+ unless @closed
222
+ @closed = true
223
+ self.class.table.delete(remote_uri)
224
+ orig_close
225
+ end
226
+ end
227
+
228
+ # Sends a request and takes the result from waiter table.
229
+ def send_message(ref, msg_id, arg, block)
230
+ req_id = @protocol.send_request(ref, msg_id, arg, block)
231
+ @protocol.reader_thread(Thread.current)
232
+ succ, result = DRb.waiter_table.take(req_id, msg_id, arg)
233
+ @protocol.remove_reader_thread_watcher(Thread.current)
234
+ return succ, result
235
+ end
236
+ end
237
+
238
+ class DRbServer
239
+ # ClientRequest represents client's requests.
240
+ class ClientRequest
241
+ def self.receive(client)
242
+ self.new(*client.recv_request)
243
+ end
244
+
245
+ attr_reader :req_id
246
+ attr_reader :obj
247
+ attr_reader :msg_id
248
+ attr_reader :argv
249
+ attr_reader :block
250
+
251
+ def initialize(req_id, obj, msg_id, argv, block)
252
+ @req_id = req_id
253
+ @obj = obj
254
+ @msg_id = msg_id.intern
255
+ @argv = argv
256
+ @block = block
257
+ end
258
+
259
+ def eval
260
+ @block ? eval_with_block : eval_without_block
261
+ end
262
+
263
+ private
264
+
265
+ # Checks whether it can invoke method.
266
+ def valid?
267
+ return false unless @req_id
268
+ return false unless @msg_id
269
+ return false unless @argv
270
+ return true
271
+ end
272
+
273
+ def eval_without_block
274
+ if Proc === @obj && @msg_id == :__drb_yield
275
+ ary = @argv.size == 1 ? @argv : [@argv]
276
+ ary.map(&@obj)[0]
277
+ else
278
+ @obj.__send__(@msg_id, *@argv)
279
+ end
280
+ end
281
+
282
+ def block_yield(x)
283
+ if x.size == 1 && x[0].class == Array
284
+ x[0] = DRbArray.new(x[0])
285
+ end
286
+ @block.call(*x)
287
+ end
288
+
289
+ def eval_with_block
290
+ @obj.__send__(@msg_id, *@argv) do |*x|
291
+ jump_error = nil
292
+ begin
293
+ block_value = block_yield(x)
294
+ rescue LocalJumpError
295
+ jump_error = $!
296
+ end
297
+ if jump_error
298
+ case jump_error.reason
299
+ when :break
300
+ break(jump_error.exit_value)
301
+ else
302
+ raise jump_error
303
+ end
304
+ end
305
+ block_value
306
+ end
307
+ end
308
+ end
309
+
310
+ class Invoker
311
+ extend Forwardable
312
+
313
+ attr_accessor :thread
314
+ def_delegators :@request, :req_id, :obj, :msg_id, :argv, :block
315
+
316
+ def initialize(drb_server, client, request)
317
+ @drb_server = drb_server
318
+ @client = client
319
+ @request = request
320
+ check_insecure_method
321
+ end
322
+
323
+ # @api private
324
+ def inspect
325
+ "#<Invoker %s#%s(%s)>" % [@request.obj, @request.msg_id, @request.argv]
326
+ end
327
+ alias :to_s :inspect
328
+
329
+ # perform without setup_message
330
+ def invoke
331
+ result = safe_invoke
332
+ if @request.msg_id == :to_ary && result.class == Array
333
+ result = DRbArray.new(result)
334
+ end
335
+ return true, result
336
+ rescue StandardError, ScriptError, Interrupt => e
337
+ return false, e
338
+ end
339
+
340
+ private
341
+
342
+ def check_insecure_method
343
+ @drb_server.check_insecure_method(@request.obj, @request.msg_id)
344
+ end
345
+
346
+ def safe_invoke
347
+ if $SAFE < @drb_server.safe_level
348
+ info = Thread.current['DRb']
349
+ Thread.new do
350
+ Thread.current['DRb'] = info
351
+ $SAFE = @drb_server.safe_level
352
+ @request.eval
353
+ end.value
354
+ else
355
+ @request.eval
356
+ end
357
+ end
358
+ end
359
+
360
+ class RequestLooper
361
+ def self.start(server, client)
362
+ self.new(server).start(client)
363
+ end
364
+
365
+ def initialize(server)
366
+ @server = server
367
+ end
368
+
369
+ def start(client)
370
+ Thread.current['DRb'] = {'client' => client, 'server' => @server}
371
+ @server.add_exported_uri(client.uri)
372
+
373
+ loop {handle_request(client)}
374
+ end
375
+
376
+ private
377
+
378
+ def handle_request(client)
379
+ request = ClientRequest.receive(client)
380
+ invoker = Invoker.new(@server, client, request)
381
+ Thread.start(invoker) do |iv|
382
+ Thread.current['DRb'] = {'client' => client, 'server' => @server}
383
+ call_invoker(client, iv)
384
+ end
385
+ rescue DRbConnError => e
386
+ client.close
387
+ if Global.show_communication
388
+ puts "closed socket on server side"
389
+ ErrorReport.print(e)
390
+ end
391
+ raise StopIteration
392
+ end
393
+
394
+ def call_invoker(client, invoker)
395
+ # perform invoker with retaining the information
396
+ invoker.thread = Thread.current
397
+ @server.invokers_mutex.synchronize {@server.invokers << invoker}
398
+ succ, result = invoker.invoke
399
+ @server.invokers_mutex.synchronize {@server.invokers.delete(invoker)}
400
+ invoker.thread = nil
401
+
402
+ # error report
403
+ if !succ && Global.show_communication
404
+ result.backtrace.each {|x| puts x}
405
+ end
406
+
407
+ # send_reply with req_id
408
+ client.send_reply(invoker.req_id, succ, result) rescue nil
409
+ end
410
+ end
411
+
412
+ def main_loop
413
+ if @protocol.uri =~ /^receiver:/
414
+ RequestLooper.start(self, @protocol)
415
+ # stop transceiver
416
+ @thread.kill.join
417
+ else
418
+ Thread.start(@protocol.accept) do |client|
419
+ # relay socket doesn't need request receiver loop because its aim is
420
+ # to get connection only
421
+ unless @protocol.kind_of?(RelaySocket)
422
+ RequestLooper.start(self, client)
423
+ end
424
+ end
425
+ end
426
+ end
427
+
428
+ attr_reader :invokers
429
+ attr_reader :invokers_mutex
430
+
431
+ def initialize(uri=nil, front=nil, config_or_acl=nil)
432
+ if Hash === config_or_acl
433
+ config = config_or_acl.dup
434
+ else
435
+ acl = config_or_acl || @@acl
436
+ config = {
437
+ :tcp_acl => acl
438
+ }
439
+ end
440
+
441
+ @config = self.class.make_config(config)
442
+
443
+ @protocol = DRbProtocol.open_server(uri, @config)
444
+ @uri = @protocol.uri
445
+ @exported_uri = [@uri]
446
+
447
+ @front = front
448
+ @idconv = @config[:idconv]
449
+ @safe_level = @config[:safe_level]
450
+
451
+ @grp = ThreadGroup.new
452
+ @thread = run
453
+
454
+ # current performing invokers
455
+ @invokers = []
456
+ @invokers_mutex = Mutex.new
457
+
458
+ DRb.regist_server(self)
459
+ end
460
+
461
+ def add_exported_uri(uri)
462
+ DRb.mutex.synchronize do
463
+ @exported_uri << uri unless @exported_uri.include?(uri)
464
+ end
465
+ end
466
+ end
467
+ end