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
@@ -8,7 +8,7 @@
8
8
  #
9
9
 
10
10
  require 'flowtestbase'
11
- require 'openwfe/expressions/raw_prog'
11
+ require 'openwfe/def'
12
12
 
13
13
  include OpenWFE
14
14
 
@@ -10,7 +10,7 @@
10
10
  #require 'profile'
11
11
 
12
12
  require 'flowtestbase'
13
- require 'openwfe/expressions/raw_prog'
13
+ require 'openwfe/def'
14
14
 
15
15
  include OpenWFE
16
16
 
@@ -10,7 +10,7 @@
10
10
  #require 'profile'
11
11
 
12
12
  require 'flowtestbase'
13
- require 'openwfe/expressions/raw_prog'
13
+ require 'openwfe/def'
14
14
 
15
15
  include OpenWFE
16
16
 
@@ -28,7 +28,8 @@ class FlowTest26c < Test::Unit::TestCase
28
28
  # Test 0
29
29
  #
30
30
 
31
- N = 10_000
31
+ #N = 10_000
32
+ N = 1000
32
33
 
33
34
  class TestDefinition0 < ProcessDefinition
34
35
  sequence do
@@ -0,0 +1,97 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Dec 24 22:02:12 JST 2007
8
+ #
9
+
10
+ #require 'profile'
11
+
12
+ require 'flowtestbase'
13
+ require 'openwfe/def'
14
+
15
+ include OpenWFE
16
+
17
+
18
+ class FlowTest26d < Test::Unit::TestCase
19
+ include FlowTestBase
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #def teardown
25
+ #end
26
+
27
+ #
28
+ # Test 0
29
+ #
30
+
31
+ #N = 10_000
32
+ N = 1_000
33
+
34
+ class TestDefinition0 < ProcessDefinition
35
+ concurrence do
36
+ N.times do
37
+ count
38
+ end
39
+ end
40
+ end
41
+
42
+ def test_load_0
43
+
44
+ #log_level_to_debug
45
+
46
+ #@engine.get_scheduler.sstop
47
+ #
48
+ # JRuby is no friend of the Scheduler ( was :) )
49
+
50
+ $count = 0
51
+
52
+ @engine.register_participant("count") do |workitem|
53
+ $count += 1
54
+ print "."
55
+ end
56
+
57
+ fei = @engine.launch(LaunchItem.new(TestDefinition0))
58
+ puts "launched #{fei}"
59
+
60
+ #log_level_to_debug
61
+
62
+ @engine.wait_for fei
63
+
64
+ assert_equal N, $count
65
+ end
66
+
67
+ #
68
+ # Thu Sep 13 15:41:20 JST 2007
69
+ #
70
+ # ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.8.3]
71
+ #
72
+ # 10_000 in 27.69s
73
+ #
74
+ # before optimization : 10k in 138.341
75
+ #
76
+ #
77
+ # ruby 1.8.5 (2007-09-13 rev 3876) [i386-jruby1.1]
78
+ #
79
+ # 10_000 in 53.96s
80
+ #
81
+ # ruby 1.8.5 (2007-09-13 rev 3876) [i386-jruby1.1]
82
+ # -O -J-server
83
+ #
84
+ # 10_000 in 42.616s
85
+
86
+ #
87
+ # Thu Nov 8 21:36:02 JST 2007
88
+ #
89
+ # ruby 1.8.6 (2007-06-07 patchlevel 36) [universal-darwin9.0]
90
+ #
91
+ # 10_000 in 39.089
92
+ #
93
+ # ?
94
+ #
95
+
96
+ end
97
+
@@ -0,0 +1,71 @@
1
+
2
+ #
3
+ # Testing OpenWFE
4
+ #
5
+ # John Mettraux at openwfe.org
6
+ #
7
+ # Mon Oct 9 22:19:44 JST 2006
8
+ #
9
+
10
+ require 'openwfe/def'
11
+
12
+ require 'flowtestbase'
13
+
14
+
15
+ class FlowTestRecursion < Test::Unit::TestCase
16
+ include FlowTestBase
17
+
18
+ #def teardown
19
+ #end
20
+
21
+ #def setup
22
+ #end
23
+
24
+ #
25
+ # test 0
26
+ #
27
+
28
+ class Test0 < OpenWFE::ProcessDefinition
29
+ sequence do
30
+ #print_i
31
+ #subprocess :ref => "Test"
32
+ subprocess :ref => "Testy"
33
+ end
34
+ process_definition :name => "Testy" do
35
+ sequence do
36
+ print_i
37
+ subprocess :ref => "Testy"
38
+ end
39
+ #_loop do
40
+ # print_i
41
+ #end
42
+ end
43
+ end
44
+
45
+ def test_0
46
+
47
+ i = 0
48
+ last = Time.now.to_f
49
+
50
+ @engine.register_participant :print_i do
51
+ now = Time.now.to_f
52
+ print "#{i}"
53
+ if i % 10 == 0
54
+ print "("
55
+ print "#{now-last}"
56
+ print " #{@engine.get_expression_storage.size}"
57
+ print ")"
58
+ end
59
+ print " "
60
+ last = now
61
+ i += 1
62
+ end
63
+
64
+ #dotest TestTag0, "blah"
65
+ @engine.launch Test0
66
+
67
+ sleep 360
68
+ end
69
+
70
+ end
71
+
@@ -13,7 +13,7 @@ require 'test/unit'
13
13
  #require 'openwfe/workitem'
14
14
  #require 'openwfe/flowexpressionid'
15
15
  require 'openwfe/engine/engine'
16
- require 'openwfe/expressions/raw_prog'
16
+ require 'openwfe/def'
17
17
  require 'openwfe/worklist/storeparticipant'
18
18
 
19
19
  include OpenWFE
@@ -0,0 +1,152 @@
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
+
12
+ #require 'openwfe/workitem'
13
+ require 'openwfe/expressions/condition'
14
+
15
+ #
16
+ # testing expression conditions
17
+ #
18
+
19
+ class ConditionTest < Test::Unit::TestCase
20
+ include OpenWFE::ConditionMixin
21
+
22
+ def setup
23
+ @debug = false
24
+ end
25
+
26
+ #def teardown
27
+ #end
28
+
29
+ def test_0
30
+
31
+ #@debug = true
32
+
33
+ assert_t "true"
34
+ assert_F "false"
35
+
36
+ assert_t "1 == 1"
37
+
38
+ assert_t "'a' == 'a'"
39
+ assert_t '"a" == "a"'
40
+
41
+ assert_t "a == a"
42
+ assert_F "'a' == a"
43
+
44
+ #assert_t "!= ''"
45
+
46
+ assert_F " == 1 "
47
+ assert_F " == 1"
48
+ assert_F "== 1"
49
+ end
50
+
51
+ def test_0b
52
+
53
+ #@debug = true
54
+
55
+ assert_t "a"
56
+ assert_F ""
57
+ end
58
+
59
+ def test_1
60
+
61
+ #@debug = true
62
+
63
+ assert_set_t "1 is set"
64
+ assert_set_t "1 set"
65
+ assert_set_F "1 is not set"
66
+ assert_set_F "1 not set"
67
+
68
+ assert_set_t " is not set"
69
+ assert_set_t " not set"
70
+ assert_set_F " is set"
71
+ assert_set_F " set"
72
+
73
+ assert_t "1 is set"
74
+ assert_t "1 set"
75
+ assert_F "1 is not set"
76
+ assert_F "1 not set"
77
+
78
+ assert_t " is not set"
79
+ assert_t " not set"
80
+ assert_F " is set"
81
+ assert_F " set"
82
+ end
83
+
84
+ def test_2
85
+
86
+ #@debug = true
87
+
88
+ $my_owferu_var = nil
89
+
90
+ #assert_F "f = File.open('toto', 'w'); f.puts('nada'); f.close"
91
+ assert_t "$my_owferu_var = 3; $my_owferu_var = 4"
92
+ assert_equal nil, $my_owferu_var
93
+
94
+ #assert_F "fe.reply('a')"
95
+ assert_t "fe.reply('a')"
96
+ end
97
+
98
+ protected
99
+
100
+ #
101
+ # just for test_2
102
+ #
103
+ def reply (m)
104
+ @fei = nil
105
+ end
106
+
107
+ def assert_t (s, inv=false)
108
+
109
+ r = eval_condition(s, nil)
110
+
111
+ #puts "raw r is _#{r}_" if @debug
112
+
113
+ r = (not r) if inv
114
+
115
+ assert r, ">#{s}< should have evaluated to _#{not inv}_"
116
+ end
117
+
118
+ def assert_F (s)
119
+
120
+ assert_t s, true
121
+ end
122
+
123
+ def assert_set_t (s, inv=false)
124
+
125
+ r = eval_set s
126
+ r = (not r) if inv
127
+
128
+ assert r, ">#{s}< should have evaluated to _#{not inv}_"
129
+ end
130
+
131
+ def assert_set_F (s)
132
+
133
+ assert_set_t s, true
134
+ end
135
+
136
+ #def evalc (s)
137
+ # eval_condition(s, nil)
138
+ #end
139
+
140
+ def lookup_attribute (attname, workitem)
141
+
142
+ attname
143
+ end
144
+
145
+ def ldebug (&block)
146
+
147
+ # don't do a thing
148
+ return unless @debug
149
+
150
+ puts " " + block.call
151
+ end
152
+ end
@@ -9,7 +9,7 @@
9
9
 
10
10
  require 'test/unit'
11
11
 
12
- require 'openwfe/expressions/simplerep'
12
+ require 'openwfe/expool/parser'
13
13
 
14
14
  #
15
15
  # testing definition.get_description
@@ -33,25 +33,30 @@ end
33
33
 
34
34
  def test_0
35
35
 
36
- rep = OpenWFE::SimpleExpRepresentation.from_code DEF0
36
+ #rep = OpenWFE::SimpleExpRepresentation.from_code DEF0
37
+ rep = OpenWFE::DefParser.parse_string DEF0
37
38
 
38
- assert_equal rep.get_description, "not much to say"
39
+ assert_equal(
40
+ "not much to say",
41
+ OpenWFE::ExpressionTree.get_description(rep))
39
42
  end
40
43
 
41
- DEF1 = '''
44
+ DEF1 = <<-EOS
42
45
  <process-definition name="x" revision="y">
43
46
  <description>
44
47
  just a tiny process
45
48
  </description>
46
49
  <participant ref="nada" />
47
50
  </process-definition>
48
- '''.strip
51
+ EOS
49
52
 
50
53
  def test_1
51
54
 
52
- rep = OpenWFE::SimpleExpRepresentation.from_s DEF1
55
+ rep = OpenWFE::DefParser.parse_string DEF1
53
56
 
54
- assert_equal rep.get_description, "just a tiny process"
57
+ assert_equal(
58
+ "just a tiny process",
59
+ OpenWFE::ExpressionTree.get_description(rep))
55
60
  end
56
61
  end
57
62
 
@@ -11,7 +11,7 @@ require 'test/unit'
11
11
 
12
12
  require 'openwfe/workitem'
13
13
  require 'openwfe/engine/engine'
14
- require 'openwfe/expressions/raw_prog'
14
+ require 'openwfe/def'
15
15
  require 'openwfe/participants/participants'
16
16
  require 'openwfe/participants/enoparticipants'
17
17
  #require 'flowtestbase'
@@ -27,7 +27,7 @@ class FeLookupAttTest < Test::Unit::TestCase
27
27
  "a" => true,
28
28
  "b" => false,
29
29
  }
30
- fe = FlowExpression.new(nil, nil, nil, nil, attributes)
30
+ fe = FlowExpression.new_exp nil, nil, nil, nil, attributes
31
31
 
32
32
  assert_equal true, fe.lookup_boolean_attribute("a", nil)
33
33
  assert_equal true, fe.lookup_boolean_attribute(:a, nil)
@@ -151,6 +151,22 @@ class FeiTest < Test::Unit::TestCase
151
151
  assert_equal s1, fei1.to_s
152
152
  end
153
153
 
154
+ def test_web_s
155
+
156
+ s1 = "(fei 0.9.16 eng http://test/test.xml test 1.0 123456 do-test 0.0)"
157
+ fei1 = OpenWFE::FlowExpressionId.from_s s1
158
+
159
+ assert_equal(
160
+ [ "123456", "0.0" ],
161
+ OpenWFE::FlowExpressionId.split_web_s(fei1.to_web_s))
162
+ end
163
+
164
+ def test_from_h
165
+
166
+ fei = new_fei()
167
+ assert_equal fei, OpenWFE::FlowExpressionId.from_h(fei.to_h)
168
+ end
169
+
154
170
  protected
155
171
 
156
172
  def puts_hash (h)