pione 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (593) hide show
  1. data/.gitignore +1 -0
  2. data/.simplecov +1 -0
  3. data/History.txt +9 -0
  4. data/Rakefile +1 -71
  5. data/example/Fib/Fib.pione +9 -8
  6. data/example/HelloWorld/HelloWorld.pione +2 -0
  7. data/example/HelloWorld/pione-package.json +15 -0
  8. data/example/HelloWorld/scenario/Scenario.pione +2 -0
  9. data/example/HelloWorld/scenario/pione-scenario.json +10 -0
  10. data/example/SerialProcessing/SerialProcessing.pione +2 -0
  11. data/example/SerialProcessing/pione-package.json +15 -0
  12. data/example/SerialProcessing/scenario/Scenario.pione +1 -0
  13. data/example/SerialProcessing/scenario/pione-scenario.json +10 -0
  14. data/lib/pione.rb +28 -35
  15. data/lib/pione/agent.rb +4 -4
  16. data/lib/pione/agent/agent-exception.rb +52 -0
  17. data/lib/pione/agent/basic-agent.rb +246 -239
  18. data/lib/pione/agent/broker.rb +232 -216
  19. data/lib/pione/agent/input-generator.rb +113 -133
  20. data/lib/pione/agent/job-terminator.rb +38 -0
  21. data/lib/pione/agent/logger.rb +24 -54
  22. data/lib/pione/agent/messenger.rb +11 -16
  23. data/lib/pione/agent/process-manager.rb +50 -19
  24. data/lib/pione/agent/task-worker.rb +126 -236
  25. data/lib/pione/agent/tuple-space-client.rb +16 -39
  26. data/lib/pione/agent/tuple-space-provider.rb +66 -0
  27. data/lib/pione/agent/tuple-space-receiver.rb +137 -0
  28. data/lib/pione/command.rb +2 -3
  29. data/lib/pione/command/basic-command.rb +347 -207
  30. data/lib/pione/command/command-exception.rb +38 -0
  31. data/lib/pione/command/option.rb +112 -104
  32. data/lib/pione/command/pione-broker.rb +85 -43
  33. data/lib/pione/command/pione-clean.rb +51 -8
  34. data/lib/pione/command/pione-client.rb +321 -292
  35. data/lib/pione/command/pione-log.rb +92 -53
  36. data/lib/pione/command/pione-package.rb +112 -59
  37. data/lib/pione/command/pione-relay-account-db.rb +107 -78
  38. data/lib/pione/command/pione-relay-client-db.rb +93 -72
  39. data/lib/pione/command/pione-relay.rb +37 -32
  40. data/lib/pione/command/pione-syntax-checker.rb +112 -87
  41. data/lib/pione/command/pione-task-worker.rb +135 -118
  42. data/lib/pione/command/pione-tuple-space-provider.rb +83 -50
  43. data/lib/pione/command/pione-tuple-space-receiver.rb +89 -50
  44. data/lib/pione/command/pione-tuple-space-viewer.rb +101 -99
  45. data/lib/pione/command/pione-val.rb +50 -29
  46. data/lib/pione/command/spawner.rb +74 -0
  47. data/lib/pione/front.rb +0 -2
  48. data/lib/pione/front/basic-front.rb +48 -26
  49. data/lib/pione/front/broker-front.rb +8 -16
  50. data/lib/pione/front/client-front.rb +10 -18
  51. data/lib/pione/front/front-exception.rb +12 -0
  52. data/lib/pione/front/relay-front.rb +6 -6
  53. data/lib/pione/front/task-worker-front.rb +3 -9
  54. data/lib/pione/front/tuple-space-provider-front.rb +6 -14
  55. data/lib/pione/front/tuple-space-receiver-front.rb +4 -11
  56. data/lib/pione/global.rb +135 -0
  57. data/lib/pione/global/broker-variable.rb +20 -0
  58. data/lib/pione/global/client-variable.rb +18 -0
  59. data/lib/pione/global/input-generator-variable.rb +7 -0
  60. data/lib/pione/global/log-variable.rb +53 -0
  61. data/lib/pione/global/network-variable.rb +7 -0
  62. data/lib/pione/global/package-variable.rb +28 -0
  63. data/lib/pione/global/path-variable.rb +52 -0
  64. data/lib/pione/global/relay-variable.rb +86 -0
  65. data/lib/pione/global/system-variable.rb +39 -0
  66. data/lib/pione/global/task-worker-variable.rb +17 -0
  67. data/lib/pione/global/tuple-space-notifier-variable.rb +60 -0
  68. data/lib/pione/lang.rb +55 -0
  69. data/lib/pione/lang/basic-model.rb +45 -0
  70. data/lib/pione/lang/boolean.rb +86 -0
  71. data/lib/pione/lang/common-parser.rb +202 -0
  72. data/lib/pione/lang/conditional-branch-parser.rb +57 -0
  73. data/lib/pione/lang/conditional-branch-transformer.rb +36 -0
  74. data/lib/pione/lang/conditional-branch.rb +73 -0
  75. data/lib/pione/lang/context-parser.rb +39 -0
  76. data/lib/pione/lang/context-transformer.rb +41 -0
  77. data/lib/pione/lang/context.rb +229 -0
  78. data/lib/pione/lang/data-expr.rb +265 -0
  79. data/lib/pione/lang/declaration-parser.rb +174 -0
  80. data/lib/pione/lang/declaration-transformer.rb +153 -0
  81. data/lib/pione/lang/declaration.rb +322 -0
  82. data/lib/pione/lang/definition.rb +88 -0
  83. data/lib/pione/lang/document-parser.rb +19 -0
  84. data/lib/pione/lang/document-transformer.rb +12 -0
  85. data/lib/pione/lang/environment.rb +344 -0
  86. data/lib/pione/{parser → lang}/error-message.yml +0 -0
  87. data/lib/pione/lang/expr-parser.rb +228 -0
  88. data/lib/pione/{transformer → lang}/expr-transformer.rb +32 -44
  89. data/lib/pione/lang/expr.rb +70 -0
  90. data/lib/pione/lang/feature-expr.rb +425 -0
  91. data/lib/pione/lang/float.rb +104 -0
  92. data/lib/pione/lang/integer.rb +159 -0
  93. data/lib/pione/lang/interpolator-parser.rb +44 -0
  94. data/lib/pione/lang/interpolator-transformer.rb +13 -0
  95. data/lib/pione/lang/keyed-sequence.rb +98 -0
  96. data/lib/pione/lang/lang-exception.rb +224 -0
  97. data/lib/pione/lang/literal-parser.rb +134 -0
  98. data/lib/pione/lang/literal-transformer.rb +171 -0
  99. data/lib/pione/lang/message.rb +41 -0
  100. data/lib/pione/lang/ordinal-sequence.rb +203 -0
  101. data/lib/pione/lang/package-expr.rb +86 -0
  102. data/lib/pione/lang/parameters.rb +121 -0
  103. data/lib/pione/lang/piece.rb +42 -0
  104. data/lib/pione/{model → lang}/pione-method.rb +26 -63
  105. data/lib/pione/lang/rule-expr.rb +70 -0
  106. data/lib/pione/lang/sequence.rb +215 -0
  107. data/lib/pione/lang/string.rb +116 -0
  108. data/lib/pione/lang/ticket-expr.rb +48 -0
  109. data/lib/pione/{model → lang}/type.rb +70 -99
  110. data/lib/pione/lang/variable.rb +35 -0
  111. data/lib/pione/location.rb +13 -1
  112. data/lib/pione/{uri-scheme → location}/broadcast-scheme.rb +2 -2
  113. data/lib/pione/location/data-location.rb +22 -5
  114. data/lib/pione/location/dropbox-location.rb +10 -8
  115. data/lib/pione/{uri-scheme → location}/dropbox-scheme.rb +2 -2
  116. data/lib/pione/location/ftp-location.rb +6 -0
  117. data/lib/pione/location/git-repository-location.rb +6 -17
  118. data/lib/pione/{uri-scheme → location}/git-scheme.rb +2 -2
  119. data/lib/pione/location/http-location.rb +8 -1
  120. data/lib/pione/location/local-location.rb +57 -4
  121. data/lib/pione/{uri-scheme → location}/local-scheme.rb +2 -2
  122. data/lib/pione/location/{exception.rb → location-exception.rb} +13 -1
  123. data/lib/pione/{uri-scheme/basic-scheme.rb → location/location-scheme.rb} +7 -6
  124. data/lib/pione/{uri-scheme → location}/myftp-scheme.rb +2 -2
  125. data/lib/pione/log.rb +7 -6
  126. data/lib/pione/log/debug.rb +75 -0
  127. data/lib/pione/log/domain-log.rb +4 -5
  128. data/lib/pione/log/message-log.rb +2 -2
  129. data/lib/pione/log/process-log.rb +16 -25
  130. data/lib/pione/log/process-record.rb +1 -0
  131. data/lib/pione/log/system-log.rb +165 -55
  132. data/lib/pione/package.rb +21 -0
  133. data/lib/pione/package/document.rb +27 -0
  134. data/lib/pione/package/package-archiver.rb +152 -0
  135. data/lib/pione/package/package-cache.rb +79 -0
  136. data/lib/pione/package/package-database.rb +121 -0
  137. data/lib/pione/package/package-exception.rb +38 -0
  138. data/lib/pione/{component → package}/package-expander.rb +13 -7
  139. data/lib/pione/package/package-filename.rb +46 -0
  140. data/lib/pione/package/package-handler.rb +106 -0
  141. data/lib/pione/package/package-info.rb +72 -0
  142. data/lib/pione/package/package-reader.rb +202 -0
  143. data/lib/pione/package/package-scanner.rb +133 -0
  144. data/lib/pione/package/scenario-handler.rb +95 -0
  145. data/lib/pione/package/scenario-info.rb +34 -0
  146. data/lib/pione/package/scenario-reader.rb +29 -0
  147. data/lib/pione/package/scenario-scanner.rb +96 -0
  148. data/lib/pione/patch.rb +0 -1
  149. data/lib/pione/patch/drb-patch.rb +377 -298
  150. data/lib/pione/patch/rinda-patch.rb +4 -3
  151. data/lib/pione/relay/relay-socket.rb +1 -4
  152. data/lib/pione/rule-engine.rb +27 -0
  153. data/lib/pione/{rule-handler → rule-engine}/action-handler.rb +41 -40
  154. data/lib/pione/rule-engine/basic-handler.rb +266 -0
  155. data/lib/pione/rule-engine/data-finder.rb +97 -0
  156. data/lib/pione/{rule-handler → rule-engine}/empty-handler.rb +2 -3
  157. data/lib/pione/rule-engine/engine-exception.rb +33 -0
  158. data/lib/pione/rule-engine/flow-handler.rb +490 -0
  159. data/lib/pione/{rule-handler → rule-engine}/root-handler.rb +5 -14
  160. data/lib/pione/{rule-handler → rule-engine}/system-handler.rb +1 -1
  161. data/lib/pione/rule-engine/update-criteria.rb +111 -0
  162. data/lib/pione/system.rb +3 -1
  163. data/lib/pione/system/config.rb +12 -45
  164. data/lib/pione/system/domain-info.rb +3 -12
  165. data/lib/pione/system/init.rb +2 -8
  166. data/lib/pione/system/system-exception.rb +29 -0
  167. data/lib/pione/test-helper.rb +43 -0
  168. data/lib/pione/test-helper/command-helper.rb +65 -0
  169. data/lib/pione/test-helper/extension.rb +9 -0
  170. data/lib/pione/test-helper/lang-helper.rb +196 -0
  171. data/lib/pione/test-helper/location-helper.rb +27 -0
  172. data/lib/pione/test-helper/package-helper.rb +11 -0
  173. data/lib/pione/test-helper/parser-helper.rb +45 -0
  174. data/lib/pione/test-helper/transformer-helper.rb +136 -0
  175. data/lib/pione/test-helper/tuple-helper.rb +13 -0
  176. data/lib/pione/test-helper/tuple-space-helper.rb +31 -0
  177. data/lib/pione/test-helper/webserver.rb +50 -0
  178. data/lib/pione/tuple-space.rb +4 -6
  179. data/lib/pione/{tuple → tuple-space}/basic-tuple.rb +63 -50
  180. data/lib/pione/tuple-space/tuple-definition.yml +165 -0
  181. data/lib/pione/tuple-space/tuple-space-exception.rb +25 -0
  182. data/lib/pione/tuple-space/tuple-space-interface.rb +123 -0
  183. data/lib/pione/tuple-space/tuple-space-server.rb +15 -26
  184. data/lib/pione/util.rb +16 -11
  185. data/lib/pione/util/backslash-notation.rb +11 -0
  186. data/lib/pione/util/digest.rb +71 -0
  187. data/lib/pione/util/embeded-expr-expander.rb +23 -0
  188. data/lib/pione/util/evaluatable.rb +9 -6
  189. data/lib/pione/util/free-thread-generator.rb +46 -0
  190. data/lib/pione/util/ftp-server.rb +3 -4
  191. data/lib/pione/util/id.rb +28 -23
  192. data/lib/pione/util/misc.rb +22 -4
  193. data/lib/pione/util/package-parameters-list.rb +12 -9
  194. data/lib/pione/{parser → util}/parslet-extension.rb +75 -64
  195. data/lib/pione/util/positionable.rb +65 -0
  196. data/lib/pione/util/zip.rb +12 -11
  197. data/lib/pione/version.rb +1 -1
  198. data/{test → misc}/endurance-test/graph.plt +0 -0
  199. data/{test → misc}/endurance-test/run.sh +0 -0
  200. data/pione.gemspec +45 -37
  201. data/test/agent/spec_basic-agent.rb +116 -99
  202. data/test/agent/spec_broker.rb +41 -25
  203. data/test/agent/spec_input-generator.rb +66 -57
  204. data/test/agent/spec_job-terminator.rb +27 -0
  205. data/test/agent/spec_logger.rb +28 -25
  206. data/test/agent/spec_messenger.rb +6 -6
  207. data/test/agent/spec_task-worker.rb +97 -246
  208. data/test/agent/spec_tuple-space-client.rb +19 -15
  209. data/test/agent/spec_tuple-space-provider.rb +26 -0
  210. data/test/agent/spec_tuple-space-receiver.rb +47 -0
  211. data/test/command/command-behavior.rb +2 -2
  212. data/test/command/data/PionePackageP1/P1.pione +9 -0
  213. data/test/command/data/PionePackageP1/pione-package.json +15 -0
  214. data/test/command/data/PionePackageP2/P2.pione +10 -0
  215. data/test/command/data/PionePackageP2/pione-package.json +16 -0
  216. data/test/command/data/PionePackageP3/P3.pione +10 -0
  217. data/test/command/data/PionePackageP3/pione-package.json +16 -0
  218. data/test/command/data/PionePackageP4/P4.pione +10 -0
  219. data/test/command/data/PionePackageP4/pione-package.json +17 -0
  220. data/test/command/data/pione-process.log +471 -0
  221. data/test/command/data/pione-val.domain.dump +0 -0
  222. data/test/command/spec_pione-clean.rb +12 -0
  223. data/test/command/spec_pione-client.rb +6 -6
  224. data/test/command/spec_pione-log.rb +28 -0
  225. data/test/command/spec_pione-package.rb +111 -12
  226. data/test/command/spec_pione-val.rb +4 -4
  227. data/test/lang/data/boolean.yml +134 -0
  228. data/test/lang/data/common-parser.yml +187 -0
  229. data/test/{parser/spec_flow-element-parser.yml → lang/data/conditional-branch-parser.yml} +12 -50
  230. data/test/lang/data/context-parser.yml +148 -0
  231. data/test/lang/data/data-expr.yml +93 -0
  232. data/test/lang/data/data-expr_match.yml +59 -0
  233. data/test/lang/data/declaration-parser.yml +279 -0
  234. data/test/lang/data/document-parser.yml +29 -0
  235. data/test/{parser/spec_expr-parser.yml → lang/data/expr-parser.yml} +9 -11
  236. data/test/lang/data/feature-expr.yml +148 -0
  237. data/test/lang/data/float.yml +30 -0
  238. data/test/lang/data/integer.yml +80 -0
  239. data/test/lang/data/interpolator-parser.yml +61 -0
  240. data/test/lang/data/keyed-sequence.yml +27 -0
  241. data/test/lang/data/literal-parser.yml +207 -0
  242. data/test/lang/data/parameter-set.yml +14 -0
  243. data/test/lang/data/rule-expr.yml +27 -0
  244. data/test/lang/data/sequence.yml +66 -0
  245. data/test/lang/data/string.yml +92 -0
  246. data/test/{model/spec_ticket-expr.yml → lang/data/ticket-expr.yml} +0 -0
  247. data/test/lang/spec_boolean.rb +5 -0
  248. data/test/{parser → lang}/spec_common-parser.rb +10 -32
  249. data/test/lang/spec_conditional-branch-parser.rb +5 -0
  250. data/test/lang/spec_conditional-branch-transformer.rb +97 -0
  251. data/test/lang/spec_conditional-branch.rb +176 -0
  252. data/test/lang/spec_context-parser.rb +5 -0
  253. data/test/lang/spec_context-transformer.rb +206 -0
  254. data/test/lang/spec_context.rb +283 -0
  255. data/test/lang/spec_data-expr.rb +198 -0
  256. data/test/lang/spec_declaration-parser.rb +5 -0
  257. data/test/lang/spec_declaration-transformer.rb +272 -0
  258. data/test/lang/spec_declaration.rb +550 -0
  259. data/test/lang/spec_document-parser.rb +5 -0
  260. data/test/lang/spec_document-transformer.rb +10 -0
  261. data/test/lang/spec_environment.rb +129 -0
  262. data/test/lang/spec_expr-parser.rb +6 -0
  263. data/test/lang/spec_expr-transformer.rb +149 -0
  264. data/test/lang/spec_feature-expr.rb +5 -0
  265. data/test/lang/spec_float.rb +23 -0
  266. data/test/lang/spec_integer.rb +29 -0
  267. data/test/lang/spec_interpolator-parser.rb +5 -0
  268. data/test/lang/spec_interpolator-transformer.rb +15 -0
  269. data/test/lang/spec_keyed-sequence.rb +5 -0
  270. data/test/lang/spec_literal-parser.rb +5 -0
  271. data/test/lang/spec_literal-transformer.rb +111 -0
  272. data/test/lang/spec_message.rb +22 -0
  273. data/test/lang/spec_package-expr.rb +19 -0
  274. data/test/lang/spec_parameter-set.rb +64 -0
  275. data/test/lang/spec_pione-method.rb +57 -0
  276. data/test/lang/spec_rule-expr.rb +18 -0
  277. data/test/lang/spec_sequence.rb +5 -0
  278. data/test/lang/spec_string.rb +5 -0
  279. data/test/lang/spec_ticket-expr.rb +39 -0
  280. data/test/lang/spec_variable.rb +29 -0
  281. data/test/{uri-scheme/spec_myftp-scheme.yml → location/data/myftp-scheme.yml} +0 -0
  282. data/test/location/location-behavior.rb +2 -2
  283. data/test/location/spec_basic-location.rb +5 -1
  284. data/test/{uri-scheme → location}/spec_broadcast-scheme.rb +4 -4
  285. data/test/{uri-scheme → location}/spec_dropbox-scheme.rb +3 -3
  286. data/test/location/spec_ftp-location.rb +3 -2
  287. data/test/location/spec_git-repository-location.rb +19 -19
  288. data/test/{uri-scheme → location}/spec_git-scheme.rb +2 -2
  289. data/test/location/spec_http-location.rb +4 -12
  290. data/test/location/spec_https-location.rb +1 -3
  291. data/test/location/spec_local-location.rb +1 -1
  292. data/test/{uri-scheme → location}/spec_local-scheme.rb +3 -3
  293. data/test/{uri-scheme → location}/spec_myftp-scheme.rb +8 -10
  294. data/test/log/spec_debug.rb +53 -0
  295. data/test/log/spec_domain-log.rb +4 -5
  296. data/test/log/spec_message-log.rb +39 -33
  297. data/test/log/spec_process-log.rb +4 -2
  298. data/test/log/spec_process-record.rb +12 -10
  299. data/test/log/spec_system-log.rb +29 -11
  300. data/test/log/spec_xes-log.rb +6 -4
  301. data/test/package/data/HelloWorld+v0.1.1.ppg +0 -0
  302. data/test/package/data/HelloWorld-gitrepos.zip +0 -0
  303. data/test/{test-data/package → package/data}/HelloWorld/HelloWorld.pione +3 -0
  304. data/test/package/data/HelloWorld/pione-package.json +16 -0
  305. data/test/package/data/HelloWorld/scenario/Scenario.pione +2 -0
  306. data/test/{test-data/package → package/data}/HelloWorld/scenario/output/message.txt +0 -0
  307. data/test/package/data/HelloWorld/scenario/pione-scenario.json +10 -0
  308. data/test/{test-data/package → package/data}/HelloWorld/scenario/scenario.yml +0 -0
  309. data/test/package/data/PackageScannerP1/P1.pione +11 -0
  310. data/test/package/data/PackageScannerP2/P2.pione +9 -0
  311. data/test/package/data/PackageScannerP3/P3.pione +17 -0
  312. data/test/package/data/PackageScannerP4/.Ignore.pione +1 -0
  313. data/test/package/data/PackageScannerP4/Doc1.pione +8 -0
  314. data/test/package/data/PackageScannerP4/Doc2.pione +6 -0
  315. data/test/package/data/PackageScannerP4/Doc3.pione +6 -0
  316. data/test/package/data/PackageScannerP4/P4.pione +8 -0
  317. data/test/package/data/PackageScannerP4/sub1/.Ignore.pione +1 -0
  318. data/test/package/data/PackageScannerP4/sub1/Doc4.pione +6 -0
  319. data/test/package/data/PackageScannerP4/sub1/sub1-1/.Ignore.pione +1 -0
  320. data/test/package/data/PackageScannerP4/sub1/sub1-1/Doc5.pione +6 -0
  321. data/test/package/data/PackageScannerP4/sub2/.Ignore.pione +1 -0
  322. data/test/package/data/PackageScannerP4/sub2/sub2-1/.Ignore.pione +1 -0
  323. data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/.Ignore.pione +1 -0
  324. data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-1/Doc6.pione +6 -0
  325. data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/.Ignore.pione +1 -0
  326. data/test/package/data/PackageScannerP4/sub2/sub2-1/sub2-1-2/Doc7.pione +6 -0
  327. data/test/package/data/PackageScannerP5/P5.pione +8 -0
  328. data/test/{model/spec_feature-expr.yml → package/data/PackageScannerP5/scenario1/Scenario.pione} +0 -0
  329. data/test/package/data/PackageScannerP5/scenario2/Scenario.pione +0 -0
  330. data/test/package/data/PackageScannerP5/scenario3/Scenario.pione +0 -0
  331. data/test/package/data/PackageScannerP5/sub1/scenario4/Scenario.pione +0 -0
  332. data/test/package/data/PackageScannerP5/sub1/sub1-1/scenario5/Scenario.pione +0 -0
  333. data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-1/scenario6/Scenario.pione +0 -0
  334. data/test/package/data/PackageScannerP5/sub2/sub2-1/sub2-1-2/scenario7/Scenario.pione +0 -0
  335. data/test/package/data/ScenarioScannerS1/Scenario.pione +1 -0
  336. data/test/package/data/ScenarioScannerS1/input/i1 +0 -0
  337. data/test/package/data/ScenarioScannerS1/input/i2 +0 -0
  338. data/test/package/data/ScenarioScannerS1/input/i3 +0 -0
  339. data/test/package/data/ScenarioScannerS1/output/o1 +0 -0
  340. data/test/package/data/ScenarioScannerS1/output/o2 +0 -0
  341. data/test/package/data/ScenarioScannerS1/output/o3 +0 -0
  342. data/test/package/data/ScenarioScannerS2/Scenario.pione +1 -0
  343. data/test/package/data/ScenarioScannerS2/output/o1 +0 -0
  344. data/test/package/data/ScenarioScannerS3/Scenario.pione +2 -0
  345. data/test/package/data/ScenarioScannerS4/Scenario.pione +0 -0
  346. data/test/package/data/ScenarioScannerS5/Scenario.pione +2 -0
  347. data/test/package/data/ScenarioScannerS6/Scenario.pione +5 -0
  348. data/test/package/data/ScenarioScannerS8/Scenario.pione +1 -0
  349. data/test/{test-data/package → package/data}/TestPackage1+v0.1.0.ppg +0 -0
  350. data/test/{test-data/package → package/data}/TestPackage1/Test.pione +3 -0
  351. data/test/{test-data/package → package/data}/TestPackage1/bin/count +0 -0
  352. data/test/{test-data/package → package/data}/TestPackage1/package.yml +0 -0
  353. data/test/package/data/TestPackage1/pione-package.json +18 -0
  354. data/test/package/data/TestPackage1/scenario/case1/Scenario.pione +1 -0
  355. data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/input/1.txt +0 -0
  356. data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/output/1.count +0 -0
  357. data/test/package/data/TestPackage1/scenario/case1/pione-scenario.json +10 -0
  358. data/test/{test-data/package → package/data}/TestPackage1/scenario/case1/scenario.yml +0 -0
  359. data/test/package/data/TestPackage1/scenario/case2/Scenario.pione +1 -0
  360. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/1.txt +0 -0
  361. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/2.txt +0 -0
  362. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/input/3.txt +0 -0
  363. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/1.count +0 -0
  364. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/2.count +0 -0
  365. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/output/3.count +0 -0
  366. data/test/package/data/TestPackage1/scenario/case2/pione-scenario.json +14 -0
  367. data/test/{test-data/package → package/data}/TestPackage1/scenario/case2/scenario.yml +0 -0
  368. data/test/package/data/TestPackage1/scenario/case3/Scenario.pione +1 -0
  369. data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/a.txt +0 -0
  370. data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/input/b.txt +0 -0
  371. data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/a.count +0 -0
  372. data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/output/b.count +0 -0
  373. data/test/package/data/TestPackage1/scenario/case3/pione-scenario.json +12 -0
  374. data/test/{test-data/package → package/data}/TestPackage1/scenario/case3/scenario.yml +0 -0
  375. data/test/{component → package}/spec_document.pione +0 -0
  376. data/test/package/spec_document.rb +52 -0
  377. data/test/package/spec_package-archiver.rb +31 -0
  378. data/test/package/spec_package-database.rb +42 -0
  379. data/test/package/spec_package-expander.rb +14 -0
  380. data/test/package/spec_package-filename.rb +56 -0
  381. data/test/package/spec_package-handler.rb +50 -0
  382. data/test/package/spec_package-info.rb +22 -0
  383. data/test/package/spec_package-reader.rb +85 -0
  384. data/test/package/spec_package-scanner.rb +68 -0
  385. data/test/package/spec_scenario-handler.rb +46 -0
  386. data/test/package/spec_scenario-info.rb +16 -0
  387. data/test/package/spec_scenario-scanner.rb +92 -0
  388. data/test/patch/spec_rinda-patch.rb +1 -1
  389. data/test/patch/spec_uri-patch.rb +1 -1
  390. data/test/{rule-handler → rule-engine}/spec_action-handler.pione +0 -0
  391. data/test/rule-engine/spec_action-handler.rb +94 -0
  392. data/test/rule-engine/spec_data-finder.rb +94 -0
  393. data/test/{tuple-space → rule-engine}/spec_data-finder.yml +39 -28
  394. data/test/rule-engine/spec_empty-handler.rb +170 -0
  395. data/test/{rule-handler → rule-engine}/spec_flow-handler.pione +0 -0
  396. data/test/rule-engine/spec_flow-handler.rb +421 -0
  397. data/test/{rule-handler → rule-engine}/spec_update-criteria.pione +0 -0
  398. data/test/{rule-handler → rule-engine}/spec_update-criteria.rb +16 -12
  399. data/test/{rule-handler → rule-engine}/spec_update-criteria.yml +0 -0
  400. data/test/system/spec_domain-info.rb +13 -9
  401. data/test/system/spec_file-cache.rb +9 -9
  402. data/test/tuple-space/spec_tuple-space-server.rb +42 -40
  403. data/test/tuple/spec_basic-tuple.rb +77 -75
  404. data/test/tuple/spec_data-tuple.rb +4 -4
  405. data/test/tuple/spec_finished-tuple.rb +5 -6
  406. data/test/tuple/spec_message-tuple.rb +3 -3
  407. data/test/tuple/spec_task-tuple.rb +11 -9
  408. data/test/tuple/spec_touch-tuple.rb +3 -3
  409. data/test/tuple/spec_working-tuple.rb +8 -12
  410. data/test/tuple/tuple-behavior.rb +1 -1
  411. data/test/util/data/HelloWorld+v0.1.1.ppg +0 -0
  412. data/test/util/spec_cpu.rb +1 -1
  413. data/test/util/spec_digest.rb +15 -0
  414. data/test/util/spec_evaluatable.rb +3 -3
  415. data/test/util/spec_free-thread-generator.rb +42 -0
  416. data/test/util/spec_ftp-server.rb +4 -9
  417. data/test/util/spec_id.rb +53 -36
  418. data/test/util/spec_indentation.rb +1 -1
  419. data/test/util/spec_ip-address.rb +1 -1
  420. data/test/util/spec_package-parameters-list.rb +10 -9
  421. data/test/util/spec_process-info.rb +2 -2
  422. data/test/util/spec_uuid.rb +1 -1
  423. data/test/util/spec_variable-holdable.rb +1 -1
  424. data/test/util/spec_zip.rb +1 -1
  425. metadata +508 -364
  426. data/example/SerialProcessing/package.yml +0 -5
  427. data/example/SerialProcessing/scenario/scenario.yml +0 -10
  428. data/lib/pione/agent/command-listener.rb +0 -47
  429. data/lib/pione/agent/rule-provider.rb +0 -59
  430. data/lib/pione/agent/trivial-routine-worker.rb +0 -29
  431. data/lib/pione/agent/tuple-space-server-client-life-checker.rb +0 -31
  432. data/lib/pione/command/child-process.rb +0 -56
  433. data/lib/pione/command/daemon-process.rb +0 -10
  434. data/lib/pione/command/front-owner-command.rb +0 -25
  435. data/lib/pione/component.rb +0 -13
  436. data/lib/pione/component/document.rb +0 -88
  437. data/lib/pione/component/package-archiver.rb +0 -92
  438. data/lib/pione/component/package-filename.rb +0 -38
  439. data/lib/pione/component/package-reader.rb +0 -276
  440. data/lib/pione/component/package.rb +0 -199
  441. data/lib/pione/component/rule.rb +0 -206
  442. data/lib/pione/front/task-worker-owner.rb +0 -43
  443. data/lib/pione/front/tuple-space-provider-owner.rb +0 -11
  444. data/lib/pione/model.rb +0 -32
  445. data/lib/pione/model/assignment.rb +0 -120
  446. data/lib/pione/model/basic-model.rb +0 -228
  447. data/lib/pione/model/block.rb +0 -262
  448. data/lib/pione/model/boolean.rb +0 -168
  449. data/lib/pione/model/call-rule.rb +0 -86
  450. data/lib/pione/model/constraints.rb +0 -46
  451. data/lib/pione/model/data-expr.rb +0 -548
  452. data/lib/pione/model/feature-expr.rb +0 -875
  453. data/lib/pione/model/float.rb +0 -105
  454. data/lib/pione/model/integer.rb +0 -166
  455. data/lib/pione/model/keyed-sequence.rb +0 -150
  456. data/lib/pione/model/message.rb +0 -95
  457. data/lib/pione/model/ordinal-sequence.rb +0 -73
  458. data/lib/pione/model/package-expr.rb +0 -53
  459. data/lib/pione/model/parameters.rb +0 -374
  460. data/lib/pione/model/rule-expr.rb +0 -234
  461. data/lib/pione/model/sequence.rb +0 -273
  462. data/lib/pione/model/string.rb +0 -127
  463. data/lib/pione/model/ticket-expr.rb +0 -71
  464. data/lib/pione/model/variable-table.rb +0 -344
  465. data/lib/pione/model/variable.rb +0 -116
  466. data/lib/pione/parser.rb +0 -14
  467. data/lib/pione/parser/block-parser.rb +0 -107
  468. data/lib/pione/parser/common-parser.rb +0 -173
  469. data/lib/pione/parser/document-parser.rb +0 -141
  470. data/lib/pione/parser/expr-parser.rb +0 -354
  471. data/lib/pione/parser/feature-expr-parser.rb +0 -105
  472. data/lib/pione/parser/flow-element-parser.rb +0 -181
  473. data/lib/pione/parser/literal-parser.rb +0 -196
  474. data/lib/pione/parser/rule-definition-parser.rb +0 -158
  475. data/lib/pione/patch/monitor-patch.rb +0 -16
  476. data/lib/pione/rule-handler.rb +0 -14
  477. data/lib/pione/rule-handler/basic-handler.rb +0 -326
  478. data/lib/pione/rule-handler/flow-handler.rb +0 -414
  479. data/lib/pione/rule-handler/update-criteria.rb +0 -175
  480. data/lib/pione/system/global.rb +0 -433
  481. data/lib/pione/transformer.rb +0 -24
  482. data/lib/pione/transformer/block-transformer.rb +0 -28
  483. data/lib/pione/transformer/document-transformer.rb +0 -58
  484. data/lib/pione/transformer/feature-expr-transformer.rb +0 -60
  485. data/lib/pione/transformer/flow-element-transformer.rb +0 -66
  486. data/lib/pione/transformer/literal-transformer.rb +0 -91
  487. data/lib/pione/transformer/rule-definition-transformer.rb +0 -80
  488. data/lib/pione/transformer/transformer-module.rb +0 -39
  489. data/lib/pione/tuple-space/data-finder.rb +0 -155
  490. data/lib/pione/tuple-space/presence-notifier.rb +0 -84
  491. data/lib/pione/tuple-space/tuple-space-provider.rb +0 -85
  492. data/lib/pione/tuple-space/tuple-space-receiver.rb +0 -141
  493. data/lib/pione/tuple-space/tuple-space-server-interface.rb +0 -123
  494. data/lib/pione/tuple.rb +0 -30
  495. data/lib/pione/tuple/agent-tuple.rb +0 -10
  496. data/lib/pione/tuple/attribute-tuple.rb +0 -7
  497. data/lib/pione/tuple/base-location-tuple.rb +0 -9
  498. data/lib/pione/tuple/bye-tuple.rb +0 -9
  499. data/lib/pione/tuple/command-tuple.rb +0 -9
  500. data/lib/pione/tuple/data-null-tuple.rb +0 -14
  501. data/lib/pione/tuple/data-tuple.rb +0 -21
  502. data/lib/pione/tuple/dry-run-tuple.rb +0 -8
  503. data/lib/pione/tuple/exception-tuple.rb +0 -11
  504. data/lib/pione/tuple/finished-tuple.rb +0 -17
  505. data/lib/pione/tuple/foreground-tuple.rb +0 -7
  506. data/lib/pione/tuple/lift-tuple.rb +0 -14
  507. data/lib/pione/tuple/message-tuple.rb +0 -7
  508. data/lib/pione/tuple/process-info-tuple.rb +0 -9
  509. data/lib/pione/tuple/process-log-tuple.rb +0 -13
  510. data/lib/pione/tuple/request-rule-tuple.rb +0 -9
  511. data/lib/pione/tuple/rule-tuple.rb +0 -10
  512. data/lib/pione/tuple/task-tuple.rb +0 -40
  513. data/lib/pione/tuple/task-worker-resource-tuple.rb +0 -9
  514. data/lib/pione/tuple/ticket-tuple.rb +0 -8
  515. data/lib/pione/tuple/touch-tuple.rb +0 -14
  516. data/lib/pione/tuple/working-tuple.rb +0 -13
  517. data/lib/pione/uri-scheme.rb +0 -11
  518. data/lib/pione/util/error-report.rb +0 -27
  519. data/test/agent/spec_command-listener.rb +0 -30
  520. data/test/agent/spec_rule-provider.rb +0 -78
  521. data/test/command/spec_pione-val.domain.dump +0 -0
  522. data/test/component/spec_document.rb +0 -67
  523. data/test/component/spec_package-archiver.rb +0 -27
  524. data/test/component/spec_package-expander.rb +0 -11
  525. data/test/component/spec_package-filename.rb +0 -79
  526. data/test/component/spec_package-reader.rb +0 -100
  527. data/test/component/spec_package.rb +0 -109
  528. data/test/component/spec_rule.rb +0 -140
  529. data/test/model/spec_assignment.rb +0 -52
  530. data/test/model/spec_block.rb +0 -108
  531. data/test/model/spec_boolean.rb +0 -39
  532. data/test/model/spec_boolean.yml +0 -134
  533. data/test/model/spec_call-rule.rb +0 -23
  534. data/test/model/spec_data-expr.rb +0 -361
  535. data/test/model/spec_data-expr.yml +0 -24
  536. data/test/model/spec_data-expr_match.yml +0 -45
  537. data/test/model/spec_feature-expr.rb +0 -333
  538. data/test/model/spec_feature-expr_decide.yml +0 -28
  539. data/test/model/spec_float.rb +0 -23
  540. data/test/model/spec_float.yml +0 -30
  541. data/test/model/spec_integer.rb +0 -23
  542. data/test/model/spec_integer.yml +0 -68
  543. data/test/model/spec_keyed-sequence.rb +0 -5
  544. data/test/model/spec_keyed-sequence.yml +0 -27
  545. data/test/model/spec_message.rb +0 -40
  546. data/test/model/spec_package-expr.rb +0 -19
  547. data/test/model/spec_parameters.rb +0 -103
  548. data/test/model/spec_pione-method.rb +0 -57
  549. data/test/model/spec_rule-expr.rb +0 -28
  550. data/test/model/spec_rule-expr.yml +0 -11
  551. data/test/model/spec_sequence.rb +0 -5
  552. data/test/model/spec_sequence.yml +0 -66
  553. data/test/model/spec_string.rb +0 -47
  554. data/test/model/spec_string.yml +0 -91
  555. data/test/model/spec_ticket-expr.rb +0 -39
  556. data/test/model/spec_variable-table.rb +0 -116
  557. data/test/model/spec_variable.rb +0 -82
  558. data/test/parser/spec_block-parser.rb +0 -5
  559. data/test/parser/spec_block-parser.yml +0 -94
  560. data/test/parser/spec_document-parser.rb +0 -5
  561. data/test/parser/spec_document-parser.yml +0 -77
  562. data/test/parser/spec_expr-parser.rb +0 -6
  563. data/test/parser/spec_feature-expr-parser.rb +0 -32
  564. data/test/parser/spec_feature-expr-parser.yml +0 -25
  565. data/test/parser/spec_flow-element-parser.rb +0 -5
  566. data/test/parser/spec_literal-parser.rb +0 -5
  567. data/test/parser/spec_literal-parser.yml +0 -134
  568. data/test/parser/spec_rule-definition-parser.rb +0 -5
  569. data/test/parser/spec_rule-definition-parser.yml +0 -94
  570. data/test/rule-handler/spec_action-handler.rb +0 -79
  571. data/test/rule-handler/spec_flow-handler.rb +0 -61
  572. data/test/spec_common.rb +0 -14
  573. data/test/spec_object.rb +0 -20
  574. data/test/test-data/package/HelloWorld+v0.1.0.ppg +0 -0
  575. data/test/test-data/package/HelloWorld-gitrepos.zip +0 -0
  576. data/test/test-data/package/HelloWorld/package.yml +0 -6
  577. data/test/test-util.rb +0 -211
  578. data/test/test-util/command.rb +0 -53
  579. data/test/test-util/package.rb +0 -9
  580. data/test/test-util/parser.rb +0 -45
  581. data/test/test-util/transformer.rb +0 -50
  582. data/test/test-util/webserver.rb +0 -43
  583. data/test/transformer/spec_block-transformer.rb +0 -33
  584. data/test/transformer/spec_document-transformer.rb +0 -50
  585. data/test/transformer/spec_expr-transformer.rb +0 -126
  586. data/test/transformer/spec_feature-expr-transformer.rb +0 -21
  587. data/test/transformer/spec_flow-element-transformer.rb +0 -154
  588. data/test/transformer/spec_literal-transformer.rb +0 -64
  589. data/test/transformer/spec_rule-definition-transformer.rb +0 -172
  590. data/test/tuple-space/spec_data-finder.rb +0 -94
  591. data/test/tuple-space/spec_tuple-space-provider.rb +0 -36
  592. data/test/tuple-space/spec_tuple-space-receiver.rb +0 -32
  593. data/test/util/spec_error-report.rb +0 -51
@@ -1,149 +1,166 @@
1
1
  module Pione
2
2
  module Command
3
- # This is a class for +pione-task-worker+ command. +pione-task-worker+
4
- # starts a task worker agent with tuple space server.
5
- class PioneTaskWorker < ChildProcess
6
- define_info do
7
- set_name "pione-task-worker"
8
- set_tail {|cmd|
9
- begin
10
- "{Front: %s, ParentFront: %s}" % [
11
- Global.front.uri, cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri
12
- ]
13
- rescue => e
14
- Util::ErrorReport.warn("faild to get command line options.", self, e, __FILE__, __LINE__)
15
- end
16
- }
17
- set_banner <<BANNER
18
- Run task worker process. This command is launched by other processes like
19
- pione-client or pione-broker.
20
- BANNER
3
+ # This is a body for +pione-task-worker+ command.
4
+ class PioneTaskWorker < BasicCommand
5
+ #
6
+ # basic informations
7
+ #
8
+
9
+ command_name "pione-task-worker" do |cmd|
10
+ "front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
21
11
  end
22
12
 
23
- define_option do
24
- use :color
25
- use :debug
26
- use :my_ip_address
27
- use :no_parent
28
- use :parent_front
29
-
30
- define(:connection_id) do |item|
31
- item.long = '--connection-id=ID'
32
- item.desc = 'set connection id'
33
- item.value = proc {|id| id}
34
- end
13
+ command_banner(Util::Indentation.cut(<<-TEXT))
14
+ Run a task worker process. This command assumes to be launched by
15
+ pione-client or pione-broker, so you should not execute this by hand.
16
+ TEXT
35
17
 
36
- define(:features) do |item|
37
- item.long = '--features=FEATURES'
38
- item.desc = 'set features'
39
- item.value = proc do |features|
40
- begin
41
- DocumentTransformer.new.apply(
42
- DocumentParser.new.feature_expr.parse(features)
43
- )
44
- rescue Parslet::ParseFailed => e
45
- puts "invalid parameters: " + str
46
- Util::ErrorReport.print(e)
47
- abort
48
- end
49
- end
50
- end
18
+ command_front Front::TaskWorkerFront
51
19
 
52
- validate do |option|
53
- # check requisite options
54
- abort("error: no connection id") if option[:connection_id].nil?
55
-
56
- # get the parent front server
57
- begin
58
- option[:parent_front].uuid
59
- rescue => e
60
- if Pione.debug_mode?
61
- debug_message "pione-task-worker cannot get the parent front server: %s" % e
62
- end
63
- abort
64
- end
65
- end
20
+ #
21
+ # options
22
+ #
23
+
24
+ use_option :color
25
+ use_option :debug
26
+ use_option :my_ip_address
27
+ use_option :parent_front
28
+ use_option :features
29
+
30
+ define_option(:tuple_space_id) do |item|
31
+ item.long = '--tuple-space-id=UUID'
32
+ item.desc = 'tuple space id that the worker joins'
33
+ item.requisite = true
34
+ item.value = proc {|id| id}
35
+ end
36
+
37
+ #
38
+ # class methods
39
+ #
40
+
41
+ # Create a new process of +pione-task-worker+ command.
42
+ def self.spawn(features, tuple_space_id)
43
+ spawner = Spawner.new("pione-task-worker")
44
+
45
+ # debug options
46
+ spawner.option("--debug=system") if Global.debug_system
47
+ spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
48
+ spawner.option("--debug=rule_engine") if Global.debug_rule_engine
49
+ spawner.option("--debug=communication") if Global.debug_communication
50
+ spawner.option("--debug=presence_notification") if Global.debug_presence_notification
51
+
52
+ # requisite options
53
+ spawner.option("--parent-front", Global.front.uri)
54
+ spawner.option("--tuple-space-id", tuple_space_id)
55
+ spawner.option("--features", features) if features
56
+
57
+ # optionals
58
+ spawner.option("--color") if Global.color_enabled
59
+
60
+ spawner.spawn # this method returns child front
66
61
  end
67
62
 
63
+ #
64
+ # instance methods
65
+ #
66
+
68
67
  attr_reader :agent
69
68
  attr_reader :tuple_space_server
70
69
 
71
- private
70
+ #
71
+ # command lifecycle: setup phase
72
+ #
72
73
 
73
- def create_front
74
- Pione::Front::TaskWorkerFront.new(self)
75
- end
74
+ setup_phase :timeout => 15
75
+ setup :parent_process_connection, :module => CommonCommandAction
76
+ setup :tuple_space
77
+ setup :agent
78
+ setup :base_location
79
+ setup :job_terminator
80
+
81
+ # Get tuple space from parent process and test the connection.
82
+ def setup_tuple_space
83
+ @tuple_space = option[:parent_front].get_tuple_space(option[:tuple_space_id])
76
84
 
77
- prepare do
78
- begin
79
- @tuple_space_server = option[:parent_front].get_tuple_space_server(option[:connection_id])
80
- @agent = Pione::Agent[:task_worker].new(@tuple_space_server, option[:features])
81
- @command_listener = Pione::Agent[:command_listener].new(@tuple_space_server, self)
85
+ unless @tuple_space
86
+ abort("%s cannot get tuple space \"%s\"." % [command_name, option[:tuple_space_id]])
87
+ end
82
88
 
83
- # connect caller front
84
- option[:parent_front].add_task_worker_front(Global.front, option[:connection_id])
89
+ if Util.error?(:timeout => 3) {@tuple_space.uuid}
90
+ abort("%s cannot connect to tuple space." % command_name)
91
+ end
92
+ end
85
93
 
86
- abort("pione-task-worker error: no tuple space server") unless @tuple_space_server
94
+ # Create a task worker agent.
95
+ def setup_agent
96
+ @agent = Agent::TaskWorker.new(@tuple_space, option[:expressive_features])
97
+ end
87
98
 
88
- # get base uri
89
- if @tuple_space_server.base_location.kind_of?(Location::DropboxLocation)
90
- Location::Dropbox.init(@tuple_space_server)
91
- unless Location::Dropbox.ready?
99
+ # Setup base location.
100
+ def setup_base_location
101
+ if @tuple_space.base_location.kind_of?(Location::DropboxLocation)
102
+ Location::Dropbox.init(@tuple_space)
103
+ unless Location::Dropbox.ready?
92
104
  abort("You aren't ready to access Dropbox.")
93
- end
94
105
  end
95
- rescue => e
96
- msg = "Exception raised in preparing task-worker, go termination process."
97
- Util::ErrorReport.warn(msg, self, e, __FILE__, __LINE__)
98
- call_terminations
99
106
  end
100
107
  end
101
108
 
102
- start do
103
- # start task worker activity
109
+ # Create a job terminator and setup the action.
110
+ def setup_job_terminator
111
+ @job_terminator = Agent::JobTerminator.new(@tuple_space) do
112
+ terminate
113
+ end
114
+ end
115
+
116
+ #
117
+ # command lifecycle: execution phase
118
+ #
119
+
120
+ handle_execution_exception(DRb::DRbConnError) do |cmd, e|
121
+ Log::Debug.system do
122
+ "%s goes termination phase because the exception was catched: %s" % [cmd.command_name, e.message]
123
+ end
124
+ cmd.terminate
125
+ end
126
+ execute :job_terminator
127
+ execute :agent
128
+
129
+ # Start the job terminator.
130
+ def execute_job_terminator
131
+ @job_terminator.start
132
+ end
133
+
134
+ # Start task worker activity and wait the termination.
135
+ def execute_agent
104
136
  @agent.start
105
- @command_listener.start
137
+ @agent.wait_until_terminated(nil)
138
+ end
106
139
 
107
- # wait...
108
- begin
109
- @agent.running_thread.join
110
- rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
111
- # ignore
140
+ #
141
+ # command lifecycle: termination phase
142
+ #
143
+
144
+ termination_phase :timeout => 10
145
+ terminate :job_terminator
146
+ terminate :agent
147
+ terminate :parent_process_connection, :module => CommonCommandAction
148
+
149
+ # Terminate job terminator.
150
+ def terminate_job_terminator
151
+ if @job_terminator and not(@job_terminator.terminated?)
152
+ @job_terminator.terminate
112
153
  end
113
154
  end
114
155
 
115
- terminate do
116
- Global.monitor.synchronize do
117
- begin
118
- # flag
119
- return if @terminated
120
- @terminated = true
121
-
122
- # terminate the agent
123
- if @agent
124
- @agent.terminate
125
-
126
- Timeout.timeout(5) do
127
- while true
128
- break if @agent.terminated? and @agent.running_thread and @agent.running_thread.stop?
129
- sleep 1
130
- end
131
- end
132
- end
133
-
134
- # disconnect parent front
135
- option[:parent_front].remove_task_worker_front(self, option[:connection_id])
136
-
137
- rescue DRb::DRbConnError, DRb::ReplyReaderThreadError => e
138
- Util::ErrorReport.warn("Disconnected in termination process of task worker agent.", self, e, __FILE__, __LINE__)
139
- rescue ThreadError => e
140
- # tuple space may be closed
141
- Util::ErrorReport.warn("Failed in termination process of task worker agent.", self, e, __FILE__, __LINE__)
142
- rescue Timeout::Error => e
143
- Util::ErrorReport.warn("Timeouted in termination of pione-task-worker.", self, e, __FILE__, __LINE__)
144
- end
156
+ # Terminate task worker agent.
157
+ def terminate_agent
158
+ if @agent
159
+ @agent.terminate
160
+ @agent.wait_until_terminated(nil)
145
161
  end
146
162
  end
147
163
  end
148
164
  end
149
165
  end
166
+
@@ -1,68 +1,101 @@
1
1
  module Pione
2
2
  module Command
3
3
  # PioneTupleSpaceProvider is for +pione-tuple-space-provider+ command.
4
- class PioneTupleSpaceProvider < ChildProcess
5
- define_info do
6
- set_name "pione-tuple-space-provider"
7
- set_tail {|cmd|
8
- front_uri = begin Global.front.uri rescue "failed" end
9
- parent_front = begin cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri rescue "failed" end
10
- "{Front: %s, ParentFront: %s}" % [front_uri, parent_front]
11
- }
12
- set_banner <<TXT
13
- Run tuple space provider process for sending tuple space presence notifier. This
14
- command is launched by other processes like pione-client or pione-relay
15
- normally, but you can force to start by calling with --no-parent option.
16
- TXT
17
- end
4
+ class PioneTupleSpaceProvider < BasicCommand
5
+ #
6
+ # command info
7
+ #
18
8
 
19
- define_option do
20
- use :debug
21
- use :color
22
- use :my_ip_address
23
- use :no_parent
24
- use :parent_front
25
- use :presence_notification_address
26
- use :show_communication
27
- use :show_presence_notifier
9
+ command_name "pione-tuple-space-provider" do |cmd|
10
+ "front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
28
11
  end
29
12
 
30
- attr_reader :tuple_space_provider
13
+ command_banner(Util::Indentation.cut(<<-TXT))
14
+ Run tuple space provider process for sending tuple space presence
15
+ notifier. This command assumes to be launched by other processes like
16
+ pione-client or pione-relay.
17
+ TXT
31
18
 
32
- # @api private
33
- def create_front
34
- Pione::Front::TupleSpaceProviderFront.new(self)
19
+ command_front Pione::Front::TupleSpaceProviderFront do |cmd|
20
+ [cmd.option[:parent_front].get_tuple_space(nil)]
35
21
  end
36
22
 
37
- prepare do
38
- # make tuple space provider
39
- @tuple_space_provider = TupleSpaceProvider.new
40
- end
23
+ #
24
+ # options
25
+ #
26
+
27
+ use_option :color
28
+ use_option :debug
29
+ use_option :my_ip_address
30
+ use_option :parent_front
31
+ use_option :presence_notification_address
32
+
33
+ #
34
+ # class methods
35
+ #
41
36
 
42
- start do
43
- # start provider activity
44
- @tuple_space_provider.start
37
+ # Create a new process of tuple space provider command.
38
+ def self.spawn
39
+ spawner = Spawner.new(command_name)
45
40
 
46
- begin
47
- # set my URI to caller front as its provider
48
- unless option[:no_parent_mode]
49
- option[:parent_front].set_tuple_space_provider(Global.front.uri)
50
- end
41
+ # debug options
42
+ spawner.option("--debug=system") if Global.debug_system
43
+ spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
44
+ spawner.option("--debug=rule_engine") if Global.debug_rule_engine
45
+ spawner.option("--debug=communication") if Global.debug_communication
46
+ spawner.option("--debug=presence_notification") if Global.debug_presence_notification
51
47
 
52
- # wait
53
- DRb.thread.join
54
- rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
55
- # ignore
48
+ # requisite options
49
+ spawner.option("--parent-front", Global.front.uri)
50
+ spawner.option("--my-ip-address", Global.my_ip_address)
51
+ Global.presence_notification_addresses.each do |address|
52
+ spawner.option("--presence-notification-address", address.to_s)
56
53
  end
54
+
55
+ # optionals
56
+ spawner.option("--color") if Global.color_enabled
57
+
58
+ spawner.spawn
59
+ end
60
+
61
+ #
62
+ # instance methods
63
+ #
64
+
65
+ attr_reader :agent
66
+
67
+ #
68
+ # command lifecycle: setup phase
69
+ #
70
+
71
+ setup_phase :timeout => 5
72
+ setup :parent_process_connection, :module => CommonCommandAction
73
+
74
+ #
75
+ # command lifecycle: execution phase
76
+ #
77
+
78
+ execute :agent
79
+
80
+ # Start agent activity and wait the termination.
81
+ def execute_agent
82
+ @agent = Agent::TupleSpaceProvider.start(Global.front)
83
+ @agent.wait_until_terminated(nil)
57
84
  end
58
85
 
59
- terminate do
60
- Global.monitor.synchronize do
61
- begin
62
- @tuple_space_provider.terminate
63
- rescue DRb::DRbConnError, DRb::ReplyReaderThreadError
64
- abort
65
- end
86
+ #
87
+ # command lifecycle: termination phase
88
+ #
89
+
90
+ termination_phase :timeout => 5
91
+ terminate :agent
92
+ terminate :parent_process_connection, :module => CommonCommandAction
93
+
94
+ # Terminate agent.
95
+ def terminate_agent
96
+ if @agent and not(@agent.terminated?)
97
+ @agent.terminate
98
+ @agent.wait_until_terminated(nil)
66
99
  end
67
100
  end
68
101
  end
@@ -2,70 +2,109 @@ module Pione
2
2
  module Command
3
3
  # PioneTupleSpaceReceiver is a command that launchs tuple space receiver
4
4
  # agent.
5
- class PioneTupleSpaceReceiver < ChildProcess
6
- define_info do
7
- set_name "pione-tuple-space-receiver"
8
- set_tail {|cmd|
9
- front = Global.front.uri
10
- parent_front = cmd.option[:no_parent_mode] ? "nil" : cmd.option[:parent_front].uri
11
- "{Front: %s, ParentFront: %s}" % [front, parent_front]
12
- }
13
- set_banner <<TXT
14
- Run tuple space receiver process for receiving tuple space presence
15
- notifier. This command is launched by other processes like pione-broker
16
- normally, but you can force to start by calling with --no-parent option.
17
- TXT
5
+ class PioneTupleSpaceReceiver < BasicCommand
6
+ #
7
+ # basic informations
8
+ #
9
+
10
+ command_name "pione-tuple-space-receiver" do |cmd|
11
+ "front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
18
12
  end
19
13
 
20
- define_option do
21
- use :debug
22
- use :color
23
- use :my_ip_address
24
- use :no_parent
25
- use :parent_front
26
- use :show_communication
27
- use :show_presence_notifier
28
-
29
- define(:presence_port) do |item|
30
- item.long = "--presence-port=PORT"
31
- item.desc = "set presence port number"
32
- item.action = lambda do |option, port|
33
- Global.presence_port = port.to_i
34
- end
14
+ command_banner(Util::Indentation.cut(<<-TXT))
15
+ Run tuple space receiver process for receiving tuple space presence
16
+ notifier. This command is launched by other processes like pione-broker
17
+ normally, but you can force to start by calling with --no-parent option.
18
+ TXT
19
+
20
+ command_front Front::TupleSpaceReceiverFront
21
+
22
+ #
23
+ # options
24
+ #
25
+
26
+ use_option :color
27
+ use_option :debug
28
+ use_option :my_ip_address
29
+ use_option :parent_front
30
+
31
+ define_option(:presence_port) do |item|
32
+ item.long = "--presence-port=PORT"
33
+ item.desc = "set presence port number"
34
+ item.action = lambda do |_, _, port|
35
+ Global.presence_port = port.to_i
35
36
  end
36
37
  end
37
38
 
38
- attr_reader :tuple_space_receiver
39
+ #
40
+ # class methods
41
+ #
42
+
43
+ # Create a new process of tuple space provider command.
44
+ def self.spawn
45
+ spawner = Spawner.new("pione-tuple-space-receiver")
46
+
47
+ # debug options
48
+ spawner.option("--debug=system") if Global.debug_system
49
+ spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
50
+ spawner.option("--debug=rule_engine") if Global.debug_rule_engine
51
+ spawner.option("--debug=communication") if Global.debug_communication
52
+ spawner.option("--debug=presence_notification") if Global.debug_presence_notification
53
+
54
+ # requisite options
55
+ spawner.option("--parent-front", Global.front.uri)
56
+ spawner.option("--my-ip-address", Global.my_ip_address)
57
+ spawner.option("--presence-port", Global.presence_port.to_s)
58
+
59
+ # optionals
60
+ spawner.option("--color") if Global.color_enabled
39
61
 
40
- def create_front
41
- Front::TupleSpaceReceiverFront.new(self)
62
+ spawner.spawn
42
63
  end
43
64
 
44
- prepare do
45
- @tuple_space_receiver = TupleSpaceReceiver.new
65
+ #
66
+ # instance methods
67
+ #
68
+
69
+ attr_reader :tuple_space_receiver
70
+
71
+ #
72
+ # command lifecycle: setup phase
73
+ #
74
+
75
+ setup :parent_process_connection, :module => CommonCommandAction
76
+ setup :broker
77
+
78
+ # set my uri to parent front as its provider
79
+ def setup_broker
80
+ option[:parent_front].set_tuple_space_receiver(Global.front.uri)
46
81
  end
47
82
 
48
- start do
49
- begin
50
- # start provider activity
51
- @tuple_space_receiver.start
83
+ #
84
+ # command lifecycle: execution phase
85
+ #
52
86
 
53
- # set my uri to parent front as its provider
54
- unless option[:no_parent_mode]
55
- option[:parent_front].set_tuple_space_receiver(Global.front.uri)
56
- end
87
+ execute :agent
57
88
 
58
- # wait
59
- DRb.thread.join
60
- rescue DRb::ReplyReaderThreadError => e
61
- # ignore reply reader error
62
- end
89
+ # create a tuple space receiver agent
90
+ def execute_agent
91
+ @agent = Agent::TupleSpaceReceiver.start(option[:parent_front])
92
+ @agent.wait_until_terminated(nil)
93
+ rescue Agent::ConnectionError
94
+ Log::SystemLog.fatal("pione-tuple-space-receiver is terminated because pione-borker may be dead.")
95
+ terminate
63
96
  end
64
97
 
65
- terminate do
66
- Global.monitor.synchronize do
67
- @tuple_space_receiver.terminate
68
- end
98
+ #
99
+ # command lifecycle: termination phase
100
+ #
101
+
102
+ termination_phase :timeout => 5
103
+ terminate :agent
104
+ terminate :parent_process_connection, :module => CommonCommandAction
105
+
106
+ def terminate_agent
107
+ @agent.terminate if @agent
69
108
  end
70
109
  end
71
110
  end