openwferu 0.9.16 → 0.9.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/examples/about_state.rb +81 -0
  2. data/examples/engine_template.rb +7 -0
  3. data/lib/openwfe/contextual.rb +2 -2
  4. data/lib/openwfe/def.rb +2 -3
  5. data/lib/openwfe/{util/schedulers.rb → engine.rb} +3 -39
  6. data/lib/openwfe/engine/engine.rb +202 -251
  7. data/lib/openwfe/engine/process_status.rb +359 -0
  8. data/lib/openwfe/expool/errorjournal.rb +6 -6
  9. data/lib/openwfe/expool/expressionpool.rb +161 -239
  10. data/lib/openwfe/expool/expstorage.rb +185 -55
  11. data/lib/openwfe/expool/journal.rb +1 -2
  12. data/lib/openwfe/expool/parser.rb +233 -0
  13. data/lib/openwfe/expool/threadedexpstorage.rb +6 -18
  14. data/lib/openwfe/expool/wfidgen.rb +25 -7
  15. data/lib/openwfe/expool/yamlexpstorage.rb +60 -37
  16. data/lib/openwfe/expressions/condition.rb +49 -12
  17. data/lib/openwfe/expressions/environment.rb +45 -15
  18. data/lib/openwfe/expressions/expressionmap.rb +39 -19
  19. data/lib/openwfe/expressions/fe_concurrence.rb +24 -13
  20. data/lib/openwfe/expressions/fe_cron.rb +19 -18
  21. data/lib/openwfe/expressions/fe_cursor.rb +69 -28
  22. data/lib/openwfe/expressions/fe_define.rb +4 -1
  23. data/lib/openwfe/expressions/fe_do.rb +1 -3
  24. data/lib/openwfe/expressions/fe_equals.rb +131 -20
  25. data/lib/openwfe/expressions/fe_fqv.rb +27 -3
  26. data/lib/openwfe/expressions/fe_iterator.rb +14 -7
  27. data/lib/openwfe/expressions/fe_listen.rb +7 -2
  28. data/lib/openwfe/expressions/fe_misc.rb +187 -20
  29. data/lib/openwfe/expressions/fe_participant.rb +8 -7
  30. data/lib/openwfe/expressions/fe_reserve.rb +105 -33
  31. data/lib/openwfe/expressions/fe_save.rb +55 -5
  32. data/lib/openwfe/expressions/{fe_value.rb → fe_set.rb} +6 -82
  33. data/lib/openwfe/expressions/fe_sleep.rb +25 -15
  34. data/lib/openwfe/expressions/fe_subprocess.rb +2 -2
  35. data/lib/openwfe/expressions/fe_wait.rb +3 -2
  36. data/lib/openwfe/expressions/fe_when.rb +7 -15
  37. data/lib/openwfe/expressions/flowexpression.rb +90 -49
  38. data/lib/openwfe/expressions/merge.rb +7 -1
  39. data/lib/openwfe/expressions/raw.rb +261 -63
  40. data/lib/openwfe/expressions/{raw_prog.rb → rprocdef.rb} +94 -179
  41. data/lib/openwfe/expressions/time.rb +36 -12
  42. data/lib/openwfe/expressions/timeout.rb +9 -7
  43. data/lib/openwfe/expressions/value.rb +126 -0
  44. data/lib/openwfe/flowexpressionid.rb +52 -22
  45. data/lib/openwfe/listeners/listeners.rb +3 -3
  46. data/lib/openwfe/listeners/socketlisteners.rb +8 -5
  47. data/lib/openwfe/logging.rb +6 -3
  48. data/lib/openwfe/omixins.rb +8 -6
  49. data/lib/openwfe/orest/xmlcodec.rb +16 -12
  50. data/lib/openwfe/participants.rb +38 -0
  51. data/lib/openwfe/participants/participant.rb +1 -1
  52. data/lib/openwfe/participants/participantmap.rb +24 -10
  53. data/lib/openwfe/participants/participants.rb +4 -3
  54. data/lib/openwfe/participants/soapparticipants.rb +1 -1
  55. data/lib/openwfe/participants/socketparticipants.rb +1 -1
  56. data/lib/openwfe/rudefinitions.rb +7 -5
  57. data/lib/openwfe/storage/yamlcustom.rb +10 -10
  58. data/lib/openwfe/storage/yamlfilestorage.rb +12 -12
  59. data/lib/openwfe/tools/flowtracer.rb +6 -5
  60. data/lib/openwfe/util/dollar.rb +42 -85
  61. data/lib/openwfe/util/ometa.rb +1 -3
  62. data/lib/openwfe/util/workqueue.rb +1 -1
  63. data/lib/openwfe/utils.rb +33 -11
  64. data/lib/openwfe/version.rb +2 -2
  65. data/lib/openwfe/workitem.rb +76 -14
  66. data/lib/openwfe/worklist/storelocks.rb +9 -4
  67. data/lib/openwfe/worklist/storeparticipant.rb +1 -1
  68. data/test/back_0916_test.rb +101 -0
  69. data/test/bm/ft_26_load.rb +1 -1
  70. data/test/bm/ft_26b_load.rb +1 -1
  71. data/test/bm/ft_26c_load.rb +3 -2
  72. data/test/bm/ft_26d_load.rb +97 -0
  73. data/test/bm/ft_recu.rb +71 -0
  74. data/test/concurrence_test.rb +1 -1
  75. data/test/condition_test.rb +152 -0
  76. data/test/description_test.rb +12 -7
  77. data/test/eno_test.rb +1 -1
  78. data/test/expool_20031219_0916.tgz +0 -0
  79. data/test/fe_lookup_att_test.rb +1 -1
  80. data/test/fei_test.rb +16 -0
  81. data/test/file_persistence_test.rb +8 -12
  82. data/test/filep_cancel_test.rb +116 -0
  83. data/test/flowtestbase.rb +47 -25
  84. data/test/ft_0.rb +1 -1
  85. data/test/ft_10_loop.rb +29 -14
  86. data/test/{ft_10b_loop2.rb → ft_10b_loop.rb} +2 -11
  87. data/test/ft_11_ppd.rb +6 -17
  88. data/test/ft_11b_ppd.rb +1 -4
  89. data/test/ft_12_blockparticipant.rb +1 -1
  90. data/test/ft_13_eno.rb +1 -1
  91. data/test/ft_15_iterator.rb +1 -1
  92. data/test/ft_15b_iterator.rb +1 -1
  93. data/test/ft_17_condition.rb +6 -6
  94. data/test/ft_18_pname.rb +1 -1
  95. data/test/ft_20_cron.rb +1 -1
  96. data/test/ft_21_cron.rb +6 -4
  97. data/test/ft_22_history.rb +1 -1
  98. data/test/ft_23_when.rb +1 -1
  99. data/test/ft_23b_when.rb +18 -6
  100. data/test/ft_23c_wait.rb +8 -6
  101. data/test/ft_25_cancel.rb +7 -5
  102. data/test/ft_27_getflowpos.rb +22 -17
  103. data/test/ft_28_fileparticipant.rb +1 -2
  104. data/test/ft_2_concurrence.rb +1 -1
  105. data/test/ft_2b_concurrence.rb +25 -20
  106. data/test/ft_30_socketlistener.rb +0 -3
  107. data/test/ft_34_cancelwfid.rb +9 -9
  108. data/test/ft_35_localdefs.rb +0 -1
  109. data/test/ft_36_subprocids.rb +6 -6
  110. data/test/ft_38_tag.rb +3 -2
  111. data/test/ft_38b_tag.rb +229 -0
  112. data/test/ft_39_reserve.rb +3 -18
  113. data/test/ft_39b_reserve.rb +34 -5
  114. data/test/ft_3b_lookup_vf.rb +83 -0
  115. data/test/ft_40_defined.rb +2 -11
  116. data/test/ft_42_environments.rb +4 -6
  117. data/test/ft_44b_restore.rb +88 -22
  118. data/test/ft_45_citerator.rb +57 -11
  119. data/test/ft_49_condition.rb +4 -2
  120. data/test/ft_4_misc.rb +24 -3
  121. data/test/ft_50_xml_attribute.rb +17 -20
  122. data/test/ft_54_listen.rb +1 -1
  123. data/test/ft_54b_listen.rb +2 -2
  124. data/test/ft_56_timeout.rb +8 -1
  125. data/test/ft_57_a.rb +10 -10
  126. data/test/ft_59_ps.rb +49 -16
  127. data/test/ft_60_ecancel.rb +52 -10
  128. data/test/ft_63_pause.rb +8 -8
  129. data/test/ft_65_stringlaunch.rb +4 -6
  130. data/test/ft_67_schedlaunch.rb +4 -4
  131. data/test/ft_69_cancelmissing.rb +4 -2
  132. data/test/ft_70_lookupvar.rb +2 -2
  133. data/test/ft_72_lookup_processes.rb +2 -2
  134. data/test/ft_73_cancel_sub.rb +8 -8
  135. data/test/ft_77_segments.rb +38 -0
  136. data/test/ft_78_eval.rb +154 -0
  137. data/test/ft_79_tticket.rb +185 -0
  138. data/test/ft_80_spname.rb +95 -0
  139. data/test/ft_81_exp.rb +64 -0
  140. data/test/ft_82_trecu.rb +48 -0
  141. data/test/ft_83_badpause.rb +62 -0
  142. data/test/ft_84_updateexp.rb +125 -0
  143. data/test/ft_9b_cursor.rb +105 -0
  144. data/test/ft_tests.rb +14 -1
  145. data/test/hash_test.rb +7 -7
  146. data/test/hparticipant_test.rb +4 -4
  147. data/test/lookup_vf_test.rb +94 -0
  148. data/test/misc_test.rb +5 -3
  149. data/test/orest_test.rb +4 -3
  150. data/test/param_test.rb +12 -16
  151. data/test/participant_test.rb +36 -0
  152. data/test/pending.rb +10 -10
  153. data/test/rake_ltest.rb +1 -10
  154. data/test/rake_qtest.rb +7 -6
  155. data/test/raw_prog_test.rb +89 -121
  156. data/test/restart_cron_test.rb +84 -36
  157. data/test/restart_paused_test.rb +100 -0
  158. data/test/restart_sleep_test.rb +1 -1
  159. data/test/restart_tests.rb +1 -0
  160. data/test/restart_when_test.rb +33 -22
  161. data/test/ruby_procdef_test.rb +19 -18
  162. data/test/sec_test.rb +74 -35
  163. data/test/storage_test.rb +44 -0
  164. data/test/test.rb +3 -0
  165. data/test/timeout_test.rb +7 -18
  166. data/test/wfid_test.rb +2 -1
  167. data/test/wi_test.rb +29 -18
  168. metadata +121 -57
  169. data/lib/openwfe/expressions/raw_xml.rb +0 -176
  170. data/lib/openwfe/expressions/simplerep.rb +0 -266
  171. data/lib/openwfe/util/kotoba.rb +0 -236
  172. data/lib/openwfe/util/lru.rb +0 -171
  173. data/lib/openwfe/util/otime.rb +0 -246
  174. data/lib/openwfe/util/safe.rb +0 -160
  175. data/lib/openwfe/util/scheduler.rb +0 -1158
  176. data/test/cron_test.rb +0 -113
  177. data/test/cronline_test.rb +0 -60
  178. data/test/dollar_test.rb +0 -90
  179. data/test/kotoba_test.rb +0 -72
  180. data/test/lru_test.rb +0 -79
  181. data/test/safely_test.rb +0 -84
  182. data/test/scheduler_1_test.rb +0 -88
  183. data/test/scheduler_test.rb +0 -363
  184. data/test/time_test.rb +0 -84
@@ -1,88 +0,0 @@
1
-
2
- #
3
- # Testing OpenWFE
4
- #
5
- # John Mettraux at openwfe.org
6
- #
7
- # Sun Oct 29 16:18:25 JST 2006
8
- #
9
-
10
- require 'test/unit'
11
- require 'openwfe/util/scheduler'
12
-
13
- #
14
- # testing otime and the scheduler
15
- #
16
-
17
- class Scheduler1Test < Test::Unit::TestCase
18
-
19
- #def setup
20
- #end
21
-
22
- #def teardown
23
- #end
24
-
25
- def test_0
26
-
27
- scheduler = OpenWFE::Scheduler.new
28
- scheduler.sstart
29
-
30
- job_id = scheduler.schedule_every "500", :tags => "Avery" do
31
- # don't do a thing
32
- end
33
-
34
- successful = true
35
-
36
- 200000.times do
37
- #assert_not_nil scheduler.get_job(job_id)
38
- if scheduler.get_job(job_id) == nil
39
- successful = false
40
- break
41
- end
42
- end
43
-
44
- scheduler.sstop
45
-
46
- assert successful
47
- end
48
-
49
- def test_1
50
-
51
- scheduler = OpenWFE::Scheduler.new
52
- scheduler.sstart
53
-
54
- job_id = scheduler.schedule_every "500", :tags => "Avery" do
55
- # don't do a thing
56
- end
57
-
58
- successful = true
59
-
60
- 200000.times do
61
- #assert_equal 1, scheduler.find_jobs("Avery").size
62
- if scheduler.find_jobs("Avery").size != 1
63
- successful = false
64
- break
65
- end
66
- end
67
-
68
- scheduler.sstop
69
-
70
- assert successful
71
- end
72
-
73
- #
74
- # testing "deviation", if I may call it like that...
75
- #
76
- def _test_2
77
- scheduler = OpenWFE::Scheduler.new
78
- scheduler.sstart
79
- last = nil
80
- job_id = scheduler.schedule_every "1s" do
81
- t = Time.now
82
- puts t.to_f
83
- end
84
- sleep 4 * 60
85
- scheduler.sstop
86
- end
87
-
88
- end
@@ -1,363 +0,0 @@
1
-
2
- #
3
- # Testing OpenWFE
4
- #
5
- # John Mettraux at openwfe.org
6
- #
7
- # Sun Oct 29 16:18:25 JST 2006
8
- #
9
-
10
- require 'test/unit'
11
- require 'openwfe/util/scheduler'
12
-
13
- #
14
- # testing otime and the scheduler
15
- #
16
-
17
- class SchedulerTest < Test::Unit::TestCase
18
-
19
- #def setup
20
- #end
21
-
22
- #def teardown
23
- #end
24
-
25
- def test_scheduler_0
26
-
27
- $var = nil
28
-
29
- scheduler = OpenWFE::Scheduler.new
30
- scheduler.sstart
31
-
32
- sid = scheduler.schedule_in('2s', :schedulable => TestSchedulable.new)
33
-
34
- assert \
35
- sid,
36
- "scheduler_0 did not return a job id"
37
-
38
- assert \
39
- (not $var),
40
- "scheduler_0 is blocking but should not"
41
-
42
- sleep 2.5
43
- scheduler.sstop
44
-
45
- #puts ">#{$var}<"
46
-
47
- assert_equal "ok", $var
48
- end
49
-
50
- def test_scheduler_1
51
-
52
- $var = nil
53
-
54
- scheduler = OpenWFE::Scheduler.new
55
- scheduler.sstart
56
-
57
- sid = scheduler.schedule_in('1s') do
58
- $var = "ok..1"
59
- end
60
-
61
- assert \
62
- sid,
63
- "scheduler_1 did not return a job id"
64
-
65
- assert \
66
- (not $var),
67
- "scheduler_1 is blocking but should not"
68
-
69
- sleep 2
70
- scheduler.sstop
71
-
72
- #puts ">#{$var}<"
73
-
74
- assert "ok..1", $var
75
- end
76
-
77
- #
78
- # test idea by ara.t.howard on the ruby-talk ml
79
- #
80
- def test_scheduler_2
81
-
82
- text = ""
83
-
84
- scheduler = OpenWFE::Scheduler.new()
85
- scheduler.sstart
86
-
87
- scheduler.schedule_in("1s") do
88
- text << "one"
89
- sleep(2)
90
- end
91
- scheduler.schedule_in("1s") do
92
- text << "two"
93
- end
94
-
95
- sleep(2)
96
-
97
- scheduler.sstop
98
-
99
- #puts text
100
-
101
- assert_equal text, "onetwo"
102
- end
103
-
104
-
105
- #
106
- # test Scheduler::is_cron_string(s)
107
- #
108
- def test_scheduler_3
109
-
110
- assert OpenWFE::Scheduler.is_cron_string("* * * * *")
111
- assert OpenWFE::Scheduler.is_cron_string("10/2 * * * *")
112
- assert (not OpenWFE::Scheduler.is_cron_string("10d10m"))
113
- end
114
-
115
-
116
- #
117
- # Testing schedule_every()
118
- #
119
- def test_scheduler_4
120
-
121
- scheduler = OpenWFE::Scheduler.new()
122
- scheduler.sstart
123
-
124
- #
125
- # phase 0
126
-
127
- count = 0
128
-
129
- job_id = scheduler.schedule_every("1s") do
130
- count += 1
131
- end
132
-
133
- sleep 3.5
134
-
135
- assert_equal 3, count
136
-
137
- job = scheduler.get_job job_id
138
-
139
- assert_equal "1s", job.schedule_info
140
-
141
- #
142
- # phase 1
143
-
144
- es = EverySchedulable.new
145
-
146
- job_id = scheduler.schedule_every("500", es)
147
-
148
- #sleep(3.4) # was a bit soonish for JRuby...
149
- sleep 3.5
150
-
151
- assert_equal es.count, 6
152
-
153
- scheduler.unschedule(job_id)
154
-
155
- sleep(1)
156
-
157
- assert_equal es.count, 6
158
-
159
- # done
160
-
161
- scheduler.sstop
162
- end
163
-
164
- #
165
- # testing to see if the scheduler immediately executes schedule_in(t)
166
- # requests where t < scheduler.frequency.
167
- # (100ms < 250ms)
168
- #
169
- def test_scheduler_5
170
-
171
- scheduler = OpenWFE::Scheduler.new
172
- scheduler.sstart
173
-
174
- touched = false
175
-
176
- scheduler.schedule_in "100" do
177
- touched = true
178
- end
179
-
180
- assert touched
181
-
182
- scheduler.sstop
183
- end
184
-
185
- #
186
- # Testing to see if a second job with the same id discards the first one.
187
- #
188
- def test_scheduler_6
189
-
190
- scheduler = OpenWFE::Scheduler.new
191
- scheduler.start
192
-
193
- value = nil
194
-
195
- scheduler.schedule_in "3s", :job_id => "job" do
196
- value = 0
197
- end
198
- scheduler.schedule_in "2s", :job_id => "job" do
199
- value = 1
200
- end
201
-
202
- sleep 2.5
203
-
204
- assert_equal value, 1
205
-
206
- sleep 4
207
-
208
- assert_equal value, 1
209
-
210
- scheduler.stop
211
- end
212
-
213
- #
214
- # Testing custom precision.
215
- #
216
- def test_scheduler_7
217
-
218
- scheduler = OpenWFE::Scheduler.new(:scheduler_precision => 0.100)
219
-
220
- assert_equal scheduler.precision, 0.100
221
- end
222
-
223
- #
224
- # Making sure that a job scheduled in the past is executed immediately
225
- # and not scheduled.
226
- #
227
- # This test also makes sure that schedule_at() understands the
228
- # time.to_s format.
229
- #
230
- def test_8
231
-
232
- scheduler = OpenWFE::Scheduler.new
233
- scheduler.start
234
-
235
- var = false
236
-
237
- job_id = scheduler.schedule_at Time.now.to_s do
238
- var = true
239
- end
240
-
241
- assert_equal var, true
242
- assert_nil job_id
243
- end
244
-
245
- #
246
- # Scheduling in the past, with :discard_past set to true.
247
- #
248
- def test_8b
249
-
250
- scheduler = OpenWFE::Scheduler.new
251
- scheduler.start
252
-
253
- var = nil
254
-
255
- job_id = scheduler.schedule_at(Time.now.to_s, :discard_past => true) do
256
- var = "something"
257
- end
258
-
259
- assert_nil var
260
- assert_nil job_id
261
-
262
- scheduler.stop
263
- end
264
-
265
- #
266
- # Testing restarting the scheduler.
267
- #
268
- def test_9
269
-
270
- scheduler = OpenWFE::Scheduler.new
271
- scheduler.start
272
-
273
- value = nil
274
-
275
- scheduler.schedule_in "2s" do
276
- value = 0
277
- end
278
-
279
- assert_nil value
280
-
281
- scheduler.stop
282
-
283
- sleep 0.5
284
-
285
- scheduler.start
286
-
287
- assert_nil value
288
-
289
- sleep 2
290
-
291
- assert_equal value, 0
292
-
293
- scheduler.stop
294
- end
295
-
296
- #
297
- # Testing tags
298
- #
299
- def test_10
300
-
301
- scheduler = OpenWFE::Scheduler.new
302
- scheduler.start
303
-
304
- value = nil
305
-
306
- scheduler.schedule_in "3s", :tags => "fish" do
307
- value = "fish"
308
- end
309
-
310
- assert_equal scheduler.find_jobs('deer'), []
311
- assert_equal scheduler.find_jobs('fish').size, 1
312
-
313
- scheduler.schedule "* * * * *", :tags => "fish" do
314
- value = "cron-fish"
315
- end
316
- scheduler.schedule "* * * * *", :tags => "vegetable" do
317
- value = "daikon"
318
- end
319
-
320
- assert_equal scheduler.find_jobs('fish').size, 2
321
- #puts scheduler.find_jobs('fish')
322
-
323
- scheduler.find_jobs('fish').each do |job|
324
- scheduler.unschedule(job.job_id)
325
- end
326
-
327
- assert_equal scheduler.find_jobs('fish'), []
328
-
329
- assert_equal scheduler.find_jobs('vegetable').size, 1
330
-
331
- scheduler.find_jobs('vegetable')[0].unschedule
332
-
333
- assert_equal scheduler.find_jobs('vegetable').size, 0
334
- end
335
-
336
-
337
- protected
338
-
339
- class TestSchedulable
340
- include OpenWFE::Schedulable
341
-
342
- def trigger (params)
343
- $var = "ok"
344
- end
345
- end
346
-
347
- class EverySchedulable
348
- include OpenWFE::Schedulable
349
-
350
- attr_accessor :job_id, :count
351
-
352
- def initialize
353
- @job_id = -1
354
- @count = 0
355
- end
356
-
357
- def trigger (params)
358
- #puts "toto"
359
- @count += 1
360
- end
361
- end
362
-
363
- end