pione 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (304) hide show
  1. data/.gitignore +2 -0
  2. data/.s3cfg +42 -0
  3. data/.travis.yml +18 -4
  4. data/.yardopts +1 -0
  5. data/Gemfile +3 -0
  6. data/History.txt +14 -0
  7. data/Procfile +7 -0
  8. data/Rakefile +25 -0
  9. data/bin/pione-interactive +6 -0
  10. data/bin/{pione-compiler → pione-notification-listener} +1 -1
  11. data/bin/{pione-broker → pione-task-worker-broker} +1 -1
  12. data/doc/man/pione-list-param.md +36 -0
  13. data/example/ActionError/ActionError.pione +9 -0
  14. data/example/ActionError/pione-package.json +15 -0
  15. data/example/CountChar/CountChar.pione +1 -1
  16. data/example/ScoreAggregation/ScoreAggregation.pione +1 -1
  17. data/example/Touch/pione-package.json +15 -0
  18. data/lib/pione.rb +12 -0
  19. data/lib/pione/agent.rb +3 -3
  20. data/lib/pione/agent/basic-agent.rb +10 -4
  21. data/lib/pione/agent/input-generator.rb +3 -3
  22. data/lib/pione/agent/{process-manager.rb → job-manager.rb} +10 -7
  23. data/lib/pione/agent/job-terminator.rb +2 -2
  24. data/lib/pione/agent/logger.rb +3 -3
  25. data/lib/pione/agent/messenger.rb +20 -9
  26. data/lib/pione/agent/notification-listener.rb +88 -0
  27. data/lib/pione/agent/task-worker-broker.rb +84 -0
  28. data/lib/pione/agent/task-worker.rb +3 -2
  29. data/lib/pione/agent/tuple-space-client.rb +1 -0
  30. data/lib/pione/agent/tuple-space-provider.rb +17 -35
  31. data/lib/pione/command.rb +33 -15
  32. data/lib/pione/command/action.rb +105 -0
  33. data/lib/pione/command/basic-command.rb +34 -376
  34. data/lib/pione/command/command-exception.rb +12 -11
  35. data/lib/pione/command/common.rb +198 -0
  36. data/lib/pione/command/option.rb +159 -204
  37. data/lib/pione/command/pione-action-exec.rb +85 -0
  38. data/lib/pione/command/pione-action-list.rb +43 -19
  39. data/lib/pione/command/pione-action-print.rb +79 -0
  40. data/lib/pione/command/pione-action.rb +8 -67
  41. data/lib/pione/command/pione-clean.rb +88 -68
  42. data/lib/pione/command/pione-client.rb +475 -332
  43. data/lib/pione/command/pione-command.rb +14 -31
  44. data/lib/pione/command/pione-compile.rb +90 -0
  45. data/lib/pione/command/pione-config-get.rb +53 -0
  46. data/lib/pione/command/pione-config-list.rb +64 -0
  47. data/lib/pione/command/pione-config-set.rb +59 -0
  48. data/lib/pione/command/pione-config-unset.rb +50 -0
  49. data/lib/pione/command/pione-config.rb +61 -0
  50. data/lib/pione/command/pione-diagnosis-notification.rb +235 -0
  51. data/lib/pione/command/pione-diagnosis.rb +21 -0
  52. data/lib/pione/command/pione-interactive.rb +188 -0
  53. data/lib/pione/command/pione-lang-check-syntax.rb +163 -0
  54. data/lib/pione/command/pione-lang-interactive.rb +146 -0
  55. data/lib/pione/command/pione-lang.rb +22 -0
  56. data/lib/pione/command/pione-log-format.rb +163 -0
  57. data/lib/pione/command/pione-log-list-id.rb +48 -0
  58. data/lib/pione/command/pione-log.rb +19 -101
  59. data/lib/pione/command/pione-notification-listener.rb +95 -0
  60. data/lib/pione/command/pione-package-add.rb +137 -0
  61. data/lib/pione/command/pione-package-build.rb +122 -0
  62. data/lib/pione/command/pione-package-show.rb +96 -0
  63. data/lib/pione/command/pione-package-update.rb +59 -0
  64. data/lib/pione/command/pione-package.rb +11 -139
  65. data/lib/pione/command/pione-task-worker-broker.rb +88 -0
  66. data/lib/pione/command/pione-task-worker.rb +148 -98
  67. data/lib/pione/command/pione-tuple-space-provider.rb +62 -54
  68. data/lib/pione/command/pione-tuple-space-viewer.rb +105 -83
  69. data/lib/pione/command/pione-val.rb +39 -39
  70. data/lib/pione/command/spawner.rb +34 -27
  71. data/lib/pione/front.rb +4 -2
  72. data/lib/pione/front/basic-front.rb +86 -23
  73. data/lib/pione/front/client-front.rb +2 -2
  74. data/lib/pione/front/diagnosis-notification-front.rb +40 -0
  75. data/lib/pione/front/front-exception.rb +7 -1
  76. data/lib/pione/front/notification-listener-front.rb +36 -0
  77. data/lib/pione/front/notification-recipient-interface.rb +19 -0
  78. data/lib/pione/front/relay-front.rb +4 -4
  79. data/lib/pione/front/task-worker-broker-front.rb +19 -0
  80. data/lib/pione/front/task-worker-front.rb +2 -2
  81. data/lib/pione/front/tuple-space-provider-front.rb +3 -2
  82. data/lib/pione/global.rb +3 -1
  83. data/lib/pione/global/client-variable.rb +1 -1
  84. data/lib/pione/global/config.rb +63 -7
  85. data/lib/pione/global/diagnosis-variable.rb +26 -0
  86. data/lib/pione/global/item.rb +28 -5
  87. data/lib/pione/global/log-variable.rb +6 -5
  88. data/lib/pione/global/network-variable.rb +75 -4
  89. data/lib/pione/global/path-variable.rb +1 -1
  90. data/lib/pione/global/system-variable.rb +12 -12
  91. data/lib/pione/global/task-worker-broker-variable.rb +43 -0
  92. data/lib/pione/global/tuple-space-notifier-variable.rb +3 -55
  93. data/lib/pione/lang/boolean.rb +4 -0
  94. data/lib/pione/lang/data-expr.rb +1 -1
  95. data/lib/pione/lang/integer.rb +1 -1
  96. data/lib/pione/lang/string.rb +4 -0
  97. data/lib/pione/lang/type.rb +1 -1
  98. data/lib/pione/location.rb +1 -0
  99. data/lib/pione/location/data-location.rb +41 -13
  100. data/lib/pione/location/dropbox-location.rb +175 -56
  101. data/lib/pione/location/ftp-location.rb +4 -1
  102. data/lib/pione/location/http-location.rb +5 -3
  103. data/lib/pione/location/https-location.rb +4 -2
  104. data/lib/pione/location/local-location.rb +6 -3
  105. data/lib/pione/location/location-exception.rb +12 -0
  106. data/lib/pione/location/notification-scheme.rb +46 -0
  107. data/lib/pione/log.rb +8 -7
  108. data/lib/pione/log/debug.rb +9 -9
  109. data/lib/pione/log/domain-log.rb +6 -1
  110. data/lib/pione/log/message-log-receiver.rb +32 -0
  111. data/lib/pione/log/system-log.rb +62 -141
  112. data/lib/pione/model.rb +7 -0
  113. data/lib/pione/model/notification-listener-model.rb +29 -0
  114. data/lib/pione/model/task-worker-broker-model.rb +129 -0
  115. data/lib/pione/notification.rb +13 -0
  116. data/lib/pione/notification/address.rb +104 -0
  117. data/lib/pione/notification/exception.rb +10 -0
  118. data/lib/pione/notification/message.rb +109 -0
  119. data/lib/pione/notification/receiver.rb +90 -0
  120. data/lib/pione/notification/recipient.rb +68 -0
  121. data/lib/pione/notification/task-worker-broker-recipient.rb +85 -0
  122. data/lib/pione/notification/transmitter.rb +84 -0
  123. data/lib/pione/pnml.rb +35 -0
  124. data/lib/pione/pnml/annotation-extractor.rb +47 -0
  125. data/lib/pione/pnml/compiler.rb +176 -0
  126. data/lib/pione/pnml/input-merge-complement.rb +78 -0
  127. data/lib/pione/pnml/input-parallelization-complement.rb +75 -0
  128. data/lib/pione/pnml/input-reduction.rb +80 -0
  129. data/lib/pione/pnml/invalid-arc-elimination.rb +41 -0
  130. data/lib/pione/pnml/io-expansion.rb +88 -0
  131. data/lib/pione/pnml/isolated-element-elimination.rb +32 -0
  132. data/lib/pione/pnml/net-rewriter.rb +44 -0
  133. data/lib/pione/pnml/output-decomposition-complement.rb +77 -0
  134. data/lib/pione/pnml/output-reduction.rb +86 -0
  135. data/lib/pione/pnml/output-synchronization-complement.rb +77 -0
  136. data/lib/pione/pnml/pione-model.rb +417 -0
  137. data/lib/pione/pnml/pnml-exception.rb +23 -0
  138. data/lib/pione/pnml/pnml-model.rb +368 -0
  139. data/lib/pione/pnml/reader.rb +51 -0
  140. data/lib/pione/rule-engine/action-handler.rb +8 -6
  141. data/lib/pione/rule-engine/basic-handler.rb +5 -5
  142. data/lib/pione/rule-engine/engine-exception.rb +7 -6
  143. data/lib/pione/rule-engine/flow-handler.rb +27 -18
  144. data/lib/pione/system.rb +3 -1
  145. data/lib/pione/system/domain-dump.rb +34 -0
  146. data/lib/pione/system/file-cache.rb +92 -13
  147. data/lib/pione/system/init.rb +3 -0
  148. data/lib/pione/system/normalizer.rb +40 -0
  149. data/lib/pione/system/status.rb +5 -5
  150. data/lib/pione/system/system-exception.rb +14 -1
  151. data/lib/pione/task-worker-broker.rb +7 -0
  152. data/lib/pione/task-worker-broker/basic-provider.rb +20 -0
  153. data/lib/pione/task-worker-broker/easy-provider.rb +65 -0
  154. data/lib/pione/test-helper.rb +27 -0
  155. data/lib/pione/test-helper/command-helper.rb +9 -101
  156. data/lib/pione/tuple-space/basic-tuple.rb +1 -1
  157. data/lib/pione/tuple-space/tuple-definition.yml +4 -6
  158. data/lib/pione/tuple-space/tuple-space-interface.rb +3 -45
  159. data/lib/pione/tuple-space/tuple-space-server.rb +45 -0
  160. data/lib/pione/util.rb +1 -2
  161. data/lib/pione/util/boolean-value.rb +62 -0
  162. data/lib/pione/util/completion.rb +111 -0
  163. data/lib/pione/util/evaluatable.rb +13 -27
  164. data/lib/pione/util/package-parameters-list.rb +15 -27
  165. data/lib/pione/util/zip.rb +8 -3
  166. data/lib/pione/version.rb +1 -1
  167. data/lib/rootage.rb +20 -0
  168. data/lib/rootage/action.rb +114 -0
  169. data/lib/rootage/argument.rb +46 -0
  170. data/lib/rootage/command.rb +218 -0
  171. data/lib/rootage/core.rb +532 -0
  172. data/lib/rootage/exception.rb +107 -0
  173. data/lib/rootage/help.rb +148 -0
  174. data/lib/rootage/help.txt.erb +31 -0
  175. data/lib/rootage/log.rb +226 -0
  176. data/lib/rootage/normalizer.rb +184 -0
  177. data/lib/rootage/option.rb +152 -0
  178. data/lib/rootage/scenario-test-result.erb +39 -0
  179. data/lib/rootage/scenario.rb +362 -0
  180. data/lib/rootage/test-helper.rb +115 -0
  181. data/man/pione-list-param.1 +44 -0
  182. data/misc/clock.rb +9 -0
  183. data/misc/machine-info.sh +21 -0
  184. data/misc/pione-completion.bash +238 -0
  185. data/misc/pione-completion.erb +53 -0
  186. data/misc/pione-completion.zsh +238 -0
  187. data/misc/pione.god +22 -0
  188. data/misc/ui.xml +23 -0
  189. data/pione.gemspec +3 -1
  190. data/test/agent/spec_basic-agent.rb +1 -1
  191. data/test/agent/spec_input-generator.rb +2 -2
  192. data/test/agent/spec_messenger.rb +6 -9
  193. data/test/agent/spec_notification-listener.rb +80 -0
  194. data/test/agent/{spec_broker.rb → spec_task-worker-broker.rb} +13 -10
  195. data/test/agent/spec_tuple-space-provider.rb +10 -6
  196. data/test/command/command-behavior.rb +3 -11
  197. data/test/command/data/pione-list-param/AdvancedParameters.pione +12 -0
  198. data/test/command/data/pione-list-param/BasicParameters.pione +12 -0
  199. data/test/command/spec_pione-action-exec.rb +16 -0
  200. data/test/command/spec_pione-action-list.rb +15 -10
  201. data/test/command/spec_pione-action-print.rb +14 -0
  202. data/test/command/spec_pione-action.rb +6 -19
  203. data/test/command/spec_pione-clean.rb +29 -46
  204. data/test/command/spec_pione-client.rb +29 -36
  205. data/test/command/spec_pione-command.rb +6 -6
  206. data/test/command/{spec_pione-compiler.rb → spec_pione-compile.rb} +11 -13
  207. data/test/command/spec_pione-config-get.rb +47 -0
  208. data/test/command/spec_pione-config-list.rb +42 -0
  209. data/test/command/spec_pione-config-set.rb +38 -0
  210. data/test/command/spec_pione-config-unset.rb +44 -0
  211. data/test/command/spec_pione-config.rb +11 -0
  212. data/test/command/spec_pione-diagnosis-notification.rb +23 -0
  213. data/test/command/spec_pione-diagnosis.rb +11 -0
  214. data/test/command/spec_pione-lang-check-syntax.rb +12 -0
  215. data/test/command/spec_pione-lang.rb +11 -0
  216. data/test/command/spec_pione-log-format.rb +29 -0
  217. data/test/command/spec_pione-log-list-id.rb +17 -0
  218. data/test/command/spec_pione-log.rb +6 -20
  219. data/test/command/spec_pione-package-add.rb +55 -0
  220. data/test/command/spec_pione-package-build.rb +57 -0
  221. data/test/command/spec_pione-package-show.rb +72 -0
  222. data/test/command/{spec_pione-update-package-info.rb → spec_pione-package-update.rb} +12 -13
  223. data/test/command/spec_pione-package.rb +4 -104
  224. data/test/command/spec_pione-val.rb +10 -7
  225. data/test/global/spec_config.rb +50 -0
  226. data/test/global/spec_item.rb +1 -1
  227. data/test/literate-action/data/HelloWorld.md +1 -1
  228. data/test/location/location-behavior.rb +1 -1
  229. data/test/location/spec_dropbox-location.rb +39 -0
  230. data/test/location/spec_notification-scheme.rb +37 -0
  231. data/test/log/spec_debug.rb +5 -4
  232. data/test/log/spec_message-log-receiver.rb +13 -0
  233. data/test/log/spec_message-log.rb +6 -9
  234. data/test/log/spec_system-log.rb +5 -3
  235. data/test/notification/spec_address.rb +229 -0
  236. data/test/notification/spec_message.rb +30 -0
  237. data/test/notification/spec_receiver.rb +36 -0
  238. data/test/notification/spec_transmitter.rb +37 -0
  239. data/test/pnml/data/ConditionalBranchIf.pnml +270 -0
  240. data/test/pnml/data/ConditionalBranchIfElse.pnml +309 -0
  241. data/test/pnml/data/IOExpansionComplex.pnml +363 -0
  242. data/test/pnml/data/IOExpansionSimple.pnml +140 -0
  243. data/test/pnml/data/InputMergeComplementComplex.pnml +381 -0
  244. data/test/pnml/data/InputMergeComplementSimple.pnml +248 -0
  245. data/test/pnml/data/InputParallelizationComplementComplex.pnml +433 -0
  246. data/test/pnml/data/InputParallelizationComplementSimple.pnml +288 -0
  247. data/test/pnml/data/InputReductionComplex.pnml +192 -0
  248. data/test/pnml/data/InputReductionLong.pnml +344 -0
  249. data/test/pnml/data/InputReductionSimple.pnml +140 -0
  250. data/test/pnml/data/IsolatedElementElimination.pnml +171 -0
  251. data/test/pnml/data/OutputDecompositionComplementComplex.pnml +381 -0
  252. data/test/pnml/data/OutputDecompositionComplementSimple.pnml +242 -0
  253. data/test/pnml/data/OutputReductionComplex.pnml +186 -0
  254. data/test/pnml/data/OutputReductionLong.pnml +344 -0
  255. data/test/pnml/data/OutputReductionSimple.pnml +140 -0
  256. data/test/pnml/data/OutputSynchronizationComplementComplex.pnml +498 -0
  257. data/test/pnml/data/OutputSynchronizationComplementSimple.pnml +347 -0
  258. data/test/pnml/data/SampleNet.pnml +238 -0
  259. data/test/pnml/spec_input-merge-complement.rb +40 -0
  260. data/test/pnml/spec_input-parallelization-complement.rb +50 -0
  261. data/test/pnml/spec_input-reduction.rb +113 -0
  262. data/test/pnml/spec_invalid-arc-elimination.rb +33 -0
  263. data/test/pnml/spec_io-expansion.rb +126 -0
  264. data/test/pnml/spec_isolated-element-elimination.rb +25 -0
  265. data/test/pnml/spec_output-decomposition-complement.rb +40 -0
  266. data/test/pnml/spec_output-reduction.rb +114 -0
  267. data/test/pnml/spec_output-synchronization-complement.rb +62 -0
  268. data/test/pnml/spec_pione-element.rb +144 -0
  269. data/test/pnml/spec_pnml-element.rb +373 -0
  270. data/test/pnml/spec_reader.rb +16 -0
  271. data/test/rootage/spec_argument.rb +18 -0
  272. data/test/rootage/spec_command.rb +239 -0
  273. data/test/rootage/spec_core.rb +198 -0
  274. data/test/rootage/spec_scenario.rb +149 -0
  275. data/test/system/{spec_domain-info.rb → spec_domain-dump.rb} +6 -6
  276. data/test/system/spec_file-cache.rb +6 -9
  277. data/test/tuple-space/spec_finished-tuple.rb +1 -1
  278. data/test/util/{spec_package-parameters-list_1.pione → data/package-parameters-list/Param1.pione} +0 -0
  279. data/test/util/{spec_package-parameters-list_2.pione → data/package-parameters-list/Param2.pione} +0 -0
  280. data/test/util/{spec_package-parameters-list_3.pione → data/package-parameters-list/Param3.pione} +0 -0
  281. data/test/util/{spec_package-parameters-list_4.pione → data/package-parameters-list/Param4.pione} +0 -0
  282. data/test/util/spec_boolean-value.rb +32 -0
  283. data/test/util/spec_completion.rb +22 -0
  284. data/test/util/spec_package-parameters-list.rb +39 -52
  285. data/test/util/spec_zip.rb +28 -1
  286. metadata +288 -47
  287. data/bin/pione-tuple-space-receiver +0 -5
  288. data/lib/pione/agent/broker.rb +0 -304
  289. data/lib/pione/agent/tuple-space-receiver.rb +0 -137
  290. data/lib/pione/command/pione-broker.rb +0 -104
  291. data/lib/pione/command/pione-compiler.rb +0 -57
  292. data/lib/pione/command/pione-relay-account-db.rb +0 -141
  293. data/lib/pione/command/pione-relay-client-db.rb +0 -118
  294. data/lib/pione/command/pione-relay.rb +0 -59
  295. data/lib/pione/command/pione-syntax-checker.rb +0 -214
  296. data/lib/pione/command/pione-tuple-space-receiver.rb +0 -111
  297. data/lib/pione/command/pione-update-package-info.rb +0 -53
  298. data/lib/pione/front/broker-front.rb +0 -22
  299. data/lib/pione/front/tuple-space-receiver-front.rb +0 -11
  300. data/lib/pione/global/broker-variable.rb +0 -33
  301. data/lib/pione/system/domain-info.rb +0 -25
  302. data/lib/pione/util/pnml-compiler.rb +0 -168
  303. data/test/agent/spec_tuple-space-receiver.rb +0 -47
  304. data/test/util/spec_pnml-compiler.rb +0 -32
@@ -0,0 +1,88 @@
1
+ module Pione
2
+ module Command
3
+ # `PioneTaskWorkerBroker` is a command that starts activity of task worker
4
+ # broker agent. This command will spawn `pione-task-worker`.
5
+ class PioneTaskWorkerBroker < BasicCommand
6
+ #
7
+ # informations
8
+ #
9
+
10
+ define(:toplevel, true)
11
+ define(:name, "pione-task-worker-broker")
12
+ define(:desc, "run task worker broker agent to launch task workers")
13
+ define(:front, Front::TaskWorkerBrokerFront)
14
+ define(:model, Model::TaskWorkerBrokerModel)
15
+ define(:notification_recipient, Notification::TaskWorkerBrokerRecipient) {|cmd, model|
16
+ [model, Global.notification_listener]
17
+ }
18
+
19
+ #
20
+ # options
21
+ #
22
+
23
+ option(CommonOption.color)
24
+ option(CommonOption.debug)
25
+ option(CommonOption.features)
26
+ option(CommonOption.communication_address)
27
+ option(CommonOption.task_worker_size) do |item|
28
+ item.type = :positive_integer
29
+ end
30
+ option CommonOption.file_cache_method
31
+ option CommonOption.file_sliding
32
+
33
+ #
34
+ # command lifecycle: setup phase
35
+ #
36
+
37
+ phase(:setup) do |item|
38
+ item.configure(:timeout => 10)
39
+ item << :task_worker_broker_agent
40
+ end
41
+
42
+ setup(:task_worker_broker_agent) do |item|
43
+ item.desc = "Create a task worker broker agent"
44
+
45
+ item.assign(:task_worker_broker_agent) do
46
+ Agent::TaskWorkerBroker.new(model)
47
+ end
48
+ end
49
+
50
+ #
51
+ # command lifecycle: execution phase
52
+ #
53
+
54
+ phase(:execution) do |item|
55
+ item << :task_worker_broker_agent
56
+ end
57
+
58
+ execution(:task_worker_broker_agent) do |item|
59
+ item.desc = "Start agent activity of task worker broker"
60
+
61
+ item.process do
62
+ model[:task_worker_broker_agent].start!
63
+ end
64
+ end
65
+
66
+ #
67
+ # command lifecycle: termination phase
68
+ #
69
+
70
+ phase(:termination) do |item|
71
+ item.configure(:timeout => 15)
72
+ item << ProcessAction.terminate_children
73
+ item << :task_worker_broker_agent
74
+ end
75
+
76
+ termination(:task_worker_broker_agent) do |item|
77
+ item.desc = "Terminate the agent"
78
+
79
+ item.process do
80
+ test(model[:task_worker_broker_agent])
81
+ test(not(model[:task_worker_broker_agent].terminated?))
82
+
83
+ model[:task_worker_broker_agent].terminate
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
@@ -1,65 +1,64 @@
1
1
  module Pione
2
2
  module Command
3
- # This is a body for +pione-task-worker+ command.
3
+ # `PioneTaskWorker` is a command that runs pione task worker agents.
4
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]
11
- end
12
-
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
17
-
18
- command_front Front::TaskWorkerFront
19
-
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
5
  #
38
6
  # class methods
39
7
  #
40
8
 
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")
9
+ # Create a new process of `pione-task-worker` command.
10
+ def self.spawn(model, features, tuple_space_id)
11
+ spawner = Spawner.new(model, "pione-task-worker")
44
12
 
45
13
  # debug options
46
14
  spawner.option("--debug=system") if Global.debug_system
47
15
  spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
48
16
  spawner.option("--debug=rule_engine") if Global.debug_rule_engine
49
17
  spawner.option("--debug=communication") if Global.debug_communication
50
- spawner.option("--debug=presence_notification") if Global.debug_presence_notification
18
+ spawner.option("--debug=notification") if Global.debug_notification
51
19
 
52
20
  # requisite options
53
- spawner.option("--parent-front", Global.front.uri)
21
+ spawner.option("--parent-front", model[:front].uri.to_s)
54
22
  spawner.option("--tuple-space-id", tuple_space_id)
55
23
  spawner.option("--features", features) if features
56
24
 
57
- # optionals
58
- spawner.option("--color") if Global.color_enabled
25
+ # others
26
+ spawner.option("--color", Global.color_enabled)
27
+ spawner.option("--file-cache-method", System::FileCache.cache_method.name.to_s)
28
+ spawner.option("--file-sliding", Global.file_sliding)
59
29
 
60
30
  spawner.spawn # this method returns child front
61
31
  end
62
32
 
33
+ #
34
+ # informations
35
+ #
36
+
37
+ define(:toplevel, true)
38
+ define(:name, "pione-task-worker")
39
+ define(:desc, "process tasks")
40
+ define(:front, Front::TaskWorkerFront)
41
+
42
+ #
43
+ # options
44
+ #
45
+
46
+ option CommonOption.color
47
+ option CommonOption.debug
48
+ option CommonOption.communication_address
49
+ option CommonOption.parent_front
50
+ option CommonOption.features
51
+ option CommonOption.file_cache_method
52
+ option CommonOption.file_sliding
53
+
54
+ option(:tuple_space_id) do |item|
55
+ item.type = :string
56
+ item.long = '--tuple-space-id'
57
+ item.arg = 'UUID'
58
+ item.desc = 'Tuple space ID that the worker joins'
59
+ item.requisite = true
60
+ end
61
+
63
62
  #
64
63
  # instance methods
65
64
  #
@@ -71,50 +70,79 @@ module Pione
71
70
  # command lifecycle: setup phase
72
71
  #
73
72
 
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
73
+ phase(:setup) do |item|
74
+ item.configure(:timeout => 15)
75
+
76
+ item << ProcessAction.connect_parent
77
+ item << :tuple_space
78
+ item << :task_worker_agent
79
+ item << :job_terminator
80
+ item << :base_location
81
+ end
80
82
 
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])
83
+ setup(:tuple_space) do |item|
84
+ item.desc = "Get a tuple space from parent"
84
85
 
85
- unless @tuple_space
86
- abort("%s cannot get tuple space \"%s\"." % [command_name, option[:tuple_space_id]])
86
+ item.assign(:tuple_space) do
87
+ model[:parent_front].get_tuple_space(model[:tuple_space_id])
87
88
  end
88
89
 
89
- if Util.error?(:timeout => 3) {@tuple_space.uuid}
90
- abort("%s cannot connect to tuple space." % command_name)
90
+ item.process do
91
+ test(not(model[:tuple_space]))
92
+
93
+ arg = {name: cmd.name, id: option[:tuple_space_id]}
94
+ cmd.abort('"%{name}" cannot get the tuple space "%{id}".' % arg)
95
+ end
96
+
97
+ item.process do
98
+ if Util.error?(:timeout => 3) {model[:tuple_space].uuid}
99
+ cmd.abort('"%{name}" cannot connect to tuple space.' % {name: cmd.name})
100
+ end
91
101
  end
92
102
  end
93
103
 
94
- # Create a task worker agent.
95
- def setup_agent
96
- @agent = Agent::TaskWorker.new(@tuple_space, Global.expressional_features)
97
- rescue Agent::TupleSpaceError => e
98
- abort(e.message)
104
+ setup(:task_worker_agent) do |item|
105
+ item.desc = "Create a task worker agent"
106
+
107
+ item.assign(:task_worker_agent) do
108
+ Agent::TaskWorker.new(model[:tuple_space], Global.expressional_features)
109
+ end
110
+
111
+ item.exception(Agent::TupleSpaceError) do |e|
112
+ cmd.abort(e)
113
+ end
99
114
  end
100
115
 
101
- # Setup base location.
102
- def setup_base_location
103
- if @tuple_space.base_location.kind_of?(Location::DropboxLocation)
104
- Location::Dropbox.init(@tuple_space)
105
- unless Location::Dropbox.ready?
106
- abort("You aren't ready to access Dropbox.")
116
+ setup(:base_location) do |item|
117
+ item.desc = "Get a base location"
118
+
119
+ item.assign(:base_location) do
120
+ model[:tuple_space].base_location
121
+ end
122
+
123
+ item.process do
124
+ # enable Dropbox location
125
+ if model[:base_location].is_a?(Location::DropboxLocation)
126
+ begin
127
+ Location::DropboxLocation.enable(model[:tuple_space])
128
+ rescue Location::DropboxLocationUnavailable => e
129
+ arg = {addr: model[:base_location].address}
130
+ cmd.abort('Base location "%{addr}" is on Dropbox, but it is not ready.' % arg)
131
+ end
107
132
  end
108
133
  end
109
134
  end
110
135
 
111
- # Create a job terminator and setup the action.
112
- def setup_job_terminator
113
- @job_terminator = Agent::JobTerminator.new(@tuple_space) do |status|
114
- if status.error?
115
- abort("pione-task-worker catched the error: %s" % status.exception.message)
116
- else
117
- terminate
136
+ setup(:job_terminator) do |item|
137
+ item.desc = "Create a job terminator and setup the action"
138
+
139
+ item.assign(:job_terminator) do
140
+ Agent::JobTerminator.new(model[:tuple_space]) do |status|
141
+ if status.error?
142
+ cmd.abort('"%s" catched the error: %s' % [cmd.name, status.message])
143
+ else
144
+ cmd.terminate
145
+ end
118
146
  end
119
147
  end
120
148
  end
@@ -123,50 +151,72 @@ module Pione
123
151
  # command lifecycle: execution phase
124
152
  #
125
153
 
126
- handle_execution_exception(DRb::DRbConnError) do |cmd, e|
127
- Log::Debug.system do
128
- "%s goes termination phase because the exception was catched: %s" % [cmd.command_name, e.message]
154
+ phase(:execution) do |item|
155
+ item << :job_terminator
156
+ item << :task_worker_agent
157
+
158
+ item.exception(DRb::DRbConnError) do |e|
159
+ Log::Debug.system do
160
+ "%s goes termination phase because the exception was catched: %s" % [cmd.name, e.message]
161
+ end
162
+ cmd.terminate
129
163
  end
130
- cmd.terminate
131
164
  end
132
- execute :job_terminator
133
- execute :agent
134
165
 
135
- # Start the job terminator.
136
- def execute_job_terminator
137
- @job_terminator.start
166
+ execution(:job_terminator) do |item|
167
+ item.desc = "Start the job terminator"
168
+
169
+ item.process do
170
+ model[:job_terminator].start
171
+ end
138
172
  end
139
173
 
140
- # Start task worker activity and wait the termination.
141
- def execute_agent
142
- @agent.start
143
- @agent.wait_until_terminated(nil)
174
+ execution(:task_worker_agent) do |item|
175
+ item.desc = "Start task worker activity and wait the termination"
176
+
177
+ item.process do
178
+ model[:task_worker_agent].start
179
+ model[:task_worker_agent].wait_until_terminated(nil)
180
+ end
144
181
  end
145
182
 
146
183
  #
147
184
  # command lifecycle: termination phase
148
185
  #
149
186
 
150
- termination_phase :timeout => 10
151
- terminate :job_terminator
152
- terminate :agent
153
- terminate :parent_process_connection, :module => CommonCommandAction
187
+ phase(:termination) do |item|
188
+ item.configure(:timeout => 10)
189
+ item << ProcessAction.disconnect_parent
190
+ item << :job_terminator
191
+ item << :task_worker_agent
192
+ end
193
+
194
+ termination(:job_terminator) do |item|
195
+ item.desc = "Terminate job terminator agent"
154
196
 
155
- # Terminate job terminator.
156
- def terminate_job_terminator
157
- if @job_terminator and not(@job_terminator.terminated?)
158
- @job_terminator.terminate
197
+ item.condition do
198
+ test(model[:job_terminator])
199
+ test(not(model[:job_terminator].terminated?))
200
+ end
201
+
202
+ item.process do
203
+ model[:job_terminator].terminate
159
204
  end
160
205
  end
161
206
 
162
- # Terminate task worker agent.
163
- def terminate_agent
164
- if @agent
165
- @agent.terminate
166
- @agent.wait_until_terminated(nil)
207
+ termination(:task_worker_agent) do |item|
208
+ item.desc = "Terminate task worker agent"
209
+
210
+ item.condition do
211
+ test(model[:task_worker_agent])
212
+ test(not(model[:task_worker_agent].terminated?))
213
+ end
214
+
215
+ item.process do
216
+ model[:task_worker_agent].terminate
217
+ model[:task_worker_agent].wait_until_terminated(nil)
167
218
  end
168
219
  end
169
220
  end
170
221
  end
171
222
  end
172
-
@@ -1,101 +1,109 @@
1
1
  module Pione
2
2
  module Command
3
- # PioneTupleSpaceProvider is for +pione-tuple-space-provider+ command.
3
+ # `PioneTupleSpaceProvider` is for `pione-tuple-space-provider` command.
4
4
  class PioneTupleSpaceProvider < BasicCommand
5
- #
6
- # command info
7
- #
8
-
9
- command_name "pione-tuple-space-provider" do |cmd|
10
- "front: %s, parent: %s" % [Global.front.uri, cmd.option[:parent_front].uri]
11
- end
12
-
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
18
-
19
- command_front Pione::Front::TupleSpaceProviderFront do |cmd|
20
- [cmd.option[:parent_front].get_tuple_space(nil)]
21
- end
22
-
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
5
  #
34
6
  # class methods
35
7
  #
36
8
 
37
9
  # Create a new process of tuple space provider command.
38
- def self.spawn
39
- spawner = Spawner.new(command_name)
10
+ def self.spawn(cmd)
11
+ spawner = Spawner.new(cmd.model, "pione-tuple-space-provider")
40
12
 
41
13
  # debug options
42
14
  spawner.option("--debug=system") if Global.debug_system
43
15
  spawner.option("--debug=ignored_exception") if Global.debug_ignored_exception
44
16
  spawner.option("--debug=rule_engine") if Global.debug_rule_engine
45
17
  spawner.option("--debug=communication") if Global.debug_communication
46
- spawner.option("--debug=presence_notification") if Global.debug_presence_notification
18
+ spawner.option("--debug=notification") if Global.debug_notification
47
19
 
48
20
  # 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)
21
+ spawner.option("--parent-front", cmd.model[:front].uri.to_s)
22
+ spawner.option("--communication-address", Global.communication_address.to_s)
23
+ Global.notification_targets.each do |address|
24
+ spawner.option("--notification-target", address.to_s)
53
25
  end
54
26
 
55
27
  # optionals
56
- spawner.option("--color") if Global.color_enabled
28
+ spawner.option("--color", Global.color_enabled)
57
29
 
58
30
  spawner.spawn
59
31
  end
60
32
 
61
33
  #
62
- # instance methods
34
+ # informations
63
35
  #
64
36
 
65
- attr_reader :agent
37
+ define(:toplevel, true)
38
+ define(:name, "pione-tuple-space-provider")
39
+ define(:desc, "run tuple space provider agent")
40
+ define(:front, Pione::Front::TupleSpaceProviderFront)
41
+
42
+ #
43
+ # options
44
+ #
45
+
46
+ option CommonOption.color
47
+ option CommonOption.debug
48
+ option CommonOption.communication_address
49
+ option CommonOption.parent_front
50
+ option NotificationOption.notification_targets
66
51
 
67
52
  #
68
53
  # command lifecycle: setup phase
69
54
  #
70
55
 
71
- setup_phase :timeout => 5
72
- setup :parent_process_connection, :module => CommonCommandAction
56
+ phase(:setup) do |item|
57
+ item.configure(:timeout => 5)
58
+
59
+ item << ProcessAction.connect_parent
60
+ end
73
61
 
74
62
  #
75
63
  # command lifecycle: execution phase
76
64
  #
77
65
 
78
- execute :agent
66
+ phase(:execution) do |item|
67
+ item << :start_agent
68
+ item << :wait_agent
69
+ end
70
+
71
+ execution(:start_agent) do |item|
72
+ item.desc = "Start an agent activity"
79
73
 
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)
74
+ item.assign(:agent) do
75
+ Agent::TupleSpaceProvider.start(model[:front].uri)
76
+ end
77
+ end
78
+
79
+ execution(:wait_agent) do |item|
80
+ item.desc = "Wait agent to terminate"
81
+
82
+ item.process do
83
+ model[:agent].wait_until_terminated(nil)
84
+ end
84
85
  end
85
86
 
86
87
  #
87
88
  # command lifecycle: termination phase
88
89
  #
89
90
 
90
- termination_phase :timeout => 5
91
- terminate :agent
92
- terminate :parent_process_connection, :module => CommonCommandAction
91
+ phase(:termination) do |seq|
92
+ seq.configure(:timeout => 5)
93
+
94
+ seq << :agent
95
+ seq << ProcessAction.disconnect_parent
96
+ end
97
+
98
+ termination(:agent) do |item|
99
+ item.desc = "Terminate the agent"
100
+
101
+ item.process do
102
+ test(model[:agent])
103
+ test(model[:agent].terminated?)
93
104
 
94
- # Terminate agent.
95
- def terminate_agent
96
- if @agent and not(@agent.terminated?)
97
- @agent.terminate
98
- @agent.wait_until_terminated(nil)
105
+ model[:agent].terminate
106
+ model[:agent].wait_until_terminated(nil)
99
107
  end
100
108
  end
101
109
  end