-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathloop_range_step.xml
116 lines (98 loc) · 3.82 KB
/
loop_range_step.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<workflow-app name="loop_${loop_name}_(${loop_value}_of_${loop_start}_to_${loop_end})"
xmlns="uri:oozie:workflow:0.4">
<start to="check_fork"/>
<decision name="check_fork">
<switch>
<case to="fork">${loop_parallel eq "true"}</case>
<case to="run_serial">${loop_parallel eq "false"}</case>
<default to="error"/>
</switch>
</decision>
<!-- _______________________________________________________________________________ -->
<!-- We implement parallelism through a recursively-built tree of two-pronged forks
where the left prong is the action we want to loop over and the right prong is the
next fork down the tree. -->
<fork name="fork">
<path start="check_run_parallel"/>
<path start="check_continue_parallel"/>
</fork>
<decision name="check_run_parallel">
<switch>
<!-- We add zero to gently persuade the strings to be ints -->
<case to="run_parallel">${(loop_value + 0) le (loop_end + 0)}</case>
<default to="join"/>
</switch>
</decision>
<action name="run_parallel">
<sub-workflow>
<app-path>${loop_action}</app-path>
<propagate-configuration/>
</sub-workflow>
<ok to="join"/>
<error to="error"/>
</action>
<decision name="check_continue_parallel">
<switch>
<case to="continue_parallel">${(loop_value + 0) lt (loop_end + 0)}</case>
<default to="join"/>
</switch>
</decision>
<action name="continue_parallel">
<sub-workflow>
<!-- Take the red pill -->
<app-path>${wf:appPath()}</app-path>
<propagate-configuration/>
<configuration>
<property>
<name>loop_value</name>
<value>${loop_value + 1}</value>
</property>
</configuration>
</sub-workflow>
<ok to="join"/>
<error to="error"/>
</action>
<join name="join" to="end"/>
<!-- _______________________________________________________________________________ -->
<!-- We implement serial looping (as like a traditional for loop) by recursively
running the action until we reach the end of the range. -->
<decision name="check_run_serial">
<switch>
<case to="run_serial">${(loop_value + 0) le (loop_end + 0)}</case>
<default to="end"/>
</switch>
</decision>
<action name="run_serial">
<sub-workflow>
<app-path>${loop_action}</app-path>
<propagate-configuration/>
</sub-workflow>
<ok to="check_continue_serial"/>
<error to="error"/>
</action>
<decision name="check_continue_serial">
<switch>
<case to="continue_serial">${(loop_value + 0) lt (loop_end + 0)}</case>
<default to="end"/>
</switch>
</decision>
<action name="continue_serial">
<sub-workflow>
<app-path>${wf:appPath()}</app-path>
<propagate-configuration/>
<configuration>
<property>
<name>loop_value</name>
<value>${loop_value + 1}</value>
</property>
</configuration>
</sub-workflow>
<ok to="end"/>
<error to="error"/>
</action>
<!-- _______________________________________________________________________________ -->
<kill name="error">
<message>Oops!</message>
</kill>
<end name="end"/>
</workflow-app>