This repository was archived by the owner on Jan 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathbatch-processing001.html
More file actions
332 lines (320 loc) · 11.9 KB
/
batch-processing001.html
File metadata and controls
332 lines (320 loc) · 11.9 KB
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Introduction to Batch Processing</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="css/style.css" rel="stylesheet">
<script src="https://use.fontawesome.com/96c4d89611.js"></script>
</head>
<body>
<table id="doc-title" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="top">
<b>Java Platform, Enterprise Edition (Java EE) 8</b><br />
<b>The Java EE Tutorial</b>
<!-- <p class="beta">Beta Draft (Pre-General Availability)</p> -->
</td>
</tr>
</table>
<hr />
<table width="90%" id="top-nav" cellspacing="0" cellpadding="0">
<colgroup>
<col width="12%"/>
<col width="12%"/>
<col width="*"/>
</colgroup>
<tr>
<td align="left">
<a href="batch-processing.html">
<span class="vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Previous</span>
</a>
</td>
<td align="left">
<a href="batch-processing002.html">
<span class=" vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Next</span>
</a>
</td>
<td align="right">
<a href="toc.html">
<span class=" vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Contents</span>
</a>
</td>
</tr>
</table>
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p><a id="BCGJDEEH"></a><a id="introduction-to-batch-processing"></a></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_introduction_to_batch_processing">Introduction to Batch Processing</h2>
<div class="sectionbody">
<div class="paragraph">
<p>Some enterprise applications contain tasks that can be executed without
user interaction. These tasks are executed periodically or when resource
usage is low, and they often process large amounts of information such
as log files, database records, or images. Examples include billing,
report generation, data format conversion, and image processing. These
tasks are called batch jobs.</p>
</div>
<div class="paragraph">
<p>Batch processing refers to running batch jobs on a computer system. Java
EE includes a batch processing framework that provides the batch
execution infrastructure common to all batch applications, enabling
developers to concentrate on the business logic of their batch
applications. The batch framework consists of a job specification
language based on XML, a set of batch annotations and interfaces for
application classes that implement the business logic, a batch container
that manages the execution of batch jobs, and supporting classes and
interfaces to interact with the batch container.</p>
</div>
<div class="paragraph">
<p>A batch job can be completed without user intervention. For example,
consider a telephone billing application that reads phone call records
from the enterprise information systems and generates a monthly bill for
each account. Since this application does not require any user
interaction, it can run as a batch job.</p>
</div>
<div class="paragraph">
<p>The phone billing application consists of two phases: The first phase
associates each call from the registry with a monthly bill, and the
second phase calculates the tax and total amount due for each bill. Each
of these phases is a step of the batch job.</p>
</div>
<div class="paragraph">
<p>Batch applications specify a set of steps and their execution order.
Different batch frameworks may specify additional elements, like
decision elements or groups of steps that run in parallel. The following
sections describe steps in more detail and provide information about
other common characteristics of batch frameworks.</p>
</div>
<div class="paragraph">
<p><a id="sthref261"></a><a id="steps-in-batch-jobs"></a></p>
</div>
<div class="sect2">
<h3 id="_steps_in_batch_jobs">Steps in Batch Jobs</h3>
<div class="paragraph">
<p>A step is an independent and sequential phase of a batch job. Batch jobs
contain chunk-oriented steps and task-oriented steps.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Chunk-oriented steps (chunk steps) process data by reading items from
a data source, applying some business logic to each item, and storing
the results. Chunk steps read and process one item at a time and group
the results into a chunk. The results are stored when the chunk reaches
a configurable size. Chunk-oriented processing makes storing results
more efficient and facilitates transaction demarcation.</p>
<div class="paragraph">
<p>Chunk steps have three parts.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The input retrieval part reads one item at a time from a data source,
such as entries on a database, files in a directory, or entries in a log
file.</p>
</li>
<li>
<p>The business processing part manipulates one item at a time using the
business logic defined by the application. Examples include filtering,
formatting, and accessing data from the item for computing a result.</p>
</li>
<li>
<p>The output writing part stores a chunk of processed items at a time.</p>
<div class="paragraph">
<p>Chunk steps are often long-running because they process large amounts of
data. Batch frameworks enable chunk steps to bookmark their progress
using checkpoints. A chunk step that is interrupted can be restarted
from the last checkpoint. The input retrieval and output writing parts
of a chunk step save their current position after the processing of each
chunk, and can recover it when the step is restarted.</p>
</div>
<div class="paragraph">
<p><a href="#BABFJBAH">Figure 58-1</a> shows the three parts of two steps in a
batch job.</p>
</div>
<div class="paragraph">
<div class="title"><strong>Figure 58-1 Chunk Steps in a Batch Job</strong></div>
<p><span class="image"><img src="img/javaeett_dt_058.png" alt="This figure shows a batch job that contains two chunk steps: step A and step B. Step A has the three parts of a chunk-oriented step: input retrieval A, business processing A, and output writing A. Step B also has the three parts of a chunk-oriented step: input retrieval B, business processing B, and output writing B."></span></p>
</div>
</li>
</ul>
</div>
</li>
</ul>
</div>
<div class="paragraph">
<p>For example, the phone billing application consists of two chunk steps.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>In the first step, the input retrieval part reads call records from
the registry; the business processing part associates each call with a
bill and creates a bill if one does not exist for an account; and the
output writing part stores each bill in a database.</p>
</li>
<li>
<p>In the second step, the input retrieval part reads bills from the
database; the business processing part calculates the tax and total
amount due for each bill; and the output writing part updates the
database records and generates printable versions of each bill.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>This application could also contain a task step that cleaned up the
files from the bills generated for the previous month.</p>
</div>
<div class="paragraph">
<p><a id="sthref263"></a><a id="parallel-processing"></a></p>
</div>
</div>
<div class="sect2">
<h3 id="_parallel_processing">Parallel Processing</h3>
<div class="paragraph">
<p>Batch jobs often process large amounts of data or perform
computationally expensive operations. Batch applications can benefit
from parallel processing in two scenarios.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Steps that do not depend on each other can run on different threads.</p>
</li>
<li>
<p>Chunk-oriented steps where the processing of each item does not depend
on the results of processing previous items can run on more than one
thread.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Batch frameworks provide mechanisms for developers to define groups of
independent steps and to split chunk-oriented steps in parts that can
run in parallel.</p>
</div>
<div class="paragraph">
<p><a id="sthref264"></a><a id="status-and-decision-elements"></a></p>
</div>
</div>
<div class="sect2">
<h3 id="_status_and_decision_elements">Status and Decision Elements</h3>
<div class="paragraph">
<p>Batch frameworks keep track of a status for every step in a job. The
status indicates if a step is running or if it has completed. If the
step has completed, the status indicates one of the following.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>The execution of the step was successful.</p>
</li>
<li>
<p>The step was interrupted.</p>
</li>
<li>
<p>An error occurred in the execution of the step.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>In addition to steps, batch jobs can also contain decision elements.
Decision elements use the exit status of the previous step to determine
the next step or to terminate the batch job. Decision elements set the
status of the batch job when terminating it. Like a step, a batch job
can terminate successfully, be interrupted, or fail.</p>
</div>
<div class="paragraph">
<p><a href="#BCGDCDCA">Figure 58-2</a> shows an example of a job that contains
chunk steps, task steps and a decision element.</p>
</div>
<div id="BCGDCDCA" class="paragraph">
<div class="title"><strong>Figure 58-2 Steps and Decision Elements in a Job</strong></div>
<p><span class="image"><img src="img/javaeett_dt_059.png" alt="This figure shows a batch job that contains two chunk steps, a task step and a decision element. The job starts with chunk step A, continues with chunk step B, and then decision element D evaluates condition 1. The condition is based on the status of step B. If condition 1 is true, the job terminates; otherwise the job continues with step C and then the job ends."></span></p>
</div>
<div class="paragraph">
<p><a id="sthref266"></a><a id="batch-framework-functionality"></a></p>
</div>
</div>
<div class="sect2">
<h3 id="_batch_framework_functionality">Batch Framework Functionality</h3>
<div class="paragraph">
<p>Batch applications have the following common requirements.</p>
</div>
<div class="ulist">
<ul>
<li>
<p>Define jobs, steps, decision elements, and the relationships between
them.</p>
</li>
<li>
<p>Execute some groups of steps or parts of a step in parallel.</p>
</li>
<li>
<p>Maintain state information for jobs and steps.</p>
</li>
<li>
<p>Launch jobs and resume interrupted jobs.</p>
</li>
<li>
<p>Handle errors.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>Batch frameworks provide the batch execution infrastructure that
addresses the common requirements of all batch applications, enabling
developers to concentrate on the business logic of their applications.
Batch frameworks consist of a format to specify jobs and steps, an
application programming interface (API), and a service available at
runtime that manages the execution of batch jobs.</p>
</div>
</div>
</div>
</div>
<hr />
<table width="90%" id="bottom-nav" cellspacing="0" cellpadding="0">
<colgroup>
<col width="12%"/>
<col width="12%"/>
<col width="*"/>
</colgroup>
<tr>
<td align="left">
<a href="batch-processing.html">
<span class=" vector-font"><i class="fa fa-arrow-circle-left" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Previous</span>
</a>
</td>
<td align="left">
<a href="batch-processing002.html">
<span class="vector-font"><i class="fa fa-arrow-circle-right vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Next</span>
</a>
</td>
<td align="right">
<a href="toc.html">
<span class="vector-font"><i class="fa fa-list vector-font" aria-hidden="true"></i></span>
<span style="position:relative;top:-2px;">Contents</span>
</a>
</td>
</tr>
</table>
<span id="copyright">
<a href="img/cpyr.adoc">
<img src="img/oracle.gif" height="10px" alt="Oracle Logo" />
<span>Copyright © 2017, Oracle and/or its affiliates. All rights reserved.</span>
</a>
</span>
<!--<p align="center" class="beta">Beta Draft (Pre-General Availability)</p> -->
</body>
</html>