pione 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. data/.gitignore +2 -1
  2. data/History.txt +11 -0
  3. data/LICENSE.txt +1 -1
  4. data/README.md +1 -1
  5. data/bin/pione-log +5 -0
  6. data/example/CountChar/CountChar.pione +1 -1
  7. data/example/SieveOfEratosthenes/SieveOfEratosthenes.pione +39 -38
  8. data/lib/pione.rb +14 -35
  9. data/lib/pione/agent/input-generator.rb +38 -40
  10. data/lib/pione/agent/logger.rb +52 -19
  11. data/lib/pione/agent/rule-provider.rb +5 -8
  12. data/lib/pione/agent/task-worker.rb +25 -32
  13. data/lib/pione/agent/tuple-space-client.rb +22 -14
  14. data/lib/pione/command.rb +21 -0
  15. data/lib/pione/command/basic-command.rb +267 -84
  16. data/lib/pione/command/child-process.rb +21 -18
  17. data/lib/pione/command/daemon-process.rb +9 -8
  18. data/lib/pione/command/front-owner-command.rb +8 -25
  19. data/lib/pione/command/pione-broker.rb +27 -24
  20. data/lib/pione/command/pione-clean.rb +6 -6
  21. data/lib/pione/command/pione-client.rb +143 -128
  22. data/lib/pione/command/pione-log.rb +61 -0
  23. data/lib/pione/command/pione-relay-account-db.rb +40 -38
  24. data/lib/pione/command/pione-relay-client-db.rb +38 -42
  25. data/lib/pione/command/pione-relay.rb +19 -20
  26. data/lib/pione/command/pione-syntax-checker.rb +70 -45
  27. data/lib/pione/command/pione-task-worker.rb +56 -66
  28. data/lib/pione/command/pione-tuple-space-provider.rb +36 -45
  29. data/lib/pione/command/pione-tuple-space-receiver.rb +34 -32
  30. data/lib/pione/command/pione-tuple-space-viewer.rb +63 -47
  31. data/lib/pione/location.rb +10 -0
  32. data/lib/pione/location/basic-location.rb +272 -0
  33. data/lib/pione/location/dropbox-location.rb +139 -0
  34. data/lib/pione/location/ftp-location.rb +156 -0
  35. data/lib/pione/location/local-location.rb +116 -0
  36. data/lib/pione/log.rb +10 -0
  37. data/lib/pione/log/domain-info.rb +72 -0
  38. data/lib/pione/log/process-log.rb +176 -0
  39. data/lib/pione/log/process-record.rb +189 -0
  40. data/lib/pione/log/xes-log.rb +105 -0
  41. data/lib/pione/model/assignment.rb +88 -80
  42. data/lib/pione/model/binary-operator.rb +74 -68
  43. data/lib/pione/model/block.rb +218 -207
  44. data/lib/pione/model/boolean.rb +123 -112
  45. data/lib/pione/model/call-rule.rb +72 -65
  46. data/lib/pione/model/data-expr.rb +596 -290
  47. data/lib/pione/model/float.rb +108 -103
  48. data/lib/pione/model/integer.rb +133 -129
  49. data/lib/pione/model/message.rb +79 -72
  50. data/lib/pione/model/package.rb +42 -38
  51. data/lib/pione/model/parameters.rb +265 -236
  52. data/lib/pione/model/rule-expr.rb +247 -242
  53. data/lib/pione/model/rule-io.rb +137 -133
  54. data/lib/pione/model/rule.rb +307 -292
  55. data/lib/pione/model/string.rb +110 -99
  56. data/lib/pione/model/variable-table.rb +300 -271
  57. data/lib/pione/model/variable.rb +88 -83
  58. data/lib/pione/option.rb +13 -0
  59. data/lib/pione/option/child-process-option.rb +19 -0
  60. data/lib/pione/{command-option → option}/common-option.rb +6 -5
  61. data/lib/pione/option/option-interface.rb +73 -0
  62. data/lib/pione/{command-option → option}/presence-notifier-option.rb +4 -3
  63. data/lib/pione/option/task-worker-owner-option.rb +24 -0
  64. data/lib/pione/{command-option → option}/tuple-space-provider-option.rb +6 -4
  65. data/lib/pione/option/tuple-space-provider-owner-option.rb +18 -0
  66. data/lib/pione/option/tuple-space-receiver-option.rb +8 -0
  67. data/lib/pione/parser/common-parser.rb +3 -2
  68. data/lib/pione/parser/expr-parser.rb +6 -1
  69. data/lib/pione/patch/em-ftpd-patch.rb +21 -0
  70. data/lib/pione/patch/rinda-patch.rb +31 -23
  71. data/lib/pione/rule-handler/action-handler.rb +35 -25
  72. data/lib/pione/rule-handler/basic-handler.rb +92 -18
  73. data/lib/pione/rule-handler/flow-handler.rb +104 -98
  74. data/lib/pione/rule-handler/root-handler.rb +11 -0
  75. data/lib/pione/system/common.rb +10 -0
  76. data/lib/pione/system/file-cache.rb +103 -84
  77. data/lib/pione/system/global.rb +67 -12
  78. data/lib/pione/system/init.rb +20 -0
  79. data/lib/pione/transformer/expr-transformer.rb +6 -1
  80. data/lib/pione/tuple-space/data-finder.rb +33 -6
  81. data/lib/pione/tuple-space/tuple-space-receiver.rb +4 -3
  82. data/lib/pione/tuple-space/tuple-space-server-interface.rb +58 -13
  83. data/lib/pione/tuple-space/tuple-space-server.rb +13 -11
  84. data/lib/pione/tuple-space/update-criteria.rb +8 -7
  85. data/lib/pione/tuple/base-location-tuple.rb +9 -0
  86. data/lib/pione/tuple/basic-tuple.rb +7 -7
  87. data/lib/pione/tuple/data-tuple.rb +5 -2
  88. data/lib/pione/tuple/lift-tuple.rb +14 -0
  89. data/lib/pione/tuple/rule-tuple.rb +1 -1
  90. data/lib/pione/tuple/task-tuple.rb +5 -1
  91. data/lib/pione/version.rb +1 -1
  92. data/pione.gemspec +5 -1
  93. data/test/location/spec_basic-location.rb +35 -0
  94. data/test/location/spec_ftp-location.rb +100 -0
  95. data/test/location/spec_local-location.rb +99 -0
  96. data/test/log/data/sample.log +1003 -0
  97. data/test/log/spec_xes-log.rb +11 -0
  98. data/test/model/spec_data-expr.rb +249 -6
  99. data/test/model/spec_data-expr.yml +45 -0
  100. data/test/parser/spec_expr-parser.yml +4 -0
  101. data/test/spec_data-finder.rb +13 -7
  102. data/test/spec_data-finder.yml +42 -13
  103. data/test/system/spec_file-cache.rb +39 -0
  104. data/test/test-util.rb +226 -1
  105. data/test/transformer/spec_expr-transformer.rb +12 -1
  106. metadata +107 -24
  107. data/bin/pione-search-log +0 -30
  108. data/lib/pione/command-option/basic-option.rb +0 -42
  109. data/lib/pione/command-option/child-process-option.rb +0 -17
  110. data/lib/pione/command-option/daemon-option.rb +0 -12
  111. data/lib/pione/command-option/task-worker-owner-option.rb +0 -17
  112. data/lib/pione/command-option/tuple-space-provider-owner-option.rb +0 -16
  113. data/lib/pione/command-option/tuple-space-receiver-option.rb +0 -12
  114. data/lib/pione/command/tuple-space-provider-owner.rb +0 -6
  115. data/lib/pione/resource/basic-resource.rb +0 -92
  116. data/lib/pione/resource/dropbox-resource.rb +0 -106
  117. data/lib/pione/resource/ftp.rb +0 -84
  118. data/lib/pione/resource/local.rb +0 -113
  119. data/lib/pione/tuple/base-uri-tuple.rb +0 -9
  120. data/lib/pione/tuple/shift-tuple.rb +0 -13
  121. data/lib/pione/util/log.rb +0 -79
  122. data/test/spec_resource.rb +0 -73
@@ -1,245 +1,250 @@
1
- module Pione::Model
2
- # Rule representation in the flow element context.
3
- class RuleExpr < BasicModel
4
- set_pione_model_type TypeRuleExpr
5
-
6
- attr_reader :package
7
- attr_reader :name
8
- attr_reader :params
9
- attr_reader :input_ticket_expr
10
- attr_reader :output_ticket_expr
11
-
12
- # Create a rule expression.
13
- #
14
- # @param package [String]
15
- # package name
16
- # @param name [String]
17
- # rule name
18
- # @param params [Parameters]
19
- # parameters
20
- # @param input_ticket_expr [TicketExpr]
21
- # input ticket condition
22
- # @param output_ticket_expr [TicketExpr]
23
- # output ticket condition
24
- def initialize(package, name, params, input_ticket_expr, output_ticket_expr)
25
- @package = package
26
- @name = name
27
- @params = params
28
- @input_ticket_expr = input_ticket_expr
29
- @output_ticket_expr = output_ticket_expr
30
- super()
31
- end
32
-
33
- # Returns rule path form.
34
- # @return [String]
35
- # rule path string
36
- def path
37
- "&%s:%s" % [@package.name, @name]
38
- end
39
-
40
- # FIXME
41
- def rule_path
42
- raise UnboundVariableError.new(self) if @package.include_variable?
43
- "&%s:%s" % [@package.name, @name]
44
- end
45
-
46
- # @api private
47
- def task_id_string
48
- "RuleExpr<%s,#{@name}>" % [@package.task_id_string]
49
- end
50
-
51
- # @api private
52
- def textize
53
- "rule_expr(%s,\"%s\")" % [@package.textize, @name]
54
- end
55
-
56
- # Create a new rule expression with adding the ticket expression as input
57
- # condition.
58
- #
59
- # @param ticket_expr [TicketExpr]
60
- # ticket expression as additional input condition
61
- # @return [RuleExpr]
62
- # new rule expression
63
- def add_input_ticket_expr(ticket_expr)
64
- return self.class.new(@package, @name, @params, @input_ticket_expr + ticket_expr, @output_ticket_expr)
65
- end
66
-
67
- # Create a new rule expression with adding the ticket expression as output
68
- # condition.
69
- #
70
- # @param ticket_expr [TicketExpr]
71
- # ticket expression as additional output condition
72
- # @return [RuleExpr]
73
- # new rule expression
74
- def add_output_ticket_expr(ticket_expr)
75
- return self.class.new(@package, @name, @params, @input_ticket_expr, @output_ticket_expr + ticket_expr)
76
- end
77
-
78
- # Sets a package name and returns a new expression.
79
- # @param [String] package
80
- # package name
81
- # @return [RuleExpr]
82
- # new rule expression with the package name
83
- def set_package(package)
84
- return self.class.new(package, @name, @params)
85
- end
86
-
87
- # Sets parameters and returns a new expression.
88
- # @param [Parameters] params
89
- # parameters
90
- # @return [RuleExpr]
91
- # new rule expression with the parameters
92
- def set_params(params)
93
- return self.class.new(@package, @name, params, @input_ticket_expr, @output_ticket_expr)
94
- end
95
-
96
- # Evaluates the object with the variable table.
97
- # @param [VariableTable] vtable
98
- # variable table for evaluation
99
- # @return [BasicModel]
100
- # evaluation result
101
- def eval(vtable)
102
- return self.class.new(
103
- @package.eval(vtable),
104
- @name,
105
- @params.eval(vtable),
106
- @input_ticket_expr.eval(vtable),
107
- @output_ticket_expr.eval(vtable)
108
- )
109
- end
110
-
111
- # Returns true if the package or parameters include variables.
112
- # @return [Boolean]
113
- # true if the package or parameters include variables
114
- def include_variable?
115
- [ @package.include_variable?,
116
- @params.include_variable?,
117
- @input_ticket_expr.include_variable?,
118
- @output_ticket_expr.include_variable?
119
- ].any?
120
- end
121
-
122
- # @api private
123
- def ==(other)
124
- return false unless other.kind_of?(self.class)
125
- return false unless @package = other.package
126
- return false unless @name == other.name
127
- return false unless @params == other.params
128
- return true
129
- end
130
-
131
- # @api private
132
- alias :eql? :"=="
133
-
134
- # @api private
135
- def hash
136
- @package.hash + @name.hash + @params.hash
137
- end
138
-
139
- # Return a set that contains self as a single element.
140
- #
141
- # @return [Set<RuleExpr>]
142
- # a set that contains self
143
- def to_set
144
- Set.new([self])
145
- end
146
- end
147
-
148
- class CompositionalRuleExpr < RuleExpr
149
- # Create a new compositional rule expression. This consists from left and
150
- # right child expressions.
151
- #
152
- # @param left [RuleExpr]
153
- # left expression
154
- # @param right [RuleExpr]
155
- # right expression
156
- def initialize(left, right)
157
- @left = left
158
- @right = right
159
- end
160
-
161
- # Create a new compositioanl rule expression with adding the ticket
162
- # expression as input condition of left expression.
163
- #
164
- # @param ticket_expr [TicketExpr]
165
- # ticket expression as additional input condition
166
- # @return [CompositionalRuleExpr]
167
- # new rule expression
168
- def add_input_ticket_expr(ticket_expr)
169
- return self.class.new(@left.add_input_ticket_expr(ticket_expr), @right)
170
- end
171
-
172
- # Create a new compositional rule expression with adding the ticket
173
- # expression as output condition of right expression.
174
- #
175
- # @param ticket_expr [TicketExpr]
176
- # ticket expression as additional output condition
177
- # @return [CompositionalRuleExpr]
178
- # new rule expression
179
- def add_output_ticket_expr(ticket_expr)
180
- return self.class.new(@left, @right.add_output_ticket_expr(ticket_expr))
181
- end
182
-
183
- # Evaluates left and right expressions with the variable table.
184
- #
185
- # @param [VariableTable] vtable
186
- # variable table for evaluation
187
- # @return [CompositionalRuleExpr]
188
- # evaluation result
189
- def eval(vtable)
190
- return self.class.new(@left.eval(vtable), @right.eval(vtable))
191
- end
192
-
193
- # @api private
194
- def ==(other)
195
- return false unless other.kind_of?(self.class)
196
- return to_set == other.to_set
197
- end
198
- alias :eql? :"=="
199
-
200
- # @api private
201
- def hash
202
- @left.hash + @right.hash
203
- end
204
-
205
- # Return a set that contains all rule expressions of left and right.
206
- #
207
- # @return [Set<RuleExpr>]
208
- # a set that contains all rule expressions of left and right
209
- def to_set
210
- @left.to_set + @right.to_set
211
- end
212
- end
213
-
214
- TypeRuleExpr.instance_eval do
215
- define_pione_method("==", [TypeRuleExpr], TypeBoolean) do |rec, other|
216
- PioneBoolean.new(
217
- rec.package == other.package &&
218
- rec.name == other.name &&
219
- rec.params == other.params)
220
- end
221
-
222
- define_pione_method("!=", [TypeRuleExpr], TypeBoolean) do |rec, other|
223
- PioneBoolean.not(rec.call_pione_method("==", other))
224
- end
225
-
226
- define_pione_method("params", [TypeParameters], TypeRuleExpr) do |rec, params|
227
- rec.set_params(params)
228
- end
229
-
230
- define_pione_method("as_string", [], TypeString) do |rec|
231
- PioneString.new(rec.name)
232
- end
233
-
234
- define_pione_method("==>", [TypeTicketExpr], TypeRuleExpr) do |rec, ticket_expr|
235
- rec.add_output_ticket_expr(ticket_expr)
236
- end
237
-
238
- define_pione_method(">>>", [TypeRuleExpr], TypeRuleExpr) do |rec, other|
239
- ticket_expr = TicketExpr.new([rec.path])
240
- left = rec.add_output_ticket_expr(ticket_expr)
241
- right = other.add_input_ticket_expr(ticket_expr)
242
- CompositionalRuleExpr.new(left, right)
1
+ module Pione
2
+ module Model
3
+ # Rule representation in the flow element context.
4
+ class RuleExpr < BasicModel
5
+ set_pione_model_type TypeRuleExpr
6
+
7
+ attr_reader :package
8
+ attr_reader :name
9
+ attr_reader :params
10
+ attr_reader :input_ticket_expr
11
+ attr_reader :output_ticket_expr
12
+
13
+ # Create a rule expression.
14
+ #
15
+ # @param package [String]
16
+ # package name
17
+ # @param name [String]
18
+ # rule name
19
+ # @param params [Parameters]
20
+ # parameters
21
+ # @param input_ticket_expr [TicketExpr]
22
+ # input ticket condition
23
+ # @param output_ticket_expr [TicketExpr]
24
+ # output ticket condition
25
+ def initialize(package, name, params, input_ticket_expr, output_ticket_expr)
26
+ @package = package
27
+ @name = name
28
+ @params = params
29
+ @input_ticket_expr = input_ticket_expr
30
+ @output_ticket_expr = output_ticket_expr
31
+ super()
32
+ end
33
+
34
+ # Return rule path form.
35
+ #
36
+ # @return [String]
37
+ # rule path string
38
+ def path
39
+ "&%s:%s" % [@package.name, @name]
40
+ end
41
+
42
+ # FIXME
43
+ def rule_path
44
+ raise UnboundVariableError.new(self) if @package.include_variable?
45
+ "&%s:%s" % [@package.name, @name]
46
+ end
47
+
48
+ # @api private
49
+ def task_id_string
50
+ "RuleExpr<%s,#{@name}>" % [@package.task_id_string]
51
+ end
52
+
53
+ # @api private
54
+ def textize
55
+ "rule_expr(%s,\"%s\")" % [@package.textize, @name]
56
+ end
57
+
58
+ # Create a new rule expression with adding the ticket expression as input
59
+ # condition.
60
+ #
61
+ # @param ticket_expr [TicketExpr]
62
+ # ticket expression as additional input condition
63
+ # @return [RuleExpr]
64
+ # new rule expression
65
+ def add_input_ticket_expr(ticket_expr)
66
+ return self.class.new(@package, @name, @params, @input_ticket_expr + ticket_expr, @output_ticket_expr)
67
+ end
68
+
69
+ # Create a new rule expression with adding the ticket expression as output
70
+ # condition.
71
+ #
72
+ # @param ticket_expr [TicketExpr]
73
+ # ticket expression as additional output condition
74
+ # @return [RuleExpr]
75
+ # new rule expression
76
+ def add_output_ticket_expr(ticket_expr)
77
+ return self.class.new(@package, @name, @params, @input_ticket_expr, @output_ticket_expr + ticket_expr)
78
+ end
79
+
80
+ # Sets a package name and returns a new expression.
81
+ #
82
+ # @param [String] package
83
+ # package name
84
+ # @return [RuleExpr]
85
+ # new rule expression with the package name
86
+ def set_package(package)
87
+ return self.class.new(package, @name, @params, @input_ticket_expr, @output_ticket_expr)
88
+ end
89
+
90
+ # Set parameters and returns a new expression.
91
+ #
92
+ # @param params [Parameters]
93
+ # parameters
94
+ # @return [RuleExpr]
95
+ # new rule expression with the parameters
96
+ def set_params(params)
97
+ return self.class.new(@package, @name, params, @input_ticket_expr, @output_ticket_expr)
98
+ end
99
+
100
+ # Evaluate the object with the variable table.
101
+ #
102
+ # @param vtable [VariableTable]
103
+ # variable table for evaluation
104
+ # @return [BasicModel]
105
+ # evaluation result
106
+ def eval(vtable)
107
+ return self.class.new(
108
+ @package.eval(vtable),
109
+ @name,
110
+ @params.eval(vtable),
111
+ @input_ticket_expr.eval(vtable),
112
+ @output_ticket_expr.eval(vtable)
113
+ )
114
+ end
115
+
116
+ # Return true if the package or parameters include variables.
117
+ #
118
+ # @return [Boolean]
119
+ # true if the package or parameters include variables
120
+ def include_variable?
121
+ [ @package.include_variable?,
122
+ @params.include_variable?,
123
+ @input_ticket_expr.include_variable?,
124
+ @output_ticket_expr.include_variable?
125
+ ].any?
126
+ end
127
+
128
+ # @api private
129
+ def ==(other)
130
+ return false unless other.kind_of?(self.class)
131
+ return false unless @package = other.package
132
+ return false unless @name == other.name
133
+ return false unless @params == other.params
134
+ return true
135
+ end
136
+ alias :eql? :"=="
137
+
138
+ # @api private
139
+ def hash
140
+ @package.hash + @name.hash + @params.hash
141
+ end
142
+
143
+ # Return a set that contains self as a single element.
144
+ #
145
+ # @return [Set<RuleExpr>]
146
+ # a set that contains self
147
+ def to_set
148
+ Set.new([self])
149
+ end
150
+ end
151
+
152
+ class CompositionalRuleExpr < RuleExpr
153
+ # Create a new compositional rule expression. This consists from left and
154
+ # right child expressions.
155
+ #
156
+ # @param left [RuleExpr]
157
+ # left expression
158
+ # @param right [RuleExpr]
159
+ # right expression
160
+ def initialize(left, right)
161
+ @left = left
162
+ @right = right
163
+ end
164
+
165
+ # Create a new compositioanl rule expression with adding the ticket
166
+ # expression as input condition of left expression.
167
+ #
168
+ # @param ticket_expr [TicketExpr]
169
+ # ticket expression as additional input condition
170
+ # @return [CompositionalRuleExpr]
171
+ # new rule expression
172
+ def add_input_ticket_expr(ticket_expr)
173
+ return self.class.new(@left.add_input_ticket_expr(ticket_expr), @right)
174
+ end
175
+
176
+ # Create a new compositional rule expression with adding the ticket
177
+ # expression as output condition of right expression.
178
+ #
179
+ # @param ticket_expr [TicketExpr]
180
+ # ticket expression as additional output condition
181
+ # @return [CompositionalRuleExpr]
182
+ # new rule expression
183
+ def add_output_ticket_expr(ticket_expr)
184
+ return self.class.new(@left, @right.add_output_ticket_expr(ticket_expr))
185
+ end
186
+
187
+ # Evaluate left and right expressions with the variable table.
188
+ #
189
+ # @param [VariableTable] vtable
190
+ # variable table for evaluation
191
+ # @return [CompositionalRuleExpr]
192
+ # evaluation result
193
+ def eval(vtable)
194
+ return self.class.new(@left.eval(vtable), @right.eval(vtable))
195
+ end
196
+
197
+ # @api private
198
+ def ==(other)
199
+ return false unless other.kind_of?(self.class)
200
+ return to_set == other.to_set
201
+ end
202
+ alias :eql? :"=="
203
+
204
+ # @api private
205
+ def hash
206
+ @left.hash + @right.hash
207
+ end
208
+
209
+ # Return a set that contains all rule expressions of left and right.
210
+ #
211
+ # @return [Set<RuleExpr>]
212
+ # a set that contains all rule expressions of left and right
213
+ def to_set
214
+ @left.to_set + @right.to_set
215
+ end
216
+ end
217
+
218
+ TypeRuleExpr.instance_eval do
219
+ define_pione_method("==", [TypeRuleExpr], TypeBoolean) do |rec, other|
220
+ PioneBoolean.new(
221
+ rec.package == other.package &&
222
+ rec.name == other.name &&
223
+ rec.params == other.params)
224
+ end
225
+
226
+ define_pione_method("!=", [TypeRuleExpr], TypeBoolean) do |rec, other|
227
+ PioneBoolean.not(rec.call_pione_method("==", other))
228
+ end
229
+
230
+ define_pione_method("params", [TypeParameters], TypeRuleExpr) do |rec, params|
231
+ rec.set_params(params)
232
+ end
233
+
234
+ define_pione_method("as_string", [], TypeString) do |rec|
235
+ PioneString.new(rec.name)
236
+ end
237
+
238
+ define_pione_method("==>", [TypeTicketExpr], TypeRuleExpr) do |rec, ticket_expr|
239
+ rec.add_output_ticket_expr(ticket_expr)
240
+ end
241
+
242
+ define_pione_method(">>>", [TypeRuleExpr], TypeRuleExpr) do |rec, other|
243
+ ticket_expr = TicketExpr.new([rec.path])
244
+ left = rec.add_output_ticket_expr(ticket_expr)
245
+ right = other.add_input_ticket_expr(ticket_expr)
246
+ CompositionalRuleExpr.new(left, right)
247
+ end
243
248
  end
244
249
  end
245
250
  end