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,22 @@
1
+ module Pione
2
+ module Command
3
+ # `PioneLang` is a utility set for PIONE language.
4
+ class PioneLang < BasicCommand
5
+ #
6
+ # informations
7
+ #
8
+
9
+ define(:name, "lang")
10
+ define(:desc, "PIONE language utilities")
11
+
12
+ #
13
+ # requirements
14
+ #
15
+
16
+ require 'pione/command/pione-lang-interactive'
17
+ require 'pione/command/pione-lang-check-syntax'
18
+ end
19
+
20
+ PioneCommand.define_subcommand("lang", PioneLang)
21
+ end
22
+ end
@@ -0,0 +1,163 @@
1
+ module Pione
2
+ module Command
3
+ # `PioneLogFormat` is a command that converts PIONE raw log into XES or
4
+ # other formats.
5
+ class PioneLogFormat < BasicCommand
6
+ #
7
+ # basic informations
8
+ #
9
+
10
+ define(:name, "format")
11
+ define(:desc, "Convert PIONE raw log into XES or other formats")
12
+
13
+ #
14
+ # arguments
15
+ #
16
+
17
+ argument PioneLogArgument.log_location
18
+
19
+ #
20
+ # options
21
+ #
22
+
23
+ option_pre(:prepare_model) do |item|
24
+ item.process do
25
+ model[:trace_types] = []
26
+ model[:agent_types] = []
27
+ end
28
+ end
29
+
30
+ option CommonOption.color
31
+ option CommonOption.debug
32
+
33
+ option(:trace_types) do |item|
34
+ item.type = :string
35
+ item.long = "--trace-type"
36
+ item.arg = "NAME"
37
+ item.desc = 'Output only the trace type: "agent", "rule", or "task"'
38
+
39
+ item.process {|val| model[:trace_types] << val}
40
+ end
41
+
42
+ option(:agent_types) do |item|
43
+ item.type = :string
44
+ item.arg = "NAME"
45
+ item.long = "--agent-type"
46
+ item.desc = 'Output only the agent type: "task_worker", "input_generator", ...'
47
+
48
+ item.process {|val| model[:agent_types] << val}
49
+ end
50
+
51
+ option(:format) do |item|
52
+ item.type = :symbol_downcase
53
+ item.range = [:xes, :json, :xml]
54
+ item.long = "--format"
55
+ item.arg = "NAME"
56
+ item.desc = 'Set format type'
57
+ item.init = :xes
58
+ end
59
+
60
+ option(:log_id) do |item|
61
+ item.type = :string
62
+ item.long = "--log-id"
63
+ item.arg = "ID"
64
+ item.desc = "Target log ID"
65
+ end
66
+
67
+ #
68
+ # command lifecycle: setup phase
69
+ #
70
+
71
+ phase(:setup) do |seq|
72
+ seq << :trace_filters
73
+ seq << :formatter
74
+ seq << :raw_log
75
+ end
76
+
77
+ setup(:trace_filters) do |item|
78
+ item.desc = "Setup trace filters"
79
+
80
+ item.assign(:trace_filters) do
81
+ Array.new
82
+ end
83
+
84
+ # agent filters
85
+ item.process do
86
+ test(model[:trace_types].include?("agent"))
87
+
88
+ if model[:agent_types].empty?
89
+ model[:trace_filters] << Proc.new do |trace|
90
+ trace.attributes.include?(XES.string("pione:traceType", "agent_activity"))
91
+ end
92
+ else
93
+ model[:trace_filters] << Proc.new do |trace|
94
+ trace.attributes.include?(XES.string("pione:traceType", "agent_activity")) and
95
+ model[:agent_types].includes?(trace.events.first.org_resource)
96
+ end
97
+ end
98
+ end
99
+
100
+ # rule filters
101
+ item.process do
102
+ test(model[:trace_types].include?("rule"))
103
+
104
+ model[:trace_filters] << Proc.new do |trace|
105
+ trace.attributes.include?(XES.string("pione:traceType", "rule_process"))
106
+ end
107
+ end
108
+
109
+ # task filters
110
+ item.process do
111
+ test(model[:trace_types].include?("task"))
112
+
113
+ model[:trace_filters] << Proc.new do |trace|
114
+ trace.attributes.include?(XES.string("pione:traceType", "task_process"))
115
+ end
116
+ end
117
+ end
118
+
119
+ setup(:formatter) do |item|
120
+ item.desc = "Setup formatter"
121
+
122
+ item.assign(:formatter) do
123
+ if Log::ProcessLog.known?(model[:format])
124
+ Log::ProcessLog[model[:format]]
125
+ else
126
+ cmd.abort("Unknown format: %s" % model[:format])
127
+ end
128
+ end
129
+ end
130
+
131
+ setup(:raw_log) do |item|
132
+ item.desc = "Read raw log table"
133
+
134
+ item.assign(:raw_log_table) do
135
+ model[:formatter].read(model[:log_location])
136
+ end
137
+
138
+ item.assign(:log_id) do
139
+ test(not(model[:log_id]))
140
+ model[:raw_log_table].keys.sort.last
141
+ end
142
+ end
143
+
144
+ #
145
+ # command lifecycle: execution phase
146
+ #
147
+
148
+ phase(:execution) do |item|
149
+ item << :format_log
150
+ end
151
+
152
+ execution(:format_log) do |item|
153
+ item.desc = "Format log file from the event log"
154
+
155
+ item.process do
156
+ puts(model[:raw_log_table][model[:log_id]].format(model[:trace_filters]))
157
+ end
158
+ end
159
+ end
160
+
161
+ PioneLog.define_subcommand("format", PioneLogFormat)
162
+ end
163
+ end
@@ -0,0 +1,48 @@
1
+ module Pione
2
+ module Command
3
+ # `PioneLogListId` is a command that list IDs in PIONE raw log.
4
+ class PioneLogListId < BasicCommand
5
+ #
6
+ # informations
7
+ #
8
+
9
+ define(:name, "list-id")
10
+ define(:desc, "List log IDs")
11
+
12
+ #
13
+ # arguments
14
+ #
15
+
16
+ argument PioneLogArgument.log_location
17
+
18
+ #
19
+ # options
20
+ #
21
+
22
+ option CommonOption.color
23
+ option CommonOption.debug
24
+
25
+ #
26
+ # command lifecycle: execution phase
27
+ #
28
+
29
+ phase(:execution) do |seq|
30
+ seq << :list_id
31
+ end
32
+
33
+ execution(:list_id) do |item|
34
+ item.desc = "List raw log IDs"
35
+
36
+ item.process do
37
+ raw_log_table = Log::XESLog.read(model[:log_location])
38
+ raw_log_table.keys.each do |log_id|
39
+ puts log_id
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ PioneLog.define_subcommand("list-id", PioneLogListId)
46
+ end
47
+ end
48
+
@@ -1,120 +1,38 @@
1
1
  module Pione
2
2
  module Command
3
- # PioneLog is a command for viewing PIONE log or converting into other formats.
3
+ # `PioneLog` is a command set of log utilities.
4
4
  class PioneLog < BasicCommand
5
5
  #
6
6
  # basic informations
7
7
  #
8
8
 
9
- command_name "pione-log"
10
- command_banner "View and convert PIONE log."
11
- PioneCommand.add_subcommand("log", self)
9
+ define(:name, "log")
10
+ define(:desc, "Log utilities")
12
11
 
13
12
  #
14
- # options
13
+ # requirements
15
14
  #
16
15
 
17
- use_option :color
18
- use_option :debug
19
-
20
- option_default :trace_filter, []
21
-
22
- define_option(:agent_activity) do |item|
23
- item.long = "--agent-activity[=TYPE]"
24
- item.desc = "output only agent activity log"
25
- item.action = proc do |_, option, name|
26
- option[:trace_filter] << Proc.new do |trace|
27
- trace.attributes.include?(XES.string("pione:traceType", "agent_activity")) and
28
- (name.nil? or trace.events.first.org_resource == name)
29
- end
30
- end
31
- end
32
-
33
- define_option(:rule_process) do |item|
34
- item.long = "--rule-process"
35
- item.desc = "generate rule process log"
36
- item.action = proc do |_, option|
37
- option[:trace_filter] << Proc.new do |trace|
38
- trace.attributes.include?(XES.string("pione:traceType", "rule_process"))
39
- end
40
- end
41
- end
42
-
43
- define_option(:task_process) do |item|
44
- item.long = "--task-process"
45
- item.desc = "generate task process log"
46
- item.action = proc do |_, option|
47
- option[:trace_filter] << Proc.new do |trace|
48
- trace.attributes.include?(XES.string("pione:traceType", "task_process"))
49
- end
50
- end
51
- end
52
-
53
- define_option(:location) do |item|
54
- item.long = "--location=LOCATION"
55
- item.desc = "set log location of PIONE process"
56
- item.default = Location["local:./output/pione-process.log"]
57
- item.value = proc {|location| Location[location]}
58
- end
59
-
60
- define_option(:format) do |item|
61
- item.long = "--format=(XES|JSON|HTML)"
62
- item.desc = "set format type"
63
- item.default = :xes
64
- item.value = proc {|name| name.downcase.to_sym}
65
- end
66
-
67
- define_option(:log_id) do |item|
68
- item.long = "--log-id=ID"
69
- item.desc = "target log id"
70
- end
71
-
72
- validate_option do |option|
73
- unless option[:location].exist?
74
- abort("File not found in the location: %s" % option[:location].uri.to_s)
75
- end
76
- end
16
+ require 'pione/command/pione-log-format'
17
+ require 'pione/command/pione-log-list-id'
18
+ end
77
19
 
78
- #
79
- # command lifecycle: setup phase
80
- #
20
+ # `PioneLogArgument` provides common arguments for `pione log` subcommands.
21
+ module PioneLogArgument
22
+ extend Rootage::ArgumentCollection
81
23
 
82
- setup :formatter
83
- setup :raw_log
84
- setup :log_id
24
+ define(:log_location) do |item|
25
+ item.type = :location
26
+ item.heading = "location"
27
+ item.desc = "Location of PIONE raw log"
85
28
 
86
- # Setup formatter.
87
- def setup_formatter
88
- if Log::ProcessLog.known?(option[:format])
89
- @formatter = Log::ProcessLog[option[:format]]
90
- else
91
- abort("Unknown format: %s" % option[:format])
29
+ item.process do |loc|
30
+ test(not(loc.exist?))
31
+ cmd.abort("File not found in the location: %s" % loc.uri)
92
32
  end
93
33
  end
94
-
95
- # Read raw log table.
96
- def setup_raw_log
97
- @raw_log_table = @formatter.read(option[:location])
98
- end
99
-
100
- def setup_log_id
101
- if option[:log_id]
102
- @log_id = option[:log_id]
103
- else
104
- @log_id = @raw_log_table.keys.sort.last
105
- end
106
- end
107
-
108
- #
109
- # command lifecycle: execution phase
110
- #
111
-
112
- execute :format_log
113
-
114
- # Format log file from the event log.
115
- def execute_format_log
116
- puts(@raw_log_table[@log_id].format(option[:trace_filter]))
117
- end
118
34
  end
35
+
36
+ PioneCommand.define_subcommand("log", PioneLog)
119
37
  end
120
38
  end
@@ -0,0 +1,95 @@
1
+ module Pione
2
+ module Command
3
+ # `PioneNotificationListener` is a command that listens notification
4
+ # messages and sends it to registered receivers.
5
+ class PioneNotificationListener < BasicCommand
6
+ #
7
+ # informations
8
+ #
9
+
10
+ define(:toplevel, true)
11
+ define(:name, "pione-notification-listener")
12
+ define(:desc, "listen notification messages")
13
+ define(:front, Front::NotificationListenerFront)
14
+ define(:model, Model::NotificationListenerModel)
15
+
16
+ #
17
+ # options
18
+ #
19
+
20
+ option CommonOption.color
21
+ option CommonOption.debug
22
+ option CommonOption.communication_address
23
+ option NotificationOption.notification_receivers
24
+
25
+ #
26
+ # command lifecycle: setup phase
27
+ #
28
+
29
+ phase(:setup) do |item|
30
+ item << :model
31
+ end
32
+
33
+ setup(:model) do |item|
34
+ item.desc = "Initialize the command model"
35
+
36
+ item.assign(:notification_listener_agents) {Array.new}
37
+ item.assign(:threads) {ThreadsWait.new}
38
+ end
39
+
40
+ #
41
+ # command lifecycle: execution phase
42
+ #
43
+
44
+ phase(:execution) do |item|
45
+ item << :notification_listener_agents
46
+ end
47
+
48
+ execution(:notification_listener_agents) do |item|
49
+ item.desc = "Create notification listener agents"
50
+
51
+ # launch a listener agent
52
+ item.process do
53
+ Global.notification_receivers.each do |address|
54
+ agent = Agent::NotificationListener.start(model, address)
55
+ model[:notification_listener_agents] << agent
56
+ model[:threads].join_nowait(
57
+ Thread.new {agent.wait_until_terminated(nil)}
58
+ )
59
+ end
60
+ end
61
+
62
+ # wait agents
63
+ item.process do
64
+ model[:threads].all_waits
65
+ end
66
+
67
+ item.exception(Agent::ConnectionError) do
68
+ Log::SystemLog.fatal('`pione-notification-listener` is terminated because pione-borker may be dead.')
69
+ cmd.terminate
70
+ end
71
+ end
72
+
73
+ #
74
+ # command lifecycle: termination phase
75
+ #
76
+
77
+ phase(:termination) do |item|
78
+ item.configure(:timeout => 5)
79
+ item << :notification_listener_agents
80
+ end
81
+
82
+ termination(:notification_listener_agents) do |item|
83
+ item.desc = "Terminate notification listener agent"
84
+
85
+ item.process do
86
+ model[:notification_listener_agents].each do |agent|
87
+ if not(agent.terminated?)
88
+ agent.terminate
89
+ end
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end