Batch JCL
Batch JCL
ibm.com/redbooks
Christian Strauer
Sridhar Sudarsan
Susann Thomas
Andreas Wagner
Janet Wall
SG24-7779-01
Note: Before using this information and the product it supports, read the information in Notices on
page ix.
Copyright International Business Machines Corporation 2009, 2012. All rights reserved.
Note to U.S. Government Users Restricted Rights -- Use, duplication or disclosure restricted by GSA ADP Schedule
Contract with IBM Corp.
Contents
Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix
Trademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .x
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
The team who wrote this book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
Now you can become a published author, too! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiv
Comments welcome. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Stay connected to IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Summary of changes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
July 2012, Second Edition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Chapter 1. Executive overview of batch modernization on z/OS . . . . . . . . . . . . . . . . . .
1.1 Do you still need batch? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.2 Is replacing batch with OLTP an option? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.3 Strengths of z/OS for batch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.4 Batch modernization on z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 New technologies can help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1.6 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
1
2
2
3
4
5
6
19
20
20
21
22
22
23
iii
24
25
26
27
28
33
34
36
36
38
39
39
41
45
47
47
49
50
51
52
54
54
55
55
56
57
58
58
58
60
60
64
64
65
67
77
78
79
80
80
82
83
84
iv
157
158
160
160
161
162
164
168
177
178
178
180
181
181
183
185
185
189
190
191
193
200
207
209
210
210
211
212
212
212
Contents
13.3.1
13.3.2
13.3.3
13.3.4
213
218
219
221
223
224
225
234
234
235
240
242
249
263
263
266
270
270
279
vi
301
302
302
303
304
304
305
305
305
305
306
306
306
306
309
310
312
313
313
314
314
314
314
319
320
324
325
337
338
338
338
339
339
341
342
343
344
344
344
345
345
346
346
348
351
351
352
352
352
352
353
354
357
360
360
364
365
367
370
Chapter 21. Reduce batch complexity using middleware for transformation logic .
21.1 WebSphere Transformation Extender: Enabling universal transformation . . . . . . . .
21.2 Business value of WebSphere Transformation Extender . . . . . . . . . . . . . . . . . . . . .
21.3 Sample using WebSphere Transformation Extender in z/OS batch . . . . . . . . . . . . .
21.3.1 Creating the mapping file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.2 Transferring files to z/OS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
21.3.3 Running the job on z/OS to transform input data . . . . . . . . . . . . . . . . . . . . . . .
371
373
374
375
377
393
394
Chapter 22. Reduce batch complexity by eliminating custom file transfer logic . . .
22.1 Using WebSphere MQ FTE to perform managed file transfers. . . . . . . . . . . . . . . . .
22.2 Initiating file transfer using a Java job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.3 Initiating file transfer using an Ant job . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22.4 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
397
398
401
403
404
vii
406
406
406
407
408
409
410
410
411
412
414
416
417
417
423
424
424
426
429
430
437
442
445
448
450
453
453
453
454
454
Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
IBM Redbooks publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Other publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Online resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
How to get IBM Redbooks publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Help from IBM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
455
455
455
456
457
457
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 459
viii
Notices
This information was developed for products and services offered in the U.S.A.
IBM may not offer the products, services, or features discussed in this document in other countries. Consult
your local IBM representative for information on the products and services currently available in your area. Any
reference to an IBM product, program, or service is not intended to state or imply that only that IBM product,
program, or service may be used. Any functionally equivalent product, program, or service that does not
infringe any IBM intellectual property right may be used instead. However, it is the user's responsibility to
evaluate and verify the operation of any non-IBM product, program, or service.
IBM may have patents or pending patent applications covering subject matter described in this document. The
furnishing of this document does not give you any license to these patents. You can send license inquiries, in
writing, to:
IBM Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY 10504-1785 U.S.A.
The following paragraph does not apply to the United Kingdom or any other country where such
provisions are inconsistent with local law: INTERNATIONAL BUSINESS MACHINES CORPORATION
PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states do not allow disclaimer of
express or implied warranties in certain transactions, therefore, this statement may not apply to you.
This information could include technical inaccuracies or typographical errors. Changes are periodically made
to the information herein; these changes will be incorporated in new editions of the publication. IBM may make
improvements and/or changes in the product(s) and/or the program(s) described in this publication at any time
without notice.
Any references in this information to non-IBM Web sites are provided for convenience only and do not in any
manner serve as an endorsement of those Web sites. The materials at those Web sites are not part of the
materials for this IBM product and use of those Web sites is at your own risk.
IBM may use or distribute any of the information you supply in any way it believes appropriate without incurring
any obligation to you.
Information concerning non-IBM products was obtained from the suppliers of those products, their published
announcements or other publicly available sources. IBM has not tested those products and cannot confirm the
accuracy of performance, compatibility or any other claims related to non-IBM products. Questions on the
capabilities of non-IBM products should be addressed to the suppliers of those products.
This information contains examples of data and reports used in daily business operations. To illustrate them
as completely as possible, the examples include the names of individuals, companies, brands, and products.
All of these names are fictitious and any similarity to the names and addresses used by an actual business
enterprise is entirely coincidental.
COPYRIGHT LICENSE:
This information contains sample application programs in source language, which illustrate programming
techniques on various operating platforms. You may copy, modify, and distribute these sample programs in
any form without payment to IBM, for the purposes of developing, using, marketing or distributing application
programs conforming to the application programming interface for the operating platform for which the sample
programs are written. These examples have not been thoroughly tested under all conditions. IBM, therefore,
cannot guarantee or imply reliability, serviceability, or function of these programs.
ix
Trademarks
IBM, the IBM logo, and ibm.com are trademarks or registered trademarks of International Business Machines
Corporation in the United States, other countries, or both. These and other IBM trademarked terms are
marked on their first occurrence in this information with the appropriate symbol ( or ), indicating US
registered or common law trademarks owned by IBM at the time this information was published. Such
trademarks may also be registered or common law trademarks in other countries. A current list of IBM
trademarks is available on the Web at http://www.ibm.com/legal/copytrade.shtml
The following terms are trademarks of the International Business Machines Corporation in the United States,
other countries, or both:
AIX
BatchPipes
CICS
DataMirror
DataPower
DataStage
DB2
developerWorks
DRDA
DS8000
FICON
GDPS
QualityStage
RACF
Rational
Redbooks
Redbooks (logo)
RMF
System z10
System z
Tivoli
WebSphere
z/OS
z10
zSeries
Preface
Mainframe computers play a central role in the daily operations of many of the worlds largest
corporations, and batch processing is a fundamental part of the workloads that run on the
mainframe. A large portion of the workload on IBM z/OS systems is processed in batch
mode. Although several IBM Redbooks publications discuss application modernization on
the IBM z/OS platform, this book specifically addresses batch processing in detail.
Many different technologies are available in a batch environment on z/OS systems. This book
demonstrates these technologies and shows how the z/OS system offers a sophisticated
environment for batch. In this practical book, we discuss a variety of themes that are of
importance for batch workloads on z/OS systems and offer examples that you can try on your
own system. The book also includes a chapter on future developments in batch processing.
The audience for this book includes IT architects and application developers, with a focus on
batch processing on the z/OS platform.
xi
computing. He earned a BS in computer science from Purdue University and will complete his
MS in computer science from Rensselaer Polytechnic Institute (RPI) in Troy, NY with a thesis
in the area of quantifying and improving the resiliency of middleware infrastructures.
Patrick Bruinsma is a certified Senior IT Specialist with 10 years of advanced experience on
z/OS, OS/390, DB2, MQ Series, WebSphere MQ Workflow, Blaze Advisor, CICS,
Workload Manager, Java, WebSphere Application Server for z/OS, z/OS UNIX (UNIX System
Services), and SAP on z/OS, as well as general installation and implementation expertise on
nearly all z/OS software. He is proficient in teaching technical education and has co-authored
several IBM Redbooks publications. In January 2007, Patrick was appointed System z
Software IT Architect. For the last 4 years, he has focused on the design and integration of
large-scale commercial computing environments, mainly in the mainframe computing arena.
He supports the System z sales team and provides expertise on platform positioning and
solution design.
Manuel Mueller is an IT Specialist with IBM Software Group Services. He joined IBM in 2003
as a member of the IMS Technical Sales team. His work centers on integration techniques
of mainframe data and applications into a heterogenous landscape. He has authored an IBM
Redbooks publication about WebSphere Information Integrator and has taught several
workshops on System z, covering Data Propagation and Information Integration of IMS, DB2,
VSAM, and others. After he joined the Software Group IM Services team, he worked on a
variety of projects that are all clustered around data storage in databases and data intensive
applications. This work includes the acquaintance with several products, most prominent
among which are z/OS, UNIX, IMS, DB2, and SAP. He has a BS in Information Technology
Management from the University of Cooperative Education (Berufsakademie) Stuttgart,
Germany, and the Open University London, U.K., in a partnership program with IBM.
Martin Packer is a Senior IT Specialist working for IBM in the U.K. and Ireland. He has 24
years of mainframe performance experience, having consulted with dozens of customers in
that time. He has contributed to a large number of IBM Redbooks publications over the past
20 years, has presented at many conferences, and has built a number of tools for processing
mainframe performance instrumentation, most notably in the areas of batch window
reduction, Parallel Sysplex Performance, and DB2 Tuning. He holds a Bachelors Degree in
Math and Physics and a Masters Degree in Information Technology, both from the University
College in London.
Christian Strauer is an IT specialist from IBM Germany. He works as a System z technical
presales specialist in the Financial Services and Insurance sector. His areas of expertise are
Java, Java batch, and XML solutions on System z as well as System z capacity planning. He
has worked for IBM since 2002, when he started his studies at the University of Cooperative
Education in Mannheim. After his studies, Christian joined the System z Field Technical Sales
Support team in 2005 and was involved in many Java and XML projects on z/OS throughout
Germany. Christian has authored an IBM Redbooks publication about Java Batch on z/OS.
He holds a diploma in Applied Computer Sciences.
Sridhar Sudarsan is an Executive IT Architect with Software Lab Services in IBM. He has led
enterprise architecture solutions for several customers worldwide for over 10 years. His
clients include large companies in the finance, public sector, automobile, and SRM industry
verticals. He has consulted with customers to build and realize their IT strategy. He invented
the batch programming model in J2EE, now included in WebSphere Compute Grid. He
champions and leads the enterprise batch modernization and modern bulk processing
strategy in IBM and at customers.
Susann Thomas is an IT specialist at IBM Research and Development in Boeblingen,
Germany, and specializes in modern technologies such as WebSphere solutions on z/OS.
She works as a lab services specialist for Worldwide Technology Practice in the IBM Software
xii
Preface
xiii
Willie Favero
Data Warehouse for System z Swat Team, DB2 SME, IBM Silicon Valley Laboratory, IBM
Software Group, USA
Denis Gaebler
IT Specialist, IBM Software Group, Germany
Timothy Hahn
IBM Distinguished Engineer, IBM Software Group, Rational
Avard Hart
System z Solution Architect, IBM USA
Eugene Kuehlthau
IT Specialist, Advanced Technical Support (ATS), USA
Patricia Pettersson
WebSphere Technical Sales, IBM Software Group, Sweden
Gary Puchkoff
Senior Technical Staff Member, IBM Systems and Technology Group. System z Strategy and
Architecture, Poughkeepsie, USA
Chris Vignola
Senior Technical Staff Member, WebSphere XD Architect, Java Batch & Compute Grid, IBM
Software Group, Poughkeepsie, USA
Maryela Weihrauch
IBM Distinguished Engineer, DB2 z/OS Development - Solutions Architect, IBM Silicon Valley
Lab, USA
Kirk Wolf and Steve Goetze
Dovetailed Technologies, LLC
Claus Weidenfeller
GAD, Germany
Frank Yaeger
DFSORT Development Team, IBM Silicon Valley Lab, USA
xiv
Comments welcome
Your comments are important to us!
We want our books to be as helpful as possible. Send us your comments about this book or
other IBM Redbooks publications in one of the following ways:
Use the online Contact us review Redbooks form found at:
ibm.com/redbooks
Send your comments in an email to:
[email protected]
Mail your comments to:
IBM Corporation, International Technical Support Organization
Dept. HYTD Mail Station P099
2455 South Road
Poughkeepsie, NY 12601-5400
Preface
xv
xvi
Summary of changes
This section describes the technical changes made in this edition of the book and in previous
editions. This edition might also include minor corrections and editorial changes that are not
identified.
Summary of Changes
for SG24-7779-01
for Batch Modernization on z/OS
as created or updated on July 26, 2012.
New information
Added Chapter 11, Batch environment enhancements in z/OS V1R13 on page 177
xvii
xviii
Chapter 1.
Batch processing has significant advantages when it comes to performing repetitive logic.
Static data is read only once, then cached and used throughout the program. Also, for
example, one SQL query to update a status field in 10,000 rows of a database table is far
more efficient than 10,000 online transaction processing (OLTP) programs, each running a
query to update the status field in one row at a time.
Thus, batch processing in the sense of bulk processing of massive amounts of transactions
during non-office hours remains a viable and strategic option. Because organizations want
results faster without waiting for overnight OLTP processing, we will the need to run batch
processes at any time during the day, in parallel with the OLTP window.
It might look like the ideal IT environment consists of OLTP only, where each user action
immediately leads to making all the updates without delay and where a user immediately
receives the desired output. However, there are many functions in an information system that
cannot and should not be designed and run as an OLTP function. Therefore, the design for an
information system needs to identify clearly the functions that are implemented as a batch
function.
Note: Java development of z/OS applications can be done entirely on the workstation
using Eclipse or IBM Rational tools. In the case of Java stand-alone batch, a basic
understanding of JCL, TSO, ISPF, and UNIX is needed to set up the runtime
environment and test on z/OS.
In the case of the WebSphere XD Compute Grid programming model, the developer
does not need to work with JCL, TSO, and ISPF to deploy and test batch programs.
The batch window needs to be shortened or made more efficient.
An indirect reason for modernizing the batch environment might be that the traditional
batch window is getting shorter (because the OLTP window is getting longer).
Performance optimization, increased parallelism, and moving certain batch processes into
the OLTP window are options to achieve a shorter batch window. These activities might
require that you deploy new technologies.
You want to run batch at any time.
As already mentioned, just because the current batch window is getting shorter, the batch
workload itself is not reduced, leading to the consideration of running a batch job either in
the traditional nightly batch window or at any time during the OLTP window. Introducing
batch processes during the OLTP window might impose some challenges, especially with
regards to accessing data concurrently.
Maintaining the actual batch programs is too complex.
The number and complexity of batch programs might lead to a situation where it takes too
much time to implement new business requirements, especially in the case where batch
programs contain numerous lines of code for formatting and transforming data.
State-of-the-art tooling and middleware can help to make the process of maintaining
complex batch applications more agile and less error prone.
1.6 Conclusion
z/OS is a natural operating system for running large mission-critical batch workloads in a
reliable way. Disaster recovery, automatic restart of broken jobs, automatic rollback of
database updates to the latest sync point are all part of the z/OS solution. Hundreds of
Fortune 1000 companies run mission-critical batch on z/OS. With the introduction of Java and
Java-based middleware on z/OS, this quality can be put into action for a broader set of
functional requirements and other technologies can help to reduce complexity or reduce the
traditional batch window.
Part 1
Part
Overview of batch
processing
In this part of the book, we provide an introduction to batch processing and batch processing
modernization in Chapter 2, Introduction to batch modernization on z/OS on page 9. We
also position a framework for batch bulk processing in Chapter 3, Bulk processing reference
architecture on page 19.
Chapter 2.
Introduction to batch
modernization on z/OS
Today, mainframe computers play a central role in the daily operations of many of the worlds
largest corporations. While other forms of computing are used extensively in various business
capacities, the mainframe occupies a coveted place in todays e-business environment. In
banking, finance, health care, insurance, public utilities, government, and a multitude of other
public and private enterprises, the mainframe computer continues to form the foundation of
modern business.
For almost all companies in every industry, batch processing is still a fundamental,
mission-critical component. In this book, we describe aspects of modern batch processing
and point out why it might be necessary to change the current batch process to achieve
modern business requirements.
In this chapter, we introduce the concept of batch modernization and discuss the following
topics:
Differences between OLTP and batch processing
Taking advantage of z/OS features for batch processing
Drivers for change
Batch workload
Application
program
Input
data
Output
data
Processes data to
perform a particular task
Query
Reply
Application
program
Accesses shared data on
behalf of an online user
10
Generally, one batch program generates output data that then is used as input by another
batch program. Because of this type of dependency, a network of batch jobs can grow and
become quite complex very quickly. Appropriate tools, such as Tivoli Workload Scheduler,
help when executing and monitoring batch programs within a large job network.
In large IT environments, batch jobs usually run overnight. During this batch window, online
activity is restricted or even completely forbidden. Because the online capability is extremely
relevant for almost all companies, the batch window must end as soon as possible or at least
before the committed start time of the OLTP window. The start and times of the batch window
(which can be different on different days of the week or month) are specified in the
service-level agreement (SLA), which also includes additional information regarding
management of errors, recovery, and so forth.
Important: The batch window can vary greatly depending on the day of the week or
month. For example, most companies have different job networks on weekdays, weekends,
the last workday of the week, and the last day of the month. End of week and end of month
processing can make a job network significant more complex and longer to run. These
factors are all included in the SLA.
Examples of batch activities include:
11
12
2.2.2 Security
z/OS provides deep security integration, from the application level down to the operating
system level and the hardware.
Centralized security
The Resource Access Control Facility (RACF) provides centralized security functions, such
as user identification and authentication, resource access control, and auditing for both the
operating system and applications running on the system.
With the introduction of the System Authorization Facility suite of services, a centralized point
was created within the operating system infrastructure through which both operating system
components and applications could invoke the services of the z/OS resident security
manager.
Accountability
Accountability in z/OS is achieved by a combination of user authentication and the ability to
propagate a users credentials throughout the application. The System Management Facility
(SMF) interface is designed for collecting performance and accounting information. z/OS will
collect all accounting and performance data and present this back to the installation through
RMF and SMF records. These records can be analyzed and aggregated in performance and
capacity reports, but can also be used as a base for security analysis and accounting policies.
Network security
Networking and communications security on z/OS is provided by the Communications Server
element of z/OS. The Communications Server provides networking and communication
services for accessing z/OS applications over both SNA and TCP/IP networks. You can
exploit these features using batch. Thus, batch can be run very secure on z/OS.
2.2.3 Manageability
The z/OS operating system is designed to manage multiple workloads in a single system
image, providing the means to manage complex environments. As a consequence, z/OS is
equipped with an extensive set of management tools to manage and control thousands of
complex, simultaneously running applications, comprised of batch and online components,
databases, transaction managers, and so on.
13
Distributor to load-balance workloads throughout the systems in the sysplex and make the
network entry point into the system highly available.
These capabilities make the mainframe an ideal platform for running mixed workloads of
hundreds of different business-critical applications while achieving very high resource
utilization. Of course, batch workloads are also managed by WLM. Thus, it is possible to run
hundreds of parallel batch jobs at the same time, which is very difficult on other platforms.
2.2.5 Reliability
System z and z/OS provide an advanced combination of availability and resilience. The
combination of redundancy and virtualization delivers extraordinary levels of application
availability and recoverability. The IBM mainframe architecture protects users from hardware
failures as well as software failures. If an application fails, its workload can be picked up by a
backup of the same application running on the same physical hardware.
Mainframe workloads can be shared by systems running up to 100 km apart, allowing for
smooth disaster recovery procedures. And when the time comes to add system capacity or to
replace a failed hardware module, those hardware changes can be made without interrupting
customer service. Some mainframes run uninterrupted for years, adapting to changing needs,
workloads, and applications while continuously in production. Because batch can be very
critical, the reliability of the mainframe is a big advantage.
2.2.6 Scalability
The z/OS Parallel Sysplex configuration provides additional horizontal scalability. A sysplex
can be a cluster of up to 32 z/OS images in different partitions on different System z systems
(that are possibly geographically dispersed) with full data sharing and high availability and
recovery.
The machines participating in a Parallel Sysplex can be physically dispersed up to 100 km
from one another, which gives the capability of having a physically decentralized
infrastructure that is logically centralized.
With z/OS, the horizontal scalability is not limited to specific workloads. Any workload can
take advantage of the Parallel Sysplex scaling options. Scalability is fundamental in an
on-demand world, and the IT infrastructure should be able to scale when business demands
more resources.
Another key performance and scalability benefit is provided by the HiperSockets virtual
TCP/IP network, which eliminates network delays between applications and subsystems
running within a mainframe.
2.2.7 Availability
System z has many components that address availability.
Parallel Sysplex, the clustering solution for the z/OS environment, provides both scalability
and availability. A failure of one image in the cluster does not affect the other images, and any
specific transaction running on the Parallel Sysplex can be fully dispatched and recovered in
any other image, making use of the full data sharing architecture.
For higher availability and disaster recovery purposes, a Parallel Sysplex can be configured in
a Geographically Dispersed Parallel Sysplex (GDPS) mode.
14
15
Even if the existing batch process is implemented optimally in terms of performance, process
controlling, and monitoring, there could still be requirements that might lead to deploying new
tools, processes, and technologies.
In the following sections, we discuss the key drivers for change in a batch environment on
z/OS. In the remainder of the book, we continue to work with these themes.
Sending e-mails
The ability to send e-mails has become quite a common requirement in modern applications,
for example using an e-mail confirmation for notification that a payment is processed.
Although you can accomplish this requirement using a traditional programming language, it is
quite complicated. Again, for a language such as Java, this requirement is easy to implement.
Processing XML
Because of its flexibility in data structure, XML is very suitable for exchanging any kind of
data. In fact, XML has established itself as a new standard for data exchange. For example,
with DB2 V9, you can store XML data natively in DB2 databases, allowing a user to query
data using XML Query Language (XQuery). Also, other mainframe components have
expanded regarding XML capabilities, including extensions to traditional languages
(Enterprise COBOL and Enterprise PL/I) and the system environment (XML System
Services).
Although you can now process XML data with traditional languages, this method is not always
recommended because of some limitations. However, because XML is also very important for
batch, it is best to evaluate the different options, including XML in all different languages, from
COBOL and PL/I using C/C++ to Java.
16
Today, new standards are also developed on distributed platforms and become available on
the mainframe through new types of middleware, such as Business Process Execution
Language (BPEL), Web Services, and Web 2.0. In some cases, these new standards do not
make it into traditional programming languages on z/OS.
2.3.2 Necessary skills to maintain and use the current technology are
no longer available
A growing problem for many companies is that skills in traditional technologies are more
difficult to find. New employees might not have knowledge of traditional mainframe
technologies because their education normally is not mainframe minded. Typical mainframe
skills include:
To work with a traditional batch environment on z/OS, a basic, although extensive, training is
required. Also, it takes time to really become a professional. Using new standards and
programming languages can soften the training requirement significantly, especially when
WebSphere middleware and a Java batch programming model is used for batch programs. In
this case, there is no need to have JCL, TSO, ISPF, and COBOL skills.
Note: Java development of z/OS applications can be done entirely on the workstation
using Eclipse or IBM Rational tools. In the case of Java stand-alone batch, a basic
understanding of JCL, TSO, ISPF, and UNIX is needed to set up the runtime environment
and to test on z/OS.
In the case of the WebSphere XD Compute Grid programming model, the developer does
not need to work with JCL, TSO, and ISPF to deploy and test batch programs.
17
18
Chapter 3.
19
3.2 Overview
The bulk processing reference architecture provides a blueprint for various kinds of batch
processing that apply to a single application or across an enterprise. This architecture is
based on the proven way of establishing building blocks of bulk processing, with a partially
layered architecture using services and components and data flows that represent and
implement bulk business processes. An architecture built using relationships between layers
can help design bulk processes in the context of any architecture, which is a significant step
towards making batch processing a first class workload. This architecture enables bulk
business processes to be modeled as they should be, as bulk IT processes and services, to
gain the economies of scale in execution. Using a reference architecture for bulk processing
aligns with modern trends in computing, such as service-oriented architecture (SOA) design
techniques, which help address the declining skills issues that we describe in 2.3.2,
Necessary skills to maintain and use the current technology are no longer available on
page 17.
The major capability that the bulk processing solution stack offers is reuse of existing assets.
There are a large number of existing batch applications that are written in various
programming languages and that run on mainframe platforms that can and should be reused.
As business and IT transformation roadmaps are created and executed, in the initial stages,
re-use is critical to minimize down time and to understand the approaches to re-engineer
assets for the next several years.
20
The bulk processing reference model is an extensible and flexible architecture blueprint that
provides:
Reduced IT cost, which allows reuse of business and application artifacts (design,
implementation, and system management) throughout OLTP and batch systems.
The capability to take advantage current, highly available IT skills to design, implement,
and manage bulk applications using modern programming languages and techniques.
Optimized and efficient execution to run bulk applications on heterogeneous platforms and
to take advantage of the platform capabilities.
Flexibility in the design of bulk processes based on business requirements that can be
interleaved with OLTP processes to take advantage of technology rather than being
constrained by it.
Agility to deliver applications align to business needs quicker and with lower overhead.
Layers allow a clear separation of concerns to facilitate the design of bulk processes. The
bulk processing reference model defines a blueprint that can be used to then define the
layers, the components within each layer, the options available at each layer, and the typical
architectural decisions that need to be made.
Bulk
application
development
Infrastructure services
System
management
and
operations
Data access
management services
Analytics
The Layers architectural pattern helps to structure applications that can be decomposed into groups of subtasks in
which each group of subtasks is at a particular level of abstraction. See Buschmann, F., R. Meunier, H. Rohnert, P.
Sommerlad, and M. Stal. Pattern-Oriented Software Architecture: A System Of Patterns. West Sussex, England:
John Wiley & Sons Ltd., 1996.
21
Sometimes, the concepts of layers and tiers are often used interchangeably. However, the
important difference to note here is that a layer is a logical structuring mechanism for the
elements that make up the software solution, whereas a tier is a physical structuring
mechanism for the system infrastructure. In this section, we discuss only the logical
structuring of the software solution elements.
All bulk applications are likely to have some manifestation of each of these layers in the
implementation; however, they are not mandatory in the design. While each of the layers have
a key role to play, the level of importance in a given solution can be different. The components
might also differ based on a number of factors, including business and IT key performance
indicators (KPI), existing applications and infrastructure, as well as time and budget
constraints.
The core of the execution environment for running batch applications is in the center that
comprises the Invocation and scheduling services, bulk application container, data access
management services, and Infrastructure services. The surrounding layersbulk application
development, system management, and operations and analyticsare used to develop,
manage, and optimize bulk applications and apply throughout the life cycle.
In the following sections, we look at each of these layers in detail and discuss the relationship
between them.
Queue based
data access
In-m em ory
data access
Custo m d ata
access
The In-memory data access in the figure represents either an in-memory database (IMDB)
or an in-memory data grid (IMDG). With performance and throughput being paramount to
completing jobs before a deadline, topologies using IMDB or IMDG are attractive. There are
specific decision factors that go into selecting one or the other:
An IMDB has more flexibility in storing the data in a normalized form and better querying
capabilities.
An IMDG tends to be more programming language based (for example WebSphere
eXtreme Scale has a POJO-based framework) and provides more scalability. A
programming language based framework can be used to store:
In-memory transient referential data that is used to process all records
In-memory chunks of input stream records to avoid an I/O for every record
In-memory chunks of output stream records before flushing them to an output I/O
stream
Data can also be read from or written to queues. The queues can represent an input stream
of data that is processed by the container. It also represents messages being put in queues
for further consumption downstream after the unit of work processes records.
These are the most commonly used data access forms that are in play in the majority of the
batch jobs. There might be some custom data access patterns in use, because of a more
complex assortment of data from multiple data sources, or due to other interoperability
reasons. These data access mechanisms should be used cautiously in green-field application
developments weighing trade-offs between maintenance and upkeep costs with the flexibility
that it provides.
All data access management services need to be highly optimized because there is a
potential to invoke a service at least once for every record that is processed in bulk
applications. Given volumes that are typically processed in batch jobs, this processing can
affect throughput significantly.
23
checkpoint, if required;
loopend
clean up job step and data streams;
A checkpoint is one of the key distinguishing features of bulk jobs from OLTP applications, in
that data gets committed in chunks, along with other required housekeeping to maintain
recovery information for restarting jobs. An extreme example is doing a checkpoint after every
record, which equates to how OLTP applications typically work. At the other extreme is doing
a checkpoint at the end of the job step, which might not be feasible in most cases, because
recoveries can be expensive and too many locks can be held in the database for too much
time. It is generally somewhere between these two extremes. The checkpoint interval can
vary depending on a number of factors, such as whether jobs are run concurrently with OLTP
applications, how long locks can be held, the amount of hardware resources available, SLAs
to be met, time available to meet deadlines, and so forth. Depending on the technology used,
there are static ways of setting these checkpoint intervals, but ideally checkpoint intervals can
be set dynamically as well.
What differentiates containers is the quality of services, including but not limited to:
Ad ho c
Bulk Partner
services
Invocation services
Bu siness p rocess
and event services
Plan ned
Scheduler
services
Planned jobs are set to be invoked based on pre-determined criteria, for example calendar
date, time of the day, or completion of prior jobs based on a network of job flows defined. In
the early days of computing, planned jobs were the only way jobs were invoked, and batch
jobs ran when OLTP systems shut down or at night after provisioning dedicated resources to
execute batch jobs. Planned jobs are in vogue in many enterprises today and, in many cases,
make business sense, because there are deadlines to meet as set by regulatory boards or
customers. Planned jobs provide more control to allocate resources for the workload type.
Arguably, in some cases, problem determination is easier. A good example of a planned job is
sending inventory status updates to the retail headquarters from a store done twice a day, at
noon and midnight.
24
Ad hoc jobs are invoked because of a triggered event or rule and can run at any time. For
example, if business partners send files of data that need to be processed, a job can be
triggered to start after every n files are available, where n is a set number of files. Using the
same retail inventory status update example, an ad hoc trigger rule can be set to start the
status update job when 30% of the items are at 60% of original. Using ad hoc rules is better
aligned with a direct business need, provides flexibility, and is a first step in running data
processing when needed so that the customer gets near real-time access to information.
Combining the planned and ad hoc jobs is fairly normal and takes advantage of the strengths
of both. The complexity is shifted to designing the applications and resource provisioning. In
Chapter 14, Create agile batch by implementing trigger mechanisms on page 223, we
discuss in more detail different methods to trigger ad hoc batch jobs.
jo b
Executing
Client
Interaction
init
iat
ed
status
Scheduling
job dispatched
o ri ng
m o n it tr o l
& co n
3
2
re so ur ce
as signed
event s &
timers
resource
usage s tatus
Workload
Mgmt
Resource
Broking
Provisionin g Mgm t
Reso urce & Software Pro visioning
Resources: physical, logical, virtual
Software: middleware & applications
Figure 3-4 shows a comprehensive set of steps that are required in the management and
execution of every job:
1. The client first initiates the job, either triggered by an event or at a pre-set schedule.
2. The scheduler then schedules this job.
3. The scheduler queues the job for dispatch and tracking.
This phase analyses the job and the resources available for execution and plans for the
dispatch of the job. In order to plan for the resources, optionally a resource broker can be
Chapter 3. Bulk processing reference architecture
25
used. For example, Tivoli Workload Scheduler uses a resource broker to manage the
assignment of resources to a job, based on availability and capacity determined
dynamically. The resource broker uses services from a resource manager that has the
physical and virtual resource model and its attributes and an overview of the resource
configuration. Tivoli Dynamic Workload Broker provides a number of these capabilities. A
provisioning manager discovers and tracks data center resources to enable more accurate
server provisioning and software deployments. It also facilitates efforts to consistently
follow user defined policies and preferred configurations, in support of corporate and
regulatory compliance efforts. The workload management helps with balancing the
workload across available resources to optimize resource usage. A solution could be built
using all or a subset of these capabilities, depending on cost and complexity of the jobs
that need to be executed and managed.
4. The scheduler then dispatches the job to the execution environment where, upon
completion, the status is sent back to the client.
New Bulk
processing
requirements
Extract model
Create/modify
model
Separate batch
infrast ruct ure logic
from application
logic
Identify a unit of
work t o be run in a
loop
Legacy code
Batch application
development
Bulk applications can be built from scratch as the result of green-field requirements.
Alternatively, as in many cases, they can be the result of an evolutionary migration,
re-engineering or re-designing a project of existing batch applications. Figure 3-5 shows the
approaches that can be followed for development.
Identify reusable
code
Devel op
application
For modernization, the approach is based on a guiding principle: Do not perform code
translations without doing a proper due diligence. Simply performing a code translation of
batch applications from, say, COBOL to Java without due diligence will probably prove
expensive and unworkable. Moreover, it will produce unreadable, unmaintainable, and
inefficient code. To understand what the platform-independent model for the batch jobs would
be, the business logic and flows need to be abstracted, which will provide a platform
independent model.
26
A combination of manual processes and tools can be used to create these business logic and
data flow artifacts. Doing so ensures that current implementations and future requirements
can be captured more accurately. The platform independent models can then be
implemented in any platform specific model and programming language using a model driven
approach.
For the more green-field requirements for bulk processing, the best practice is to follow a
similar approach of first modeling the solution. The key elements to be identified are the data
streams and the unit of work to be applied to the data in the streams. Identifying partitionable
segments of data helps with optimizing the design and helps to design an efficient
implementation. Depending on the target platform of choice, a number of other elements
specific to each programming model and runtime environment will need to be factored in the
design and implementation.
This development approach does not focus on the deployment and testing aspects of bulk
applications in detail. Common best practices in OLTP applications also apply to bulk
applications deployment and testing.
3.3.7 Analytics
The analytics component applies to every element in the bulk processing reference
architecture. For example, in the invocation optimization component, you want to have insight
into the ability to determine the best target application server for an incoming job request.
This information can be determined by simple algorithms to some very sophisticated
techniques using analytics. Some of the simplest implementations will maintain a table of the
available target servers, and a server is chosen using round robin or randomly. At the other
end of the spectrum of algorithms, you have a self-learning system that determines a target
available server based on historical data of getting the best throughput. This determination
requires collecting and analyzing data from the infrastructure, data, and application
containers over a period of time.
If there are shared resources between OLTP and bulk applications, the workload manager
can make decisions based on business rules that then drive the checkpoint policies. For
example, WLM might determine the following conditions based on predefined SLAs:
A batch job is negatively impacting the OLTP, and OLTP is more important
Dynamically reduce the checkpoint interval for the batch jobs
Dynamically inject pauses between the checkpoint intervals for the batch jobs
The deadline for a particular batch job is approaching, we need to speed it up
Dynamically increase the checkpoint interval for the batch jobs
Dynamically decrease pauses between the checkpoint intervals for the batch jobs
Most of the current systems have some level of analytics built in, which we describe in the
following chapters.
27
Invocation services
Ad ho c
Bulk Partner
services
Plan ned
Bu siness p rocess
and event services
Scheduler
services
Bulk
ap plication
devel opm ent
Environment for
creating and
migrating bulk
applications
System
managem ent
and
o perations
Queue based
data access
In-m em ory
data access
Custo m d ata
access
Manage, monitor
and secure bulk
processes
In fo rmatio n storage
A nal ytics
for scheduling, check-pointing, resour ce management
We use this reference architecture as we describe the various products that enable batch
processing on z/OS in this book. We unfold and dive deeper into each layer using specific
products and capabilities of the products to provide a better understanding of how the layers
all can be used in conjunction to build a solution specific to your bulk processing needs.
28
Figure 3-7 illustrates the products that can be used in each layer. We discuss some of these
products in more detail in the remainder of this book.
Bulk Partner
services
WebSphere ESB
WebSphereMessage
ESB
WebSphere
Broker
WebSphereDatapower
Message Broker
WebSphere
WebSphere Datapower
WebSphere Transf ormation Extender
WebSphereMQ
Tr ansformation Extender
WebSphere
WebSphereMQ
MQFT E
WebSphere
WebSphere MQ FT E
Bulk
ap plication
devel opm ent
Environment for
cr eating
andormation Extender
WebSphere
Transf
WebSphere
Trbulk
ansformation
migrating
WebSphere
Message
Broker Extender
WebSphere Message Broker
F ile Data
WebSphere
MQ FT E
applications
WebSphere
MQ
FT
E
D atastage TX
access
Datastage TX
WebSphere Compute
WebSphere Compute
Grid
Grid
TWS
TWS
T ivoli Workload
Tivoli Workload
scheduler
scheduler
scheduling services
Bu si ness p rocess
and event services
Scheduler
services
WebSpher e Com pute Grid
WebSphere Compute Grid
WebSpher e ESB
WebSphere
ESB
WebSpher
e Message
Broker
WebSphere Message Broker
WebSpher e Datapower
WebSphere
Datapower
WebSpher e Transf ormation Extender
WebSphere
Transformation Extender
WebSpher
e MQ
WebSphere MQ
WebSpher e MQ FT E
WebSphere MQ
FT E
System
managem ent
and
o perations
WebSphere MQ
WebSphere MQ
Custo m d ata
access
Manage, monitor
and secure bulk
processes
29
30
Part 2
Part
31
As shown with these examples, these types of requirements cannot be implemented on z/OS
using traditional batch technologies, such as JCL and COBOL.
Note: What is traditional technology actually? In the context of this book, we identify
traditional technology as technologies that are widely in use on z/OS for batch processing
for decades, such as JCL, MVS data sets, COBOL, PL/I, and Assembler. These
technologies are well proven and provide excellent quality of service but, unfortunately, do
not provide support for all todays requirements. In contrast, modern technologies include
programming languages, frameworks, and middleware that have been added to z/OS over
the past decade, are also well proven, but still not widely in use on z/OS.
In this part of the book, we discuss different new technologies with a focus on supporting new
state-of-the-art requirements. The choice of the programming language is key when it comes
to supporting functional requirements, and we discuss scenarios using traditional
programming languages as well as new programming languages such as Java and PHP.
We also discuss different runtime environments in combination with Java. In addition to using
Java stand-alone in JCL, you can also use Java in a runtime container, such as WebSphere
XD Compute Grid, inside an IMS BMP, or inside a DB2 stored procedure. In all of these,
cases the developer has access to a broader functionality.
We include samples that you can download from the Web site as described in Appendix C,
Additional material on page 453.
We discuss the following technologies in this part:
In Chapter 4, Implement new functionality using traditional languages on page 33, we
discuss the enhanced capabilities of COBOL and PL/I and how to use the XML
capabilities.
In Chapter 5, Introduction to Java on z/OS on page 49, we discuss using the Java
language and follow on with the following chapters that discuss using Java in different
environments:
In Chapter 6, Implement new functionality using Java in traditional containers on
page 57, we discuss traditional runtime environments, including CICS, IMS, and DB2.
In Chapter 7, Implement new functionality using stand-alone Java on page 77, we
discuss stand-alone in JCL.
In Chapter 8, Implement new functionality using Java in WebSphere XD Compute
Grid on page 93, we discuss WebSphere XD Compute Grid.
In Chapter 9, Implement new functionality using PHP on z/OS on page 157, we discuss
PHP in stand-alone batch.
32
Chapter 4.
33
Source
code
Compiler
Object
module
Binder
Load
module
Execution
Figure 4-1 Process flow for an application using a traditional procedural programming language
these strengths. If a given application merits the added complication of writing it in multiple
languages, the designer should take advantage of the particular features of each language.
Keep in mind, however, that when it is time to update the application, multiple skills must be
available. Thus, complexity in design must always be weighed against ease of maintenance.
You might find that your investment in applications written in traditional languages is reaching
its end and that you have many reasons to move to a higher level language such as Java, but
that you are not ready to change all your applications to Java or another modern language.
Remember that COBOL or PL/I, though not todays hottest technology, still offers a very
efficient way to fulfil most enterprise computing requirements, which is operating on data.
Although there seems to be a rush to code everything in Java and other Web-enabled
languages, COBOL or PL/I remain a proven language to handle large volumes of data to be
processed on the mainframe.
Reasons to convert from a lower-level procedural language to a higher-level language
include:
Traditional code can be difficult to maintain because of a shortage of available skills.
Tooling for higher-level languages is more state-of-the-art and more productive.
There is a lack of functionality in lower-level languages.
COBOL and PL/I sometimes have a lack in functionality to serve certain new requirements.
However, in some areas, these languages have advanced significantly and can now be used
for fulfilling the following requirements that were not possible a few years ago:
XML support in COBOL and PL/I
The XML support available in COBOL and PL/I can be used to for certain functionality
requiring the usage of XML, but both COBOL and PL/I have limitations compared to Java.
Also, the syntax of COBOL or PL/I applications draws a lot of energy and attention from
the developer instead of focusing on the thinking process needed for software
development. However, for small and simple applications that only process XML
documents it is not difficult to use the XML support available in COBOL and PL/I.
Interoperability with C/C++
The COBOL and PL/I compilers provide compatibility for calling a C/C++ program, making
it easier to decide to implement enhanced functionality in C/C++ modules and reuse those
modules in COBOL and PL/I programs.
Interoperability with Java
The COBOL and PL/I compilers provide compatibility for integrating traditional programs
with Java components. (See 5.5, Java Interoperability with COBOL and PL/I on page 55
for more detailed information.)
Unicode support
Unicode support for Enterprise COBOL and PL/I also helps to modernize your
applications, particularly the case if your application is used across countries or regions
with different languages. More information is provided in Enterprise COBOL for z/OS
Programming Guide Version 4 Release 1, SC23-8529 and Enterprise PL/I for z/OS
Programming Guide Version 3 Release 8, SC27-1457.
The earlier traditional compilers for z/OS do not take advantage of the System z hardware
advancements. The latest compilers take advantage of the hardware exploitation.
35
36
services parsing is eligible for zAAP. See 4.2.4, Using z/OS XML System Services on
page 39 for more information.
XMLPARSE(COMPAT)
This compiler option selects the XML parser that is built into the COBOL library. This
option provides compatibility with XML parsing in Enterprise COBOL Version 3.
Processing XML input involves passing control to and receiving control from the XML parser.
You start this exchange of control by using the XML PARSE statement, which specifies a
processing procedure that receives control from the XML parser to handle the parser events.
You use special registers in your processing procedure to exchange information with the
parser.
Use the following COBOL facilities to process XML input:
Use the XML PARSE statement to begin XML parsing and to identify the document and
your processing procedure
Use the ENCODING phrase of the XML PARSE statement to specify the encoding of the
XML document
Use your processing procedure to control the parsing, that is to receive and process XML
events and associated document fragments and to return to the parser for continued
processing
Use the following special registers to receive and pass information:
XML-CODE to receive the status of XML parsing and, in some cases, to return
information to the parser
XML-EVENT to receive the name of each XML event from the parser
XML-NTEXT to receive XML document fragments that are returned as national
character data
XML-TEXT to receive document fragments that are returned as alphanumeric data
XML-NAMESPACE or XML-NNAMESPACE to receive a namespace identifier for a
NAMESPACE-DECLARATION XML event or for an element name or attribute name
that is in a namespace
XML-NAMESPACE-PREFIX or XML-NNAMESPACE-PREFIX to receive a namespace
prefix for a NAMESPACE-DECLARATION XML event or for an element name or
attribute name that is prefixed
The XML namespace special registers are undefined outside the processing procedure.
You can use the ENCODING phrase and the RETURNING NATIONAL phrase of the XML
PARSE statement only when the XMLPARSE(XMLSS) compiler option is in effect.
Link-edit considerations: COBOL programs that contain the XMLPARSE statement must
be link-edited with AMODE 31.
37
A namespace prefix to qualify the start and end tag of each element, if you specify a
namespace
A statement to receive control if an exception occurs
Optionally, you can generate an XML declaration for the document and can cause eligible
source data items to be expressed as attributes in the output rather than as elements.
You can use the XML-CODE special register to determine the status of XML generation.
After you transform COBOL data items to XML, you can use the resulting XML output in
various ways, such as deploying it in a Web service, passing it as a message to WebSphere
MQ, or transmitting it for subsequent conversion to a CICS communication area.
Link-edit considerations: COBOL programs that contain the XML GENERATE statement
must be link-edited with AMODE 31.
38
The new PLISAXC built-in subroutine uses the z/OS XML System Services and this workload
is 100% eligible for the zAAP specialty engine. See 4.2.4, Using z/OS XML System Services
on page 39 for more information.
Note: You can find more information regarding XML support in Enterprise PL/I for z/OS
Programming Guide Version 3 Release 8, SC27-1457.
39
is intended for use by system components, middleware, and applications that need a simple,
efficient, XML parsing solution. z/OS XML can currently be accessed by a C/C++ or an
Assembler programming interface. The z/OS XML parser includes the following specifications
and functions:
Is written in Assembler language.
Is an integrated parser for z/OS and a non-Java environment.
Provides a buffer-in, buffer-out processing model instead of the event-driven model that is
common to SAX parsers.
Natively handles a number of character encodings, including UTF-8, UTF-16 (big endian),
IBM-1047, and IBM-037.
Uses buffer spanning to handle documents of unbounded length.
Contains minimal linkage overhead.
Provides the ability for parsing operations to be run 100% on a System z Application
Assist Processor (zAAP) when called in TCB mode or a System z10 Integrated
Information Processor (zIIP) when called in SRB mode, for example DRDA mode.
Provides assistive aids to the user in debugging not well formed documents.
z/OS XML is an integrated component of the z/OS base, so no additional installation is
required. This integration also makes z/OS XML a high-performance parser, supporting z/OS
environments where minimum overhead is a priority, such as SRB and cross-memory modes.
The interface itself is simple and efficient, consisting of five Assembler-level callable services
that avoid event-driven interface overhead. z/OS XML parses its XML documents to a
self-defining binary form that is easy to navigate all while complying with the World Wide Web
Consortiums XML specifications.
z/OS XML, like most XML parsers, can parse and check the syntax of an entire XML
document. z/OS XML rises above other parsers, however, with its ability to parse incomplete
documents as part of a series of fragments that make up an entire XML document. This ability
saves on storage overhead when dealing with large XML documents that could be hundreds
of megabytes in size. Rather than allocate one large buffer to fit a particular XML document,
z/OS XML allows applications to allocate, use, and reuse a smaller buffer in memory to step
through the entire document. A 100 MB document, for example, could be sequentially parsed
in 100 fragments of 1 MB each, thereby greatly reducing an applications memory footprint.
z/OS XML allows greater customization for storage management by supporting
application-specific exits for allocating and de-allocating storage. z/OS XML also supports a
string identifier exit which allows applications to further save on storage by assigning
numerical identifiers to strings from the XML document. Finally, z/OS XML provides an
interface to efficiently query an XML documents encoding.
You call the z/OS XML parser natively from a COBOL or PL/I application, but, for example, to
handle a pointer in COBOL is not as simple, which is why Enterprise COBOL and PL/I, DB2
for z/OS, and the XML Toolkit for z/OS exploit the z/OS XML parser to reduce the application
development and to increase performance.
40
Each of the individual technologies had its strengths and its weaknesses:
XML Toolkit for z/OS
The XML Toolkit for z/OS provides the SAX2 and DOM as de-facto standard XML parsing
APIs. The parser is function-rich, but performance is unacceptable. It provides an
event-driven programming model where the caller and parser call one another to walk
through the document. As items are identified by the parser, they are passed to the
appropriate event handler. This processing model makes offload impractical and there is
too much entry/exit overhead.
See Figure 4-2.
Parser
Application
SAX2, DOM
event handlers
z/OS XML
z/OS XML is a parser for z/OS components and applications with the following key
characteristics:
z/OS XML attacks the XML problem from an absolute performance standpoint as well as
cost-performance through offload to assist processors.
See Figure 4-3.
41
Appl ication
z/ OS XML SS
of fload
onload
XML t ext
parse ( )
consume
datastream
XL/XP
The XL/XP XML parser is specialized in high-performance validation and the schemas are
pre-compiled to improve parse-time performance. XL/XP is a derivative of
research-based, and IBM-internal XML parsers and delivers the same parsed data stream
as z/OS XML.
See Figure 4-4.
XL /XP
OSR
Generator
App lication
Schema text
Parser
Generate an optimized
s chema for us e at
parse time
parse ( )
XML text
consume
datastream
42
Figure 4-5 provides a brief overview how the components z/OS, XLXP, and the XML Toolkit
work together.
event handlers
SAX 2 or D OM
Network services
Initiate a
SAX parse
event handlers
Parser
event handlers
event handlers
call to event
handlers
event handlers
2
offload
z /OS XML
xmlReader
event generator,
glue code
parse to
data
stream
Other SAX
classes
onload
4
3
Figure 4-5 Architectural overview of using z/OS XML, XLXP, and the XML Toolkit
43
With the combination of these components the following problems are addressed and solved:
Parse with schema validation
Integrate an existing proprietary IBM validating parser (XL/XP) with the z/OS XML
parser.
XL/XP is already incorporated in existing IBM middleware products and z/OS XML
becomes a container providing offload and an API.
SAX2 and DOM interfaces
Slide z/OS XML under the XML Toolkit for z/OS
Extend existing class library to allow re-direction of parsing to z/OS XML
z/OS XML does the actual parse, and the XML Toolkit provides the API and external
behaviors
Additional supporting functionality
Offsets to locations of parsed items in the source document
Fully qualified names in end element records
Mark attribute value records generated as defaults from the DTD
Enhanced IPCS support
More supported encodings
European country extended code pages (EBCDIC based), 19 new in total
100% zIIP offload
When caller is in enclave SRB mode, z/OS XML offloads to a zIIP
Will now always offload 100% of z/OS XML, and not the dialed percentage of the
enclave
New functions delivered through different mechanisms
z/OS releases
SPEs (APARs)
XML Toolkit for z/OS releases
DB2 is the first exploiter that currently uses both XL/XP for parsing with validation, and z/OS
XML for non-validating parses in V9.
The system requirements are as follows:
z/OS XML APARs
OA25903 - rollback of the validating parse function from z/OS V1.10 to V1.9
OA22777 - support for 19 additional European encodings (available now)
OA23828 - offload 100% of parser cycles on zIIP when in SRB mode
XML Toolkit for z/OS APARs:
OA22700 - use z/OS XML for non-validating parse requests (for release 9 of the toolkit)
44
DB2 Engine
7
XML
XML
Application
XML
3
5
6
XSR
Relational
XML Storage
Insert XML
Store as XML
Retrieve XML
Publish XML
Select XML
XML to XML
XML to Relational
Relational to XML
45
46
You can find more detailed information about pureXML capabilities in the following resources:
DB2 Version 9.1 for z/OS XML Guide, SC18-9858, which is available at:
http://publib.boulder.ibm.com/epubs/pdf/dsnxgk10.pdf
DB2 9 for z/OS: Deploying SOA Solutions, SG24-7663, which is available at:
http://www.redbooks.ibm.com/abstracts/sg247663.html
4.2.7 Summary
There are lots of possibilities to work with XML under z/OS. IBM System z offers excellent
performance with z/OS XML System Services. z/OS XML and its high performance together
with zAAP and zIIP speciality processors is a very cost efficient solution.
47
When you need to bridge from COBOL or PL/I to Java or vice versa. In that case you can
use Java Native Interface (JNI) to bridge between Java and C/C++ and ILC to bridge
between C/C++ and COBOL or PL/I.
When you need to plug in a vendor product into your existing COBOL or PL/I batch
environment. A vendor product might provide modules in C/C++ that you need to integrate
in existing COBOL or PL/I batch programs, such as for printing purposes.
Note that mixing languages should not be a goal by itself, because it increases complexity
and dependency on multiple programming skills. Consider mixing languages and using ILC
only if there is no other option. The good thing is that with the Language Environment and
ILC, z/OS provides one virtual environment for multiple programming languages.
Note: The IBM C compilers and the IBM COBOL and PL/I compilers use the same default
linkage.
48
Chapter 5.
49
Java
bytecode
Java
bytecode
Java
bytecode
Java
bytecode
Java
bytecode
Java
bytecode
Windows
JVM
X86 Linux
JVM
AIX
JVM
Linux on
Power JVM
z/OS
JVM
Linux on
System z JVM
Platform
specific
extensions
Platform
specific
extensions
Platform
specific
extensions
Platform
specific
extensions
Platform
specific
extensions
Platform
specific
extensions
z/OS
Linux on
System z
Windows
X86 Linux
X86 Processor
AIX
Linux on
Power
For different kinds of operating systems and their underlaying hardware, a special IBM JVM is
available. This JVM abstracts the underlaying components of the OS and hardware by
translating the compiled Java bytecode to OS specific instructions. As a result, every Java
program can be run on all of the mentioned platforms without recompiling it.
Note: Java bytecode is not bound to the IBM JVM. It also runs in other JVMs that comply
to the Java standard.
All the IBM JVMs are built on a common code base with platform specific extensions. This
allows a common handling of IBM JVMs on all platforms.
In addition to the aspect of code reuse for batch modernization on z/OS, Java also offers the
following advantages on z/OS:
Easy programming model through object orientation
Java skills are more readily available in the market
Rich in functionality
Very good development tools on Eclipse base available
50
Can be run on System z10 Application Assist Processor (zAAP) to reduce cost
Data proximity
Due to local connectors to data back-end systems, you can achieve high performance. For
example, the JDBC Type II driver for z/OS allows Java z/OS programs to interact with DB2
z/OS based on a cross memory connection. In contrast to the TCP/IP based JDBC Type
IV driver, this eliminates the cost for the network connection. Especially in a batch
environment where typically much data is involved, this can be a competitive advantage.
Multithreading support
In contrast to traditional z/OS programming languages, Java supports multithreading,
which can help to achieve higher efficiency and better performance as multiple threads
can run in parallel on the processors available.
These advantages can be used in nearly all run times on z/OS:
CICS
IMS
DB2
WebSphere Application Server
WebSphere stack solutions running on WebSphere Application Server, such as
WebSphere Process Server, and WebSphere Portal
Java stand-alone under z/OS
Thus, you can use Java in batch nearly wherever you want. We discuss these run times and
their usability for Java batch in subsequent chapters in more detail.
For further information about Java on z/OS, see:
http://www.ibm.com/servers/eserver/zseries/software/java/
51
For a description of the com.ibm.jzos packages, see the full Javadoc at:
http://www.ibm.com/developerworks/java/zos/javadoc/jzos/index.html
Note: The javadoc reflects the current version of the IBM Java SDK for z/OS. If some of
these functions are not included in your SDK, update it to the latest version.
You can find samples about how to implement these APIs in the following resources:
In the JZOS Cookbook at:
http://www.alphaworks.ibm.com/tech/zosjavabatchtk/download
On the IBM Web site:
http://www.ibm.com/servers/eserver/zseries/software/java/products/jzos/jzossamp
.html
The z/OS C/C++ library supports several models of I/O when using MVS data sets:
Record mode
Stream mode
52
For example, if we define an INPUT and OUTPUT DD statement in a JCL that is calling a
Java job with the JZOS batch launcher (see 7.2, Running Java with JZOS on page 79 later
on), we can copy the INPUT data set to the OUTPUT data set in binary record mode, as
shown in Example 5-1:
Example 5-1 Copying an MVS data set in binary record mode using ZFile
53
In addition to binary record mode and text stream mode, the third way to access MVS data
sets is binary stream mode. For example. we can define the following DD statement in a JCL:
//INPUT DD DSN=STRAUER.XML.IN.BIN,DISP=SHR
This INPUT data set contains some XML data which we parse later on with the standard Java
SAXParser as shown in Example 5-4.
Example 5-4 Parsing XML from an MVS data set using ZFile binary stream mode
5.3.1 Summary
All of these z/OS Java APIs allow a very efficient integration of Java into the z/OS batch
environment because they provide the ability to use a lot of commonly used functions of other
z/OS programming languages also to be used in Java. Combined with the additional
capabilities of Java, such as object orientation or PDF creation, Java can be a very interesting
option to serve new functional requirements in a z/OS batch environment.
54
The easiest way to get around this is to use the following parameter when launching the JVM,
which causes the z/OS JVM to read/write everything in ASCII and solves the problems:
-Dfile.encoding=ISO8859-1
Note: WebSphere Application Server for z/OS is using ASCII encoding as a default.
Therefore, encoding should not be a problem in WebSphere Application Server.
55
56
Chapter 6.
57
Hierarchical databases
An IMS Database (IMS DB) is made up of records that are composed like trees (as opposed
to relational database systems, for example DB2, that store data in tables). Certain types of
data might call for a specific storage structure. For example, a phone directory matching
names and phone numbers fits well into a table, while a log of customer orders with several
articles per order likes to dwell in a tree. Figure 6-1 illustrates the concept of storing data in a
hierarchical tree.
58
The exemplary customer database shown in Figure 6-1 stores the orders and support
requests of all customers of a company. For every customer, there is one record, each with
one root segment. The root segment stores the name and the address of the respective
customer. Every record can contain several copies of the dependent segments order and
request according to the number of orders and requests that the customer placed. For every
item of an order, the product name and the number of items is noted in an extra segment.
These structures allow for fast navigation through the data and to find a position with little
effort.
Furthermore, the structures of IMS databases and XML documents are very similar. Special
applications can store XML efficiently in new or already existing IMS databases and retrieve
XML and keep the hierarchical organization of the data all the way through. In addition to
using Java, using XML can be a very good enrichment of existing IMS applications.
IMS data can be accessed by navigating the hierarchical structure. The original method for
accessing this data was Data Language/I (DL/I), which is roughly equivalent to SQL. DL/I
uses trees instead of tables and returns single segments instead of result sets. There is also
a hierarchical database interface for Java that encapsulates DL/I calls in Java methods.
To use both hierarchical and relational access to IMS databases, you must either create a
Java representation of the IMS segment hierarchy and fields or use the DLIModelUtility
plug-in to generate the IMSDatabaseView object from IMS DBDs, PSBs, and COBOL
Copybooks.
Cust_Address
Order_No
Order_Date
Item_Name
Item_Pcs
Cust 1
Street 1
40
2009-11-14
Paper
Cust 1
Street 1
40
2009-11-14
Pencil
Cust 1
Street 1
41
2009-11-18
Eraser
Cust 1
Street 1
44
2009-12-04
Envelope
Cust 1
Street 1
44
2009-12-04
Paper
Cust 2
Street 8
43
2009-12-03
Paper
20
Cust 3
Street 4
42
2009-12-01
Pencil
10
Cust 3
Street 4
42
2009-12-01
Paper
59
Java Message Processing (JMP) and Java Batch Processing (JBP) applications can access
DB2 for z/OS databases in addition to IMS databases. For more details about Java in IMS,
see IMS Version 7 Java Update, SG24-6536 and the IMS Information Center.
60
//JBPJOB
JOB 1,IMS,MSGLEVEL=1,PRTY=11,CLASS=K,MSGCLASS=A,REGION=56K
//
EXEC DFSJBP,
//
IMSID=
//
PROC MBR=TEMPNAME,PSB=,JVMOPMAS=,OUT=,
//
OPT=N,SPIE=0,TEST=0,DIRCA=000,
//
STIMER=,CKPTID=,PARDLI=,
//
CPUTIME=,NBA=,OBA=,IMSID=,
//
PREINIT=,RGN=56K,SOUT=A,
//
SYS2=,ALTID=,APARM=,ENVIRON=,LOCKMAX=,
//
XPLINK=N
//*
//JBPRGN EXEC PGM=DFSRRC00,REGION=&RGN,
//
PARM=(JBP,&MBR,&PSB,&JVMOPMAS,&OUT,
//
&OPT&SPIE&TEST&DIRCA,
//
&STIMER,&CKPTID,&PARDLI,&CPUTIME,
//
&NBA,&OBA,&IMSID,
//
&PREINIT,&ALTID,
//
'&APARM',&ENVIRON,&LOCKMAX,
//
&XPLINK)
//STEPLIB DD DSN=IMS.&SYS2.SDFSJLIB,DISP=SHR
//
DD DSN=IMS.&SYS2.SDFSRESL,DISP=SHR
//
DD DSN=IMS.&SYS2.PGMLIB,DISP=SHR
//
DD DSN=CEE.SCEERUN,DISP=SHR
//
DD DSN=SYS1.CSSLIB,DISP=SHR
//PROCLIB DD DSN=IMS.&SYS2.PROCLIB,DISP=SHR
//SYSUDUMP DD SYSOUT=&SOUT,
//
DCB=(LRECL=121,RECFM=VBA,BLKSIZE=3129),
//
SPACE=(125,(2500,100),RLSE,,ROUND)
61
Example
Example 6-2 shows a JBP application that performs the following tasks:
Connecting to a database
Making a restart call
Performing database processing
Periodically making checkpoints
Issuing a final checkpoint
Disconnecting from the database at the end of the program
//Establish DB connection
IMSTransaction.getTransaction().restart();
//Restart application
//after abend from last
//checkpoint
repeat {
repeat {
results=statement.executeQuery(...); //Perform DB processing
...
MessageQueue.insertMessage(...);
//Send output messages
...
}
IMSTransaction.getTransaction().checkpoint(); //Periodic checkpoints
// divide work
}
conn.close();
return;
}
62
//Close DB connection
For more detailed information about the programming model for symbolic checkpoint and
restart, see JBP application with symbolic checkpoint and restart at:
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.ims10.doc.apg
/ie0j1bas999243.htm#symbckpt
If you need transactionality, this IMS feature can be a big advantage compared to stand-alone
Java batch applications, which we discuss in Chapter 7, Implement new functionality using
stand-alone Java on page 77.
63
database and helps application developers build Java applications. Jobs to build the
Dealership database comes with the IMS installation. For more information about the IVP
jobs and tasks for the IMS sample application for XQuery support in IMS, see the IMS Version
10: Installation Guide at:
http://www-306.ibm.com/software/data/ims/imsjava/
For details about the classes that you use to develop a JBP application, see the Java API
specification for IMS at:
http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.im
s10.doc.apr/ims10javadoc.htm
64
program (written in any language) that is capable of connecting to DB2 and using SQL is
suitable to invoke Java batch within DB2.
65
so forth) on the WLM setup panels. For more information about how to do this setup, refer to
DB2 9 for z/OS Stored Procedures: Through the CALL and Beyond, SG24-7604.
XPLINK(ON),
ENVAR("DB2_BASE=/usr/lpp/db2/d9gg/db2910_base",
"_CEE_ENVFILE=/u/wagnera/javastp/cee_envfile.txt",
"TZ=EST5EDT",
"JCC_HOME=/usr/lpp/db2/d9gg/db2910_jdbc",
"JAVA_HOME=/usr/lpp/java/J5.0"),
MSGFILE(JSPDEBUG,,,,ENQ)
This file contains an environment variable called JAVA_HOME. With this variable, you can
point to a specific directory with a Java version in your runtime environment. In our system,
we used Java version 5.0.
Important: We recommend that you use the same Java compiler version in your
development environment as the one configured for your DB2 Java stored procedure
runtime environment.
We used the _CEE_ENVFILE variable to point to a separate file with further runtime options.
This file is stored in the UNIX System Services file system. See Example 6-5 for an example
that we used.
Example 6-5 Content of /u/wagnera/javastp/cee_envfile.txt file
CLASSPATH=/u/wagnera/javastp/PdfGenerate.jar:/u/wagnera/javastp/lib/iText-2.1.5.jar
The Java program for the stored procedure needs two different JAR files:
PdfGenerate.jar
iText-2.1.5.jar
66
In the next chapter, we explain in detail how to create and store the JAR files in the UNIX
System Services file system.
After we completed these steps, our system environment was prepared to run a Java stored
procedure.
Note: The user who is supposed to start the stored procedure address space must have
READ authority to all configuration and JAR files that are used by the stored procedure.
Note that this user is usually not the same user who calls the DB2 stored procedure!
COBOL job
creating data
CALL
Java
Stored procedure
creating PDF files
store_fs
read XML
DB2 table
with XML
column
store_db2
store_fs_db2
DB2 table
with BLOB
column
67
NOT NULL
Next, we insert test data in XML format. This XML data should contain information about a
company (all employees and the departments for which they work). The easiest way to insert
the data is using an SQL INSERT statement. For our test, we inserted only two rows in DB2
with data from two different companies.
Example 6-7 shows an extract of our INSERT statements. Example A-4 on page 426 lists the
the complete statements for this example.
Example 6-7 Insert XML test data
68
pdfDir
Directory to store PDF files in the UNIX System Services file system
From a Java stored procedure perspective, these two parameters are used only to control the
flow of the Java coding. They are pure input parameters.
With DB2 stored procedures, you can also return values to the caller. You can use result sets
for multiple returned rows of data. Returned parameters are called output parameters. It is
also possible to define a parameter for input and output processing.
When defining the DB2 stored procedure you have to decide whether the parameter is input
(IN), output (OU), or both input and output (INOUT).
Example 6-8 The runGenerate method in the GenPdf Java Class
69
To create PDF files, we use the Open Source Java library iText-2.1.5.jar. To use this
library, we follow these steps:
1. We first create a folder called lib in the Eclipse Project
2. Then, we download iText-2.1.5.jar from the following Web site:
http://www.lowagie.com/iText/download.html
3. Finally, we save this file in the lib folder of the Eclipse project.
Because the library iText-2.1.5.jar is needed to develop and run the Java program, we
copy this file through FTP to the runtime environment of the Java stored procedure on z/OS.
In our case, as shown in Example 6-5 on page 66, the Java environment expects this file in
the UNIX System Services folder /u/wagnera/javastp/lib.
Then, we include the iText-2.1.5.jar in the Eclipse Build Path by right-clicking the Java
project and selecting Build Path Configure Build Path as shown in Figure 6-4.
In the next window, we select Add Jars, select the iTest-2.1.5.jar file, and press OK twice.
Now, the two classesGenPdf and PdfCreatorcompile without any errors.
Next, we take a closer look at some code of class PdfCreator. As shown in Example 6-9, the
connection URL in our case is jdbc:default:connection. This URL forces DB2 to use the
same physical thread that processes the CALL statement for the stored procedure, which is
important regarding DB2 processing. For example, if DB2 uses a different thread for SQL
processing within our stored procedure than the process that called our stored procedure, we
cannot access data within the stored procedure because it is blocked by the process that
called the stored procedure.
Example 6-9 Get Connection within Java stored procedure
70
In our example, we use XML data as input for our stored procedure, as shown in
Example 6-10. Thereby, each row of our table contains all data from one single company.
Example 6-10 SELECT data from XML column
71
Example 6-12 shows the CREATE statement for the stored procedure. There are many more
parameters available. For detailed information about each parameter, refer to the SQL
documentation of DB2 for z/OS.
Example 6-12 Creating the stored procedure in DB2
Deploying the Java files to the UNIX System Services file system
Because our stored procedure runs on z/OS, we build a JAR file and copy this file to the z/OS
environment. As shown in Example 6-5 on page 66, the Java environment expects the file
PdfGenerate.jar in UNIX System Services folder /u/wagnera/javastp. To build and copy the
JAR file, we used an Ant script in Eclipse.
To use Ant, you download the following Open Source libraries:
The jakarta-oro-2.0.8.zip file from the Apache Jakarta Project at:
http://jakarta.apache.org/site/downloads/downloads_oro.cgi
The commons-net-2.0.zip file from the Apache Commons Project at:
http://commons.apache.org/downloads/download_net.cgi
72
Now, right-click the Java project JavaSTP, and select New File to create a file called
deploy.xml. In this file, we configure the necessary steps for the deploy process (that is
compile the Java source, build the JAR file, and copy the JAR file to UNIX System Services
file system). For the entire content of this file, see Example B-3.
Next, right-click the Java project JavaSTP, and select New File to create a file called
zos.properties. In this file we configure necessary parameters that are used as input for the
deploy.xml script to copy the JAR file (server, user, password, JAR directory, and JAR name).
See Example 6-13.
Example 6-13 The zos.properties file for the deploy process
73
appl.home = /u/wagnera/javastp
# jar name
jarname = PdfGenerate.jar
# time to wait for output in seconds
waittime = 0
# remote debugging
debug= no
The JAR file is copied to the UNIX System Services file
/u/wagnera/javastp/PdfGenerate.jar. As mentioned previously, the user who starts the
stored procedure address space must have READ authority to this file.
Finally, we build and copy the JAR file with the Ant script to z/OS by right-clicking deploy.xml
and selecting Run As Ant Build.
We recommend to use a local Java application to call this system stored procedure.
To do this, we create a second Java project called UtilSTP (click File New Java Project)
in Eclipse. Then, we create the package com.ibm.itso.sample in the src folder of the UtilSTP
project. In this package, we create the new Java class RefreshWLM. Example 6-14 shows the
relevant code to refresh our WLM Application Environment. You can find the entire Java
source code in Example B-5 on page 435.
Example 6-14 Refresh application environment
74
Important: Every time you deploy a new version with the Ant script, you have to issue
RefreshWLM (right-click RefreshWLM and select RunAs Java Application) to activate
the new version in DB2 for z/OS.
75
76
Chapter 7.
RC
>0
=0
RC
=0
>0
RC
You can completely integrate Java into your existing batch environment. For example, after
running a COBOL preparation step with a Return Code (RC) of zero, you can then use Java
Copyright IBM Corp. 2009, 2012. All rights reserved.
77
to implement functionality that is difficult to implement in COBOL. In the Java step, you need a
launch mechanism that creates the JVM and launches the Java program. The launched
Java program itself can then generate RCs at the end so that the job automation starts other
jobs based on the results.
In this chapter, we discuss different z/OS stand-alone Java batch launchers, introduce ways
to interact from Java with other languages, talk about development capabilities in stand-alone
Java batch, and give an example of how to enrich an existing COBOL job with Java
functionality in a stand-alone batch environment.
This chapter includes the following topics:
78
Figure 7-2 illustrates how JZOS works. A Job Control Language (JCL) calls the JZOS batch
launcher load module which creates the JVM under UNIX System Services. The JCL
contains all relevant information about how to launch the batch job:
USS
JZ OS address space
*.class files
JVM
JZOS Batch
launcher
TWS
JCL
JES Sysout
z/OS
Figure 7-2 JZOS overview
The JVM called by the JZOS load module then initiates the Java program by calling the main
class. While the Java batch job is running, all System.out.println and System.err.println
are redirected to the SYSOUT and SYSERR DD designations, respectively, of the job.
Another advantage of JZOS is that the launcher and the JVM run in the same address space,
making job accounting easier and allowing the use of DD statement. Because JZOS Java
batch jobs are launched by standard z/OS JCL, it is easier to integrate Java batch jobs in
workload scheduling products such as Tivoli Workload Scheduler.
Note: Every time you start a JZOS batch job, a JVM is initiated. For further information
about how this might impact performance see 18.2, Stand-alone Java batch on page 339.
79
In summary, the JZOS batch launcher is a good tool to enrich your existing batch environment
with Java functionality.
For further information about JZOS, see the following Web site:
http://www.ibm.com/servers/eserver/zseries/software/java/products/jzos/overview.html
Another excellent resource is Java Stand-alone Applications on z/OS Volume II, SG24-7291.
bash
vi
viascii
vim
openssh
These tools, and many others, can also be used on z/OS. For more information, see the z/OS
UNIX System Services Tools at the following Web site:
http://www.ibm.com/servers/eserver/zseries/zos/unix/tools/
80
For Java code development, Eclipse-based tools are very common. Such Eclipse-based tools
can also be used for stand-alone Java batch development in combination with the JZOS
batch launcher.
An excellent starting point for developing stand-alone Java is the JZOS Cookbook, which you
can downloaded from:
http://www.alphaworks.ibm.com/tech/zosjavabatchtk/download
If you want to use the Eclipse platform only for development of z/OS batch written in Java, you
can find a cost free and very efficient solution described in Java Stand-alone Applications on
z/OS Volume II, SG24-7291. This book includes a chapter that describes a solution that is
based on Ant scripts, which allows you to compile and deploy a Java batch application to
z/OS with only a few clicks. This solution combines the advantages of Eclipse-like syntax
highlighting and code completion with an easy deployment to z/OS, including job output in
Eclipse. In most cases, you will not need 3270 sessions.
If you also want do develop programs in traditional languages such as COBOL and PL/I in
Eclipse with features such as syntax highlighting or code completion, IBM Rational Developer
for System z is a solution. Rational Developer for System z is an Eclipse-based integrated
development environment (IDE) that allows application developers to edit, compile, build, and
interactively debug COBOL, PL/I, and Java programs. Syntax highlighting, build assistance,
and interactive debug of applications running on remote z/OS systems are supported. In
addition, users can directly access z/OS data sets, including JCL and UNIX System Services
files, and can view VSAM data using the IDE. For Java developers who are familiar with an
IDE, Rational Developer for System z can ease interaction with z/OS and raise productivity.
You can find further details about how to use Rational Developer for System z for z/OS
application development in Topics on Version 7 of IBM Rational Developer for System z and
IBM WebSphere Developer for System z, SG24-7482.
Note: you can also combine the advantages of the Ant script and Rational Developer for
System z.
81
TW S
Sequential
dataset
COBOL job
creating data
for invoices
DB2
COBOL job
printing invoices
on printer
Java job
creating
pdf invoices
Java job
sending pdf files
files via E-Mail
Because printed invoices cost money (in the form of printer cost, paper, and postage),
invoices based on PDF files are an alternative. However, because creating PDF files in
COBOL and PL/I is more difficult and time consuming, we created a third job in this sample
that is written in Java. This Java job uses the same DB2 input data as the COBOL printing job,
but instead of real printed invoices, it creates PDF files using a Java PDF library. To send
those invoices directly to the recipient, we create another job in Java that sends these files
using e-mail to their recipients. All of the jobs and their dependencies are managed by Tivoli
Workload Scheduler.
Note: We do not show how to implement the COBOL print job and the e-mail send job
because most z/OS users will understand this process. Furthermore, sending e-mails with
Java is quite easy and, therefore, we do not need explain it further here. Our purpose is to
show how to use Java to implement a new piece of functionality and integrate it within the
batch flow, not to explain all the possible functionality of Java.
82
This scenario demonstrates the easy integration of Java functionality into an existing z/OS
batch landscape. The Java job behaves as all other jobs:
The advantage of using Java in this scenario is that Java provides an easy way to solve the
functionality requirements. For e-mail or PDF creation, Java includes libraries that only need a
few lines of code to implement the job.
83
You can find the Data Definition Language (DDL) and SQL statements to insert this sample in
Appendix A, DB2 configuration on page 423 as well as in the Eclipse project file that is
included in the additional material for this book. You can find the COBOL source code and the
flat file in Appendix C, Additional material on page 453.
84
4. Next, include these three JAR files in the Eclipse Build Path. Right-click the project, and
select Build Path Configure Build Path as shown in Figure 7-6. In the window that
opens, select Add Jars.
85
5. Next, select the DB2 and iText JAR files as shown in, Figure 7-7 and press OK.
86
6. Figure 7-8 shows the build path for our test environment. Select OK.
7. Open the zos-properties file and enter a new JAR file name:
jarname = pdfinvoice.jar
8. Now, to code the program, we create a new package called com.ibm.itso in the src folder.
Then, we create the following new classes in that package:
InvoiceCreator.java
PdfCreator.java
In both classes, we add the Java code to get the required invoice data from the DB2 tables
using JDBC and the iText classes to generate the PDF files. You can find the complete
code in Java PDF creator on page 437.
Note: Because we use only the JDBC Type II Driver for the cross-memory data access
between DB2 and z/OS, the two JAR files, db2jcc_license_cisuz.jar and db2jcc.jar,
are not required to be in the Java Build Path of Eclipse. Nevertheless, in our example,
we include them for cases where we might need DB2 specific functions, such as a Type
IV connection test with Java.
87
9. To launch the Java job with the JZOS batch launcher, we modify the HelloWorld JCL in the
jcl folder of the Eclipse workspace to look like the sample shown in Example 7-1.
Example 7-1 JCL to launch Java PDF Creator
//STRAUERA JOB
/*JOBPARM SYSAFF=SC48,L=9999
//PROCLIB JCLLIB ORDER=SYS1.IBM.PROCLIB
//HOLD OUTPUT JESDS=ALL,DEFAULT=Y,OUTDISP=(HOLD,HOLD)
//JAVA EXEC PROC=JVMPRC50,
// JAVACLS='com.ibm.itso.sample.InvoiceCreator',
// ARGS='/u/strauer/jzos/pdf'
//STEPLIB DD DISP=SHR,DSN=DB9G9.SDSNLOAD
//
DD DISP=SHR,DSN=DB9G9.SDSNLOD2
//STDENV DD *
#This is a shell script which configures
# any environment variables for the Java JVM.
# Variables must be exported to be seen by the launcher.
. /etc/profile
export APPL_HOME=/u/strauer/jzos
export JAVA_HOME=/usr/lpp/java/J5.0
export DB2_HOME=/usr/lpp/db2/d9gg/db2910_jdbc/classes
export PATH="$PATH":"{JAVA_HOME}"/bin:
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin/classic
LIBPATH="$LIBPATH":"/usr/lpp/db2/d9gg/db2910_jdbc/lib"
export LIBPATH="$LIBPATH":
# Customize your CLASSPATH here
# Add application home directory and jars to CLASSPATH
for i in "${DB2_HOME}"/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done
for i in "${APPL_HOME}"/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done
export CLASSPATH="$CLASSPATH":
# Configure JVM options
IJO="-Xms16m -Xmx128m"
# Uncomment the following line if you want to debug the application
#IJO="$IJO -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000"
# Uncomment the following if you want to run with Ascii file encoding..
IJO="$IJO -Dfile.encoding=ISO8859-1"
IJO="$IJO -Ddb2.jcc.ssid=D9G1"
export IBM_JAVA_OPTIONS="$IJO "
export JAVA_DUMP_HEAP=false
export JAVA_PROPAGATE=NO
export IBM_JAVA_ZOS_TDUMP=NO
//
88
89
10.Finally, deploy and submit the job with the Ant script by right-clicking deploy.xml. Then,
select Run As Ant Build as shown in Figure 7-9.
90
The output on the system console looks similar to that shown in Example 7-2.
Example 7-2 Java batch job output
[...]
JVMJZBL1023N Invoking com.ibm.itso.sample.InvoiceCreator.main()...
[java] JVMJZBL1024N com.ibm.itso.sample.InvoiceCreator.main() completed.
[java] JVMJZBL1021N JZOS batch launcher completed, return code=0
[java] !! END OF JES SPOOL FILE !!
[java] Connecting to DB2
[java] ... connected.
[java] Starting to create pdf file /u/strauer/jzos/pdf/Invoice_No_1.pdf...
[java] ... invoice pdf file created.
[java] Starting to create pdf file /u/strauer/jzos/pdf/Invoice_No_2.pdf...
[java] ... invoice pdf file created.
[java] Starting to create pdf file /u/strauer/jzos/pdf/Invoice_No_3.pdf...
[java] ... invoice pdf file created.
[java] Starting to create pdf file /u/strauer/jzos/pdf/Invoice_No_7.pdf...
[java] ... invoice pdf file created.
[java] Starting to create pdf file /u/strauer/jzos/pdf/Invoice_No_8.pdf...
[java] ... invoice pdf file created.
[java] !! END OF JES SPOOL FILE !!
[...]
11.Now, check the results and open one of the created PDF files. Figure 7-10 shows one of
the batch-created PDF files from our test environment.
12.Finally, we can implement another job in Java that takes these PDF files and sends them
to the appropriate recipients using e-mail.
In summary, this sample application shows an easy and effective method to use Java with the
JZOS batch launcher to enrich an existing batch environment with new functionality.
91
92
Chapter 8.
93
With the Java EE platform as the core foundation for WebSphere Application Server for z/OS,
WebSphere XD Compute Grid delivers the following improved qualities:
Business flexibility delivers the core capabilities to more efficiently and effectively support
both Java batch and OLTP workloads concurrently.
Processing enables centralized management for a heterogeneous IT infrastructure that
consists of both WebSphere and non-WebSphere application servers.
Extended manageability offers simpler and improved management of complex system
operations with real-time visualization tools, application versioning, and gradual, controlled
implementation of autonomic capabilities such as health management. This manageability
helps to reduce the cost and complexity of managing WebSpheres IT resources.
Dynamic operations enable the Java EE application environment to support a focused
configuration of WebSphere resources, and helps to increase the speed at which a
company can adapt to business change.
High-performance computing optimizes the performance of business-critical applications
to support near-linear scalability for high-end transaction processing. Improves customer
service levels while also taking advantage of existing Java skills and resources.
This chapter includes the following topics:
94
Web Client
Start Transaction
MQ & SIB
Messages
Web Services
Clients
T raditional O LTP
JEE Application
Client
EJB Clients
Business Logic
Database
Commit Transaction
WebSphere provides many of the overall system services (that is container services) that are
required by complex business applications. Some typical container services are security,
transaction support, Web services, session pooling, connection pooling, caching, and
messaging, just to name a few. All this leads to a simplified Java application design,
accelerates development time, simplifies management, and increases the applications
overall security, availability, performance, and stability.
Unfortunately, the Java-based business logic residing within WebSphere Application Server
for z/OS is not efficiently accessible from traditional batch. Figure 8-2 shows that traditional
runtime environments, such as IMS, CICS, and TSO, exist in addition to the OLTP
environment that is based on WebSphere Application Server. Integration between the
traditional runtime environments and WebSphere Application Server is based on connectors
and messaging.
95
IMS
JES
External
Scheduler
CICS
Native Runtime
(COBOL, PL/I, etc)
JCL
JCL
JCL
DB2
WebSphere z/OS
JC
L
JCL
Java
Client
Figure 8-2 Traditional batch and OLTP workload in WebSphere Application Server for z/OS today
96
IMS
JES
External
Scheduler
CICS
Native Runtime
(COBOL, PL/I, etc)
JCL
JCL
JCL
DB2 z/OS
WebSphere XD
Compute Grid
for z/OS
JC
L
JCL
Java
Client
Figure 8-3 Batch and OLTP workload in WebSphere XD Compute Grid on z/OS
97
BATCH
External Scheduler
JEE Ap plicatio n
Web Client
EJB
MQ & SIB
Messages
Request (HTTP/IIOP)
Client
EJB Clients
Business Logic
Web
Service
Respons e (HTTP(IIOP)
Commit Transaction
Web Services
Clients
98
JDBC
DB2
JCA
CICS
etc
A WebSphere XD Compute Grid environment (as shown in Figure 8-5) is modeled after the
z/OS Job Entry Subsystem (JES), which uses components such as Job Control Language
(JCL), a job dispatcher, and job executors (JES initiators).
Non-WebSphere z/OS
XD Agent
J2E E
WebSphere z/OS
Job Logs
xJ CL
X D Config
Non-WebSphere z/OS
XD Agent
J 2EE
Job Logs
Pa rtitio ni ng
Strateg i es
X D Config
WebSphere z/OS
GEE
J 2EE 5
xJCL
J ob Logs
WAS Conf ig
Job dispatcher
WebSphere z/OS
Programmatic
(EJ B, JMS, or Web Services)
Job Logs
External Scheduler
(like TWS for z/OS)
7
Container
Databa se
(LREE)
J2E E
Job Logs
WSGrid Client
PJM
8
6
Job
Scheduler
Databas e
(LRS)
GEE
WAS
Config
JD BC
J DBC
Job Logs
WA S Conf ig
WebSphere z/OS
9
GEE
WAS Confi g
WebSphere z/OS
J2 EE
J ob Logs
WAS Conf ig
WebSphere XD Compute Grid has an XML-based job description metadata called xJCL, a
job dispatcher called the Job Scheduler (JS), and multi-threaded job executors called Grid
Execution Endpoints (GEE). In addition, a Parallel Job Manager (PJM) component partitions
and governs the execution of parallel batch jobs. Each of these WebSphere XD Compute
Grid components are Java EE applications that can be placed in one JVM or in a fully
clustered environment, that allow you to use WebSphere Application Server for z/OS security,
scalability, high availability, and life cycle management best practices. The components of
such a WebSphere XD Compute Grid environment are:
Web, Shell, API
The job scheduler exposes the following API types to access its management functions:
The Job Management Console (JMC), which is a Web interface
The lrcmd shell command
APIs that are available as either Web Services and EJBs (see 14.2, Using WebSphere
XD Compute Grid trigger mechanisms on page 234)
However, jobs can also be submitted to the system using an enterprise scheduler like
Tivoli Workload Scheduler for z/OS (see 14.3.2, Integrate Tivoli Workload Scheduler for
z/OS with WebSphere XD Compute Grid on page 266).
99
xJCL
Jobs are described using a job control language. Compute Grid jobs use an XML based
job control language. The job description identifies which application to run, its inputs, and
outputs.
Job scheduler
The job scheduler (JS) is the job entry point to XD Compute Grid that provides all job
life-cycle management functions, such as submit, cancel, restart, and so forth, and the
monitoring functionality. It maintains a history of all jobs, including those waiting to run,
those running, and those that have already run. It also maintains usage data for jobs that
have run. The JS dispatches workload to either the PJM or GEE and also hosts the JMC.
Batch container
The batch container is called the Grid Execution Endpoint (GEE) component that executes
the actual business logic of the batch jobs. Java EE-based batch applications run inside
the WebSphere batch container. Native execution applications run inside a separate
container, which is described in the following section. A WebSphere cell can have any
number of batch containers.
Java EE batch application
Java EE batch applications are regular WebSphere Java EE applications, deployed as an
Enterprise Archive (EAR) file, that contain implementations of one or more Java batch
applications. These Java batch applications follow either the transactional batch or
compute-intensive programming models.
Scheduler tables
The job scheduler uses a relational database (LRS) to store job information. It can be any
relational database supported by WebSphere Application Server. If the job scheduler is
clustered, the database must be a network database, such as DB2.
Container tables
The batch container uses a relational database (LREE) to store checkpoint information for
transactional batch applications. The database can be any relational database supported
by WebSphere Application Server. If the batch container is clustered, the database must
be a network database, such as DB2.
JDBC
JDBC is standard JDBC connectivity to the scheduler and container tables, as supported
by the WebSphere Application Server connection manager.
Parallel Job Manager
The Parallel Job Manager (PJM) breaks large batch jobs into smaller partitions for parallel
execution and provides job life-cycle management (submit, stop, cancel, and restart) for
the single logical job and each of its partitions. The PJM component is not a required
component in a WebSphere XD Compute Grid environment.
All of this means that a WebSphere XD Compute Grid environment supports todays batch
processing needs, including:
24x7 batch processing, where batch can be executed concurrently with online transaction
processing (OLTP)
Sharing business services across batch and OLTP, where a service can be executed in
multiple execution environments without sacrificing efficiencies, such as bulk-data
processing
100
101
J2SE
JZOS
Launcher
JCL
JCL
Java
JES
JZOS
APIs
ZFS
External
Scheduler
JCL
JCL
JCL
WebSphere XD
Compute Grid
for z/OS
JCL
JCL
Java
HFS
VSAM
JZOS
APIs
However, the JZOS launcher is not efficient for thousands of batch jobs that are run within a
batch window, because a J2SE JVM lacks the following capabilities:
No security, transaction, or connection management facilities
No checkpoint or restart facility for batch jobs (which must be implemented by the Java
program itself)
No inherent high availability or other quality of service (QoS) that WebSphere Application
Server for z/OS provides
The JVM is not persistent or reusable (because each job step that uses Java needs to
reload the JVM)
Compared to JZOS, WebSphere XD Compute Grid is built on WebSphere Application Server
for z/OS and takes advantage of all necessary QoS and services provided by the WebSphere
Application Server for z/OS run time such as:
102
The WebSphere XD Compute Grid environment delivers the following tools for executing
transactional Java batch applications:
103
8.4.1 Security
Because of the rapid growth of e-business and the integration of different organizations,
securing and managing (IT) infrastructures has become very complex and demanding.
Protecting sensitive and confidential data from malicious intruders, deadly viruses, and
worms is not an easy task. It requires constant monitoring of the daily IT business operations
and deploying the latest security technology.
WebSphere XD Compute Grid is based on a WebSphere Application Server for z/OS
environment. Thus, WebSphere XD Compute Grid uses the WebSphere Application Server
for z/OS security and underlying operating system infrastructure security which can provide
customers running enterprise applications with secure and reliable services, which are
consistently managed by a security product such as RACF.
The security infrastructure of the underlying operating system provides certain security
services to the WebSphere security application, including the file system security support to
secure sensitive files in WebSphere product installation. The WebSphere system
administrator can configure the product to obtain authentication information directly from the
operating system user registry. On z/OS, WebSphere LocalOS registry uses the System
Authorization Facility (SAF) implementation. SAF is a common set of APIs that allow a z/OS
pluggable z/OS security manager, such as RACF or a third-party equivalent, to manage
authentication and authorization needs on z/OS. These security products contain information
about users, groups of users, resources, and user or group access to those resources. These
products provide authentication and access control for the z/OS environment.
Note: You can find more information about WebSphere security at Version 7 in general in
WebSphere Application Server V7.0 Security Guide, SG24-7660.
For more information about security in WebSphere on z/OS at Version 6.1, refer to Security
in WebSphere Application Server V6.1 and J2EE 1.4 on z/OS, SG24-7384.
WebSphere XD Compute Grid security is based on the following techniques:
WebSphere authentication for access to job scheduler interfaces. Users defined to the
active WebSphere security registry can authenticate and gain access to the job
scheduler's Web, command line, and programmatic interfaces.
Role-based security for permission rights to job. Authenticated users must be assigned to
the appropriate roles to perform actions against jobs. There are two roles:
lrsubmitter
Users in the lrsubmitter role can submit and operate on their own jobs but on no others.
lradmin
Users in the lradmin role can submit jobs and operate on their own or anyone elses
jobs.
WebSphere XD Compute Grid roles are assigned through the job scheduler configuration
page in the WebSphere administrative console.
the types of workload that are running on the system influence the system setup. If you want
to run highly parallel jobs, if you have many concurrent jobs, or if you have a high submission
rate of jobs, the Parallel Job Manager (PJM) is needed.
If high availability is needed, clustering of Compute Grid components is needed. Both the job
scheduler and the batch container should be deployed to, and operated on, clusters to
provide high availability. For all these requirements you have to set up a high available and
very scalable WebSphere Application Server for z/OS batch environment for your Java EE
based batch applications as shown in Figure 8-7.
Load Balancer
z/OS
z/OS
LPAR
LPAR
CPU
WebSphere z/OS
JS
JS
J VM
CPU
LPAR
CPU
W ebSphere z/OS
JVM
CPU
CPU
LPAR
CPU
W ebSphere z/O S
WebSphere z/OS
PJM
PJM
J VM
J VM
CPU LPAR
CPU
CCPU
PU
C PU
CPU
LPAR
CPU
CPU
WebSphere z/OS
WebSphere z/OS
GEE
GEE
JVM
J VM
Databas e
Typical application clustering techniques should be used with the job scheduler to ensure it is
highly available. The job scheduler (JS) supports multiple methods of access to its APIs, such
as Web application, command line, Web service, and Enterprise JavaBean (EJB). Ensuring
highly available network access to a clustered job scheduler depends on the job scheduler
API access method. These choices include using the WebSphere plug-in or the On-Demand
Router (ODR) from the WebSphere XD Operations Optimization feature. The batch container
is made highly available simply by deploying it to a cluster. The job scheduler automatically
recognizes the batch container is clustered and takes advantage of it to ensure a highly
available execution environment for the batch jobs that run there.
The most available and scalable WebSphere Application Server for z/OS batch environment
has redundant job scheduler, parallel job manager, and grid execution endpoints. Each
component is clustered across two data centers. If you have a clustered job scheduler you
have multiple active job schedulers and your jobs can be managed by any scheduler in your
cluster environment. If your grid execution endpoints are clustered your batch applications are
hosted also on clusters. Also, database sharing and shared file systems are necessary for a
high available and scalable WebSphere Application Server for z/OS batch environment.
105
}
createJobStep()}
WebSphere XD
Compute Grid
Batch Container
Initialize
Native Structures:
Cobol Modules, DFSort, etc
processJobStep() {
Execute
Native Structures:
Cobol Modules, DFSort, etc
destroyJobStep() {
Teardown
Native Structures:
Cobol Modules, DFSort, etc
Figure 8-8 WebSphere XD Compute Grid Batch and traditional z/OS Interoperability
The batch container operates with WebSphere Application Server for z/OS, which is a
multi-machine configuration, but WebSphere XD Compute Grid also provides a unit test
environment that you can run on a standalone WebSphere Application Server. WebSphere
XD Compute Grid also offers an Eclipse-based development experience, and additionally
supports Rational Application Developer or Rational Developer for System z as a full-function
development environment.
106
At a high level, a batch job is a declarative construct that directs the execution of a series of
one or more batch applications, and specifies their inputs and outputs. A batch job performs
this set of tasks in sequence to accomplish a particular business function. Batch applications
are programs designed to execute non-interactively in the background. Input and output is
generally accessed as logical constructs by the batch application and are mapped to concrete
data resources by the batch job definition.
Batch jobs commonly process large volumes of input/output data that are frequently
record-oriented, usually representing critical business data. Business processing tasks
performed by batch jobs can range widely. Batch jobs have been used in the System z
environment for decades and continue as a backbone of many large and medium sized
businesses to this day.
Figure 8-9 shows the basic anatomy of the elements in a batch job. The job definition
describes the batch steps to execute and the sequence in which they run. Each step is
defined with a particular batch application to invoke and its input and output data. Common
sources and destinations for data include files, databases, transaction systems, message
queues, and so on.
Input
Data
Execute Step N
if Step N-1 RC = 0
Step 1
Step N
Java
Java
Output
Data
107
Note: WebSphere XD Compute Grid V6.1 extends the simple POJO style offered by the
compute-intensive model to transactional batch. Transactional batch programs are also
implemented as simple POJOs and packaged into EAR files for deployment. Here, we
concentrate on building a POJO-based batch application because this method is the
preferred method for building a batch application. For more information about the batch
programming model, see the Information Center for WebSphere XD Compute Grid at:
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1m1/index.jsp
A WebSphere XD Compute Grid batch application consists of a set of POJOs and runs under
the control of the WebSphere XD Compute Grid batch container, which itself runs as an
extension to a standard WebSphere Application Server. Figure 8-10 depicts the application
components and their relationship to the batch container.
Batch application
Batch
JobStep
Batch Controller
async bean
F ile s ystem
Batch
Data Stream
Checkpoint
algorithm
Checkpoint
algorithm
Result
algorithm
Result
algorithm
C he ckp oi nt
da ta
J DBC
App li cati on fi le s
JDBC
Batch Container
RDB
Ap pli ca ti on ta bl es
RDB
Co nta in er tab le s
The batch container runs a batch job under the control of an asynchronous bean, which you
can think of as a container-managed thread. The batch container processes a job definition
and carries out its life cycle, using an asynchronous bean as the unit of execution.
A batch application is made up of the following user-provided components:
Batch job step
This POJO provides the batch job step with access to data. A batch
application can be written to access one batch data stream or several.
A batch data stream can be written to provide access to any sort of
data, including data from RDBs, file systems, message queues,
through J2C connectors, and so on.
The batch container is responsible for open, close, and checkpoint-related callbacks onto a
batch data stream during the life cycle of a job step. The batch job step itself calls methods on
the batch data stream to get and put data.
108
109
3. Testing the batch application in Eclipse using the Batch Simulator, with a Unit Test
Environment on the local machine, on z/OS with the Batch Simulator, and on WebSphere
XD Compute Grid on z/OS.
4. Running Echo batch application on WebSphere XD Compute Grid z/OS.
5. Debugging your application in the Unit Test Server.
6. Reusing the Echo application for huge data processing using BDS.
1
2
4
BDS
Framework
BDS
POJO
Job
properties
Batch Simulator
Generate
Packaging.properties
script
packageApp
script
Packaging
properties
*.ear
WebSphere
Batch
Test Server
(Batch UTE)
installApp
script
Generate xJCL
script
xJCL
runJob
script
Job
Log
110
J2EE *.ear
EJB *.jar
ejb-jar.xml
application.xml
ibm-ejb-jar-bnd.xml
Standard
WebSphere
J2EE
deployment
WebSphere XD
C om pute Grid
Batch
Container
Batch
Framework
EJB
was.policy
Batch
Controller
EJB
4. The Batch Simulator is a light-weight, non-Java EE batch run time that exercises the
WebSphere XD Compute Grid programming model. This runs in any standard Java
development environment like Eclipse, and facilitates simpler application development
because you are only dealing with POJOs and no middleware run time. The Batch
Simulator is really for developing and testing your business logic. When your business
logic is sound, you would execute function tests, system tests, and then deploy to
production. You can download this from batch simulator download.
5. The Unit Test Environment (UTE) runs your batch application in a single WebSphere
server that has the WebSphere XD Compute Grid run time installed. It is important to
function-test your applications in the UTE to ensure that it behaves as expected when
transactions are applied.
6. The Batch Packager is a utility that generates the necessary artifacts (for EAR creation)
for deploying your POJO-based business logic into the WebSphere XD Compute Grid run
time. The Batch Packager is a script that can be integrated into the deployment process of
your application. It can also be run independently of the WebSphere run time, so you do
not need any heavy-weight installs in your development environment.
111
To explain how to use the BDS Framework pattern and how to use the WebSphere XD
Compute Grid Batch development Eclipse workspace that is delivered with this book, we use
the simple Echo sample application for reading, processing, and writing the data.
Note: You can also download an Eclipse workspace from the WebSphere XD Compute
Grid Wiki, which provides more than the Echo sample, from the following Web site:
http://www.ibm.com/developerworks/forums/thread.jspa?threadID=228339&tstart=0
The workspace is designed for batch application development and testing and is
preconfigured with the BDS Framework, Batch Simulator, and Batch Packager utility (shown
in Figure 8-11 on page 110).
Note: You can read more about the Compute Grid tools in the WebSphere XD Compute
Grid Wiki at:
http://www-128.ibm.com/developerworks/forums/thread.jspa?messageID=14038395
038395
This project combines the WebSphere XD Compute Grid development tools into a
ready-to-use environment. It includes sample applications and Ant scripts to install and run
them in a WebSphere XD Compute Grid test server. The test server is optional and installed
separately (see Testing using the WebSphere XD Compute Grid UTE on page 129 for more
details).
The Echo application demonstrates a trivial batch application which we use for implementing
all input and output patterns of the BDS Framework. This framework simplifies batch
application development by allowing the developer to focus on writing core-business logic and
not have to deal with the WebSphere XD Compute Grid specific programming model.
Note: The joblogs are retrieved and stored back into Eclipse project.
Figure 8-11 on page 110 illustrates this life cycle.
To get started with the sample, download and decompress the WXDCG_sample.zip file and
open the Eclipse workspace (batchdevenv.6.1.0.3.1/workspace). The workspace supplies
source code and build/install/run Ant scripts for the Echo application.
Scripts are supplied for the following actions:
112
data
ear
joblog
lib
props.packaging
props.simulator
Run properties for the Batch Simulator. One properties file is provided
for each sample application
script.ant
script.ant/config
script.ant/imports
script.wsadmin
tmp
xJCL
The workspace is nearly ready to use when you first open it. In fact, no configuration is
required if you intend only to execute the sample applications locally inside Eclipse using the
Batch Simulator. Configuration is required only to use the WebSphere XD Compute Grid Test
Server. To configure the Workspace to use the WebSphere XD Compute Grid Test Server,
edit scripts.ant/config/WASConfig.xml. Read the comment block at the top of
WASConfig.xml for instructions. Basically, you must specify a WebSphere Application Server
profile directory and a WebSphere Application Server server host and port.
1. Open the WASconfig.xml file under script.ant config.
2. Specify the following:
The WebSphere Application Server home installation directory, for example,
</WebSphere/AppServer/profiles/AppSrv01>
The WebSphere Application Server host name, for example, <localname>
The WebSphere Application Server default port, for example, <9080>
See Figure 8-13.
113
Figure 8-13 Configure the Workspace to use the Compute Grid Test Server, WASconfig.xml
JDBC
Z File
dat a
IB M co de
IBM co de
IBM co d e
inputs tr ea m
GenericXDBatchStep
outputs tre am
text file
byte file
ZFile
text file
Use r co de
Us er co de
U ser co d e
byte file
In detail, the input and output pattern of the BDS framework are:
JDBCReaderPattern and JDBCWriterPattern
Used to retrieve/write data from a database using a JDBC connection. The supported
classes are:
LocalJDBCReader / LocalJDBCWriter
JDBCReader / JDBCWriter
CursorHoldableJDBCReader
114
115
import
import
import
import
import
import
import
import
import
import
import
java.sql.ResultSet;
java.sql.ResultSetMetaData;
java.util.HashMap;
java.util.Properties;
com.ibm.jzos.ZFile;
com.ibm.websphere.batch.devframework.configuration.BDSFWLogger;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.ByteReaderPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.FileReaderPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.JDBCReaderPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.RecordOrientedDatasetReaderPattern;
com.ibm.websphere.batch.samples.echo.domainobjects.EchoDataHolder;
java.io.BufferedOutputStream;
java.io.BufferedWriter;
java.io.IOException;
java.sql.PreparedStatement;
java.util.Properties;
com.ibm.jzos.ZFile;
com.ibm.websphere.batch.devframework.configuration.BDSFWLogger;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.ByteWriterPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.FileWriterPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.JDBCWriterPattern;
com.ibm.websphere.batch.devframework.datastreams.patternadapter.RecordOrientedDatasetWriterPattern;
com.ibm.websphere.batch.samples.echo.domainobjects.EchoDataHolder;
116
JDBCWriterPattern, RecordOrientedDatasetWriterPattern {
...
}
A batch step class Echo.java in the com.batch.steps package which corresponds to the
basic flow echoReader --> Echo Step --> echoWriter. That means while not yet done
processing all records in the input stream, read the next record from echoReader, pass the
input record to the Echo step, which will apply some transformation to it, and write the
transformed record to the output stream. A batch step, represented as a
BatchJobStepInterface, whose task is to execute business logic against a stream of
records.
See Example 8-3.
Example 8-3 Basic flow of a batch step class
while (!doneProcessingRecords) {
inputRecord = getNextRecord();
outputRecord = processRecord(inputRecord);
writeOutputRecord(outputRecord);
}
The input batch data stream can be zero, one or n input or output streams. In the Echo
example, there is one input stream reading from a file and one output stream writing to a file.
The job definition for the simple Echo batch application includes the following information:
You have two options for your job definition to test your application:
Write the xJCL
Use a properties file and then generate the xJCL using a Ant script. The syntax is similar
to the xJCL and shown in Example 8-4.
Example 8-4 Properties for Echo batch application
job-name=Echo
application-name=Echo
controller-jndi-name=ejb/com/ibm/ws/batch/EchoBatchController
#
utilityjars=../lib/batchframework.jar;../lib/ibmjzos-1.4.jar
checkpoint-algorithm=com.ibm.wsspi.batch.checkpointalgorithms.RecordbasedBase
checkpoint-algorithm-prop.recordcount=1000
#Input Stream declarations
bds.inputStream=com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteReader
bds-prop.inputStream.PATTERN_IMPL_CLASS=com.batch.streams.inputstreams.EchoReader
bds-prop.inputStream.FILENAME=${echo.data}/input.txt
bds-prop.inputStream.debug=false
bds-prop.inputStream.EnablePerformanceMeasurement=false
bds-prop.inputStream.EnableDetailedPerformanceMeasurement=false
117
The WebSphere XD Compute Grid Batch Simulator includes an option for generating a
properties file for the WebSphere XD Compute Grid Batch Packager utility. This utility creates
a Java EE EAR file. To generate packaging properties using the Batch Simulator, simply
invoke the simulator as part of the configuration in the Eclipse workspace, passing the
simulator job properties, plus the -writePackagingProps flag, for example:
java com.ibm.websphere.batch.BatchSimulator EchoJobStep.props
writePackagingProps
You can use the generatePackagingProps.EchoBatchJobStep.xml Ant script from the
script.ant folder of the sample workspace to create the packaging properties for the
EchoJobStep application, as shown in Figure 8-15.
118
WebSphere XD Compute Grid includes a packaging utility called the Batch Packager.
Because WebSphere XD Compute Grid batch applications run in WebSphere Application
Servers, they are installed as Java EE EAR files. The Batch Packager handles many of the
details surrounding the EJB deployment descriptor and other minor details of EAR file
creation. The Batch Packager is driven by a properties file.
119
Use the packageApp.Echo.xml Ant script from the script.ant folder of the sample workspace
to create the EAR file for the Echo application, as shown in Figure 8-17 on page 120.
120
121
If you are using a properties file instead of writing the xJCL, you can use an Ant script called
generate.xJCL.Echo.xml, which is also provided in the workspace to generate the xJCL. See
Figure 8-18.
If you are writing the xJCL by yourself, you have to specify for each step the input/output
stream and the step you will use. The following code snippets explain each part in some more
122
detail. You can find the sample job in the xJCL folder (it is the generated xJCL from the
properties file /props.simulator/Echo.props). It is built as follows:
1. You have to declare the inputStream that the GenericXDBatchStep will look up and
resolve. See Example 8-6 for an excerpt and see Echo.xml in the xJCL directory of the
workspace for the complete XML.
Example 8-6 Declaration of inputStream in xJCL
<job name="Echo" default-application-name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<job-step name="Step1">
...
<batch-data-streams>
...
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="FILENAME" value="${echo.data}/input.txt"/>
...
<prop name="PATTERN_IMPL_CLASS" value="com.ibm.websphere.batch.samples.echo.streams.inputstreams.EchoReader"/>
</props>
<impl-class>
com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteReader</impl-class>
</bds>
</batch-data-streams>
...
</job-step>
</job>
2. You have to declare the outputStream that the GenericXDBatchStep will look up and
resolve. See Example 8-7 for an excerpt and see Echo.xml in the xJCL directory of the
workspace for the complete XML.
Example 8-7 Declaration of outputStream in xJCL
<job name="Echo" default-application-name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<job-step name="Step1">
...
<batch-data-streams>
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="FILENAME" value="${echo.data}/output.txt"/>
...
<prop name="PATTERN_IMPL_CLASS"
value="com.ibm.websphere.batch.samples.echo.streams.outputstreams.EchoWriter"/>
</props>
<impl-class>
com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteWriter</impl-class>
</bds>
...
</batch-data-streams>
...
</job-step>
</job>
123
3. You have to reference GenericXDBatchStep as the implementation for the job, as shown in
Example 8-8.
Example 8-8 Reference the GenericXDBatchStep
<job name="Echo" default-application-name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<jndi-name>ejb/com/ibm/ws/batch/EchoBatchController</jndi-name>
<step-scheduling-criteria>
<scheduling-mode>sequential</scheduling-mode>
</step-scheduling-criteria>
<checkpoint-algorithm name="chkpt">
<classname>com.ibm.wsspi.batch.checkpointalgorithms.RecordbasedBase</classname>
<props>
<prop name="recordcount" value="1000"/>
</props>
</checkpoint-algorithm>
<results-algorithms>
<results-algorithm name="jobsum">
<classname>com.ibm.wsspi.batch.resultsalgorithms.jobsum</classname>
</results-algorithm>
</results-algorithms>
<job-step name="Step1">
<jndi-name>ejb/GenericXDBatchStep</jndi-name>
<checkpoint-algorithm-ref name="chkpt"/>
<results-ref name="jobsum"/>
...
</job-step>
</job>
4. You have to specify your Batch Record Processor implementation as a step property, as
shown in Example 8-9.
Example 8-9 Batch record processor implementation
<job name="Echo" default-application-name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
...
<props>
<prop name="EnablePerformanceMeasurement" value="false"/>
<prop name="EnableDetailedPerformanceMeasurement" value="false"/>
<prop name="debug" value="false"/>
<prop name="BATCHRECORDPROCESSOR" value="com.ibm.websphere.batch.samples.echo.steps.Echo"/>
</props>
</job-step>
</job>
Now you are finished with the application development, and you can start testing the batch
application.
you to initially test your batch POJOs right inside the Eclipse environment. Bear in mind,
though, that the Batch Simulator runs in a J2SE environment, whereas the actual WebSphere
XD Compute Grid execution environment is Java EE, because it runs inside WebSphere
Application Server. Still, the Batch Simulator is useful for testing basic POJO applications and
testing the essential business logic in the batch job step.
In the example the batchsimulator.jar file is included in the Eclipse workspace but this file is
also part of the WebSphere Compute Grid installation and is located under, for example,
C:\IBM\WebSphere\AppServer\lib.
For initial testing, with the batch application in your Eclipse-based workspace, you can use
the Batch Simulator. To run the Echo sample with the Batch Simulator, you need to provide a
job definition that describes the batch job step you want to execute and its batch data
streams. A sample job definition that is ready to use for this sample batch job step can be
found in the Eclipse workspace under /props.simulator/Echo.props.
To configure a specific run for an application using the Batch Simulator in Eclipse, you have to
define that you want to run a java application. Add a name, for example, Echo, and add the
project name, the main class, the arguments which are needed and Classpath. Figure 8-20,
Figure 8-21, and Figure 8-22 show the configuration to run the Echo application using the
Batch Simulator. This is already configured in the sample workspace.
125
126
127
If you click Run Echo as shown in Figure 8-23, you receive the output as shown in
Example 8-10 in the console from the Echo sample. In addition, the output file is created.
128
...
BatchSimulator: outputStream checkpoint data: 6160000
BatchSimulator: inputStream checkpoint data: 77000
INFO->jobid: Echo:GenericXDBatchStep.destroyStep()- Total Execution Time: 1094
BatchSimulator: end job Echo - RC=0
129
and job execution environment. It also creates and configures local Derby databases to
support the job components.
Figure 8-24 shows the UTE topology.
Job Management C onsole
WebSphere JVM
Command Line Interface
J ob Scheduler
Derby
scheduler
database
xJCL
3
GEE
Derby
checkpoint
database
Programmatic
(EJB, J MS, or Web Servic es)
public getJobLog(St ring jobid) {
_scheduler. getJobLog( jobid);
}
130
131
[java] WASX7209I: Connected to process "server1" on node suthomasNode01 using SOAP connector; The
type of process is: UnManagedProcess
[java] WASX7303I: The following options are passed to the scripting environment and are available as
arguments that are stored in the argv variable: "[Echo,
C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../export/Echo.deployed.ear]"
[java] WASX7209I: Connected to process "server1" on node suthomasNode01 using SOAP connector; The
type of process is: UnManagedProcess
[java] WASX7303I: The following options are passed to the scripting environment and are available as
arguments that are stored in the argv variable: "[Echo,
C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../export/Echo.deployed.ear]"
[java] ADMA5017I: Uninstallation of Echo started.
[java] WASX7209I: Connected to process "server1" on node suthomasNode01 using SOAP connector; The
type of process is: UnManagedProcess
[java] WASX7303I: The following options are passed to the scripting environment and are available as
arguments that are stored in the argv variable: "[Echo,
C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../export/Echo.deployed.ear]"
[java] ADMA5017I: Uninstallation of Echo started.
[java] ADMA5104I: The server index entry for WebSphere:cell=suthomasNode01Cell,node=suthomasNode01 is
updated successfully.
[java] WASX7209I: Connected to process "server1" on node suthomasNode01 using SOAP connector; The
type of process is: UnManagedProcess
...
[java] installApp.py is installing Echo using
C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../export/Echo.deployed.ear
[java] ADMA5016I: Installation of Echo started.
[java] ADMA5058I: Application and module versions are validated with versions of deployment targets.
[java] ADMA5005I: The application Echo is configured in the WebSphere Application Server repository.
[java] ADMA5053I: The library references for the installed optional package are created.
[java] ADMA5005I: The application Echo is configured in the WebSphere Application Server repository.
[java] ADMA5001I: The application binaries are saved in
C:\WebSphere\ApplicationServer\profiles\AppSrv01\wstemp\Script121ef71ed7b\workspace\cells\suthomasNode01Cel
l\applications\Echo.ear\Echo.ear
[java] ADMA5005I: The application Echo is configured in the WebSphere Application Server repository.
[java] SECJ0400I: Successfuly updated the application Echo with the appContextIDForSecurity
information.
[java] ADMA5005I: The application Echo is configured in the WebSphere Application Server repository.
[java] ADMA5011I: The cleanup of the temp directory for application Echo is complete.
[java] ADMA5013I: Application Echo installed successfully.
[java] configuration saved
[java] application Echo started
[java] installApp.py complete
[java] Command complete - rc=0
BUILD SUCCESSFUL
Total time: 51 seconds
If the application is installed successfully in your local WebSphere environment, you have to
submit the job using the Eclipse workspace or using the job management console as we
describe later in this section.
132
Form your workspace, you can use the Ant script 5.runJob.Echo.xml, as shown in
Figure 8-26, for submitting a job. Right-click the script file and choose Run as Ant build.
During the job runs, you receive the output in the console of your Eclipse workspace. The job
log is also available in file under /joblog/<jobname_jobid>.job.log.txt. The output of this
sample is shown in Example 8-12.
Example 8-12 Output - Submit Job
Buildfile: C:\workspace\batchdevenv.6.1.0.3.1\workspace\BatchDevEnv\script.ant\5.runJob.Echo.xml
checkFile:
runJob:
[echo] Running job Echo.xml in Compute Grid Test Server
[echo] Test Server configuration: /WebSphere/ApplicationServer/profiles/AppSrv01
[echo] Test Server host:
localhost
[echo] Test Server port:
9083
[java] RunJob inputs:
[java] /WebSphere/ApplicationServer/profiles/AppSrv01
[java] C:\workspace\batchdevenv.6.1.0.3.1\workspace\BatchDevEnv\script.ant/..
[java] localhost
133
[java] 9083
[java] Echo.xml
[java] Substitution[0]: echo.data=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data
[java] Launched command /WebSphere/ApplicationServer/profiles/AppSrv01/bin/lrcmd.bat -cmd=submit
-xJCl=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../xJCL/Echo.xml -host=localhost -port=9083
echo.data=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data
[java] Command complete - rc=0
[java] runJob jobid=Echo:00014
[java] Launched command /WebSphere/ApplicationServer/profiles/AppSrv01/bin/lrcmd.bat -cmd=status -jobid=Echo:00014
-host=localhost -port=9083
[java] Command complete - rc=0
[java] Echo:00014 ended normally
[java] Launched command /WebSphere/ApplicationServer/profiles/AppSrv01/bin/lrcmd.bat -cmd=saveJobLog
-jobid=Echo:00014 -fileName=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../joblog/joblog.zip
-host=localhost -port=9083
[java] Command complete - rc=0
[java] Echo:00014 ended normally
[java] Launched command /WebSphere/ApplicationServer/profiles/AppSrv01/bin/lrcmd.bat -cmd=saveJobLog
-jobid=Echo:00014 -fileName=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../joblog/joblog.zip
-host=localhost -port=9083
[java] Joblog saved to
C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../joblog\Echo_00014.job.log.txt
[java] CWLRB5671I: [06/17/09 14:21:48:593 GMT-06:00] Processing for job Echo:00014 started.
[java] Original XJCL
[java] 1 : <?xml version="1.0" encoding="UTF-8"?>
[java] 2 : <!--## WebSphere Batch xJCL## This file generated on 2009.06.17 at 14:18:51 GMT-06:00 by:#
IBM Batch
Simulator Version 1.1 - Build 20080721#-->
[java] 3 : <job default-application-name="Echo" name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
[java] 4 :
<jndi-name>ejb/com/ibm/ws/batch/EchoBatchController</jndi-name>
[java] 5 :
<step-scheduling-criteria>
[java] 6 :
<scheduling-mode>sequential</scheduling-mode>
[java] 7 :
</step-scheduling-criteria>
[java] 8 :
<checkpoint-algorithm name="chkpt">
[java] 9 :
<classname>com.ibm.wsspi.batch.checkpointalgorithms.RecordbasedBase</classname>
[java] 10 :
<props>
[java] 11 :
<prop name="recordcount" value="1000"></prop>
[java] 12 :
</props>
[java] 13 :
</checkpoint-algorithm>
[java] 14 :
<results-algorithms>
[java] 15 :
<results-algorithm name="jobsum">
[java] 16 :
<classname>com.ibm.wsspi.batch.resultsalgorithms.jobsum</classname>
[java] 17 :
</results-algorithm>
[java] 18 :
</results-algorithms>
[java] 19 :
<job-step name="Step1">
[java] 20 :
<jndi-name>ejb/GenericXDBatchStep</jndi-name>
[java] 21 :
<checkpoint-algorithm-ref name="chkpt"></checkpoint-algorithm-ref>
[java] 22 :
<results-ref name="jobsum"></results-ref>
[java] 23 :
<batch-data-streams>
[java] 24 :
<bds>
[java] 25 :
<logical-name>outputStream</logical-name>
[java] 26 :
<props>
[java] 27 :
<prop name="FILENAME" value="${echo.data}/output.txt"></prop>
[java] 28 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
[java] 29 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 30 :
<prop name="AppendJobIdToFileName" value="false"></prop>
[java] 31 :
<prop name="debug" value="false"></prop>
[java] 32 :
<prop name="tablename" value="alg.tivpwxd0"></prop>
[java] 33 :
<prop name="PATTERN_IMPL_CLASS"
value="com.batch.streams.outputstreams.EchoWriter"></prop>
[java] 34 :
</props>
[java] 35 :
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteWriter</impl-class>
[java] 36 :
</bds>
[java] 37 :
<bds>
[java] 38 :
<logical-name>inputStream</logical-name>
[java] 39 :
<props>
134
[java] 40 :
<prop name="FILENAME" value="${echo.data}/input.txt"></prop>
[java] 41 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
[java] 42 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 43 :
<prop name="debug" value="false"></prop>
[java] 44 :
<prop name="PATTERN_IMPL_CLASS"
value="com.batch.streams.inputstreams.EchoReader"></prop>
[java] 45 :
</props>
[java] 46 :
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteReader</impl-class>
[java] 47 :
</bds>
[java] 48 :
</batch-data-streams>
[java] 49 :
<props>
[java] 50 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
[java] 51 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 52 :
<prop name="debug" value="false"></prop>
[java] 53 :
<prop name="BATCHRECORDPROCESSOR" value="com.batch.steps.Echo"></prop>
[java] 54 :
</props>
[java] 55 :
</job-step>
[java] 56 : </job>
[java] Substituted XJCL
[java] 1 : <?xml version="1.0" encoding="UTF-8"?>
[java] 2 : <!--## WebSphere Batch xJCL## This file generated on 2009.06.17 at 14:18:51 GMT-06:00 by:#
IBM Batch
Simulator Version 1.1 - Build 20080721#-->
[java] 3 : <job default-application-name="Echo" name="Echo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
[java] 4 :
<jndi-name>ejb/com/ibm/ws/batch/EchoBatchController</jndi-name>
[java] 5 :
<step-scheduling-criteria>
[java] 6 :
<scheduling-mode>sequential</scheduling-mode>
[java] 7 :
</step-scheduling-criteria>
[java] 8 :
<checkpoint-algorithm name="chkpt">
[java] 9 :
<classname>com.ibm.wsspi.batch.checkpointalgorithms.RecordbasedBase</classname>
[java] 10 :
<props>
[java] 11 :
<prop name="recordcount" value="1000"></prop>
[java] 12 :
</props>
[java] 13 :
</checkpoint-algorithm>
[java] 14 :
<results-algorithms>
[java] 15 :
<results-algorithm name="jobsum">
[java] 16 :
<classname>com.ibm.wsspi.batch.resultsalgorithms.jobsum</classname>
[java] 17 :
</results-algorithm>
[java] 18 :
</results-algorithms>
[java] 19 :
<job-step name="Step1">
[java] 20 :
<jndi-name>ejb/GenericXDBatchStep</jndi-name>
[java] 21 :
<checkpoint-algorithm-ref name="chkpt"></checkpoint-algorithm-ref>
[java] 22 :
<results-ref name="jobsum"></results-ref>
[java] 23 :
<batch-data-streams>
[java] 24 :
<bds>
[java] 25 :
<logical-name>outputStream</logical-name>
[java] 26 :
<props>
[java] 27 :
<prop name="FILENAME"
value="C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data/output.txt"></prop>
[java] 28 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
[java] 29 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 30 :
<prop name="AppendJobIdToFileName" value="false"></prop>
[java] 31 :
<prop name="debug" value="false"></prop>
[java] 32 :
<prop name="tablename" value="alg.tivpwxd0"></prop>
[java] 33 :
<prop name="PATTERN_IMPL_CLASS"
value="com.batch.streams.outputstreams.EchoWriter"></prop>
[java] 34 :
</props>
[java] 35 :
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteWriter</impl-class>
[java] 36 :
</bds>
[java] 37 :
<bds>
[java] 38 :
<logical-name>inputStream</logical-name>
[java] 39 :
<props>
[java] 40 :
<prop name="FILENAME"
value="C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data/input.txt"></prop>
[java] 41 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
135
[java] 42 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 43 :
<prop name="debug" value="false"></prop>
[java] 44 :
<prop name="PATTERN_IMPL_CLASS"
value="com.batch.streams.inputstreams.EchoReader"></prop>
[java] 45 :
</props>
[java] 46 :
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.FileByteReader</impl-class>
[java] 47 :
</bds>
[java] 48 :
</batch-data-streams>
[java] 49 :
<props>
[java] 50 :
<prop name="EnablePerformanceMeasurement" value="false"></prop>
[java] 51 :
<prop name="EnableDetailedPerformanceMeasurement" value="false"></prop>
[java] 52 :
<prop name="debug" value="false"></prop>
[java] 53 :
<prop name="BATCHRECORDPROCESSOR" value="com.batch.steps.Echo"></prop>
[java] 54 :
</props>
[java] 55 :
</job-step>
[java] 56 : </job>
[java] CWLRB5684I: [06/17/09 14:21:48:718 GMT-06:00] Job Echo:00014 is queued for execution
[java] CWLRB5586I: [06/17/09 14:21:48:718 GMT-06:00] CWLRS6006I: Job class Default, Importance 8, Service Class
null, Service Goal Type 0, Application Type j2ee, Submitter UNAUTHENTICATED.
[java] CWLRB5586I: [06/17/09 14:21:48:718 GMT-06:00] CWLRS6007I: Job Arrival Time 6/17/09 2:21 PM, Goal Max
Completion Time 0, Goal Max Queue Time 0, Breach Time 6/18/09 2:21 PM.
[java] CWLRB5586I: [06/17/09 14:21:48:718 GMT-06:00] CWLRS6021I: List of eligible endpoints to execute the job:
suthomasNode01/server1.
[java] CWLRB5586I: [06/17/09 14:21:48:718 GMT-06:00] CWLRS6011I: APC is not active. GAP will make the endpoint
selection.
[java] CWLRB5586I: [06/17/09 14:21:49:031 GMT-06:00] CWLRS6013I: GAP is dispatching job Echo:00014. Job queue time
0.313 seconds.
[java] CWLRB3090I: [06/17/09 14:21:49:343 GMT-06:00] Job Echo:00014 is dispatched to endpoint
suthomasNode01\server1: result: 0
[java] CWLRB5588I: [06/17/09 14:21:49:359 GMT-06:00] Setting up j2ee job Echo:00014 for execution in Grid Execution
Environment suthomasNode01Cell/suthomasNode01/server1: [jobClass Default] [jobName Echo] [module null] [user
UNAUTHENTICATED] [applicationName Echo] [applicationType j2ee] [transactionClass ${default_iiop_transaction_class}]
[java] CWLRB2210I: [06/17/09 14:21:49:453 GMT-06:00] Job setup manager bean is setting up job: Echo:00014
[java] CWLRB1690I: [06/17/09 14:21:49:468 GMT-06:00] No match found in job status table entry using key: [bjeename
*] [jobid Echo:00014]: Job Echo:00014 is not restarting.
[java] CWLRB1740I: [06/17/09 14:21:49:562 GMT-06:00] Job [Echo:00014] is in job setup.
[java] CWLRB1670I: [06/17/09 14:21:49:593 GMT-06:00] Creating abstract resources required by the job.
[java] CWLRB1760I: [06/17/09 14:21:49:625 GMT-06:00] Job [Echo:00014] is submitted for execution.
[java] CWLRB2230I: [06/17/09 14:21:49:687 GMT-06:00] Job setup manager bean completed job Echo:00014 setup: return
code: 0
[java] CWLRB1850I: [06/17/09 14:21:49:703 GMT-06:00] Initializing for step dispatch using scheduling mode:
sequential
[java] CWLRB1650I: [06/17/09 14:21:49:718 GMT-06:00] Created checkpoint repository table entry using key: [jobid
Echo:00014] [stepname Step1] [bdsname outputStream]
[java] CWLRB1650I: [06/17/09 14:21:49:734 GMT-06:00] Created checkpoint repository table entry using key: [jobid
Echo:00014] [stepname Step1] [bdsname inputStream]
[java] CWLRB1970I: [06/17/09 14:21:49:750 GMT-06:00] Created job step status table entry using key [jobid
Echo:00014] [stepname Step1]
[java] CWLRB1990I: [06/17/09 14:21:49:750 GMT-06:00] Found job results table entry matching on key: [jobid
Echo:00014]
[java] CWLRB2030I: [06/17/09 14:21:49:750 GMT-06:00] Initialization for sequential step dispatch is complete.
[java] CWLRB1870I: [06/17/09 14:21:49:750 GMT-06:00] Subscribing to job cancel or stop subject:
BizGridJobCancel_Echo:00014
[java] CWLRB1910I: [06/17/09 14:21:49:750 GMT-06:00] Dispatching job Echo:00014: job contains 1 step(s).
[java] CWLRB2420I: [06/17/09 14:21:49:828 GMT-06:00] Job [Echo:00014] Step [Step1] is in step setup.
[java] CWLRB5616I: [06/17/09 14:21:49:843 GMT-06:00] Setting step Step1 batch data stream outputStream properties:
EnableDetailedPerformanceMeasurement=false EnablePerformanceMeasurement=false
FILENAME=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data/output.txt
AppendJobIdToFileName=false debug=false PATTERN_IMPL_CLASS=com.batch.streams.outputstreams.EchoWriter
tablename=alg.tivpwxd0
[java] CWLRB5618I: [06/17/09 14:21:49:843 GMT-06:00] Initializing step Step1 batch data stream outputStream
[java] CWLRB5620I: [06/17/09 14:21:49:859 GMT-06:00] Opening step Step1 batch data stream outputStream
[java] CWLRB5616I: [06/17/09 14:21:49:859 GMT-06:00] Setting step Step1 batch data stream inputStream properties:
EnableDetailedPerformanceMeasurement=false EnablePerformanceMeasurement=false
136
FILENAME=C:/workspace/batchdevenv.6.1.0.3.1/workspace/BatchDevEnv/script.ant/../data/input.txt debug=false
PATTERN_IMPL_CLASS=com.batch.streams.inputstreams.EchoReader
[java] CWLRB5618I: [06/17/09 14:21:49:859 GMT-06:00] Initializing step Step1 batch data stream inputStream
[java] CWLRB5620I: [06/17/09 14:21:49:875 GMT-06:00] Opening step Step1 batch data stream inputStream
[java] CWLRB5622I: [06/17/09 14:21:50:031 GMT-06:00] Loading job step bean for step Step1 using jndi name:
ejb/GenericXDBatchStep
[java] CWLRB5594I: [06/17/09 14:21:50:156 GMT-06:00] Step Step1 setup is complete: ended normally
[java] CWLRB2440I: [06/17/09 14:21:50:187 GMT-06:00] Job [Echo:00014] Step [Step1] is dispatched.
...
[java] CWLRB5628I: [06/17/09 14:21:54:093 GMT-06:00] Step Step1: chkpt checkpoint taken [iteration 76000]
[java] CWLRB5628I: [06/17/09 14:21:54:109 GMT-06:00] Step Step1: chkpt checkpoint taken [iteration 77000]
[java] CWLRB5630I: [06/17/09 14:21:54:156 GMT-06:00] Step Step1 completes normally: ended normally
[java] CWLRB2460I: [06/17/09 14:21:54:156 GMT-06:00] Job [Echo:00014] Step [Step1] is in step breakdown.
[java] CWLRB5606I: [06/17/09 14:21:54:171 GMT-06:00] Destroying job step: Step1
[java] System.out: [06/17/09 14:21:54:171 GMT-06:00] INFO->jobid: Echo:00014:GenericXDBatchStep.destroyStep()Total Execution Time: 4015
[java] CWLRB5608I: [06/17/09 14:21:54:171 GMT-06:00] Job step Step1 destroy completed with rc: 0
[java] CWLRB5610I: [06/17/09 14:21:54:218 GMT-06:00] Firing Step1 results algorithm
com.ibm.wsspi.batch.resultsalgorithms.jobsum: [RC 0] [jobRC 0]
[java] CWLRB5624I: [06/17/09 14:21:54:218 GMT-06:00] Stopping step Step1 chkpt checkpoint. User transaction
status: STATUS_ACTIVE
[java] CWLRB5602I: [06/17/09 14:21:54:234 GMT-06:00] Closing Step1 batch data stream: outputStream
[java] CWLRB5602I: [06/17/09 14:21:54:843 GMT-06:00] Closing Step1 batch data stream: inputStream
[java] CWLRB5604I: [06/17/09 14:21:54:859 GMT-06:00] Freeing Step1 batch data stream: outputStream
[java] CWLRB5604I: [06/17/09 14:21:54:859 GMT-06:00] Freeing Step1 batch data stream: inputStream
[java] CWLRB2600I: [06/17/09 14:21:54:859 GMT-06:00] Job [Echo:00014] Step [Step1] completed normally rc=0.
[java] CWLRB5594I: [06/17/09 14:21:54:890 GMT-06:00] Step Step1 execution is complete: ended normally
[java] CWLRB1890I: [06/17/09 14:21:54:906 GMT-06:00] Unsubscribing from job cancel or stop subject:
BizGridJobCancel_Echo:00014
[java] CWLRB3800I: [06/17/09 14:21:54:906 GMT-06:00] Job [Echo:00014] ended normally.
[java] CWLRB5596I: [06/17/09 14:21:54:953 GMT-06:00] Grid Execution Environment sequential step processing
complete: ended
[java] CWLRB2250I: [06/17/09 14:21:54:953 GMT-06:00] Job setup manager bean is breaking down job: Echo:00014
[java] CWLRB5598I: [06/17/09 14:21:54:953 GMT-06:00] Removing job abstract resources
[java] CWLRB5600I: [06/17/09 14:21:54:953 GMT-06:00] Removing job step status table entries
[java] CWLRB2270I: [06/17/09 14:21:54:984 GMT-06:00] Job setup manager bean completed job Echo:00014 breakdown
[java] CWLRB5764I: [06/17/09 14:21:54:984 GMT-06:00] Job Echo:00014 ended
[java] Command complete - rc=0
BUILD SUCCESSFUL
Total time: 34 seconds
The sample output data will be saved in /data/output.txt, as shown in Figure 8-27.
The other option is to use the Job Management Console (JMC) to schedule a job and submit
jobs. You can also submit, manage, and view job logs using WebSphere XD Compute Grids
Job Management Console. Just point your browser at http://localhost/jmc. For example,
for checking the job log, click View jobs under Job Management, open your specific job
137
identified by the job ID, and you can see the job output of the Echo sample, as shown in
Figure 8-28.
bds-prop.inputStream.FILENAME=/u/sthomas/data/input.txt
...
bds-prop.outputStream.FILENAME=/u/sthomas/data/output.txt
138
2. The next step is to transfer the necessary files to the host. You can use FTP, an FTP client,
an Ant script from your workspace, or tools such as Rational Developer for System z to
transfer the following files to the UNIX System Services directory:
zEcho.props
Libraries
batchframework.jar
batchpackager.jar
batchsimulator.jar
batchsimulatorRT.jar
ibmjzos-1.4.jar
input.txt
Echo.jar (also available in the workspace in the lib directory)
3. Export your Echo sample to Echo.jar. Select domain objects, steps, input streams, and
output streams, right-click, and select Export in the pop-up window, as shown in
Figure 8-29.
139
4. In the following window, specify the output JAR file, and select other options, as shown in
Figure 8-30.
140
5. After the export and upload, the UNIX System Services file system on z/OS should look as
shown in Figure 8-31.
Figure 8-31 Using the Batch Simulator under UNIX System Services - Files, as shown through the
Rational Developer for System z remote system explorer view
6. Create a batch.sh file under UNIX System Services, and add the command shown in
Example 8-14.
Example 8-14 Sample batch.sh file to run Echo under z/OS with Batch Simulator
java -classpath
lib/Echo.jar:lib/batchframework.jar:lib/batchsimulator.jar:lib/batchsimulatorRT
.jar:lib/batchruntime.jar:lib/ibmjzos1.4.jar
com.ibm.websphere.batch.BatchSimulator xJCL/zEcho.props
141
7. Change the permission of the script to 755 and run the shell script batch.sh from your
UNIX System Services console, as shown in Figure 8-32. The command window of
Rational Developer for System z could also be used to invoke the chmod command and run
the shell script.
Figure 8-32 Run batch.sh to use the Batch Simulator under UNIX System Services
142
The output should look as shown in Figure 8-33 and Figure 8-34.
Figure 8-33 Run Echo sample with Batch Simulator under UNIX System Services - Part 1
Figure 8-34 Run Echo sample with Batch Simulator under UNIX System Services - Part 2
143
WebSphere z/OS
Command Line Interfac e
WebSphere JVM
xJCL
J ob Scheduler
Programmatic
(EJB, J MS, or Web Servic es)
public getJobLog( String jobid) {
_scheduler.getJobLog(jobid) ;
}
D B2 z/OS
WebSphere JVM
GEE
DB2 z/OS
Figure 8-36 WebSphere Application Server for z/OS Job Scheduler and Grid Execution Endpoint
144
We use DB2 z/OS instead of the default Derby database tables (already configured after the
installation). To use DB2 for z/OS, define a DB2 Universal JDBC Driver Provider and two data
sources for the job scheduling and for the checkpoint database. See Figure 8-37.
Figure 8-37 Data source definition for job scheduling and checkpoint database
145
The last step is to configure the Job Scheduler under System administration Job
scheduler. Set the following properties, as shown in Figure 8-38:
The Grid Execution Endpoints are defined under Job scheduler WebSphere grid
endpoint, as shown in Figure 8-39.
146
The next step, after the WebSphere XD Compute Grid z/OS is running, is to install the Echo
sample application. You can use a wsadmin script or the Admin console. When using the
Admin console, you can install your Echo sample under Applications Install New
Application. Browse to the Echo.deployed.ear file in the Eclipse workspace, and click Next,
as shown in Figure 8-40.
Click Next to accept the defaults on the next window, because we do not need any installation
options. These might be necessary for other applications. To map the modules to the GEE
server, choose the server for the grid execution, select the module EchoEJBs, click Apply
and then click Next, as shown in Figure 8-41.
147
Click Finish. Your Echo application is now installed on the grid execution server. Click Save
(directly to the master configuration), as shown in Figure 8-42.
The last step, is to start the Echo application. Select Echo, and click Start, as shown in
Figure 8-43.
148
Your Echo sample application should now start successfully, resulting in a green arrow, as
shown in Figure 8-44.
Figure 8-44 Run Echo application on WebSphere Application Server for z/OS
You can find different options to trigger a batch application in 14.2, Using WebSphere XD
Compute Grid trigger mechanisms on page 234.
149
Take note of the debugger port number. The default of 7777 should be fine. In addition,
remember that you must restart the Test Server to activate the debugger port.
150
2. Next, create a Debug Configuration in Eclipse. The port number in the debug configuration
must match the one you used in your Test Server configuration, as shown in Figure 8-46.
Click Debug to activate the debug session.
151
3. Finally, set a break point in your batch application and run a job that executes it, as shown
in Figure 8-47, by clicking in the left margin of the source code pane next to the statement
where you want the debug sessions to pause.
4. Now, run the job using the runJobEcho.xml Ant script, as shown in Figure 8-48, and this
time, the debug window opens.
152
8.7.6 Reusing the Echo application for huge data processing using BDS
With the simple Echo application you can start to create more data processing batch flows
only by using xJCL and the patterns of the BDS framework. To run the Echo example as
shown in Figure 8-49, the xJCL includes the following steps each having an input and an
output stream mapping:
File
(input.tx t)
Te xtFil eR ea der
RecordOri entedReade r
JD BCR eader
JDBCReader
R ec ordOrientedDatasetRead er
Step 1
Step 2
Step3
Step 4
Step 5
Java
Java
Java
J av a
Java
RecordOri entedDatasetWriter
JDBCWri ter
JDBCWri ter
RecordOrientedDatasetWriter
TextFi leWriter
data
data
ZFile
JOB_ID
COUNTER
STRING
ZFile
File
(output.txt)
TIMESTAMP
Note: The Echo sample uses a batch step and input/output patterns from the BDS
framework.
153
To create such data flow processing using the Echo application, which implements all BDS
patterns, you have to change the properties for the input/output stream in the xJCL:
For data in files
FileByteReader / FileByteWriter (Example 8-15)
TextFileReader / TextFileWriter (Example 8-16)
Example 8-15 xJCL properties for reading from a text file
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.batch.streams.inputstreams.EchoReader"></prop>
<prop name="FILENAME" value="/u/sthomas/data/input.txt"></prop>
<prop name="debug" value="false"></prop>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileReader</impl-class>
</bds>
Example 8-16 xJCL properties for writing to a text file
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.batch.streams.inputstreams.EchoWriter"></prop>
<prop name="FILENAME" value="/u/sthomas/data/output.txt"></prop>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.TextFileWriter</implclass>
</bds>
</bds>
154
Example 8-18 xJCL properties for writing byte data into a z/OS data set
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.batch.streams.outputstreams.EchoWriter"/>
<prop name="DSNAME" value="STHOMAS.BATCH.RECORD.OUTPUT"/>
<prop name="ds_parameters" value="wt"/>
<prop name="file.encoding" value="CP1047"/>
<prop name="debug" value="${debug}"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.ZFileStreamOrientedByteWriter</impl-c
lass>
</bds>
<bds>
<logical-name>inputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.batch.streams.inputstreams.EchoReader"/>
<prop name="jdbc_url" value="jdbc:derby:C:\\mysample\\CREDITREPORT"/>
<prop name="jdbc_driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<prop name="user_id" value="myuserid"/>
<prop name="pswd" value="mypswd"/>
<prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCReader</impl-class>
</bds>
Example 8-20 xJCL properties for writing data to a database using a JDBC connection
<bds>
<logical-name>outputStream</logical-name>
<props>
<prop name="PATTERN_IMPL_CLASS" value="com.batch.streams.outputstreams.EchoWriter"/>
<prop name="jdbc_url" value="jdbc:derby:C:\\mysample\\CREDITREPORT"/>
<prop name="jdbc_driver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<prop name="user_id" value="myuserid"/>
<prop name="pswd" value="mypswd"/>
<prop name="debug" value="true"/>
</props>
<impl-class>com.ibm.websphere.batch.devframework.datastreams.patterns.LocalJDBCWriter</impl-class>
</bds>
8.7.7 Conclusion
WebSphere Extended Deployment Compute Grid provides a simple abstraction of a batch job
step and its inputs and outputs. The programming model is concise and straightforward to
use. The built-in checkpoint/rollback mechanism makes it easy to build robust, restartable
Java batch applications. The Batch Simulator utility offers an alternative test environment that
Chapter 8. Implement new functionality using Java in WebSphere XD Compute Grid
155
runs inside your Eclipse (or Rational Application Developer or Rational Developer for System
z) development environment. Its xJCL generator can help jump start you to the next phase of
testing in the Compute Grid Unit Test Server.
8.8 Summary
Batch applications within a WebSphere XD Compute Grid environment are deployed like any
regular Java EE application. After it is deployed, WebSphere Compute Grid detects that it is a
Java EE-based batch application. When the application is deployed, an administrator can
define service policies for the application, in preparation for submitting a job. The service
policies are different for such batch applications, the only metrics supported for batch
applications are maximum desired queue time and discretionary.
156
Chapter 9.
157
PHP scripts
Additional libraries
PDO_ODBC extension
z/OS USS
Figure 9-1 PHP for z/OS overview
158
USS
PHP scripts
PHP interpreter
PHP batch
launcher
TWS
JCL
JES Sysout
z/OS
Figure 9-2 PHP batch launcher overview
BPXBATCH
BPXBATSL
AOPBATCH
COZBATCH
No
Yes
Yes
Yes
Yes (1.7+)
Yes (1.7+)
Yes
Yes
No
No
Yes
Yes
Yes
No (unless
root)
No
Yes
Yes
Yes
Yes
Yes
Limiteda
Limiteda
Limiteda
Yes
No
No
Yes
Yes
No
No
No
Yes
a. One or more ENVAR() Language Environment runtime options can be specified on the PARM
to set environment variables using JCL variables. The size of the entire PARM field is limited
to 100 characters.
159
Eclipse on local
workstation
Develop PHP scripts and JCL
ANT deploy script
USS
PHP scripts
PHP interpreter
PHP batch
launcher
JCL
JES Sysout
z/OS
To deploy and execute the locally developed scripts on z/OS afterwards, we used an Ant
script that executes the following steps:
1. Upload all locally developed *.php files using FTP in ASCII mode to a z/OS UNIX System
Services directory.
Optionally, *.php files from other external PHP libraries can also be uploaded into a
separate z/OS UNIX System Services directory.
2. Upload a JCL to an MVS data set using FTP in ASCII. This JCL is calling a batch launcher
like BPXBATCH to execute PHP under UNIX System Services.
3. Submit the job with a Java program, which is like using the Jakarta Commons Net FTP
classes to submit the job using FTP.
4. Retrieve the Output using FTP using the same program described in step 3.
160
All steps are completely automated, that means one click deploys, submits and retrieves the
output of the PHP batch. We provide a complete explanation, including the sample code, in
the next section.
TW S
Sequential
dataset
COBOL job
creating data
for invoices
DB2
COBOL job
printing invoices
on printer
PHP job
creating
pdf invoices
PHP job
sending pdf files
files via E-Mail
The ERM model for the DB2 database and the data creation job in COBOL remain the same.
For convenience, we also included it in the sample Eclipse project part of the Additional
Material as described in Importing and customizing the sample project on page 164 later on.
On the following pages, we will explain how to implement this sample with the development
environment explained in 9.3, Development tools on page 160.
161
3. Select the Eclipse Java Development Tools as shown in Figure 9-5 on page 162, click
Next, and follow the instructions to install the package.
To facilitate the application deployment from the Eclipse workbench, the Ant FTP support
in Eclipse needs to be included in the classpath.
Download commons-net-2.0.zip and jakarta-oro-2.0.8.zip from:
http://commons.apache.org/downloads/download_net.cgi
http://jakarta.apache.org/site/downloads/downloads_oro.cgi
162
5. Select the two JAR files in the c:\ant_ftp_jars directory, and click Open. The Ant FTP
support JAR files are added to the Ant classpath. Click OK.
Now, Eclipse is ready for PHP development with Ant support.
163
164
3. In the window that opens, select the Select archive file option, and then select the
compressed file using the Browse button as shown in Figure 9-8. Click Finish. Now the
project is imported.
165
execute.sh
PHPPDF
The JCL that starts the PHP job with a batch launcher.
lib
deploy.xml
The Ant script that performs the steps described in 9.3, Development
tools on page 160.
Important: You do not need to modify the deploy.xml script. All parameters, such as
destination directories, are managed by an external properties file.
submit.jar
The Java program that is called by the Ant script. It submits the job
using FTP and retrieves the job output back to Eclipse.
zos.properties
The DNS name or IP address of the z/OS system to where you want to
deploy the PHP application.
userid
A TSO user name that allows you to log in using FTP on the z/OS
destination system.
password
jcl.dsn
A partitioned data set where you can store the JCL as member.
Note: This partitioned data set must already exist or be newly allocated.
appl.home
The UNIX System Services directory where you want to store the PHP
application.
jclPath
For each Eclipse project, the JCL file names need to be different to
avoid overwriting members with the same name on the host. For that
reason, you can change the path in the zos.properties file.
waittime
If a PHP batch job runs very long, the Ant task that tries to retrieve the
job output from JES using FTP might run into a timeout. In that case,
you can use this parameter to specify a wait time in seconds.
password = PASSWORD
# The JCL PDS dataset, which must be in single quotes:
jcl.dsn = 'STRAUER.SAMPLE.JCL'
# the home directory for deploying the application jar
appl.home = /u/strauer/php
# local JCL pathes
jclPath = jcl/PHPPDF
# time to wait for output in seconds
waittime = 0 for output in seconds
waittime = 0
JCL
Next, you need to customize the JCL. Open the PHPPDF file in the jcl folder. In this JCL,
customize the following lines:
Job name
The job name has be your user ID plus exactly one character. Otherwise, we cannot
submit the job using FTP.
PARM statement in STEP1 and STEP2
We have to adjust the path to point <appl_home>/appl/execute whereby <appl_home> is
the value of appl.home set in zos.properties.
Example 9-2 shows a sample JCL.
Example 9-2 Sample JCL to submit PHP job
//STRAUERA JOB
/*JOBPARM SYSAFF=SC48,L=9999
//********************************************************************
//* Run PHP under a UNIX System Service shell
//********************************************************************
//HOLD OUTPUT JESDS=ALL,DEFAULT=Y,OUTDISP=(HOLD,HOLD)
//STEP1 EXEC PGM=BPXBATCH,
// PARM='SH chmod 755 /u/strauer/php/appl/execute.sh'
//STEP2 EXEC PGM=BPXBATCH,
// PARM='SH /u/strauer/php/appl/execute.sh'
//STDIN DD DUMMY
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//
Note: We use BPXBATCH in our sample. Of course, you can also use one of the other
batch launchers listed in Table 9-1 on page 159.
167
You can find the source code that we developed to read the DB2 z/OS data and to create PDF
files, which consists of DbConnect.php and InvoiceCreator.php, in the src folder and in PHP
PDF creator on page 442.
Assuming that ODBC for DB2 z/OS is set up properly, you need to change $dsn, $username,
and $passwd in DbConnect.php, as shown in Example 9-3.
Example 9-3 Parameters to connect to DB2 z/OS
$dsn='odbc:DB9G';
$username='STRAUER';
$passwd='PASSWORD';
Because the JCL calls the PHP application using the execute.sh shell script, you need to
customize it for your environment. The shell script consists of the following statements:
A PATH variable export pointing to the bin directory of PHP.
A STEPLIB variable export pointing SDSNLOAD and SDSNLOD2 for proper ODBC
usage.
A DSNAOINI export pointing to the ODBC ini file because ODBC would not work without
it.
168
A chmod of the DbConnect.php file because the file should only be accessible by the owner
because it contains the user name and password for DB2.
The final call of the PHP script, including a directory path as a parameter to the PHP
script. The created PDF files are stored in this directory.
You need to customize these statements to your environment. Example 9-4 shows the
customization for our example.
Example 9-4 Sample execute.sh shell script
export PATH=$PATH:/usr/lpp/php/bin
export STEPLIB=$STEPLIB:DB9G9.SDSNLOAD:DB9G9.SDSNLOD2
export DSNAOINI="/u/strauer/php/odbc.ini"
chmod 700 /u/strauer/php/appl/DbConnect.php
php /u/strauer/php/appl/InvoiceCreator.php /u/strauer/php/pdf
Now, you can deploy the application by right-clicking deploy.xml, and selecting Run As
Ant Build as shown in Figure 9-11.
169
Then, select which deployment targets to used (see Figure 9-12). The default is all. We select
Run to execute the Ant script.
[...]
[java]
[java]
[java]
[java]
[java]
[java]
[java]
[java]
[java]
[java]
[java]
PATH is /usr/lpp/Printsrv/bin:/bin:/usr/sbin:/usr/lpp/java/J5.0/bin
X-Powered-By: PHP/5.1.2
Content-type: text/html
Connecting to DB2
... Connected
Starting to create pdf file /u/strauer/php/pdf/Invoice_No_1.pdf...
Starting to create pdf file /u/strauer/php/pdf/Invoice_No_2.pdf...
Starting to create pdf file /u/strauer/php/pdf/Invoice_No_3.pdf...
Starting to create pdf file /u/strauer/php/pdf/Invoice_No_7.pdf...
Starting to create pdf file /u/strauer/php/pdf/Invoice_No_8.pdf...
!! END OF JES SPOOL FILE !!
[...]
170
Finally, you can check the results. Figure 9-13 shows how one batch created PDF files.
Note: The PHP script produces PDF files that are encoded in EBCDIC. To get around this,
we identified the following different options:
Download the PDF files in ASCII mode using FTP (this will do an automatic code page
conversion to ASCII) for further processing by other applications.
Implement an iconv job in UNIX System Services.
Modify the FPDF PHP script directly to use the PHP function iconv when performing file
system output. That means we already do a conversion from IBM-1047 to ISO8859-1
before writing to the file system.
The next step is to implement another job in PHP that takes all of these PDF files and sends
them to their recipients.
To sum it up, this sample application shows how PHP together with a batch launcher can be
used to easily get additional functionality in a batch environment.
171
172
10
Chapter 10.
173
Available skills
While talking about different programming languages and runtime environments, skills can
become a critical factor, such as:
What kind of programming skill is available in your company?
Is enough skill for the runtime environment (CICS, IMS, DB2, and WebSphere XD
Compute Grid) available?
How will the situation be in the future? Will people retire, for example? If yes, a strategy
for a new programming language or runtime environment might be evaluated.
IT Strategy
How does each scenario fit into your IT strategy (for example, do you have a Java EE
strategy)?
Platform independency
If platform independency is important for you, PHP or Java in every z/OS run time might
be the preferred language compared to COBOL, PL/I, or Assembler.
Runtime cost
Depending on which approach you choose, you might get a substantially different cost to
run a certain application with different technologies. Some factors that influence the (run
time) cost are:
Java runs largely on zAAPs, and if you have only zIIP engines and no zAAP engines,
you can use the zAAP on zIIP solution from IBM.
If you use XML in COBOL, PL/I, or Assembler, the XML parsing part can also run on a
zIIP
PHP only runs on General Purpose Processors (GPs)
Development cost
Development cost can differ depending on the programming language. Important factors
determining development cost are:
Skills availability (skills that are widely available tend to be cheaper than skills that are
scarce)
Tools productivity
Functionality of the language
Robustness of the technology (troubleshooting takes a lot of time)
Development tools
All solutions offer very good tool capabilities to develop batch applications for z/OS, so we
do not expect the tooling to be a big factor in making a decision between the options
discussed in this part of the book.
Access to z/OS data
COBOL, PL/I, C/C++, and Java in all run times offer APIs for accessing z/OS data.
However, access to native z/OS data (MVS data sets) is supported in an easier and more
natural way in COBOL, PL/I, and Assembler than in Java, C/C++ or PHP. Especially in a
high-volume batch environment with lots of I/O on MVS data sets this can become a key
decision factor. In summary:
COBOL, PL/I, and Assembler provide the most natural access to native z/OS data
C/C++ provides access for all types of data on z/OS too
174
Java programs in stand-alone batch, CICS, IMS or DB2 stored procedures can access
z/OS data sets and VSAM files using specific classes, and IMS and DB2 data on z/OS
using a native high performance JDBC driver
In addition to the Java data access methods above, Java in WebSphere XD Compute
Grid can furthermore exploit Java EE features to externalize data sources
PHP only allows access to z/OS UNIX System Services files and DB2 on z/OS. There
is no support for accessing MVS data sets.
Workload scheduler integration
Very often, jobs are managed by a workload scheduler. All discussed solutions offer the
possibility to submit jobs using a JCL, that means they can easily be integrated into a
workload scheduler like Tivoli Workload Scheduler. The integration might only differ in
small areas, for example if you use a DB2 stored procedure for batch processing, you
would have to wait for the output in JES until the stored procedure terminates.
Transactionality
If Two Phase Commit is required for your batch application, you carefully have to think
about your runtime environment. For example, all stand-alone alternatives offer no
transactionality. In contrast, containers like IMS, DB2 and WebSphere XD Compute Grid
have the ability to manage transactions. Depending on your exact requirements, these
would have to be examined in more detail concerning transactionality.
Checkpointing
As batch jobs can run very long, checkpoints can become a very important criteria to
avoid very complex rollbacks or locking aspects. For stand-alone batch applications, this
has to be implemented manually. A container such as IMS or WebSphere XD Compute
Grid in contrast already provide this functionality.
JVM startup cost
Stand-alone Java batch or Java in IMS cause a JVM startup for every job. If the jobs are
long running tasks, this is negligible. But if you have many short running Java batch jobs,
you might consider WebSphere XD Compute Grid or a Java DB2 stored procedure, which
efficiently reuse JVMs.
Performance
Different programming languages and different programming models often have a big
difference in performance. This also has to be taken into account for new functionality in
batch. In certain situations performance could be the determining factor to choose for a
certain technology.
All those criteria have to be kept in mind while choosing a technology for new functionality in
batch. Besides these distinction criteria, you should remember that all solutions can leverage
the high availability and scalability concept of the z/OS operating system and its stack
products.
To sum it up, z/OS offers a lot of excellent capabilities to implement state of the art batch
functionality.
175
176
11
Chapter 11.
Batch environment
enhancements in z/OS V1R13
In this chapter we discuss various batch environment enhancements in z/OS V1R13. We
review the IBM z/OS Batch Runtime which provides the ability to update the DB2 database
from both COBOL and Java in a single transaction, and review Java COBOL interoperability.
We also describe the following updates to improve batch job processing:
Instream data in PROCs (cataloged and instream)
Support for JOBRC (return code)
Spin and SPIN data set
Requeue a job by command on a step boundary
177
178
Transaction
Service
JES
BCDBATCH
Proc
Execution
Service
z/OS Plugin
z/ OS Plugin
z/OS Batch
Container
Policy/logs
JDBC
JAVA/Cobol App
Local DB2
179
//* *
//* VERSION=61 Java SDK 6.0.1 (31 bit) *
//* *
//* 2. Override the LOGLVL symbolic parameter to control *
//* the messages issued by the jZOS Java launcher. *
//* *
//* Use the +T option when reporting problems to IBM or *
//* to diagnose problems in the STDENV script. *
//* *
//* 3. Override the LEPARM symbolic parameter to add any *
//* application specific language environment options *
//* needed. *
//* *
//* Change History = *
//* *
//* $L0=BATCH,HBB7780,100324,KDKJ: *
//* *
//* *
//*********************************************************************
//JAVA EXEC PGM=JVMLDM&VERSION,REGION=0M,
// PARM='&LEPARM/&LOGLVL'
//*
//SYSPRINT DD SYSOUT=* System stdout
//SYSOUT DD SYSOUT=* System stderr
//STDOUT DD SYSOUT=* Java System.out
//STDERR DD SYSOUT=* Java System.err
//BCDOUT DD SYSOUT=* Batch container messages
//BCDTRACE DD SYSOUT=* Batch container trace
//*
//CEEDUMP DD SYSOUT=*
//*
z/OS batch runtime is invoked through JCL that invokes the job BCDBATCH, which invokes
the JZOS launcher to initialize the Java environment. Because BCDBATCH invokes JZOS,
one level of the JZOS launcher exists for each Java SDK level and bit mode. You define the
level with a symbolic, and your installation can update the symbolic as new levels of the Java
SDK are added or made the default.
180
//ABC JOB
//INCLUDE MEMBER=HELLO
//STEPA EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD SYSOUT=A
//SYSUT2 DD SYSOUT=A
//SYSUT1 DD DATA
HELLO WORLD
/*
181
Instream data sets are not part of the submitted JCL, so they are not included when looking at
the original JCL and are not sent over NJE to other nodes. But they do appear in the data set
list. Instream data sets work for batch jobs and started tasks. The support in z/OS V1R13
provides the ability for conceptual control data sets, where the application parameters reside,
to not be separated from proclibs or INCLUDEs.
See Example 11-3 for an instream data in PROC example.
Example 11-3 Instream data in PROC
//HELLO
PROC
//STEP1
EXEC ASMHCLG
//C.SYSIN DD *
TEST
CSECT ,
STM
14,12,12(13)
BALR 12,0
USING *,12
ST
13,SAVAREA+4
LA
13,SAVAREA
SPACE 1
WTO
'Hello world!'
SPACE 1
L
13,SAVAREA+4
LM
14,12,12(13)
SR
15,15
BR
14
SPACE 1
SAVAREA DC
18F'0'
END
//L.TEST DD DUMMY
//L.SYSXX DD *
//
PEND
Example 11-4 shows a simple example of a PROC that calls another nested PROC and has
an instream input. This can be run in a batch job or by just doing a S HELLO.
Example 11-4 PROC calling a nested PROC
s hello
$HASP100 HELLO
$HASP373 HELLO
+Hello world!
$HASP395 HELLO
ON STCINRDR
STARTED
ENDED
Example 11-5 is an example of instream data in PROCs and INCLUDEs for JES2 only. It
requires both z/OS V1R13 and JES2 1.13 on the converting system and the initiating system.
This is not supported for MSTR subsystems or by JES3.
Example 11-5 Instream data in PROCs and INCLUDEs
//PROC1 PROC
//ASTEP
EXEC PGM=xyz
//DD1
DD *
This is instream data
//
PEND
182
183
184
If JOBRC=(STEP,C.HLASM) is specified, the return code for the C step in the HLASM
procstepname is used as the completion code for the job.
185
186
Part 3
Part
187
188
12
Chapter 12.
189
DWH Database
DB2 /390
IMS
VSAM
CA-IDMS
Adabas
CADatacom
DWH Processes
DB2
Extract
Flat F iles
Staging
Layer
C leansing
Tran sfo rm
Load
DWH
Layer
Extract
Aggreg ate
Tran sform
Load
Extract
Aggreg ate
Tran sform
Load
Ad-hoc
An alysis
DB2
Data
Mart
Layer
(optional)
Detailed
Data
Cleansing
Transfo rm
Load
z/OS
zIIP exploitation
BI
Reporting
.......
OL AP
Data
Mining
Data Warehouses contain the consolidated information of multiple sources such as financial,
marketing and inventory transaction data. Todays Data Warehouses have to support mixed
workloads, such as:
These workloads can come in large quantities that include the processing of millions of data
records, representing millions of business transactions, all which need to be ordered,
organized, transformed and analyzed.
Because of the size of Data Warehouses and the fact that we have to support multiple
workloads, the System z mainframe is in many cases the best choice to operate as a Data
Warehouse DBMS server. Mainly because System z is known for its reliability, availability,
security and its protected access to data fulfilling compliance regulation. In addition, the
190
12.2 ETL
The ETL process is commonly used in enterprises when building a data repository, in most
cases a Data Warehouse. In many cases we see this process is being implemented by using
batch job procedures. Figure 12-2 illustrates the concept of ETL.
Source Data
Extract
Transform
Load
Data Warehouse
ETL is a term that refers to the processes that extracts information from an online transaction
processing (OLTP) system and other sources, transforms it according to the needs of the
Data Warehousing environment (this can also include quality requirements), and loads it into
the Data Warehouse.
The extraction process takes the data from various sources. Each of these source systems
can use a different data organization, such as relational databases, hierarchical databases,
network databases, flat files, and even unstructured data. Depending on the source of the
data, you might need different techniques for extraction. The extraction process then converts
the data into a format that the transformation process can use.
The transformation process applies various rules and functions to the extracted data to
change the source data into a form that is useful for the data warehouse. This can include
conversion to the required data structure, aggregation, converting code, joining data from
multiple sources to derive new values, and so forth. The transformation process can also
include cleansing of data, such as removing duplicates and standardizing data formats.
In the load process, the transformed data is stored into the target, the Data Warehouse. When
the Data Warehouse is built for the first time, data needs to be extracted from various
sources, transformed, and loaded one time. This is called the initial load. After the initial load,
Chapter 12. Create agile batch by optimizing the Information Management architecture
191
the Data Warehouse has to be kept relevant by updating the data from the all the sources.
This process is known as data refresh.
This process includes the following basic stages:
Extract
Retrieve the data from its source. Often, you have to consolidate data
from different sources, and in many cases this data is non-relational.
Transform
Make the data fit for operational need. The data quality aspects are
usually considered critical.
Load
Put the data into the end target database. The load is often considered
the most time consuming phase in the ETL process.
Note: Although the System z10 mainframe has some outstanding design principles in
order to process large amounts of data, ETL based batch jobs can bring a lot of complexity
to a mainframe environment. The complexity can influence the agility as well, and in many
situations it already has. In 12.2.1, Overcoming operational inefficiency with ETL on
page 193 we take a look at the operational inefficiency some of us experience today.
Traditionally, for data refresh, Data Warehouses extract data from the operational storage
through batch processes executed within maintenance windows. The batch extract jobs are
run perhaps once a month, but could be run as often as once a week, depending on the
business requirement and batch window availability. However, the need to obtain the most
recent data is becoming more and more important.
Another challenge in the batch update is the volume of data. A monthly data refresh will have
to handle a large volume of data. This will require a much longer batch window. A continuous
trickle feed might be a better option in this situation. Trickle feed is common jargon
terminology for continuously feeding the Data Warehouse. As soon as new data is generated
in the OLTP system, it is captured and passed to the ETL process in near real time. Using the
trickle feed approach, the information in a Data Warehouse is kept as recent as possible and
you avoid a batch window bottleneck.
Some of the data extracted from the OLTP window might not need a complex transformation.
It can be loaded directly to the Data Warehouse with only minor modifications. In this case,
data replication might be another option to consider. Data replication captures data from the
data source as soon as it is generated, performs minor modifications, and then inserts it into
the target database.
In most Data Warehouse environments, the ETL process is a combination of batch ETL, near
real time ETL, and replication solutions, depending on the business needs.
The locations where you run the ETL processes are an important consideration. The extract
process preferably runs on the platform where the source data is located. The
compute-intensive transformation process could run on a different platform, but this implies
moving a large amount of data between platforms. Finally, if load processing runs on a
different platform from the target system or where transformation took place, data has to be
moved again. There are many techniques available for data movement. Whichever technique
you employ for data movement, this is one of the biggest challenges in a Data Warehousing
environment.
Because most of the source data comes from the OLTP environment, we strongly suggest
hosting your Data Warehouse on the same platform and running the ETL process on that
platform. The System z platform has sufficient capabilities to support this kind of OLTP, ETL
and Data Warehousing workloads together in one or more logical environments.
192
ETL processing can be quite complex. There are many operational challenges, such as
meeting the service level agreements (SLAs), scaling to the data volumes, and completing
within the available batch window. Organizations can develop in-house applications for ETL
processing, but IBM offers a rich set of tools as well for System z. These tools support most of
the data organizations you will find today. In addition, they support complex data
transformations and cleansing requirements. The tools exploit DB2 LOAD or parallel INSERT
capability to load a large volume of data efficiently.
In the next section, we discuss ways to improve batch agility, particularly for the extraction
phase of the ETL process.
SOURCE
Q Apply
TARGET
Organizations that face pressure from business users that require extended online application
availability, and at the same time request that more jobs and reports are processed, can look
Chapter 12. Create agile batch by optimizing the Information Management architecture
193
at several IBM InfoSphere solutions for their problems. InfoSphere solutions can help solve
the following issues:
Depending on the source data, you might need a different software product, which are low
impact solutions that supports the following modes of replication:
Continuous mirroring Apply data changes at the target as it is generated at the source
Periodic mirroring
Apply net changes on a scheduled basis
Refresh
Apply a snapshot version of source system
The IBM InfoSphere Information Server suite of products provides a framework for services
around data transformation, data quality assurance, metadata management, SOA services,
and other operations. IBM InfoSphere Information Server provides the following key
integration functions:
194
Understand data
Cleanse data
Transform data
Deliver data
Data extraction batch job procedures can be improved easily using an InfoSphere solution to
deliver data. Figure 12-4 displays the IBM InfoSphere solutions that available to extract data
from a source as a first step in the ETL process.
InfoSphere Classic
Federation Server
Federation
InfoSphere Federation
Server
InfoSphere Classic
D ata Ev ent Publis her
Publication
Replication
Depending on the source and target type, you might need a different product solution from
one of the following categories:
Federation
Publication
Replication
Federation of data
A Data Warehouse can collect, consolidate, and aggregate data from various sources and
various source types. Not all sources are relational data sources, such as DB2 for z/OS is.
Some data might reside on System z in the following sources:
IMS
VSAM data sets
ADABAS
IDMS
DATACOM
Flat files
This data (or at least aggregates of it) needs to be integrated into the Data Warehouse so that
all information becomes available in a single place.
Chapter 12. Create agile batch by optimizing the Information Management architecture
195
InfoSphere Classic Federation can access this data in a way that makes it unnecessary to set
up a specialized extraction process for each of the different data sources (such as hierarchical
or relational databases).
The InfoSphere Classic Federation Data Server is installed where the data sources reside. A
connector is configured and started for each data source that needs to be accessed. These
connectors are used by the data server to access the source data from IMS, VSAM,
ADABAS, or other supported sources. The data server maps the various source data
structures to a relational structure. So all data accessed through the InfoSphere Classic
Federation Data Server looks like one relational database, even if the source is structured
hierarchically.
Mapping between source and target definitions is done with the Classic Data Architect, which
is an Eclipse-based workstation tool. It allows importing IMS DBD or COBOL copybooks to
obtain the structure definitions of source data. The user can select the information to include
in a target table, which is simulated as a relational structure by the data server. No further
configuration or coding is necessary.
An ETL server can access this data through JDBC or ODBC to move it to the Data
Warehouse in the form of staging tables or aggregates. The ETL Server and the InfoSphere
Classic Federation Data Server are primarily used for either an initial load or a full reload of
the Data Warehouse. Data in existing data sources can be updated as well, but this is usually
not required within a Data Warehouse environment.
Publication of data
After the data is loaded into the Data Warehouse, it usually must be updated incrementally.
You do not need to replace the entire content. InfoSphere Data Event Publisher and
InfoSphere Classic Data Event Publisher, respectively, are used to detect the changes in DB2
sources and existing data sources and to provide the information about the changes to the
ETL server.
The Classic Data Event Publisher and the Classic Federation have much code in common. If
you installed and configured Classic Federation before, you can extend this configuration to
allow event publishing. You must map existing data structures to relational tables by using
Classic Data Architect. You can even configure the server so that this information is used for
federation and event publishing at the same time, with just one running data server.
Instead of using a connector to directly access the existing data sources, a change capture
agent is used to detect all manipulations to the data source. In some cases, this is a logger
exit (such as IMS, for example). In other cases it is a log reader. The Change Capture Agent
sends the change information to the correlation service, which maps the existing data
structure to a relational structure that is designed with Classic Data Architect. Distribution
Service and Publisher are used to send the information about the changes through MQ to the
DataStage data integration server. The DataStage server is able to read the MQ messages
directly from the queue, just as they are transmitted. These events can then be stacked up in
staging tables and applied to the data warehouse in a composite update that is run in a batch
window.
Replication of data
Data replication is all about moving data between two systems that are the same, normally
used to keep data in a primary and secondary system consistent for disaster recovery or high
availability or to offload data to a secondary system for workload balancing, data distribution
or offloading queries.
196
Chapter 12. Create agile batch by optimizing the Information Management architecture
197
Master Data
EDW
InfoSphere
Custo m
Co ntinuou s Syn ch ro nization
In-fligh t Transformation s
ERP
Stage
or
D SA
Transform ation
DB2
DB2
EDW
Load
3
DB2
You can implement some in-flight transformation capabilities that simplify or eliminate
additional batch data extraction jobs. Particularly, InfoSphere Change Data Capture provides
functionality to do filtering, table mapping, and data translations. It also provides the option to
implement a User Exit to execute custom business logic, which can be implemented in
C/C++, Java or stored procedures.
Depending on further steps in the ETL process, by implementing more flexible data extraction
capabilities, it can provide users with the ability to access data throughout the day for
reporting and trends analysis so they can make informed business decisions and increase
revenue opportunities. In the next section, we discuss ways to improve the transformation and
load stages to accelerate the ETL process.
Note: The idea behind all this is to extract the master data without impacting the OLTP
work and by putting the data into a Data Storage Area (DSA) or staging tables for further
ETL processing. This will contribute to the agility of the batch jobs and it can make a
significant contribution in reducing the elapse time of the ETL batch jobs.
InfoSphere Change Data Capture is probably the best solution if you want a high
performance, scalable, log-based data replication for single database environments, because
it has a low impact on source or production systems. You can use it to provide a solid data
staging environment that can be used for further ETL processing to build a Data Warehouse.
198
As mentioned previously, you can implement InfoSphere Change Data Capture using one of
the following mechanisms:
SQL replication, as shown in Figure 12-6, works as follows:
Source
SOURCE2
SOURCE1
CCD
Capture
CD2
CD1
CD1
HISTORY
Apply
REPLICA
UCOPY
DB2 L og
Source
WebSphere MQ
SOURCE2
SOURCE1
CCD
Capture
Apply
UCOPY
DB2 L og
With the solution shown in Figure 12-7, you take advantage of WebSphere MQ strengths,
with guaranteed one-time delivery of data and SSL security options for encryption, digital
signatures, and so forth. This solution also provides a secure method to move data between
companies and firewalls. In addition, an outage at one site does not prevent progress on the
other. For example, the capture and MQ continue even when target system down. You can
also queue work for the target environment.
Q replication also includes the following advantages:
Chapter 12. Create agile batch by optimizing the Information Management architecture
199
DB2 Log
TX1: INSERT S1
TX2: INSERT S2
TX3: DELETE S1
TX1: UPDATE S1
TX1: COMMIT
TX3: ROLLBACK
TARGET
Q Apply
Browser
Apply Agent
MQ Put when
Commit found
Apply Agent
Apply Agent
TGT3
Zapped at Abort
Never makes it to queue
TGT1
TGT2
are composed using the Information Server Client Package interface, with simple
point-and-click techniques you can draw a schema that represents your ETL process
requirements.
An InfoSphere DataStage job consists of individual stages where every stage is a step in the
process, for example extract data from source or to transform it. Parallel jobs are supported
that run inside the InfoSphere DataStage engine and have the capability to support parallel
processing as well.
Member A
Memb er B
OLTP
OLTP
Member C
Memb er D
DWH
DWH
CEC On e
CEC Two
WebSphere
Extract
Load
ETL Accelerator
CF
CF
pSeries
xSeries
zLinux
Extract
JDBC/ODBC
Extract
JDBC/ODBC
z/OS
WebSphere
VSAM,
IAM &
sequ ential
IMS
Software AG
CA
CA
Adabas Dat aco m IDMS
The runtime engine for InfoSphere DataStage is primarily available for Linux for System z and
distributed platforms. There are however two older z/OS versions available, called InfoSphere
DataStage MVS Edition and InfoSphere DataStage Enterprise for z/OS. At the time of writing
this book, both versions are still available. It is good to know however that these z/OS
versions are still available for product order, but further development of these products is
uncertain. The way forward is InfoSphere DataStage for Linux for System z.
DB2 UDB
fo r LUW
Oracle
SQL Server
Figure 12-9 displays the following ETL architecture for building the initial Data Warehouse.
Extract, Transform, and Load is done using an ETL Accelerator, which in its current
implementation is represented by InfoSphere DataStage (IBM Information Server) on a
secondary system. This could be Linux for System z.
The data is extracted from the OLTP information of the data sharing group, transformed by
InfoSphere DataStage and then loaded into the Data Warehouse tables again.
Distributed data sources are directly integrated into InfoSphere DataStage.
In this example, the existing data sources are integrated through the WebSphere Classic
Federation Serve so that data is extracted from InfoSphere DataStage directly out of the
data sources such as IMS and VSAM.
Note: Running InfoSphere DataStage on Linux for System z enables us to use
HiperSockets and z/OS Batch Pipes, which can significantly increase the speed of loading
the data into the Data Warehouse.
Chapter 12. Create agile batch by optimizing the Information Management architecture
201
Figure 12-10 shows the use of the BatchPipes utility, which you can use to connect products
on Linux on System z with products on z/OS.
Linux on z
z/OS
Batch Pipes
DataStage Server
DSNUTILS
FTP
(Parallel Load)
FTP
Job Flow
FTP
SQL CALL
Partitioned Table
Hyp er Socket
DB2
InfoSphere DataStage integration jobs extract and transform data based on defined data
sources. The jobs eventually write the result to a data set in the file system or insert records
into a database in DB2 for z/OS by using the LOAD utility.
The LOAD utility can only read from a data set, until the writing to the data set is completed.
So the ETL job cannot write while the LOAD job processes records.
To offer a way for both writer and reader jobs to run concurrently, you can use BatchPipes
functionality. The use of batch pipes can drastically shorten the Load phase, when used in
combination with System z hardware HyperSockets. Running in a test environment
demonstrated a load time reduction as high as 40%.
For more information about the BatchPipes utility, see the following resources:
Chapter 16, Increasing concurrency by exploiting BatchPipes on page 309
Enterprise Data Warehousing with DB2 9 for z/OS, SG24-7637
After the Data Warehouse is loaded, only incremental updates are performed. The changes
on the original data sources (z/OS and distributed) are captured by a publication product,
such as WebSphere Data Event Publisher, or a replication product, such as InfoSphere
Change Data Capture, and sent through WebSphere MQ to the DataStage ETL Accelerator.
202
Member A
Member B
OLTP
OLT P
Member C
Member D
DWH
D WH
WebSphere
ETL Accelerator
C EC One
CF
CF
pSeries
xSeries
CEC Two
MQ
zLinux
Change Capture
Special InfoSphere DataStage procedural steps, which the product calls stages, take the
change information from WebSphere MQ, as shown in Figure 12-11, and updates or inserts
are performed on the Data Warehouse data.
MQ
WebSphere
MQ
WebSphere
DB2
CAIDMS
IMS
Sof twar e AG
Adabas
Capt ure
Capture
DB2 UDB
for LUW
VSAM
z/ OS
Oracle
Dist ributed
A single InfoSphere DataStage job consists of one or more stages. Each stage represents a
processing step that is required for this job. Stages are connected using links, which
represent the flow of data between different stages. The product comes with a lot of stages
that have built-in functionality. Special stages are also available that you must install
separately. For example, InfoSphere DataStage Transformation Extender is orderable as an
add-on product. You can contain a group of stages in a container to allow for modularization
and a more simple job design.
Chapter 12. Create agile batch by optimizing the Information Management architecture
203
Batch jobs
An IBM InfoSphere DataStage job consists of individual stages that are linked together, which
describe the flow of data from a data source to a data target. A stage usually has at least one
data input or one data output. However, some stages can accept more than one data input,
and output to more than one stage. Each stage has a set of predefined and editable
properties that tell it how to perform or process data. Properties might include the file name
for the sequential file stage, the columns to sort, the transformations to perform, and the
database table name for the DB2 stage. These properties are viewed or edited using stage
editors. Stages which have an iconic representation in the Designer are added to a job and
linked together using the Designer.
A parallel InfoSphere DataStage job incorporates two basic types of parallel processing,
pipeline and partitioning. Both of these methods are used at run time by the Information
Server engine to execute the job. This execution is done automatically. To the InfoSphere
DataStage developer, this job appears the same on the Designer.
Pipeline parallelism
Note: You do not need multiple processors to run in parallel. A single processor is capable
of running multiple concurrent processes. Unfortunately, with InfoSphere DataStage
Enterprise for z/OS this would result in multiple Address Spaces being initiated. This is an
undesirable side effect, which leads to higher CPU consumption and slower performance.
Partition parallelism When large volumes of data are involved, you can use the power of
parallel processing to your best advantage by partitioning the data into
a number of separate sets, with each partition being handled by a
separate instance of the job stages.
Partition parallelism is accomplished at run time, instead of a manual
process that would be required by traditional systems. The DataStage
developer only needs to specify the algorithm to partition the data, not
the degree of parallelism or where the job will execute. Using partition
parallelism the same job would effectively be run simultaneously by
several processors, each handling a separate subset of the total data.
At the end of the job the data partitions can be collected back together
again and written to a single data source.
204
Note: There is also the option to combine pipeline and partition parallel processing to
achieve even greater performance gains. In this scenario you would have stages
processing partitioned data and filling pipelines so the next one could start on that partition
before the previous one had finished.
For more information about parallel job design, see Parallel Job Developer Guide,
LC18-9891, which demonstrates how to design and run InfoSphere DataStage parallel
jobs as well as basic QualityStage functionality.
InfoSphere DataStage for Linux for System z can be an excellent runtime environment to
replace complex ETL stand-alone batch jobs and to become more agile in your current IT
environment. A lot of the work can be done without burdening the OLTP environment. In
addition to that, with InfoSphere DataStage a more efficient ETL process can be arranged
that takes advantage of out-of-box parallelism techniques.
Chapter 12. Create agile batch by optimizing the Information Management architecture
205
206
13
Chapter 13.
207
In situations where you need to run a batch program any time, including during the OLTP
window, and also run this batch program on master data, it becomes critical to implement
data access in both the OLTP transactions and the batch program in the most efficient
manner. Access to DB2 must be carefully designed and configured keeping in mind the
following principles:
Normally batch programs process a huge amount of data. Thereby often, depending on
the business logic, some data is static and does not change during the program run (for
example company address information). It is recommended to read such data only once
from the database and cache it somewhere for further processing. This will prevent your
system from running unnecessary round trips to the database.
In 13.1, Data caching on page 209, we discuss these considerations.
SQL is a flexible and powerful tool to access databases. A non-conscious developer could
theoretically write a one-line query that could hang up the performance of all your
applications accessing the database. Writing smart and well-performing queries is not
trivial.
In 13.2, Optimizing data access using SQL functionality on page 210, we provide some
best practices to apply.
In a DB2 for z/OS environment there is quite a bit of configuration and there are many
ways to optimize performance. We just name a few:
When accessing DB2 tables with static SQL, a PLAN is created and this PLAN has
several options you can configure. Making the right decisions is important.
Running DB2 utilities frequently keeps DB2 databases lean and fast.
Configuring DB2 system parameters can greatly influence performance and parallel
processing with the database.
Choosing the correct checkpoint frequency and commit scope should be a key aspect
in any DB2 application design.
When using Java, additional design and configuration decisions have to be made. The
Java DataBase Connectivity (JDBC) drivers have additional configuration options.
In 13.3, Optimizing data access using system functionality on page 212, we discuss a
variety of key considerations in optimizing DB2 access from a configuration point of view.
Note: In this book, we cannot mention all aspects and possibilities in relation to optimized
DB2 data access. You can find detailed information about optimizing database access in
the following resources:
DB2 UDB for z/OS: Design Guidelines for High Performance and Availability,
SG24-7134
DB2 9 Performance Monitoring and Tuning Guide, SC18-9851
DB2 9 for z/OS Performance Topics, SG24-7473
208
209
DB2 itself uses a lot of its own caching mechanisms. However, even if the requested data is
still in the buffer pool and does not need to be read from hard disk, there might still be reasons
for using a separate application cache, as follows:
As long as data is kept in an application cache, further access to DB2 for this data is not
required.
If the data, for whatever reason, does not exist in the buffer pool anymore, you would still
have it in the application cache.
If DB2 uses a bad access path for a query, further calls of this query would result in the
same overhead.
In general, the sooner that a cache is used, the more beneficial it is to performance.
Joining tables
Using SELECT FROM INSERT/UPDATE/DELETE/MERGE
Multi-row processing
Explain SQL statements
210
211
01 T1-VARS.
05 COLa
05 COLb
05 COLc
49 COLc-LEN
49 COLc-DATA
212
The lock owner and any concurrent processes can read but not
change the locked page or row.
U (Update)
The lock owner can read but not change the locked page or row.
Concurrent processes can read the data.
U locks reduce the chance of deadlocks when the lock owner is
reading a page or row to determine whether to change it, because the
owner can start with the U lock and then promote the lock to an X lock
to change the page or row.
213
X (Exclusive)
The lock owner can read or change the locked page or row. A
concurrent process cannot read or update the data, because he is not
allowed to acquire S, U, or X locks on the page or row.
A concurrent process can access the data if the process runs with UR
isolation level (see description of DB2 isolation levels below).
The following list contains the different modes for table, partition, and table space locks:
IS (Intent Share)
IX (Intent Exclusive)
S (Share)
U (Update)
The lock owner can read but not change the locked data;
however, the owner can promote the lock to an X lock and
then can change the data. Processes concurrent with the
U lock can acquire S locks and read the data, but no
concurrent process can acquire a U lock.
SIX (Share with Intent Exclusive) The lock owner can read and change data in the table,
partition, or table space. Concurrent processes can read
data in the table, partition, or table space but not change it.
X (Exclusive)
For example, an SQL statement locates Paul Smith in a table of customer data and changes
his address. The statement locks the entire table space in mode IX and the specific row that it
changes in mode X.
Thus, lock compatibility is very important to understand DB2 concurrency regarding parallel
processing. For example, assume one process holding an S-lock on a row and another
process wanting to read the data. The second process first tries to also set an S-lock on the
same row. Because these two locks are compatible (see Table 13-1), both processes could
read the same data. But, if the other process would want to change this data, he first has to
set an X-lock. These two locks are incompatible. Therefore, the second process has to wait
until the first process releases his S-lock.
Compatibility for page and row locks is easy to define. Table 13-1 shows whether page locks
of any two modes, or row locks of any two modes, are compatible (Yes) or not (No).
Table 13-1 Compatibility of page lock and row lock modes
214
Lock Mode
Yes
Yes
No
Yes
No
No
No
No
No
Compatibility for table space locks is slightly more complex. Table 13-2 shows whether table
space locks of any two modes are compatible.
Table 13-2 Compatibility of table and table space (or partition) lock modes
Lock Mode
IS
IX
SIX
IS
Yes
Yes
Yes
Yes
Yes
No
IX
Yes
No
Yes
Yes
No
No
Yes
No
Yes
Yes
No
No
Yes
No
Yes
No
No
No
SIX
Yes
No
No
No
No
No
No
No
No
No
No
No
The duration of a lock is the length of time the lock is held. It varies according to when the lock
is acquired and when it is released. For maximum concurrency, locks on a small amount of
data held for a short duration are better than locks on a large amount of data held for a long
duration. However, acquiring a lock requires processor time, and holding a lock requires
storage; thus, acquiring and holding one table space lock is more economical than acquiring
and holding many page locks. Consider that trade-off to meet your performance and
concurrency objectives.
One important parameter which influences duration of locks is the DB2 Isolation Level for an
SQL statement. The following list shows the different DB2 Isolation Level options.
A row or page lock is held for all accessed rows, qualifying or not,
at least until the next commit point. If the application process
returns to the same page and reads the same row again, another
application cannot have changed the rows nor have inserted any
new qualifying rows.
A row or page lock is held for rows or pages that are returned to
an application at least until the next commit point. If the
application process returns to the same page and reads the
same row again, another application cannot have changed the
rows, although additional qualifying rows might have been
inserted by another application process.
A row or page lock is held only long enough to allow the cursor to
move to another row or page. For data that satisfies the search
condition of the application, the lock is held until the application
locks the next row or page. For data that does not satisfy the
search condition, the lock is immediately released.
Isolation level RS has the highest lock behavior and, therefore, the lowest possible
concurrency. Alternatively, isolation level UR has the lowest lock behavior and the highest
possible concurrency (but with danger of reading uncommitted data).
215
Tip: A good compromise to achieve good concurrency without risk of reading uncommitted
data is to use isolation level CS. Remember, however, some application might need a
higher isolation level. Based on this information, you need to decide which isolation level to
use for your application.
You can set an Isolation Level for your SQL statements in different ways:
SQL statement level
At the end of your statement, use WITH UR/CS/RS/RR to explicit set an Isolation Level for
this single statement. This Isolation Level is used even if the package which contains this
statement is bound with a different Isolation Level.
DB2 package/plan level
When using traditional languages (such as COBOL and PL/I), you can use option
ISOLATION(UR/CS/RS/RR) when running the BIND or REBIND command for the
corresponding package or plan.
Java native application
When running a Java native application you can choose the Isolation Level by using the
method setTransactionIsolation of the current connection object. The following list
shows the JDBC and the corresponding DB2 Isolation Level.
Transaction_Serializable
Transaction_Repeatable_Read
Transaction_Read_Committed
Transaction_Read_Uncommitted
Lock avoidance
Under certain circumstances, if DB2 can determine that the data it is reading has already
been committed, it can avoid taking the lock altogether. Lock avoidance will increase
concurrency, decrease the lock, and unlock activity and associated CPU resource
consumption.
Therefore, effective lock avoidance is very important in all environments. The number of
unlock requests per commit is a good indicator of the effectiveness of lock avoidance. If
perfect lock avoidance is achieved, a transaction only takes locks on the resources that it
wants to modify, and releases all of them in a single unlock request at commit time.
216
If the number of unlock requests per commit is greater than 1 (and it always is in the real
world), it indicates that, as the rows were being processed, the transaction had to acquire and
release some S-locks. The general rule-of-thumb is that the number of unlock requests per
commit should be less than 5.
Index on expression
Indexes are often used to speed up SQL processing. However, with DB2 for z/OS V8 an index
cannot be used when running an SQL statement with expressions, as shown in
Example 13-4.
Example 13-4 Select all data for year 2003
217
MIDAW
The Modified Indirect Data Address Word (MIDAW) facility is integrated in System z
processors to improve FICON performance, especially when accessing DB2 databases.
This facility is a new method of gathering data into and scattering data from discontinuous
storage locations during an I/O operation.
218
The use of MIDAWs will not cause the bits to move any faster across the FICON link, but they
reduce the number of frames and sequences flowing across the link, which makes the
channel more efficient.
Thereby, the most benefit occurs with Extended Format data sets that have small block sizes.
Because DB2 depends on Extended Format data sets to stripe the logs, or to enable data
sets to be larger than 4 GB, DB2 is a major beneficiary from the MIDAW facility.
DSNZPARMs
With DSNZPARMs, you have many different settings available to configure a DB2 system to
your needs (like activate dynamic statement caching, maximum size of statement cache and
much, much more). Thereby, some of these DSNZPARMs relate to storage functions:
Data Set VSAM Control Interface (CI) size
With V7, DB2 uses only the VSAM CI size of 4 KB. If DB2 page size is 8, 16, or 32 KB,
DB2 treated the page as a chain of 2, 4, or 8 CIs.
Since V8, setting the DSVCI parameter to YES allows DB2 to use VSAM CI sizes of 8, 16,
and 32 KB and therefore to synchronize DB2 page size and VSAM CI size.
With DSVCI=YES, VSAM splits 32 KB CI over two blocks of 16 KB in order to span two
tracks and not waste space within a single track usage (48 KB). A 16 KB block is not used
every 15 tracks (CA size) because the CI cannot span a CA boundary.
Sequential processing and disk cache
The parameter SEQCACH is used to determine whether data in the disk cache is to be
used in sequential mode (BYPASS) or sequential detected mode (SEQ). Although
BYPASS, the default, is still a valid option for detected mode, cache is not bypassed
because the 3990 controllers were in use.
For the later disks (RVA, ESS, or DS8000), BYPASS uses sequential detect, and SEQ
uses explicit command. The differences are as follows:
SEQ (explicit) puts tracks on the accelerated list and starts pre-staging for next I/O.
Operations are done on extent boundaries or stage groups. Explicit SEQ reacts faster
and can end sooner than using the detect mechanism (BYPASS).
BYPASS (sequential detect) stages data to the end of a stage group.
The recommendation is to set SEQCACH to SEQ.
Utilities use of disk cache
The parameter SEQPRES specifies whether (YES) or not (NO, default) DB2 utilities that
scan a non-partitioning index followed by an update should allow data to remain in cache
longer when reading data. If you specify YES, DB2 utility prefetch reads remain in cache
longer, possibly improving performance of subsequent writes of large non-partitioned
indexes.
Similar to what we discussed for sequential processing and disk cache (SEQCACH), the
recommendation is to set SEQPRES to YES.
219
The following examples show only some possibilities, to optimize data access for Java
applications:
Use batch update API (addBatch or executeBatch) for larger amount of inserted, updated,
and merged rows, which can speed up processing. See Example 13-6.
Example 13-6 Using JDBC addBatch
220
You can use the JDBC method setAutoCommit to turn on or off autocommit, as shown in
Example 13-7.
Example 13-7 Java turn autocommit off
con.setAutoCommit(false);
Note: You can find more information about Java and DB2 optimization in the following
resources:
Application Programming Guide and Reference for Java, SC18-9842
DB2 for z/OS and OS/390: Ready for Java, SG24-6435
DB2 for z/OS and WebSphere: The Perfect Couple, SG24-6319
221
222
14
Chapter 14.
223
DynamicBatch Servlet
TriggerBatchBean
(Session Bean)
z/OS job
Submit
Figure 14-2 shows how this servlet looks from a user perspective. It consists of a form with
two parameter input fields as well as a Submit and Cancel button. Because this application is
intended as a template for further chapters, it is a modular, which means that we use the
parameters in other chapters for different purposes.
By click Submit, the servlet calls a Session Bean called TriggerBatchBean, which contains
the logic to call a job.
Note 1: In the template version of the application, the session bean returns only the value
of the two parameters.
Note 2: We use WebSphere Application Server for z/OS Version 6.1 in our scenario to
ensure compatibility with the J2EE 1.4 specification. Although we could have used Java EE
5.0, we wanted to ensure that a broad range of users can use this sample.
You can find the servlet and session bean source code in Dynamic batch Web application
on page 445.
224
We also provide this application as a Rational Application Developer project. See Appendix C,
Additional material on page 453 for more details. This project is be the base for the next
sections. However, if you do not have Rational Application Developer, you can also use
another J2EE development tool.
Note: Keep in mind that because we use a Web application to submit a z/OS batch job, we
do not know how long a submitted job will run. Thus, we do not wait for the job output in the
Web application and only submit it. Nevertheless, to get the results to the user, we propose
to implement some kind of notification (for example through e-mail) that informs the user
after the job of the results.
To implement the job submission, follow these steps:
1. First, switch to the J2EE Perspective in Rational Application Developer. Then, import the
three projects of the application Dynamic Batch application template in Rational
Application Developer by selecting File Import General Existing Project into
Workspace Next. Choose Select archive file. Browse for the
DynamicBatchRADProject.zip file of the additional material of this book, and press Finish.
2. Create a new class called MvsJobSubmitter.java and a class called MvsJob.java in the
com.ibm.itso.sample package to submit z/OS batch jobs from the TriggerBatchBean. The
Rational Application Developer Project Explorer should now look like that shown in
Figure 14-3.
225
com.ibm.jzos.Exec;
com.ibm.jzos.FileFactory;
com.ibm.jzos.RcException;
com.ibm.jzos.ZUtil;
226
Exec exec;
BufferedWriter intrdrWriter;
/**
* Submits a JCL read from a file
* Argument can be a Unix file/path name or a "//dataset.name".
*/
public void run(String jobName) throws IOException {
MvsJobSubmitter submitter = new MvsJobSubmitter();
// copy the file to the InternalReaderWriter (and close that writer)
copyFile(jobName, submitter.getInternalReaderWriter());
submitter.submitJob();
}
/**
* Construct an instance, which causes the "submitJob" Rexx script to
* be started to receive our JCL.
*/
public MvsJobSubmitter() throws IOException {
executeSubmit(); // starts the child process
}
/**
* Answers a writer that can be used by the client to
* send JCL to the Rexx submitJob process.
* Clients should either flush() or close() this Writer
* to ensure that buffered data is actually sent to the child process
* @return Writer
* @throws IOException
*/
public Writer getInternalReaderWriter() throws IOException {
if (intrdrWriter == null) {
intrdrWriter = exec.getStdinWriter();
}
return intrdrWriter;
}
/**
* Answers an MvsJob object which is a simple bean holding the
* submitted jobname and userid. The method should be called
* once after writing jcl to getInternalReaderWriter() and closing
* @return MvsJob if submitted successfully, otherwise an exception is thrown
*
* @throws IOException if there is an error communicating with the child Rexx
process
* or if the child process had an error submitting the process.
*/
public MvsJob submitJob() throws IOException {
if (exec == null) {
// can only do this once!
throw new IllegalStateException("Child process already stopped?");
}
MvsJob mvsjob = null;
String line;
String firstLine = null;
while ((line = exec.readLine()) != null) {
if (firstLine == null) firstLine = line;
if (mvsjob == null) {
227
228
/**
* Copy a file given its name to a Writer.
* After copying or on error, close both files.
*/
protected static void copyFile(String filename, Writer writer) throws IOException {
BufferedReader rdr = null;
try {
rdr = FileFactory.newBufferedReader(filename);
String line;
while ((line = rdr.readLine()) != null) {
writer.write(line);
writer.write("\n");
}
} finally {
writer.close();
if (rdr != null) {
rdr.close();
}
}
}
}
4. Next, insert in the MvsJob.java file the code shown in Example 14-2.
Example 14-2 MvsJob.java
/*
===========================================================================
* Licensed Materials - Property of IBM
* "Restricted Materials of IBM"
* (C) Copyright IBM Corp. 2005. All Rights Reserved
*
===========================================================================
*/
package com.ibm.itso.sample;
/**
* Simple bean which holds an MVS jobname and id.
*/
public class MvsJob {
String jobname;
String jobid;
public MvsJob(String name, String id) {
this.jobname = name;
this.jobid = id;
}
public String getJobid() {
return jobid;
}
public String getJobname() {
return jobname;
}
Chapter 14. Create agile batch by implementing trigger mechanisms
229
230
7. In the JAR Selection window, select Add JARs. select the ibmjzos.jar file, as shown in
Figure 14-5.
8. Click OK. Apply the settings by pressing OK again. Now, all code errors disappear in
Rational Application Developer.
9. With the help of the two recently created Java classes, you can submit a z/OS job by
passing a job name as an MVS data set name in the form of //dataset.name or as a UNIX
file path to the run() method in MvsJobSubmitter.java. To call this method by the
TriggerBatchBean, we open the TriggerBatchBean.java file in the Project Explorer.
10.Then, change the public String execute(String[] parameters) as shown in
Example 14-3. Because you need only one parameter from the servlet form (the job
name), perform a check within this method as to whether the parameters are valid. If yes,
call the MvsJobSubmitter.run() method, and return to the servlet that the job was
submitted. If not, return to the servlet that the parameters were wrong.
Example 14-3 TriggerBatchBean execute method
231
232
13.Next, right-click the DynamicBatchEar project and select Export Ear file as shown in
Figure 14-7.
14.Browse for a file location where you want to store this EAR file, and select Finish (see
Figure 14-8).
233
Figure 14-9 Submitting a job with the sample application in native Java
234
Submit jobs
Monitor job execution
Perform operational actions against jobs
View job logs
Manage the job repository
Manage job schedules
A job log is a file that contains a detailed record of the execution details of a job. It is
comprised of both system and application messages. Job logs are stored on the
endpoints where the job runs and on the application server that hosts the job
scheduler. Job logs are viewable through the JMC and from the command line.
A job class establishes a policy for resource consumption by a set of grid jobs. Through
this policy, execution time, number of concurrent jobs, job log and job output queue
storage can be controlled. Each job is assigned to a job class. A default job class is
provided for jobs that do not specify a class.
Classification rules are saved in a configuration file named gridclassrules.xml under
the configuration directory of WebSphere Application Server. In WebSphere XD, there
is one gridclassrules.xml per cell, and the rules are ordered based on the priority
element.
You can find more detailed information for job logs, job classes, and job classifications in the
WebSphere XD Compute Grid Information Center at:
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/index.jsp
235
in the WebSphere XD Compute Grid Execution Endpoint (GEE) and started. So, you can now
submit batch jobs. First, open the JMC in the browser. The window shown in Figure 14-10
opens.
236
View jobs in the job repository. Select View saved jobs under Job Repository. Your
zOSEcho job should be stored in the job repository. See Figure 14-12.
Submit jobs. Select Submit a job under Job Management. Choose Job repository and
browse to the job you want to submit, for example zOSEcho. Click Submit. See
Figure 14-13.
Figure 14-13 Submit job from the job repository with JMC
237
View job logs. Select View jobs under Job Management and choose the job with
<Job-name>:<job-id> that you want to view. You see the job output, and you can also
download the job log as *.txt file. See Figure 14-14.
238
Manage job schedules and view schedules. Select Create a schedule to set up a job
schedule and under View schedules you can see all your scheduled jobs. See
Figure 14-15.
239
To access the field help for the JMC, click Help in the upper, right corner of every job
management panel. See Figure 14-16.
240
<-- jobid=Echo:00032
./lrcmd.sh -cmd=status -jobid=Echo:00032 -host=wtsc48.itso.ibm.com -port=9575
CWLRB4940I: com.ibm.ws.batch.wsbatch : -cmd=status -jobid=Echo:00032
-host=wtsc48.itso.ibm.com -port=9575
CWLRB5160I: Wed Jun 24 15:26:08 EDT 2009 : Job [Echo:00032] execution has ended.
Example 14-6 shows an example of retrieving job output.
Example 14-6 Example of retrieving output of a batch job
./lrcmd.sh -cmd=output -jobid=Echo:00032 -host=wtsc48.itso.ibm.com -port=9575
CWLRB4940I: com.ibm.websphere.batch.wsbatch : -cmd=output -jobid=Echo:00032
CWLRB5000I: Wed Jun 24 15:26:55 EDT 2009 : com.ibm.ws.batch.wsbatch : response to output
CWLRB1740I: [06/24/09
CWLRB1760I: [06/24/09
CWLRB2420I: [06/24/09
setup.
CWLRB2440I: [06/24/09
dispatched.
CWLRB2460I: [06/24/09
breakdown.
CWLRB2600I: [06/24/09
normally rc=0.
CWLRB3800I: [06/24/09
End
241
Figure 14-17 shows the JMC showing the status of the job submitted using the command line
interface.
Figure 14-17 Run zOSEcho with command line utility: View submitted job from console in JMC
242
/wasalconfig/V6R1/alcell/alnodea/AppServer/profiles/default/bin>./wsadmin.sh -f
wsgridConfig.py -install -node alnodea -server allrsa01 -providers
wtsc48.itso.ibm.com,9565
WASX7209I: Connected to process "dmgr" on node aldm using SOAP connector; The t
ype of process is: DeploymentManager
WASX7303I: The following options are passed to the scripting environment and are
available as arguments that are stored in the argv variable: "-install, -node,
alnodea, -server, allrsa01, -providers, wtsc48.itso.ibm.com,9565"
wsgridConfig.py is performing install using
target cluster or server
MDI application name
JMS connection factory
JMS activation spec
JMS input queue name
JMS output queue name
JMS file store root
SIB identifier
endpoint provider list
:
:
:
:
:
:
:
:
:
/Node:alnodea/Server:allrsa01/
JobSchedulerMDI
com.ibm.ws.grid.ConnectionFactory
com.ibm.ws.grid.ActivationSpec
com.ibm.ws.grid.InputQueue
com.ibm.ws.grid.OutputQueue
/tmp/JobSchedulerBus
JobSchedulerBus
wtsc48.itso.ibm.com:9565
243
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
starting JobSchedulerMDI
wsgridConfig.py INFO: installed JobSchedulerMDI to node/server alnodea/allrsa01
Done installing JobSchedulerMDI
createBus JobSchedulerBus
wsgridConfig.py INFO: created SIB JobSchedulerBus
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created SIB member on target /Node:alnodea/Server:allrsa01/
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created SIB destination com.ibm.ws.grid.InputQueue
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created SIB destination com.ibm.ws.grid.OutputQueue
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created JMS connection factory com.ibm.ws.grid.ConnectionF
actory
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created JMS queue com.ibm.ws.grid.InputQueue
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created JMS queue com.ibm.ws.grid.OutputQueue
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
wsgridConfig.py INFO: created JMS activation spec com.ibm.ws.grid.ActivationSpec
saving config...
Done saving..
wsgridConfig.py INFO: Configuration was saved and synchronized to the active nod
es
244
You can check in the WebSphere administrative console the tasks that wsgridConfig.py
performs during the installation:
J2C connection factory, com.ibm.ws.grid.ConnectionFactory, as shown in
Figure 14-18.
245
JMS input queue name, com.ibm.ws.grid.InputQueue, and JMS output queue name,
com.ibm.ws.grid.OutputQueue, as shown in Figure 14-20.
After WSGrid is configured, you can launch it using the WSGrid.sh shell script. The script
takes in a control file as parameter which is a simple properties file that contains
information about the scheduler location and the batch job to submit.
2. Run the Wsgrid.sh script using the commands we describe here. WSGrid supports
distinct ways of specifying a WebSphere job:
a. You can specify an xJCL file. In this case, the format of invoking the command is as
follows:
WSGrid.sh <control properties file> <path to job xJCL>
The control properties file is a fully qualified path name to the file that contains the
WSGrid job properties:
246
#scheduler-host>=<hostname>
scheduler-host=wtsc48.itso.ibm.com
#scheduler-port=<port>
scheduler-port=9575
#properties
debug=false
b. You can specify the name of an xJCL file in the job repository. In this case the format of
the command is as follows:
WSGrid.sh <control properties file>
The control properties file is a fully qualified path name to the file that contains the
WSGrid control properties.
In addition to the scheduler-host and the scheduler-port, the information of the xJCL in
the repository is provided. The example zOSEchowsgrd.cntl file, as shown in
Example 14-10, is included in the workspace in the folder cntl.
Example 14-10 Sample job zOSEchowsgrid.cntl properties file with job information
#scheduler-host>=<hostname>
scheduler-host=wtsc48.itso.ibm.com
#scheduler-port=<port>
scheduler-port=9575
#repository-job=<jobname>
repository-job=zOSEcho
#properties
debug=false
The output of the command is shown in Example 14-11.
Example 14-11 Run Echo sample with ./WSGrid.sh zOSEchowsgrid.cntl
247
248
See Figure 14-22 for the status of the job in the JMC.
Figure 14-22 Run zOSEcho with WSGrid: View submitted job using WSGrid in JMC
14.2.4 Web services and EJB interfaces for the Job Scheduler
Schedulers enable Java EE application tasks to run at a requested time. Schedulers also
enable application developers to create their own stateless session EJB components to
receive event notifications during a task life cycle, allowing the plugging-in of custom logging
utilities or workflow applications.
The Job Scheduler supports programmatic access to its functions over both an enterprise
bean (EJB) interface for Java EE applications and a Web Services interface for both Java EE
and non-Java EE applications.
249
250
A Java EE server application, such as a servlet or EJB component can use the Scheduler
API. Schedulers are accessed by looking them up using a JNDI name or resource
reference. Locate Schedulers using the javax.naming.Context.lookup() method from a
J2EE server application, such as a servlet or EJB module.
3. In the JobSchedulerProxyImpl.java. file, insert the code shown in Figure 14-12.
Example 14-12 JobSchedulerProxyImpl.java
package com.ibm.ws.batch;
import java.rmi.RemoteException;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import
import
import
import
import
import
import
import
com.ibm.websphere.batch.IJobSchedulerProxy;
com.ibm.websphere.longrun.InvalidJobIDException;
com.ibm.websphere.longrun.InvalidOperationException;
com.ibm.websphere.longrun.JCLException;
com.ibm.websphere.longrun.JobScheduler;
com.ibm.websphere.longrun.JobSchedulerHome;
com.ibm.websphere.longrun.JobSubmissionException;
com.ibm.websphere.longrun.SchedulerException;
251
private
private
private
private
String
String
String
String
schedulerNodeName;
schedulerServerName;
schedulerBootstrapPort;
schedulerClusterName;
schedulerServerName ;
JobScheduler js = getJobScheduler();
js.cancelJob(jobid);
}
public void restartJob(String jobid) throws
RemoteException, InvalidJobIDException, InvalidOperationException,
SchedulerException, JCLException, JobSubmissionException
{
JobScheduler js = getJobScheduler();
js.restartJob(jobid);
}
public int getJobRC(String jobid) throws
RemoteException, InvalidOperationException, InvalidJobIDException, SchedulerException {
JobScheduler js = getJobScheduler();
int rc = js.getBatchJobRC(jobid);
return rc;
}
public int getJobStatus(String jobid) throws RemoteException, InvalidJobIDException, SchedulerException {
JobScheduler js = getJobScheduler();
int rc = js.getJobStatus(jobid);
252
return rc;
}
public JobSchedulerProxyImpl(String schedulerHostName,String schedulerNodeName,
String schedulerServerName, String schedulerBootstrapPort) {
this.schedulerHostName = schedulerHostName;
this.schedulerNodeName = schedulerNodeName;
this.schedulerServerName = schedulerServerName;
this.schedulerBootstrapPort = schedulerBootstrapPort;
}
public JobSchedulerProxyImpl(String schedulerClusterName,
String schedulerBootstrapPort, String schedulerHostName
this.schedulerHostName = schedulerHostName;
this.schedulerBootstrapPort = schedulerBootstrapPort;
this.schedulerClusterName = schedulerClusterName;
}
) {
The Scheduler is now available to use from a J2EE server application. The source is
included in the com.ibm.ws.batch package.
In the servlet SchedulerWrapperServlet.java, you need to hard code the following
variables:
Host name
Scheduler name
Node name
Bootstrap port
Cluster name
The host name and the bootstrap port is always required. Depending on your WebSphere
XD Compute Grid environment you have to set the cluster name in a clustered
environment or the server and node name in a non-clustered environment.
Also, ensure that the xJCL is placed in a string, for example, by reading an xJCL file into a
string. In this example, the simpleEchoJob xJCLs implements as a string, the same xJCL
we used in the other WebSphere XD Compute Grid samples. Depending if you use the
local UTE or the z/OS environment you have to change the file names for the input and
output file in the xJCL, for example:
local UTE
z/OS environment
253
import com.ibm.websphere.longrun.JCLException;
import com.ibm.websphere.longrun.JobSubmissionException;
import com.ibm.websphere.longrun.SchedulerException;
/**
* Servlet implementation class for Servlet: SchedulerWrapperServlet
*
*/
public class SchedulerWrapperServlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet {
/* WebSphere zOS
private String schedulerHostName = "wtsc48.itso.ibm.com";
private String schedulerNodeName = "alnodea";
private String schedulerServerName = "allrsa01";
private String schedulerBootstrapPort = "9560";
private String schedulerClusterName = null;
*/
// local WebSphere UTE
private String schedulerHostName = "localhost";
private String schedulerNodeName = "suthomasNode01";
private String schedulerServerName = "server1";
private String schedulerBootstrapPort = "2812";
private String schedulerClusterName = null;
254
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#HttpServlet()
*/
public SchedulerWrapperServlet() {
super();
}
/* (non-Javadoc)
* @see javax.servlet.GenericServlet#init()
*/
public void init() throws ServletException {
// TODO Auto-generated method stub
super.init();
if (schedulerClusterName==null){
schedProxy = new JobSchedulerProxyImpl(schedulerHostName, schedulerNodeName, schedulerServerName,
schedulerBootstrapPort);
}
else {
schedProxy = new JobSchedulerProxyImpl(schedulerClusterName, schedulerBootstrapPort,
schedulerHostName);
}
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String cmd = request.getParameter("command");
255
256
}
}
private void _cancelJob(HttpServletRequest request, HttpServletResponse response) {
try {
String jobId = request.getParameter("jobid");
if(jobId != null && !jobId.equals("")) {
schedProxy.cancelJob(jobId);
PrintWriter pw = response.getWriter();
pw.print("Cancelled Job: " + jobId);
}
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SchedulerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidOperationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidJobIDException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void _submitJob(HttpServletRequest request, HttpServletResponse response) {
try {
//String jobId = schedProxy.submitJob(simpleCIJob);
String jobId = schedProxy.submitJob(simpleEchoJob);
PrintWriter pw = response.getWriter();
pw.print("Submitted Job: " + jobId);
} catch (RemoteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SchedulerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JCLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (JobSubmissionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
// TODO Auto-generated method stub
}
}
257
258
5. Select WAR file as type for export, and click Next, as shown in Figure 14-26.
6. Select the destination for the exported SchedulerWrapperTest WAR file, and click Finish,
as shown in Figure 14-27.
The SchedulerWrapperTest.war file will be created in the directory and can now be
installed in the WebSphere environment for testing the application.
259
You have to log in to the administrative console on the local UTE or on the z/OS
environment depending where you want to install the application. The installation process
is the same in both environments. Select Applications Install New Application, as
shown in Figure 14-28.
If you install the application in your local UTE, there is only one server where you can
install the WAR file. If you want to install the application on a different WebSphere
260
environment configuration, select a server that hosts a Scheduler and not a Grid
Execution Endpoint. For all the other installation options, select the default.
8. After you installed the application successfully, start the application. Now, you are ready to
use the application where you can submit, cancel, and restart Echo jobs, or you can also
get the job status or the job return code from submitted jobs.
9. Next, call the application by entering the following address in the browser. The servlet URL
is:
http://<hostname>:<port>/SchedulerWrapperTest/SchedulerWrapperServlet
The servlet usage is simple. Use the servlet URL, and add the command that you want to
set up as follows:
cancelJob(jobid)
cancelRecurringRequest(request)
getBatchJobRC(jobid)
getJobDetails(jobid)
getJobOutput(jobid)
getJobStatus(jobid)
modifyRecurringRequest(request)
purgeJob(jobid)
removeJobFromRepository(job)
restartJob(jobid)
resumeJob(jobid)
saveJobToRepositoryAndSubmit(xJCL,job,replace)
saveJobToRepository(xJCL,job,replace)
showAllJobs()
showAllRecurringRequests()
showJobFromRepository(job)
showRecurringJobs(request)
submitJobFromRepository(job)
submitJob(xJCL)
submitRecurringRequest(job)
suspendJob(jobid,seconds)
261
Refer to the Job Scheduler Web Services Web Service Description Language (WSDL) file, as
shown in Figure 14-30, for detailed descriptions of the Web services interface.
262
Discover
Create or Transform
Build
Deploy
Test
Develop
Publish
Note: There is no sample available at the moment, but to develop the code should work as
using the EJB interface.
263
End-to-end solution
Tivoli Dynamic Workload Automation components allow IT organizations to establish a virtual
control point to build and automate a repeatable, scalable service execution process across
the enterprise. It provides the ability to consolidate enterprise-wide batch and event-triggered
workloads spanning multiple applications and systems, giving IT organizations efficient
control and management of cross-enterprise workloads.
The Tivoli Workload Automation family components can be flexibly deployed into any
solution-based environment. Customers can choose between mainframe-centric,
distributed-centric or peer-to-peer parallel end-to-end enterprise scheduling solutions.
Extensive awareness and interfacing is provided to SAP, PeopleSoft and Oracle business
applications. Additionally, the end to end solution can be extended to include Tivoli Dynamic
Workload Broker agent, which routes workloads to the best available resources on demand,
based on user policies and IT resource availability. It also automatically identifies newly
provisioned IT resources and incorporates them into the workload matching pool.
Scalability
Tivoli Workload Scheduler for z/OS has a proven track record of scaling beyond 250,000 jobs
a day in real customer production environments.
High availability
High availability for any Tivoli Dynamic Workload Automation solution is guaranteed by fail
over mechanisms. Stand-by Controller, alternate workstation, backup and flip-flop plans are
some of the features used to minimize the risk of outages in the z/OS production workload.
Backup master, full status fault tolerant agents implement the fail over mechanism in
end-to-end environment.
Fault tolerance
The end-to-end solution gives built-in fault tolerance, using the capability of the master
domain manager to generate the plan and distribute it to the agents in the network. The plan
contains a complete set of scheduling instructions, so that the agent can manage workload
and resolve dependencies even in the event of a loss of communication with the master.
264
Critical Path
Tivoli Workload Scheduler for z/OS provides a Critical Path feature to automatically manage
SLAs for milestone jobs. Milestone jobs are jobs that are critical to the business and must not
miss their deadlines. The user will flag Critical Jobs and Tivoli Workload Scheduler for z/OS
will automatically calculate the Critical Path to those jobs and promote jobs on the Critical
Paths which are late and might affect the Critical Jobs deadline. The promotion algorithm
uses the WLM integration.
265
Exposing services into WEB API, Java EE REXX calls, and REXX-based
interface
Open Java EE and Web Services interfacing allow IT organizations to consolidate custom
applications and services into the service execution process. REXX-based programming
interfaces are also available to flexibly communicate with Tivoli Workload Scheduler for z/OS.
Reporting
Advanced reporting capabilities are going to be provided this year as part of the Tivoli
Dynamic Workload Console. Standard and user defined reports will enable to display product
plan details, track and tune workload capacity during time, control the timely workload
execution according to goals and SLA, and so forth.
266
267
processing so that if the JCL job is cancelled, the underlying job is cancelled also, thus
ensuring synchronized life cycle of the two jobs.
The external scheduler interface uses the Java Message Service (JMS) as a bidirectional
communication mechanism between an external client and the Job Scheduler. The interface
uses platform messaging as the JMS provider. Integrating the Job Scheduler with an external
workload scheduler is achieved by configuring and securing the Job Scheduler, enabling the
interface by configuring the Job Scheduler message-driven interface, the service integration
bus and the JMS queues, then using the WSGrid utility to run grid jobs.
WebSphere XD Compute Grid jobs can optionally be controlled through an external workload
scheduler, such as Tivoli Workload Scheduler. Prepare for this integration by following these
required steps in the WebSphere XD Compute Grid environment:
1. Configure the WebSphere Service Integration Bus (SIBus) and required JMS artifacts.
2. Install the JobSchedulerMDI application in the same server or cluster that is hosting the
Job Scheduler.
3. Configure bus and JMS security if security is enabled in your environment.
4. Optionally implement and install the WSGridNotification SPI.
5. Use WSGrid utility as the executable launched by the external workload scheduler.
Figure 14-31 shows the job control by an external workload scheduler for the z/OS platform
environment. In this diagram, Tivoli Workload Scheduler is shown as an example workload
scheduler and shows the flow of scheduled jobs from Tivoli Workload Scheduler to WSGrid,
through Job Scheduler to the Grid Execution Endpoint and from the Grid Execution Endpoint
back to Tivoli Workload Scheduler z/OS using zConnector.
WebSphere XD
Compute Grid
Grid Executio n
Endpoi nt
Job
JES
WebSphere XD
Compute Grid
JCL
1
Tivoli Workload Scheduler z/OS
WSGrid
JCL
Job Scheduler
Message
WebSphere XD
Compute Grid
Grid Executio n
Endpoi nt
Job
Statu s Li stene r Mg r
Operation
Plan
//JOB1
JOB " "
//STEP1 PGM=IDCAMS
//STEP2 PGM=WSGRID,
//SYSIN DD *
// jndi-name="ejb/DOIT"
//
TWS
L iste ner
other
Listener
Figure 14-31 Flow of dynamic job scheduling with Tivoli Workload Scheduler for z/OS
268
z/OS
Tivoli Workload
Scheduler for z/OS
JES
JCL
JCL
IHS
IHS
WSGrid
Batch
OLTP
WebSphere XD
Compute Grid z /OS
Job Scheduler
WebSphere XD
Compute Grid z/O S
WebSphere XD
C ompute G rid z/OS
JES Initiators
WebSphere z/OS
OLTP
DB2 z/OS
Figure 14-32 Scheduling traditional batch, WebSphere XD Compute Grid batch and OLTP workload
with Tivoli Workload Scheduler z/OS
269
More information about the integration of WebSphere XD Compute Grid with external
schedulers is provided in the specific Information Center:
For Job Scheduler configuration, see:
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/index.jsp?topic=/com.ibm.
websphere.gridmgr.doc/info/scheduler/tcgconf.html
For security information, see:
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/topic/com.ibm.websphere.g
ridmgr.doc/info/scheduler/tcgexsched.html
For information about how to run WebSphere XD Compute Grid jobs with the WSGrid
utility, see:
http://publib.boulder.ibm.com/infocenter/wxdinfo/v6r1/index.jsp?topic=/com.ibm.
websphere.gridmgr.doc/info/scheduler/ccgwsgrid.html
270
MQListener runs as a single multi-threaded process under z/OS UNIX System Services.
Each thread or task establishes a connection to its configured message queue for input. Each
task also connects to a DB2 database on which to run the stored procedure. The information
about the queue and the stored procedure is stored in a table in the configuration database.
The combination of the queue and the stored procedure is a task.
MQListener tasks are grouped together into named configurations. By default, the
configuration name is empty. If you do not specify the name of a configuration for a task,
MQListener uses the configuration with an empty name.
There is support for both one-phase and two-phase commit environments. A one-phase
commit environment is where DB and MQ interactions are independent. A two-phase commit
environment is where DB and MQ interactions are combined in a single unit of work.
The MQListener UNIX System Services command db2mqln1 is the name of the executable for
one phase and db2mqln2 is the name of the executable for two phase.
Admin queue
Backout queue
Input queue having a backout queue with threshold=3
Output queue or reply queue
Dead letter queue
271
Therefore, the stored procedure that MQListener calls must have the following two
parameters:
Input parameter for incoming message in character format
Output parameter for outgoing message in character format
The Java class to generate PDF files needs two different parameters, but the incoming
message is only a single character string. Further, we want to characterize the current
running process with a jobID. Adding a jobID is necessary if you want to process many
incoming messages. The output message should contain this jobID, so you can see which
jobs have finished.
Therefore, we need create an incoming message with these parameters separated by the
colon (:) in one single character string as shown in Example 14-14.
Example 14-14 Sample incoming message
ReportJob01:store_fs_db2:/u/wagnera/javastp/pdfs
For the Java stored procedure, you need to create a method with the following features and
capabilities:
Example 14-15 shows the content of method triggeredByMQ, which is called by DB2 when
the stored procedure is called by MQListener. You can find this source code in Triggering
Java Stored procedure to generate PDF files on page 450.
Example 14-15 Method triggeredByMQ from Java Class GenPdf
temp = inMsg;
jobID = temp.substring(0, temp.indexOf(":"));
temp.substring(temp.indexOf(":") + 1);
action = temp.substring(0, temp.indexOf(":"));
pdfDir = temp.substring(temp.indexOf(":") + 1);
272
273
queues and start the configured stored procedure for this queue to process the incoming
message. Normally the system programmer is responsible for configuration and starting
MQListener tasks. Therefore, in this book we describe only the necessary steps to configure
and start a MQListener.
Use the MQListener command, db2mqln1 or db2mqln2, to configure and start MQListener
tasks. Issue the command from the z/OS UNIX System Services command line in any
directory. Alternatively, you can put the command in a file, grant execute permission, and use
the BPXBATCH utility to invoke the script from JCL.
To configure and start DB2 MQListener tasks, set up the UNIX System Services environment
for DB2 and MQ connectivity. Edit the .profile file in your UNIX System Services home
directory and append the lines as shown in Example 14-18). The values for LIBPATH, PATH,
and STEPLIB are system specific. You need to change them to fit your environment.
Example 14-18 Append data to UNIX System Services user profile .profile
#MQLISTENER
export MQLNHOME=/usr/lpp/db2/d9gg/db2910_mql/listener
export PATH=$PATH:$MQLNHOME/bin
export LIBPATH=$LIBPATH:$MQLNHOME/lib
export STEPLIB=$STEPLIB:DB9G9.SDSNEXIT:DB9G9.SDSNLOAD:DB9G9.SDSNLOD2
export STEPLIB=$STEPLIB:MQ700.SCSQLOAD:MQ700.SCSQAUTH
Example 14-19 shows the command to add a new MQListener configuration. The add
parameter with the db2mqln1 or db2mqln2 command updates a row in the DB2 table,
SYSMQL.LISTENERS. To get help with the command and the valid parameters, issue
db2mqln1/db2mqln2 help <command>.
Example 14-19 Add new MQListener
db2mqln1/db2mqln2 add
-ssID <subsystem name>
-config <configuration name>
-queueManager <queuemanager name>
-inputQueue <inputqueue name>
-procName <stored-procedure name>
-procSchema <stored-procedure schema name>
-numInstances <number of instances
To start the MQListener task, issue the command shown in Example 14-20.
Example 14-20 Start MQListener
db2mqln1/db2mqln2 run
-ssID <subsystem name>
-config <configuration name>
-adminQueue <adminqueue name>
-adminQMgr <adminqueuemanager name>
To stop or restart a MQListener task, issue the command shown in Example 14-21.
Example 14-21 Stop/Restart MQListener
db2mqln1/db2mqln2 admin
-adminQueue <adminqueue name>
-adminQMgr <adminqueuemanager name>
274
-adminCommand shutdown/restart
To remove messaging tasks from your environment, issue the command shown in
Example 14-22.
Example 14-22 Remove task from environment
db2mqln1/db2mqln2 remove
-ssID <subsystem name>
-config <configuration name>
-queueManager <queuemanager name>
-inputQueue <inputqueue name>
To display information about the configuration, issue the command shown in Example 14-23.
Example 14-23 Display information about configured tasks
db2mqln1/db2mqln2 show
-ssID <subsystem name>
-config <configuration name> | all
Now, you can start the MQListener tasks. In our example, we use the following configuration:
DB2 system
Queue Manager
Queue for input messages
Queue for output messages
Queue for failing messages
DB2 stored procedure
D9G1
MQG1
WAGNERA.DB2.REQUEST
WAGNERA.DB2.REPLY
WAGNERA.DB2.BACKOUT
BATCH.MQ_TRIGGERED_STP
We define our MQListener task with the UNIX System Services command shown in
Example 14-24.
Example 14-24 Define MQListener task
275
You can stop the MQListener task with the UNIX System Services command shown in
Example 14-26.
Example 14-26 Stop MQListener task
ADMIN_Q
JDBC_Path=/usr/lpp/db2/d9gg/db2910_jdbc
Url=jdbc:db2://<server>:<port>/<DB2Location>
Uid=<User>
Pw=<Pw>
Col=LSNR
export CLASSPATH=$CLASSPATH:$JDBC_Path/classes/db2jcc.jar
export CLASSPATH=$CLASSPATH:$JDBC_Path/classes/db2jcc_license_cisuz.jar
java com.ibm.db2.jcc.DB2Binder -url $Url -user $Uid -password $Pw -collection $Col
DynamicBatch Servlet
TriggerBatchBean
(Session Bean)
Figure 14-33 Dynamic batch sample application for use with MQListener
276
SEND MSG
MQ
input queue
Figure 14-34 shows this servlet looks from a user perspective. It consists of a form with two
parameter input fields as well as a Submit and Cancel button. By clicking Submit, the servlet
calls a Session Bean called TriggerBatchBean. This bean contains the logic to check input
parameter and send a message to queue WAGNERA.DB2.REQUEST.
Note 1: In the template version of the application, the session bean returns only the value
of the two parameters.
Note 2: In our scenario, we use WebSphere Application Server for z/OS Version 6.1 to
ensure compatibility with the J2EE 1.4 specification. Although we could have used Java EE
5.0, we wanted to ensure that a broad range of users can use this sample.
The servlet and session bean source code can be found under Dynamic batch Web
application on page 445.
We also provide this application as a Rational Application Developer project. See Appendix C,
Additional material on page 453 for more details. However, if you do not have Rational
Application Developer, you could also use some other kind of J2EE development tool.
277
return message;
}
2. Next, verify the value of the input parameter. The Java stored procedure needs the
following three input parameters, separated by a colon (:):
JobID
action
store_fs
store_db2
store_fs_db2
pdfDir
278
279
unaware that part of the system is unavailable because they have access to the data and
applications that they need.
Ability to manage a mixed workload
DB2 for z/OS effectively and efficiently manages priorities of a mixed workload as a result
of its tight integration with z/OS Workload Manager.
Protection of data integrity
Users of DB2 for z/OS can benefit from the product's well-known strength in the areas of
security and reliability.
To run DB2 as a Web service provider you need a WebSphere Application Server. The
WebSphere Application Server can be on z/OS or a distributed platform.
While DB2 can act as a Web service requester, DB2 made a conscious decision to reuse the
Web Services infrastructure that works well that is provided with products, such as
WebSphere Application Server, WebSphere Message Broker, WebSphere DataPower, and
so on, and focused on the Web service to DB2 mapping instead of reimplementing everything
from scratch.
DB2 development made a conscious decision to not start over but to use the existing Web
services infrastructure provided by application servers.
280
281
You can test the configuration by clicking Test Connection. If the connection is configured
properly, you can click Finish.
282
2. Next, select the configured Connection, and click Finish (see Figure 14-36).
3. To create the stored procedure, expand the Redbook project in the Data Project Explorer
window, select Stored Procedures, and right-click New Stored Procedure (see
Figure 14-37).
283
4. In the next window set the following options, as shown in Figure 14-38:
Name: BATCH.SOAP_TRIGGERED_STP
Language: Java
Java package: com.ibm.itso.sample
Dynamic SQL using JDBC
Click Next.
284
5. Then, remove the predefined Statement, and choose None for the Result set option as
shown in Figure 14-39. Click Next.
285
6. Now, you need to define the input and output parameters. As mentioned previously, the
test procedure must have the same input and output parameters as the procedure to
generate PDF files. You need to create the following parameters:
IN parameter ACTION - DB2 data type VARCHAR(15)
IN parameter PDF_DIR - DB2 data type VARCHAR(100)
OUT parameter OUT_MSG - DB2 data type VARCHAR(100)
In the current window, click Add to define the first parameter, as shown in Figure 14-40.
286
7. Click Next and then click Advanced to define the WLM environment (see Figure 14-41).
8. Click OK. Then, to complete the stored procedure definition, click Finish.
9. Next, you need to change the Java code. Expand the Data Project Explorer window to
receive the Java source of the test procedure and double-click the Java file (see
Figure 14-42).
10.Change the Java code to return a message to the Web Service caller as shown in
Example 14-32.
Example 14-32 Return message to Web Service caller
287
11.Now, you can deploy this Java stored procedure by right-clicking the
BATCH.SOAP_TRIGGERED_STP procedure and choosing Deploy (see Figure 14-43).
288
14.You can check the result of the test run in the Parameters tab of the SQL Results window
(see Figure 14-46).
289
3. In the window that opens, select BatchStoredProcedure, and then click > to move this
Web service from Available Web services to Selected Web services. Then, click Next
and Finish.
4. Next, build and deploy the Web service. Right-click the BatchStoredProcedure Web
service, and choose Build and Deploy (see Figure 14-49).
290
5. In the window that opens, change the following values (see Figure 14-50) and click Finish:
Web server Type: WebSphere Application Server, Version 6 (all releases)
Message protocols: Clear the REST option (Web access)
Clear this option because you do not need this feature for our test.
Note: With this step, Data Studio creates a complete Java EE Web project. This project
contain all the necessary data to call the stored procedure as a Web service (such as a
WSDL file).
291
6. Now, you need to change the Data Studio perspective. Select Window Open
Perspective Other, and choose Java EE perspective as shown in Figure 14-51.
292
Figure 14-53 Testing a Web service using the Web Services Explorer
4. To see the result of the test, click Source in the Status window. The SOAP Request and
Response displays as shown in Example 14-33.
Example 14-33 SOAP Request and Response
SOAP Request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q0="http://redbook.itso.ibm.com/BatchStoredProcedure"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
Chapter 14. Create agile batch by implementing trigger mechanisms
293
- <q0:SOAP_TRIGGERED_STP>
<ACTION>1</ACTION>
<PDF_DIR>1</PDF_DIR>
</q0:SOAP_TRIGGERED_STP>
</soapenv:Body>
</soapenv:Envelope>
SOAP Response:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <soapenv:Body>
- <SOAP_TRIGGERED_STPResponse
xmlns:ns1="http://redbook.itso.ibm.com/BatchStoredProcedure">
<OUT_MSG>This is our test Stored procedure</OUT_MSG>
</SOAP_TRIGGERED_STPResponse>
</soapenv:Body>
</soapenv:Envelope>
2. Name the script ReplaceSTP.sql, and click Finish. In file ReplaceSTP.sql script, write the
statements as shown in Example 14-34.
Example 14-34 Recreate stored procedure
LANGUAGE JAVA
PARAMETER STYLE JAVA
NOT DETERMINISTIC
FENCED
CALLED ON NULL INPUT
MODIFIES SQL DATA
NO DBINFO
NO COLLID
WLM ENVIRONMENT D9GGWLMJ
ASUTIME NO LIMIT
STAY RESIDENT YES
PROGRAM TYPE SUB
SECURITY DB2
INHERIT SPECIAL REGISTERS
STOP AFTER SYSTEM DEFAULT FAILURES
COMMIT ON RETURN NO
;
GRANT EXECUTE ON PROCEDURE BATCH.SOAP_TRIGGERED_STP TO PUBLIC;
3. Execute this statement as shown in Figure 14-55. Right-click ReplaceSTP.sql, and select
Run SQL.
295
You also need to create some Java classes in Data Studio. Because there are only a few
differences, we briefly describe the necessary steps in Data Studio for the JavaSTP
successfully. You can find more information about developing this Java class in 6.3, Java in
DB2 for z/OS on page 64.
Important: You have to use the same Java compiler version in Data Studio Java projects
as configured for the DB2 Java stored procedure runtime environment. If you do not know
the configured DB2 Java runtime version ask your DB2 system programmer.
To create the Java classes in Data Studio:
1. Create a new Java project called JavaSTP.
2. Create a new folder called lib, and store the iText-2.1.5.jar file in this folder.
3. Add iText-2.1.5.jar to the Java build path.
4. Create the deploy.xml and zos.properties files in your project. For information about the
content of these files, see 6.3, Java in DB2 for z/OS on page 64.
5. Create a Java package called com.ibm.itso.sample.
6. Create the GenPDF and PdfCreator Java classes. For this Java source code, see 6.3, Java
in DB2 for z/OS on page 64.
Important: You have to add the triggeredBySOAP method to the GenPDF class as shown
in Example 14-35.
Example 14-35 The triggeredBySOAP method and the GenPdf class
public static void triggeredBySOAP(String action, String pdfDir, String[] outMsg)
throws SQLException {
PdfCreator pdfc = new PdfCreator();
pdfc.generatePDF(action, pdfDir);
outMsg[0] = new String("PDF(s) successfully created.");
}
7. Append the jakarta-oro-2.0.8.jar and commons-net-2.0.jar JAR files for the Ant run
time to the Ant environment using Window Preferences Ant Runtime (as
described in 6.3, Java in DB2 for z/OS on page 64).
8. Deploy Java sources by right-clicking deploy.xml, and then clicking Run As Ant Build.
Here are the steps for the UtilSTP Java project:
1. Create a new Java project called UtilSTP.
2. Create a new folder called lib, and store the DB2 driver JAR files, db2jcc.jar and
db2jcc_license_cisuz.jar, in this folder.
3. Add the driver JAR files to the Java build path.
4. Create a Java package called com.ibm.itso.sample.
5. Create the Java classes RefreshWLM and TestSTP. For Java source code, see 6.3, Java in
DB2 for z/OS on page 64.
296
Important: You must change the TestSTP class as shown in Example 14-36.
Example 14-36 Change class TestSTP
CallableStatement cs = con.prepareCall("CALL BATCH.SOAP_TRIGGERED_STP(?, ?, ?)");
cs.setString(1, action);
cs.setString(2, pdfDir);
cs.registerOutParameter(3, java.sql.Types.VARCHAR);
cs.execute();
System.out.println("Call STP ended: " + cs.getString(3));
6. Refresh the WLM environment by right-clicking class RefreshWLM, and clicking Run
As Java Application.
7. Test the stored procedure by right-clicking class RefreshWLM, and clicking Run As
Java Application.
297
298
Part 4
Part
299
300
15
Chapter 15.
301
Of course, as with real projects, additional work might need to be scheduled around the main
batch window (and resources must be provisioned).
302
303
You can use these approaches (or strategies) in combination. You need to apply them
appropriately to you specific environment and batch applications.
Some approaches can be implemented with system-wide or subsystem-wide actions, for
example using the DB2 ALTER BUFFERPOOL command to increase the size of a DB2
subsystems buffer pool. Other approaches require engineering into the workload, that is
detailed implementation, such as implementing a BatchPipes/MVS pipeline, which we explain
in detail in Chapter 16, Increasing concurrency by exploiting BatchPipes on page 309.
Note: Take care not to cause resource issues through the inappropriate use of the
techniques or to cause batch processing failures (perhaps through poor understanding of
the applications logic and dependencies).
We now discuss these key strategies in more detail.
304
As well as resource considerations, ensure that important systems and other software are set
up properly as follows:
Workload Manager (WLM) set up to provide for good batch throughput
DB2 subsystems optimally tuned for batch
To be able to implement DIM techniques, you need spare memory, spare CPU capacity, and a
batch workload that is I/O-intensive.
I/O optimization is most important when the batch workload is I/O-intensive. Where there is
little spare CPU capacity I/O optimization could cause an I/O bottleneck to be replaced by a
CPU bottleneck.
Reducing the elapsed time of a set of jobs by running more of them alongside each other.
Performing I/O in parallel, using techniques such as Stripes.
Performing DB2 queries using CPU Query Parallelism to use multiple TCBs.
Cloning batch jobs to work against subsets of the data.
To be able to run more work in parallel, you need adequate resources, most importantly spare
CPU capacity and memory, and adequate I/O bandwidth.
305
306
307
308
16
Chapter 16.
Increasing concurrency by
exploiting BatchPipes
Note: In this chapter, we refer to BatchPipes/MVS as simply Pipes.
Pipes is a relatively old product, but one which continues to provide useful function, especially
for increasing concurrency. Its BatchPipeWorks component also can enable some
simplification by replacing self-written code with standard functions.
This chapter includes the following topics:
Basic function
Implementation
New Pipes connectors
Additional Pipes functions
309
Job W
Job R
With Pipes a short in-memory queue is created. This queue (or pipe) is written to by the writer
job and read from by the reader job. As records become available in the pipe the reader can
process them, removing them from the front of the queue. The writer places records on the
back of the queue.
310
Figure 16-2 shows the same scenario as Figure 16-1 but with the disk data set replaced by a
pipe. Again Job W writes the data and Job R reads it. This time Job W and Job R run
together.
Job W
Job R
311
A sort is a good example of a processing operation that breaks the pipeline. Figure 16-3
illustrates such a situation.
Job W
Job S
Sort Work
Phase
Job R
Suppose Job W writes a data set that Job S sorts and Job R reads the sorted data. Because
the last record read into the sort might be the first record the sort writes there can be no
overlap between the sort input and output phases. So Job W can be overlapped with the input
phase of Job S but not with the output phase of Job S. Similarly Job R can be overlapped with
the output phase of Job S but not the input phase. So Job W and Job R cannot overlap at all.
Pipes is able to use the Coupling Facility to create pipes between different z/OS images in a
sysplex. See 16.4.1, BatchPipePlex on page 314 for more information about cross-sysplex
pipes.
Pipes has additional record-processing capabilities, modelled on CMS Pipelines, described in
16.4.2, BatchPipeWorks on page 314. These can yield further concurrency and application
simplification.
16.2 Implementation
This section is a basic introduction to implementing Pipes. There are two steps that need to
be performed:
1. Set up the Pipes subsystem, outlined in 16.2.1, Setting up the Pipes subsystem on
page 313.
2. Replace specific individual data sets by pipes, described in 16.2.2, Implementing
Individual Pipes on page 313.
312
313
16.4.1 BatchPipePlex
Many installations allow their batch work to spread across more than one LPAR in a parallel
sysplex. With the basic Pipes implementation it is not possible for a writer to a pipe to be on
one system and a reader on another. In the case where you cannot guarantee all the
members of a pipeline will run on the same LPAR this could be a significant problem.
To pipe across systems within a parallel sysplex use BatchPipePlex. This uses a Coupling
Facility structure to extend the queue that a basic pipe would implement.
The structure is called SYSASFPssnm, where ssnm is the name associated with the BatchPipes
subsystems within the pipeplex (which must all have the same name.) For example, if all
subsystems are called PSP1 the structure is called SYSASFPPSP1.
Because the structure has a fixed single name consider duplexing it to avoid it being a single
point of failure.
Using BatchPipePlex is slower than using a basic pipe. Therefore it is recommended not to
use BatchPipePlex for a single system pipe.
16.4.2 BatchPipeWorks
While the main purpose of Pipes is to provide increased concurrency, the product also has
another useful capability: BatchPipeWorks.
BatchPipeWorks is a subset of the CMS Pipelines package, ported to z/OS. It allows the
construction of pipelines from a palette of 100 built in stages as well as stages you can write
yourself.
314
A pipeline is a series of programs called stages through which data flows. A pipeline consists
of one or more stages and the output of one stage automatically becomes the input to the
next stage. Each stage takes input records, performs a simple transformation on each of
them, and passes the result on.
Examples of things you can do are:
315
Figure 16-4 shows some of the possibilities. Job W writes to a pipe using a fittings pipeline
with three stages or fittings. Fitting 3 also writes a hardened copy to disk.
Job W
Fitting 1
Fitting 2
Fitting 3
Job R
Figure 16-4 Fittings, including one that writes a hardened copy to disk
317
318
17
Chapter 17.
319
Figure 17-1 illustrates three components to a batch job: Input, Batch Job Step, and Output.
The Input component is a domain-object factory, which maps raw bytes into a valid domain
object. The Batch Job Step component contains the business logic, including validations,
transformations, and business rules that execute against a valid domain object. This
component does not know, nor should it care, how the domain object was obtained, it simply
expects a complete (valid) domain object. Finally the Output components only task is to map
a processed domain object to raw bytes. The Output component does not care what
processing took place, only that the processed domain object is valid and can be persisted.
Each component operates on a single record, which is important when discussing parallel
processing strategies.
Strict enforcement of this encapsulation ensures agility and service reuse. For example, we
can change the source of records from a file to a database by changing the input
implementation. This change will be in complete isolation of the Batch Job Step and the
Output components. Likewise, we can change the Output implementation to persist data to a
fixed-block data set on z/OS instead of a text file, and this change will be unknown to the other
modules. Figure two illustrates an example of applying the strategy pattern not only for
encapsulating the input, process, and output components, but also within the process
component (also know as the kernel) where validations can be plugged in.
As Figure 17-2 illustrates, the Input Data Stream (Input DS) produces valid input domain
objects. One record is passed to the kernel for processing, where the kernel knows nothing
about how that domain object was obtained. The kernel, also using the strategy pattern, will
apply a set of validations and other business logic to the record. As new requirements are
dictated, additional validations can be plugged into the kernel.
320
Figure 17-2 Strategy pattern applied to create a kernel that processes batch records
Finally, the kernel returns the output domain object to the Output Data Stream (Output DS) for
persistence.
Validations and business rules that are applied to a batch application must be carefully
designed. Validations typically make use of referential data, for example, in order to validate
whether a bank account is active or not, the account number will get looked up in some
database. In the context of batch, the cost of a validation is magnified because of the number
of records that must be processed. If a validation takes 100 ms, and you must process 10
million records, the absolute fastest time the job can execute in is 1 million seconds. Caching,
data-aware routing, and complex SQL queries are a few strategies that can be applied to
reduce the complexity of the validations. For example, a more efficient way to process valid
bank account records is to add a clause in the predicate of the SQL query, select accounts
from accountTable where account.status = active. Each record processed by the
kernel will be active; therefore the validation can be removed.
There are two benefits to designing the kernel to operate on a single record whose origin is
unknown: first, by writing each module to only operate on one record at a time, we can shift
the burden of parallel processing outside of the application code and to the infrastructure; and
second, the kernel can evolve to become a service that is shared across multiple execution
styles, batch, online transactional processing, and so forth, without sacrificing performance
optimizations that each paradigm provides.
Writing multi-threaded code can be difficult, but can significantly reduce the elapsed time of a
batch job. Maintaining and debugging multi-threaded code though can be expensive. By
designing a kernel that is agnostic to the source of valid domain objects, parallel processing
can be handled by the infrastructure. As Figure 17-3 illustrates, the Input DS can be designed
to accept parameters that dictate the range of data that should be retrieved. In this example, a
constraint in the predicate of the SQL query is used, but byte ranges in files, record ranges in
Fixed Block data sets, and so forth are also possible.
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
321
Figure 17-3
Shifting the burden of parallel batch from the application to the infrastructure
Some external parallel processing engine can create multiple instances of a batch job, in this
case, the Parallel Job Manager component of WebSphere XD Compute Grid applies a
partitioning algorithm that determines the range of data that each job instance will operate on.
To maximize throughput, the partitioning strategy for a batch job should match how the data
has been partitioned. More over, the partitioning strategy can independent of the application,
where the application developer is not responsible for determining how many instances (or
threads) must be executed, nor on what data each thread will operate. By shifting this burden
to the infrastructure, workload management data, capacity metrics, service-level agreements,
and database optimizations can be used to determine the ideal concurrency setting at a
specific moment. The infrastructure optimizations, as well as the details of how the Parallel
Job Manager operates, are outside of the scope of this chapter.
Performance of batch applications tends to be very important. Not only must batch
applications complete within a specific (and often demanding) deadline, but also any
inefficiency in the application is magnified. Using the strategy pattern and clearly separating
out the roles of input, process, and output bottom-up performance analysis can help monitor
and debug performance degradations. For example, by taking start and end times before and
after each call to the Input component, we are able to get a rough idea of how much time is
spent fetching records. Using the System.currentTimeMillis call can be highly inaccurate
when processing one record, but when processing hundreds of thousands of records, this
time becomes more accurate. Example 17-1 illustrates this concept.
Example 17-1 Measuring time spent on fetching records
startTime = System.getCurrentTimeMillis();
writeRecord(processRecord);
endTime = System.getCurrentTimeMillis();
totalWriteTime = totalWriteTime + (endTime startTime);
// Now, include code to print average read/process/write/times
At the end of the job, we can calculate the average time spent reading/processing/writing
records. A simple performance test could be to determine the amount of time each
component spent completing their respective tasks, and identifying (relatively) where most of
the time was spent in the batch job. For example, when executing a job and gathering these
performance metrics, one can determine that 60% of the time was spent reading records
while the remaining 40% were split evenly in processing and writing records.
The first place to further analyze for performance improvements could be the Input
component. The performance analysis of components could be incorporated into a
continuous-integration platform as well. Because the input, process, and output modules are
independent from one another, each can be executed separately. For example, a system can
be built for each module where the input test data is constant, each new version of the
module is executed with the constant test data, and the elapsed time for each version is
tracked, where any degradation in elapsed time indicates a performance regression. This
bottom-up performance analysis can help ensure each module is highly optimized. By
focusing on building high-performance components, the assembly of these components into
new batch jobs helps ensure that these new jobs are already well optimized.
By building highly optimized, loosely integrated components, it is possible to build a library of
modules that can be easily assembled into new batch applications. As Figure 17-4 illustrates,
WebSphere XD Compute Grid xJCL definitions can be used to assemble the various input,
processing, and output components into batch jobs. By building a bottom-up performance
analysis process, each module will ideally be optimized, helping to ensure that the new jobs
also perform well.
Figure 17-4 Libraries of functions can be created and assembled using some metadata
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
323
Further processes can be built around this library of functions, where application developers
focus on building more functions into the libraries, and business analysts can assemble new
functions without having to develop or understand the underlying code. Figure 17-5 illustrates
this concept.
17.1.1 The Batch Data Stream Framework and its implementation of these
patterns
The better the contract between an application and its execution container, the more
container-managed services can be provided. In WebSphere XD Compute Grid, the contract
is the programming model for implementing batch data streams and batch job steps. The
J2EE programming model allows the EJB container to provide services such as security
demarcation, transaction context management, caching, and so on. Similarly, the WebSphere
XD Compute Grid batch container, a peer to the EJB container within an application server, s
integrates with batch applications through two programming interfaces: one for providing
checkpoint and restart functionality for input and output data streams; and the other for
influencing the checkpoint (transaction) interval for a batch job step. To take advantage of the
various container services provided by the WebSphere XD Compute Grid batch container,
applications must implement the appropriate interfaces.
The Batch Data Stream Framework (BDS Framework) provides a tight contract between the
application and the batch container, incorporates best practices, provides design patterns
using templates and callbacks that simplify the task of developing business logic, all while
ensuring there is adequate decoupling between the business logic and the proprietary
WebSphere XD Compute Grid APIs.
There are two components of the framework: first, templates for various input and output
stream types (reading/writing with JDBC, MVS data sets, UNIX files, and so forth), where the
nuances of checkpointing and restarting each of the input and output stream types have been
implemented; and second, various application design patterns, such as the strategy pattern,
and application services such as performance metrics, logging, threshold policies, and so on.
The UML for the current version of the BDSFW can be found in Appendix C, Additional
material on page 453. Details about how to implement BDS Framework applications can be
324
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
325
The Strategy pattern serves as a foundation for sharing business services across batch and
OLTP. The kernel described in the previous section can be the service that is shared across
batch and OLTP. The kernel is designed to be data injected, where the data to be processed
is passed to the kernel by some domain object factory. The alternative approach is a service
that follows a data acquired pattern, where the service will explicitly retrieve the domain object
that is to be processed. The latter type of service is typically found in OLTP applications (Web
Services, EJBs, and so forth).
Figure 17-7 illustrates how services can be shared across batch and OLTP. The shared
service is data injected, where the domain object (input Data Transfer Object or iDTO) is
passed into the service by some external mechanism.
Figure 17-7 An approach for sharing services across batch and OLTP
326
The processed domain object (oDTO, which stands for output Data Transfer Object) is
returned by the shared service to the caller. When this service is executed in OLTP mode, an
OLTP wrapper (Web service, EJB, and so forth) will obtain the iDTO, typically through some
OLTP-oriented data access layer, and invoke the shared service. When executing in batch
mode, bulk data readers and writers, managed by some batch container, will feed records into
the shared service. A more concrete example of this shared-services architecture is available
in Appendix C, Additional material on page 453.
A key component to modern batch processing is the use of container-managed services,
where the batch application only contains business-specific code. J2EE application servers
provide several containers: Web Container for managing servlets, EJB container for
managing Enterprise Java Beans, and so forth. These containers demarcate transactions,
enforce security roles, integrate with application server services such as connection and
thread pooling, and so forth. The role of containers, and maintaining their responsibilities is
important in terms of sharing services across batch and OLTP. WebSphere XD Compute Grid
delivers a batch container, which is a peer to the EJB and Web containers within an
application server. The batch container provides services like checkpoint/restart, where batch
jobs can be restarted at some point in time with complete transactional and data integrity, as
well as enforce security identities, among many other functions. Figure 17-8 illustrates the
role of OLTP containers and the batch container when sharing business services across both
of those domains.
Figure 17-8 The role of containers when sharing business services across batch and OLTP.
Services shared across OLTP and batch should be written to assume that there is a
transaction context and a security context on the thread of execution. It is then the burden of
the execution container to enforce transactional and security semantics.
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
327
The following example demonstrates how to share services across batch and OLTP. This
example shares an account reconciliation service across batch and OLTP, where the BDS
Framework is used to integrate the service with the WebSphere XD Compute Grid batch
container. To share the service, the application architecture is divided into several sections.
The application kernel is composed of the domain object, the record-processor that is the
shared business service, and the several business validations. The kernel application is then
wrapped by code specific to each execution paradigm: a batch step wrapper that connects
batch data-streams to the kernel service; and an OLTP wrapper that interacts with the
data-access layer to retrieve a single business record to be processed. Figure 17-9 depicts
the kernel, composed of the shared service and shared business validations.
328
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
329
accountStatusValidator.destroy();
fraudValidator.destroy();
sessionBalanceValidator.destroy();
return 0;
}
protected Object loadClass(String className)
{
try
{
Object retval = Thread.currentThread().getContextClassLoader().loadClass(className).newInstance();
return retval;
}
catch (Throwable t)
{
throw new RuntimeException(t);
}
}
}
When processing in batch mode, the Batch Data Stream (BDS) Framework connects the data
reader and writer batch data streams to the batch record processor. Figure 17-10 illustrates
the batch components of the application.
Figure 17-10 Class diagram for the batch wrappers to the shared service
330
The classes DataReader and DataWriter implement the relevant reader and writer patterns
from the BDS Framework. The specific roles of the classes used in batch mode are:
DataReader
The role of this class is to map the raw data to the AccountDomainObject. The input can be
from one of two types of sources: a file and a database. Therefore this data reader must
implement both the FileReaderPattern and JDBCReaderPattern interfaces from the BDS
Framework.
AccountReconciliationSharedService
The role of this class is to process each batch record which are AccountDomainObjects.
Each batch record must be validated; AccountReconcilliationSharedService, therefore,
passes the AccountDomainObject to each validator specified. If any validations fail, NULL
is returned to the BDS Framework. If all validations pass, the account balance of the
domain object is reconciled and processed record returned to the BDS Framework, which
will write the output to the outputStream.
DataWriter
The role of this class is to map the domain object to raw data and write to the appropriate
location. In the case of this batch step, the output type can either be a database or a file,
therefore SaldosDataWriter implements both the JDBCWriterPattern and
FileWriterPattern interfaces in the BDS Framework.
When operating in OLTP mode, the shared service is wrapped with code whose purpose is to
interface with the OLTP Data Access Layer (DAL) to retrieve the relevant business record to
be processed. The OLTP wrapper then invokes the shared service, passing the acquired
business record as a parameter, similar to how the service would be invoked in batch mode.
The important difference here is that when in batch mode, the input and output streams are
optimized to read and write sequential data in bulk. When in OLTP mode, the DAL is
optimized to read and write a single, random business record.
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
331
Figure 17-11 Class diagram illustrating the OLTP wrapper to the shared service
com.ibm.websphere.batch.samples.sharedservice.dal.AccountObjectDAO;
com.ibm.websphere.batch.samples.sharedservice.dal.DAL;
com.ibm.websphere.batch.samples.sharedservice.domainobjects.AccountDomainObject;
com.ibm.websphere.batch.samples.sharedservice.steps.AccountReconciliationSharedService;
332
{
try
{
AccountDomainObject obj = accountDAO.get(accountId);
obj = (AccountDomainObject) reconcileService.processRecord(obj);
if (obj == null)
return false;
else
{
accountDAO.put(obj);
return true;
}
}
catch (Throwable t)
{
throw new RuntimeException("Failed to reconcile account. " + t);
}
}
}
The service, upon initialization, gets a handle to the DAL and the configured DAO. The
reconcileAccount() method is then invoked in an OLTP context; where the service retrieves
the business record to reconcile from the DAO using the primary key passed to it. That
business record, which is the shared domain object, is then passed to the shared business
service in the same way the batch wrapper would hand a business record. As previously
stated, the shared service was written to be indifferent about the source of the business
record to be processed; therefore, the same business validations and logic are used from
both the OLTP and batch contexts.
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
333
Figure 17-12 depicts the big picture, the OLTP and batch domains, for the application.
Figure 17-12 Class diagram illustrating the entire application (OLTP and Batch wrappers to the shared service)
Ultimately, the domain object becomes critical to this pattern for shared services. In this
example, the same domain object is used across all of the processing, but that isnt a
requirement. The reader (batch data reader or the OLTP DAL) can acquire an input domain
object that is to be passed to the shared service for processing. The shared service can apply
its validations to the input domain-object, apply business logic or whatever other
transformations, and return to the caller an output domain-object. The batch data writer (or
the OLTP DAL) will then persist the output domain-object.
A potential optimization can be made to reduce the number of validations executed when in
batch mode. Specifically, more optimized queries could replace some (or all) of the business
validations. For example, when in OLTP mode, a validation can be executed that asserts the
account to be processed is indeed active. When executing the service in batch mode
however, a more optimized query, where a where clause is added limiting the data selection
to only active accounts could be execute (for example select * from table 1 where
334
account_status = active). In this case, the validations registered with the shared service
would be different; this only implies that the technique for initializing the shared service should
be smarter, where the required business validations are configured upon initialization (or can
be dynamically modified).
17.2 Conclusions
By following the proposed application design guidelines, it is possible to not only share
business services across multiple execution styles, but doing so without sacrificing any of the
performance optimizations each domain provides. More over, well-designed applications
enable flexibility, where services can be reused and composed into new business functions.
To achieve this requires strong application architecture skills, as well as a deep understanding
of the nuances of each execution paradigmbatch, OLTP, real-time, and so forth.
Chapter 17. Batch application design and patterns in WebSphere XD Compute Grid
335
336
18
Chapter 18.
337
18.1.2 Profiling
Besides JVM tuning, we can achieve a lot of in tuning the Java batch application itself.
Therefore, we have to analyze the Java application at run time with a profiler. A very efficient
profiler is JinsightLive for IBM System which is available for free under
http://www.alphaworks.ibm.com/tech/jinsightlive
JinsightLive allows us to create a profile trace of a running Java application under z/OS. With
the help of the visualizer, we can then analyze the trace with graphical representation of the
application.
Based on patterns like a long running loop that we can see in the graphics, we can identify hot
spots that consume too much CPU. Based on these findings, we next have to verify whether
those areas cannot be coded more efficiently.
Note: It can be useful for someone who did not write the Java code to analyze the code
because the developer might not see certain hot spots because of reasons for coding it in
that way.
For further information about how to use JinsightLive, refer to the Web site.
338
Tip: In contrast to OLTP J2EE / Java EE applications where we normally only trace one
transaction for profiling with JinsightLive, we create a trace of the whole application in
batch. Those traces can become very huge!
Because batch often consists of repetitive patterns implemented in loops, we recommend
to modify the application for tracing purposes to run just one iteration of a loop.
5.0 SR5
0.02
6.0 SR3
0.02
Because batch applications are normally long running jobs, this CPU time is negligible. It only
becomes a problem for very short running stand-alone Java batch applications. In that case, a
Java batch container like WebSphere XD Compute Grid helps because it reuses its JVMs for
the batch applications.
We mention the JIT, shared classes, Ahead of Time (AOT) compilation and JNI as areas to
look into for optimizing performance.
Important: There is one size fits all solution and different applications might benefit from
different settings.
Shared classes
Another way to improve JVM startup time is to use shared classes. The shared class cache is
intended to share classes across multiple JVMs. Because it resists across JVM restarts, it
339
340
19
Chapter 19.
Of course, some of these types of instrumentation might be irrelevant, for example if your
batch does not run against DB2. Another example is the case of batch which is not part of a
specific suite.
Note: This chapter mainly deals with raw sources of instrumentation, such as Systems
Management Facilities (SMF) records. Reporting tools, such as the RMF Post-processor,
are only briefly mentioned.
In this chapter, the following example illustrates the convention used:
74-1 denotes SMF Type 74 Subtype 1 records.
This chapter includes the following topics:
341
Area
Description
70
CPU
71
72
Workload
75
78 Subtype 3
I/O Queuing
RMF writes records on the RMF interval. So you can plot the major numbers on a graph by
time of day across the window.
342
Another layer below the Service Class level is the address space level. Job-Level SMF on
page 346 discusses jobs but the 30-2 and 30-3 records instrument address spaces in a way
which can best be described as allowing drill down further from the Type 72 level. Because
SMF 30-2 and 30-3 have WLM Workload and Service Class in you can break down a Service
Class CPU time into individual address space CPU time. In the batch context this is
particularly useful for understanding which started tasks are consuming CPU and how this
varies through the batch window.
SMF 30-2 and 30-3 also record the Report Class the address space runs in.
25
Memory (GB)
20
15
10
5
0
Midnight
3:00 AM
6:00 AM
9:00 AM
Midday
3:00 PM
6:00 PM
9:00 PM
Hour
System
DB2 BP0
DB2 BP1
DB2 BP2
Other Apps
Free
Figure 19-1 Buffer Pool Memory Sizes Changing As System Conditions Permit
However, to conclude increasing buffer pool sizes (or making any other tuning change) needs
instrumentation. For DB2 the main subsystem-level instrumentation is Statistics Trace.
Additional information can be found in the DB2 Catalog. Still more information related to the
subsystem (but not necessarily the application) comes from other SMF record types. Most
prominent among these non-DB2 SMF record types is 42-6.
343
Buffer Pools
Group Buffer Pools
EDM Pool
Relational Data System (RDS) Sorting
Logging
Locking
Virtual Storage
While Statistics Trace provides a useful set of instrumentation for general subsystem tuning it
should be supplemented with application-level instrumentation, most notably Accounting
Trace. (See 19.4.2, DB2 job-level Accounting Trace and deeper on page 348 for more
information about Accounting Trace.).
344
the address space in the interval for which at least 1 I/O was performed. More precisely, every
such data sets volume for which at least 1 I/O was performed.
The information includes:
These items make the 42-6 a very valuable SMF record for data set performance analysis.
Note: SMF 42-6 records are not created by DB2 but rather by DFSMS/MVS. So, while they
are written for DB2-owned data sets, they are also written for non-DB2 data sets.
19.2.4 Putting Statistics Trace, DB2 Catalog and SMF 42-6 together
DB2 Statistics Trace instruments a number of key areas where data set access is important
for performance, which includes:
Suppose you need to explain the I/O rate to disk for a specific buffer pool. (Statistics Trace
might lead you to the conclusion that this needs an explanation.)
You can use the DB2 Catalog to ascertain which tablespaces and indexspaces are in this
buffer pool. (You can get other information about these DB2 objects, such as partitioning
information and DB2s view of their size, from the Catalog.)
Using DB2s data set naming convention for tablespaces and indexspaces and the address
space name for the DBM1 address space for the DB2 subsystems you can select the SMF
42-6 data for just those data sets, including the I/O rate. (You can get other information as
well, such as DFSMS estimation of the effectiveness of disk cache for the data sets.)
Note: In addition to the SMF 42-6 information for the DB2 object you can use the IDCAMS
DCOLLECT information for the data sets associated with the object to obtain the
DFSMS/MVS view of the space used by the DB2 object.
345
Whether the job ended successfully, in so far as we can tell from return codes and ABEND
codes
The difference in timestamps for reading in and execution, which would enable an analyst
to discern whether there is a shortage of initiators.
This information enables several different kinds of analysis. Among them are:
Drawing a Gantt chart of an application based on job names and run times
Toplisting jobs, such as the most CPU-burning jobs or the longest-running jobs, or the
jobs that do the most tape processing (whether by mounts or tape EXCPs).
also obtain this information for when a disk data set is CLOSEd, again from SMF 42-6
records. 42-6 information is a very useful addition to that in Types 14, 15, 62, and 64.
347
Job W Writes
Job R1 Reads
Job R2 Reads
Time
This example shows some of the power of the LOADS technique in designing speed ups.
Accounting Trace has information about Data Sharing aspects of response time, such as
waiting for Global Locks.
It is possible for a single DB2 invocation to cause multiple SMF 101 records to be produced,
whether through parallelism or because there are more DB2 packages invoked than can fit in
a single record.
For CPU- and sysplex-query parallelism DB2 can write detailed records, one for each parallel
task, or roll up all the parallel tasks into a parent record and a rollup (child) record. For batch
tuning it is sometimes useful to have the individual one-per-task records: When the tasks
arent balanced each will record different run times, so you can spot the imbalance and
reduce it.
349
STEP010 02:35 to 04:15, Elapsed: 100 mins, CPU: 55 mins, EXCPs 1.8M
Plan PL1: 02:36 to 04:15, Elapsed: 99 mins, CPU 55 mins
Package
Name
CPU
Time
GHJG0101
38
HHJG0212
11
Sync
Database
I/O
31
Async
Read
I/O
10
Async
Write
I/O
Lock /
Latch
Wait
Figure 19-3 Sample DB2 job time breakdown report using DB2 Accounting Trace
350
Most rows in PLAN_TABLE refer to specific indexes and tables. Using the DB2 Catalog you
can relate these to specific indexspaces and tablespaces. With this information you can use
SMF 42-6 to look at the I/O performance for the relevant DB2-owned data sets.
Note: SMF 42-6 records will have the DB2 subsystems DBM1 address space name in, not
that of the batch job.
19.4.3 DFSORT
DFSORT has its own SMF record: Type 16.
An installation can specify for a SMF 16 record to be produced whenever a DFSORT
operation completes (whether directly-invoked or invoked by ICETOOL). There are two kinds
of SMF 16 records:
When SMF=SHORT is in effect or if SMF=FULL is in effect but the DFSORT operation
terminated abnormally.
When SMF=FULL is in effect.
SMF=FULL is recommended for serious DFSORT tuning work as it contains additional
information, such as a section for each SORTIN, SORTOUT and OUTFIL data set. While
some of this information duplicates that available with data set SMF records (as outlined in
19.4.1, Data Set OPENs And CLOSEs on page 346) some of it is additional.
An example of additional information is the number of records read from or written to the data
set. Record counts are important when tuning DFSORT activities as one of the major themes
is to reduce the number of records passing through each successive processing stage.
Other examples include the exit-processing specifications, major types of DFSORT control
statement (such as SUM), and whether EQUALS is specified. (EQUALS requires DFSORT to
preserve the order of records which have the same sort key, which can degrade
performance.)
Because the Type 16 record has the step number as well as job name it can be directly
related to a specific job step. To re-create the sequence within the step, because there can be
several DFSORT operations, sort the records by time stamp. JZOS and ICETOOL, as two
examples, can be used to drive multiple DFSORT operations within a single step.
For sorting operations the number of intermediate merges would ideally be only 1. z/OS
Release 10s DFSORT level introduces in SMF 16 the number of intermediate merges (in field
ICEINMRG). If this number is greater than 1 the sort might benefit from an increased virtual
storage specification. Also in Release 10 a new message became available: If additional
intermediate merges are required the job log will also contain the message:
ICE247I INTERMEDIATE MERGE ENTERED - PERFORMANCE MAY BE DEGRADED
19.4.4 BatchPipes/MVS
BatchPipes/MVS has its own SMF record, Type 91, with a number of subtypes:
351
You can use the 11 and 13 records to perform pipe balancing (minimizing reader-empty and
writer-full wait times) as well as understanding the characteristics of a pipe. The whole
pipeline topology can be reconstructed from Type 91.
Because the step number is recorded, as well as the job name, you can readily identify which
step the pipe was OPENed in and whether for read or for write. Further time stamp analysis to
determine the order in which pipes are OPENed and how far into the step they are OPENed
and CLOSEd is useful.
352
Application Definitions
The Application Description (AD) ISPF panel provides long term information about
applications, as well as allowing you to change the applications definitions. You can obtain
information about such things as:
Operations
Dependencies
Special resource requirements
Run cycles
Error tracking rules
Operator instructions.
353
IBM supplies two sample exit routines for this exit point. One of them, IEEACTRT, writes a
summary of the step in the jobs log. The IEEACTRT sample shipped with z/OS Release 7
includes support for zAAP and zIIP time.
In the absence of SMF analysis, perhaps because it hasnt been processed yet, the output
from this exit can be a useful piece of instrumentation.
SYSLOG is not designed for batch tuning but sometimes the additional information it can
provide helps to explain the performance of a batch job or the environment it runs in.
354
Part 5
Part
Reduce batch
complexity
Batch programs, jobnets, and batch windows can be very complex from an application coding
point of view. Applications programs sometimes take on too much of a burden in tasks such
as database and file I/O, conversion of data and file transfer. Many times, JCL is used for
application logic. All of this can make a batch process difficult to maintain and less agile.
There is a lot of middleware on the market that helps abstracting non-business logic out of the
application code and at the same time makes the application programs easier to maintain
using sophisticated tools.
In this part of the book, we discuss a few areas in which middleware can help to improve the
maintainability and agility of the batch process. This part includes the following chapters:
In Chapter 20, Reduce batch complexity using a Business Rules Management System
on page 357, we discuss how IBM JRules can help to maintain business rules in a very
agile manner.
In Chapter 21, Reduce batch complexity using middleware for transformation logic on
page 371, we discuss how IBM WebSphere Transformation Extender can help in
developing and maintaining transformation logic using a light runtime environment on
z/OS and sophisticated development tools.
In Chapter 22, Reduce batch complexity by eliminating custom file transfer logic on
page 397, we discuss IBM WebSphere File Transfer Edition (FTE), which you can use to
manage (batch) file transfers.
In Chapter 23, Reduce complexity by exploiting DFSORT / ICETOOL on page 405, we
discuss two z/OS technologies that can help to manage complexity in sort operations
within your batch jobs.
355
Note: Complexity with regards to data access can also be reduced by implementing a
smart Information Management architecture. Refer to Chapter 12, Create agile batch by
optimizing the Information Management architecture on page 189 for an overview of the
IBM Information Management solutions available for this purpose.
356
20
Chapter 20.
357
COBOL, Java, and so forth), business rules are not recognizable as such anymore in the
programs being generated and they just get buried between the rest of the code.
In traditional applications reuse of business rules is limited or practically non-existing.
Many business rules are imbedded in COBOL and PL/I programs and cannot be accessed
individually. When another business unit needs a similar or the same business rule as the
one that is already imbedded in an existing program, typically the developer takes a copy
of that piece of code, modifies it and re-implements it inside another COBOL or PL/I
program. In addition, there are usually two code bases: one for OLTP processing and one
for batch processing. Again, here is an example in which sharing the business rules
between OLTP and batch processing would be extremely beneficial but unfortunately in
the past has not occurred. Here is where a combination of an SOA approach and use of a
BRMS (business rules deployed as decision services) can help.
The Waterfall application development process has its risks, that is the business rule
developer (who usually is a programmer with COBOL or Java skills) has to understand
and interpret the business rules designed by the business analyst and then include it in
hard code. This approach is risky and can lead to an inflexible implementation of the
business rules designed by the Business Analyst.
Time to market is not what it should be. A simple change in a straightforward business rule
could take weeks or even months, depending on the complexity of the existing code. This
hurts the companys performance and frustrates the Line-Of-Business Managers.
Figure 20-1 illustrates the context of both business rule and regular software life cycle
management.
F unctional
enhancements/
platform upgrade
Functional
requirements
Application
development
In-production
business rule application
Synchroniz ati on
Business rule
management
Business
polic ies
Business poli cy
And rules
changes
Business policy
And rules
changes
358
Busines s policy
And rules
c hanges
To address these issues, corporations have looked to modernize their business applications
on System z. These applications modernization projects generally include addressing the
following goals:
Increase innovation and productivity, by introducing new tools and technologies
Increase business agility, by introducing a new application architecture, many times based
on SOA concepts, but also better application life cycle management tooling
Support growth initiatives
Access and reuse the business value that resides in existing systems, primarily by using
SOA concepts and rich development tooling
Reduce application maintenance costs, by reducing redundancy, improving software
quality and more productive application life cycle management tooling
These projects focus on how the core System z applications can address the need to respond
rapidly to emerging opportunities. In order to manage agile solution delivery, it is essential to
be able to understand line of business applications in terms of the business rules they
implement and the effect of rule changes on key business processes.
With the advent of a Business Rule Management System (BRMS) for enterprise application
languages such as COBOL on System z, agile responsive solution adaptation has finally
become a reality. Through the identification and externalization of application business rules,
conditions can be defined that will result in new application behaviors offering a quick and
productive route to greatly enhance the business responsiveness of CICS, IMS and batch
operations by putting the business owner in control of application behavior change and at the
same time retaining good governance and change management.
This chapter provides insight into how to reduce batch complexity using a BRMS system. It
includes the following topics:
Chapter 20. Reduce batch complexity using a Business Rules Management System
359
360
Analyze
Deploy
Validate
Author
Rule Manager
Assess
Impact
Verify
The advantages gained to quickly identify which rules need to be changed due to a change in
business policy, and then test the proposed changes prior to going into production, provides
the agility and competitive advantage to organizations.
The ILOG BRMS provides ways to:
Chapter 20. Reduce batch complexity using a Business Rules Management System
361
Technical Environment
Business Environments
Decision Validation
Services
Rule Team
Server
Rule Studio
(Eclipse)
Rule Solutions
for Office
Rule Repository
Production Environment
Rule Execution
Server for Java
Transparent
Decision Services
Rule Execution
Server for .NET
This functionality is included in a suite of tools within the ILOG BRMS, as shown in
Figure 20-3:
Rule Studio is the business rule application development tool for developers, modelers and
architects. Rule Studio is fully integrated with Eclipse, the leading framework for
application development tools. It also works with IBM Rational Application Developer,
Rational System Architect, and WebSphere Integration Developer. All rule artifacts are
managed by Rule Studio as individual plain-text or XML files compatible with Eclipse's
standard file management, and can be stored and versioned in any SCM system. And,
because Eclipse plug-ins are available for the most widely used SCM systems, developers
can do integrated source management, rule project development and Java development
for most projects using the same IDE.
Rule Team Server (RTS) is the business rule management tool for policy managers. It
combines a deep, scalable, high-performance rule repository with a thin-client rule
management application designed specifically for the needs of policy managers engaged
in rule authoring, management and maintenance. See Figure 20-4 on page 363 for an
impression of the tool.
362
The RTS repository addresses the specific needs of rule-based policy management with:
Complete multi-project rule management
Projects in RTS contain the project business object model, vocabulary and all the rule
artifacts, and are stored without reference to a specific execution model. The RTS
repository is designed to be an enterprise repository, storing in a single place multiple
independent or dependent rule projects and their histories.
Multi user access
The repository supports automatic rule-level locking, as well as user-managed
persistent locks.
Scalability
The RTS repository scales to dozens of users working on the same or different
projects, and hundreds of thousands of individual rule artifacts.
Full version and history of rule artifacts
The RTS repository serves as a fully versioned content management system for the
Business Object Model (BOM), vocabulary, and rule artifacts. As artifacts evolve with
an application, the repository maintains all prior versions of each artifact in an
accessible and browsable format, providing a complete audit trail of policy
implementations.
Baseline management
The repository maintains baselines of rule project states, allowing any previous
project state for which a baseline has been created to be recalled for examination.
Current project state can be rolled back to any previous baseline.
Chapter 20. Reduce batch complexity using a Business Rules Management System
363
364
Design
IT Development
Ru le Studio
Maintain
Line Of Business
Rule T eam
Server
Decisio n Validation
Services
Share
Cu st om
Web
Application s
Rul e R eposito ry
Deploy
IT Operations
Transparent
R ule Execut ion
Decisio n Services Server
Chapter 20. Reduce batch complexity using a Business Rules Management System
365
User T ools
Rules are
Defined,
Ana lyzed
and
Mainta ined
Rules are
Stored a nd
Shared
Rules are
deployed,
executed and
monitored in
J2EE services
System z z/OS and zLinux
Figure 20-6 ILOG JRules on System z using the Rules Execution Server
Example
A large bank has embarked into a SOA strategy on System z. The key objective of their SOA
strategy is agility and reuse. They are looking to define different types of services including
decision services. Decision services perform decisioning that is unrelated to data
transformation. Typically, they are passed data and return a data item that reflects a decision
or an action based on the execution of business rules. Examples include services that accept
credit reports and return creditworthiness scores. These services are central to the workings
of the enterprise and they often represent the core functions of a business process.
366
The bank has identified and prioritized the business decisions that they want to begin to
manage centrally. ILOGs JRules Business Rule Management System is uniquely suited for
the formulation and implementation of transparent decision services:
ILOG JRules empowers business teams to manage the business rules that automate their
policies.
ILOG JRules helps development teams to deploy these business rules as fully formed
decision services and weave them into SOA platforms.
ILOG JRules brings several business-side roles together to collaborate on transparent
decision services.
Their business analysts and business policy managers can validate and simulate rules prior
to deployment. And once the rules are fully tested, the administrator can hot-deploy them in
minutes.
The bank begins to deploy the higher priority decision services for execution. For example,
the decision service Determine Credit Worthiness was deployed and this service can now
be used by a CICS application and batch applications. By authoring the rules once and
storing them centrally in the ILOG rule repository, it eliminates the need for developers to
maintain two different code sets for online and batch processing. The business can view the
rules within the decision service and the IT department can monitor the decision service
usage.
Rules are
De fined,
Analyzed and
Maintained
User Tools
Rules are
Stored a nd
Shared
Ru le Reposit ory
Rules
for COBOL
Rules are
generated as
COBOL source
for execution in
IMS, CICS,
batch
Chapter 20. Reduce batch complexity using a Business Rules Management System
367
Example
A large manufacturing company runs its mission critical COBOL billing system (a rule
intensive application) on z/OS. This billing system is the center of a lot of other business
applications and performance is critical. The Finance Department has expressed a desire to
accelerate their release schedule substantially, in order to accommodate new products and
services that the business wants to offer. The IT department would like to streamline their
development cycle and wants to retain the COBOL execution on z/OS. In addition, the IT
department knows that the new product and service rules will need to be shared with
applications for order fulfillment. The manufacturing company will begin using ILOG JRules
with ILOG Rules for COBOL for management of their rules used in their COBOL applications.
The Business Analysts in the Finance Department work with the IT Developers to identify the
scope of data fields that will be impacted by these new rules. The IT department then
identifies the COBOL copybooks using these fields. These COBOL copybooks are then used
to create the Business Object Model (BOM) within ILOG JRules. Each COBOL field is given a
business name to ease the authoring of the rules as well as the review and reporting of the
rules.
The Business Analysts author the new product rules within Rule Team Server (the Web
management tool). Each set of business rules is based on a business decision required for a
business application. You can set up a rule project for each business decision that will in turn
equate to one subprogram generated by ILOG Rules for COBOL.
A rule flow is also designed for the ILOG Rules for COBOL project. This rule flow will be to
identify the order and dependencies in which the rule sets are needed for generation and
execution in the COBOL subprogram.
368
Because these are new rules for a new product, the COBOL developer has identified where in
the application the ILOG Rules for COBOL generated program should be called and updates
the program accordingly. Then, when notified by the business analyst that the rules are ready
for testing, the COBOL developer uses Rule Studio to generate the COBOL program from the
rules within the ILOG JRules repository. This program is compiled and linked and ready for
testing.
If these rules need to be changed, the Business Analyst would go back into RTS to make the
necessary changes. RTS handles all the versioning and traceability of the rules.
Business rule mining is the process of extracting essential intellectual business content
(business rules) from packaged or existing software, recasting them in natural language, and
storing them in a source rule repository for further analysis or forward engineering. The goal
is to capture these existing business rules in a way that the business can validate, control and
change them over time.
The target of your business rule mining effort will be directed by the objectives of the project
as well as the scope of the project phases. For example, if the first phase of a project is to
implement a system based on jurisdiction (that is, state or region), then the rule mining effort
would focus on identifying those rules that pertain to that jurisdiction. Other examples for rule
mining efforts are by sub-process, output report/screen or fields, specific business decision.
The output of the business rule mining project is the candidate business rules hopefully linked
or connected together to better understand the flow as these candidate rules were found in
the target program or programs as well as the related COBOL copybooks or file layouts.
The candidate rules and COBOL copybooks are used as sources for the modernization
project. With WebSphere ILOG Rules for COBOL, the modernization effort is done in three
steps to improve COBOL application flexibility and to rapidly create new applications with
WebSphere ILOG JRules and WebSphere ILOG Rules for COBOL:
1. Import the COBOL copybook
2. Author the business rules by using the candidate rule report and redesign the coded rules
within one of the rule artifacts in WebSphere ILOG JRules
3. Generate the COBOL program for native COBOL execution.
Summary
By using the BRMS with your existing COBOL applications, your organization can realize the
following bottom-line benefits:
Preserved business value of existing assets and rules managed as intellectual assets in
the BRMS.
Minimized business risk by ensuring consistency of the business rules throughout
business applications.
Improved competitive position through enhanced business service and reuse with the
BRMS technology.
Enhanced cost reduction and ROI with reduced total cost of ownership.
Chapter 20. Reduce batch complexity using a Business Rules Management System
369
370
21
Chapter 21.
371
372
Chapter 21. Reduce batch complexity using middleware for transformation logic
373
374
Simplified complexity
No coding
Consistent approach to multiple types of integration
Reusable objects
Adaptability
0000000001Production
0000000001Production
0000000002Development
0000000001Paul
0000000002Hannah
0000000003Mia
Smith
Smith
Brown
Chapter 21. Reduce batch complexity using middleware for transformation logic
375
The transformation rules for this process are saved in a mapping file. To develop this file, we
use the Eclipse-based WebSphere Transformation Extender Design Studio V8.2 tool.
Figure 21-1 show the following relevant steps for our sample with WebSphere Transformation
Extender:
1.
2.
3.
4.
5.
z/OS,
AIX
Linux,
Windows
Input
files
WTX
Design
Studio
Excetutab le
Map File
e.g.
MQ Ad apter
WTX
engine
Output Cards
Input Car ds
Tra nsform a tion
R ules
Examples:
- Hierarchical Data
- Binary Data
- Packed Data
- T abular Data
- Relational Data
- Nested Structures
- Mixed-T ype Data
and on and on
Type Tree
Input
Mapping
from Input
files to
output files
Output
files
Type Tree
Output
The WebSphere Transformation Extender Design Studio is used at design time to model,
develop, and test the data transformation and application integration maps and systems. You
can integrate both content transformation and content-based routing through the WebSphere
Transformation Extender Design Studio graphical interface. The WebSphere Transformation
Extender Design Studio version 8.2 is an Eclipse-based design environment that contains
several components. For this example we use two of them:
Map Editor
376
Refer to 4.2, XML support in COBOL and PL/I on page 36 for more details regarding XML support in COBOL and
PL/I.
Chapter 21. Reduce batch complexity using middleware for transformation logic
377
<Employee>
<EmpNo>3</EmpNo>
<FirstName>Mia</FirstName>
<LastName>Brown</LastName>
</Employee>
</Department>
</Company>
A corresponding XML schema definition is stored in file c:\Redbook\WTX\input.xsd (see
Example 21-4).
Example 21-4 XML Schema Definition input.xsd
01 Company.
05 Name
PIC X(20).
05 Department.
10 DepNo
PIC 9(10).
10 Description PIC X(15).
10 Employee.
378
15 EmpNo
15 FirstName
15 LastName
PIC 9(10).
PIC X(10).
PIC X(10).
Chapter 21. Reduce batch complexity using middleware for transformation logic
379
3. Next, import the XML schema definition file. Right-click Schema Files, and choose
Import File System.
4. In the window that opens, select the input.xsd file. Then, click Browse to select Redbook
project, and click Finish. This method is similar to importing XML input data.
380
2. In the window that opens, choose the input.xsd file, and Next twice. In the window that
opens, select the Redbook project (see Figure 21-5). Click Next, and then click Finish.
Chapter 21. Reduce batch complexity using middleware for transformation logic
381
3. If the input file does not open automatically, open the input.mtt file, which is located in the
Type Trees folder. Using Tree Analyze Logic Only, the input definition type tree is
checked by Design Studio. The Analysis Results tab, as shown in Figure 21-6, shows the
output of analysis process. On this tab, you can verify whether the Type Tree definition has
any warnings or errors.
4. Close the input.mtt file, and click Yes to save the changes.
Note: With the V8.2 release, maps can now use schemas directly as definitions in input or
output cards. It means that you are not required to use the XML Schema Importer to create
type trees, as in previous versions of WebSphere Transformation Extender. To use the
schema directly in a transformation map, select an .XSD file instead of an .MTT file from
within the Map Editor.
382
5. After clicking Yes, enter OutputFile as the name for this new Type Tree. Next, change the
type of OutputFile by right-clicking OutputFile and selecting Properties. In the Extender
Properties tab, change the Property Class from Category to Group (see Figure 21-8).
6. Click Yes to confirm that change. Then, right-click OutputFile, and choose Open.
Drag-and-drop Company in the first column of the Component tab, as shown in
Figure 21-9.
7. You now need to set the range of the component to specify how many occurrences of the
element are expected. To set the range of the Company Record component, right-click the
component, and select Set Range.
8. In this example, specify an indefinite number of occurrences. So, in the Max field, enter s,
which stands for Some. Then, click OK. The name changes to Company Record(s), which
tells WebSphere Transformation Extender to produce multiple different output rows (not
only one single row).
Chapter 21. Reduce batch complexity using middleware for transformation logic
383
9. Next, you need to tell WebSphere Transformation Extender to write every row in a
separate line. Right-click Record - Company, select Properties, and change the
Terminator field from NONE to Literal. You also need to change the Value field to <LF> (for
LineFeed), as shown in Figure 21-11. Click the ... button, select LF, click Insert, and then
OK.
10.Using Tree Analyze Logic Only, the output definition Type Tree is checked by
WebSphere Transformation Extender Design Studio. The Analysis Results tab, shown in
Figure 21-6 on page 382, again shows output of the analysis process. On this tab, you can
verify whether the Type Tree definition has any warnings or errors.
11.Close the output.mtt file, and save the changes.
384
2. In the window that opens, select the Redbook project, set File Name to XML2Cobol, and
click Finish.
3. Then, in the Outline tab, right-click XML2Cobol, and select New (see Figure 21-13). Enter
XML2CobolMap as the name for this map.
2. In the window that opens, set the CardName Property to InputXML and choose input.mtt
from the Redbook project as the Type Tree property (see Figure 21-15).
Chapter 21. Reduce batch complexity using middleware for transformation logic
385
3. For property Type, select DOC from the XML schema definition (see Figure 21-16).
4. Choose the input.xml file for the FilePath Property (see Figure 21-17), and click OK.
386
3. For the property Type, select OutputFile from CopyBook (see Figure 21-19).
Chapter 21. Reduce batch complexity using middleware for transformation logic
387
4. Finally, set output.txt for the FilePath property (see Figure 21-20), and click OK.
Figure 21-21 shows the content of XML2CobolMap with the Input Card on the left side and
the Output Card on the right side.
388
To solve this, create a functional map, a kind of sub-routine, that is called for each element (in
this case, for each record to be created). Click Company Record(s) on the right side and
then enter =EachCompany() in the Rule panel, as shown in Figure 21-22.
Next, define a parameter for the WebSphere Transformation Extender function using
drag-and-drop fields from the Input Card as function parameter. All different parameters must
be separated by a comma sign. To define all needed parameters:
1. Drag the left side field Name Comp companyInfo Type and drop it as the first parameter
of function EachCompany.
2. Append the comma sign followed by a blank (, ) after the first parameter.
3. Drag the left side group Department Comp companyInfo Type(1:s) and drop it as the
second parameter after the comma sign (,).
4. Append the comma sign followed by a blank (, ) after the second parameter.
5. Drag the left side group Employee Comp departmentInfo (1:s) and drop it as the third
parameter after the comma sign (,).
6. Press Enter to complete the function definition. Without pressing Enter, your function
definition changes are not activated.
Example 21-6 shows the result of the function.
Example 21-6 Content of user-defined WebSphere Transformation Extender function EachCompany
Chapter 21. Reduce batch complexity using middleware for transformation logic
389
Next, create the function EachCompany by right-clicking Company Record(s) on the right
and choosing Functional Map Wizard (see Figure 21-24).
390
In the window that opens, click Create, and then Close. Now the function EachCompany is
shown in the map window. Every parameter of EachCompany results in one corresponding
Input Card. These cards can be sorted by dragging and dropping the cards within the current
window.
Now, you can define the mapping by dragging fields from Input Cards and dropping them on
the right side, as follows:
1. Drag field In1 from input card In1 to output card field Name Field.
2. Drag field DepNo Comp departmentInfo from input card In2 to output card field DepNo
Field.
3. Drag field Description Comp departmentInfo from input card In2 to output card field
Description Field.
4. Drag field EmpNo Comp employeeInfo from input card In3 to output card field EmpNo
Field.
5. Drag field FirstName Comp employeeInfo from input card In3 to output card field
FirstName Field.
6. Drag field LastName Comp employeeInfo from input card In3 to output card field
LastName Field.
Now save the map. Figure 21-25 shows the content of map XML2CobolMap.
Chapter 21. Reduce batch complexity using middleware for transformation logic
391
To compile the map, choose Map Build to check and build the map to an internal format.
Note: After changing mapping rules or input or output cards, you must call Map Build to
recompile the map.
We defined our output card to save the transformed data in file output.txt. This file is stored
in the Misc folder (in the Extender Navigator window). Example 21-7 shows the content of our
output file. You can view the results of the map execution from within Design Studio. Click
Map View Run Results for a prompt for the inputs and outputs that you want to view.
Select or clear the boxes for the inputs and outputs that you want to review, and then click OK.
Example 21-7 Content of transformation output
0000000001Production
0000000001Production
0000000002Development
0000000001Paul
0000000002Hannah
0000000003Mia
Smith
Smith
Brown
This example shows how to transform data from XML format to COBOL copybook format
without writing any specific code. All necessary activities can be done by drag-and-drop using
WebSphere Transformation Extender Design Studio.
In the next section, 21.3.2, Transferring files to z/OS on page 393, we describe how to
transfer the mapping file and run the transformation process on the z/OS.
392
.mmc
.mvs
.hpi
.hp
.aix
.lnx
.sun
By using the build command for z/OS map, the compiled map is placed in the Map Executable
folder, and a JCL template is generated and placed in the JCL Files folder in WebSphere
Transformation Extender Design Studio. This JCL template must be modified to use the map
and files that are used.
WAGNERA.WTX.MAPS
Track
10
10
10
FB
80
16000
PDS
393
data set or member of a PDS. The record format has to Fixed Block (FB) and have the Logical
Record Length LRECL) must be 80.
Furthermore, you have to transfer the input XML data input.xml file and XML schema
definition file input.xsd. These files must be transferred in binary mode to the UNIX System
Services file system. In our example, we transferred these files to the UNIX System Services
directory /u/wagnera.
When transferring files, keep in mind the following aspects:
Specify BINARY, not performing ASCII to EBCDIC translation and not eliminating carriage
returns and line feeds). If you are using an FTP tool, double-check the options, because
most tools will not have any pre-settings for files with file type .mvs, and the file transfer
outcome might be a random result.
The file transfer must not use the CRLF option, or map corruption will result. Instead, use
either of the following options:
Use the IBM Personal Communication Facility.
Use standard FTP, which is available from a Windows command line.
Example 21-8 shows a proper FTP file transfer from the Windows command line.
Example 21-8 FTP commands to load the map file
ftp <your-host>
UserID
Password
binary
cd /u/wagnera
put C:\<WTX_workspace>\Redbook\input.xml input.xml
put C:\<WTX_workspace>\Redbook\input.xsd input.xsd
cd WAGNERA.WTX.MAPS
quote site LRECL=80 RECFM=FB
put C:\<WTX_workspace>\Redbook\XML2CobolMap.mvs XML2COB
quit
The quote site command: By using the FTP quote site command, you can set the file
type and allocation on the host.
394
The first step in the job deletes the output data set (in our example called
WAGNERA.OUT.XML2COBO), as shown in Example 21-10.
Example 21-10 Deleting the output data set
//S0
EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN
DD *
DELETE WAGNERA.OUT.XML2COBO
The next step starts a batch transformation process by running the program DTXCMDSV.
Because we are transforming XML input data, we also need the XML Toolkit in the STEPLIB,
as shown in Example 21-11.
Example 21-11 Starting the batch transformation process
//DTX
EXEC PGM=DTXCMDSV,REGION=0M,
// PARM='XML2COB /I1M ''/DD:MAPXSD'''
//STEPLIB DD DISP=SHR,DSN=BB26159.SDTXLOAD
//
DD DISP=SHR,DSN=IXM.SIXMLOD1
The program DTXCMDSV is started with two parameters:
DD name for the executable map file
XML2COB
/I1M /DD:MAPXSD Because our input Type Tree was created in WebSphere
Transformation Extender Design Studio by importing a XML schema
definition, we need this schema definition file when running our batch
transformation process. With this parameter we define the DD name
for our XML schema definition file.
Example 21-12 shows a DD name pointing to the WebSphere Transformation Extender map.
This is the PDS that we pre-allocated earlier and that we used to store the map. As mentioned
previously, the first parameter for program DTXCMDSV defines the DD name XML2COB for
the executable map file.
Example 21-12 Path to executable map file
//XML2COB
DD
DISP=SHR,DSN=WAGNERA.WTX.MAPS(XML2COB)
The next DD statements point to the necessary files for our batch transformation program, as
shown in Example 21-13.
INPUT
UNIX System Services file with input XML data. This file must be
copied binary to the UNIX System Services file system and must
contain the option encoding with the correct value.
MAPXSD
OUTPUT
For our COBOL batch program, we write the output data to an MVS
data set with copybook-style records.
Chapter 21. Reduce batch complexity using middleware for transformation logic
395
//MAPXSD
DD PATH='/u/wagnera/input.xsd'
//*
//* Define the output dataset
//OUTPUT
DD DSN=WAGNERA.OUT.XML2COBO,
//
DCB=(RECFM=VB,LRECL=80),
//
UNIT=SYSDA,
//
SPACE=(TRK,(1,1),RLSE),
//
DISP=(NEW,CATLG,DELETE)
Important: The output data set must be a variable record length file, because our output
Type Tree was configured to produce a line feed after every employee record. When using
FB format, no line feed is produced.
The number of temporary files to create depends on the characteristics of the map itself. It is
not always obvious to determine the exact number and the sizes to allocate. For complex
maps or for big files, some tests for adjustment might be necessary. Allocating the temporary
files is key for performance. Example 21-14 shows what we used.
Example 21-14 Temporary data sets
//SYSTMP01 DD DSN=&&TEMP01,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP02 DD DSN=&&TEMP02,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP03 DD DSN=&&TEMP03,
//
DISP=(NEW,DELETE,DELETE),
........
Pre-allocating work files: Pre-allocating work files is not mandatory for small amounts of
data, but we highly recommend it for performance reasons.
Use the following rules to set the number of temporary files:
One temporary data set is allocated in all cases, which is a general use work file.
One temporary data set is also allocated for each input.
Depending on how the map is constructed, the map might create a temporary data set for
each output to serve as its work file.
In addition, one temporary data set is always allocated for each input or output defined
with an RECFM that is not fixed unblocked (F) or fixed blocked standard (FBS).
Because you can develop a map with no inputs, and output work files cannot be used in
some situations, the minimum number of possible temporary files for a map execution is 1.
The maximum possible number is 1 + (2 x number of inputs) + (2 x number of outputs).
396
22
Chapter 22.
397
2.
(v6 or v7)
FTE
Agent
1.
(v6 or v7)
Queue
Manager
Operations tooling
communicates with
agent by sending
messages to a
(Command)
queue that the
Queue
agent is monitoring Manager
FTE
Agent
Queue
Manager
(v7)
(Coordination)
Queue
Manager
3.
Key
Store + forward
Subscription
Operations
Monitoring
Record Keeping
398
Chapter 22. Reduce batch complexity by eliminating custom file transfer logic
399
The WebSphere MQ FTE user interface on a Windows or Linux workstation then shows a
formatted representation on the transfer log view, as shown in Figure 22-2.
400
Figure 22-3 show how this might look on the FTE user interface.
Because messages are well formed, we can also write custom applications to read and
process transfer log messages, for example for audit purposes. Compared to normal FTP, this
kind of logging and auditing is much more effective.
For more information about WebSphere MQ FTE, see IBM WebSphere MQ File Transfer
Edition Solution Overview, REDP-4532.
In the context of batch, it is also import to know that WebSphere MQ FTE supports z/OS
UNIX System Services files as well as z/OS data sets. However, for a real batch integration,
you have to trigger the transfer with a job instead of with the operational tooling. Therefore,
you have the following options:
Using a standard Java job that submits the file transfer command to WebSphere MQ FTE
Using an Ant job
We discuss these options in the remainder of this chapter.
//STRAUERA JOB
/*JOBPARM SYSAFF=SC49
//JAVAJVM EXEC PGM=JVMLDM50,REGION=0M,PARM='+T'
//STEPLIB DD DSN=SYS1.SIEALNKE,DISP=SHR
//
DD DSN=MQ700.V090210.SCSQAUTH,DISP=SHR
//
DD DSN=MQ700.V090210.SCSQANLE,DISP=SHR
Chapter 22. Reduce batch complexity by eliminating custom file transfer logic
401
//
DD DSN=MQ700.V090210.SCSQLOAD,DISP=SHR
//SYSPRINT DD SYSOUT=*
< System stdout
//SYSOUT
DD SYSOUT=*
< System stderr
//STDOUT
DD SYSOUT=*
< Java System.out
//STDERR
DD SYSOUT=*
< Java System.err
//CEEDUMP DD SYSOUT=*
//ABNLIGNR DD DUMMY
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//STDENV
DD *
# This is a shell script that configures
# any environment variables for the Java JVM.
# Variables must be exported to be seen by the launcher.
# Use PARM='+T' and set -x to debug environment script problems
set x
. /etc/profile
#
# Java configuration (including MQ Java interface)
export JAVA_HOME=/usr/lpp/java/J5.0
export PATH=/bin:"${JAVA_HOME}"/bin
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin
LIBPATH="$LIBPATH":"${JAVA_HOME}"/bin/classic
LIBPATH="${LIBPATH}":/pp/mqmv7/V090210/java/lib/
export LIBPATH
#
# FTE configuration
export FTE_PROD=/usr/lpp/mqmfte/V7R0M1/mqhg
export FTE_CONFIG=/var/mqmfte
export _BPXK_AUTOCVT=ON
#
# Select function to be executed (script names without fte prefix)
#
. ${FTE_PROD}/bin/fteBatch CreateTransfer
#
# Set JZOS parameters to FTE values
export IBM_JAVA_OPTIONS="${FTE_JAVA_OPTIONS}"
export JZOS_MAIN_ARGS="${FTE_MAIN_ARGS}"
//MAINARGS DD *
-da CHICAGO.AGENT2 -dm MQH2 -sa CHICAGO.AGENT -sm MQH1 -t text -w
-ds "//'STRAUER.SPUFI.OUT'" -de overwrite
"//'STRAUER.SPUFI.OUT2'"
//
This sample calls the JZOS batch launcher (see 7.2, Running Java with JZOS on page 79
for more details) and invokes a WebSphere MQ FTE command. The WebSphere MQ FTE
command is passed by the MAINARGS DD statement and transfers a single data set from
agent CHICAGO.AGENT to agent CHICAGO.AGENT2. The -w parameter is included so that
the step waits for the transfer command to complete. The step return code contains the return
code from the invoked function.
You need to adjust the following parameters in the JCL:
STEPLIB to include the JZOS and MQ load modules
JAVA_HOME to point to the Java home directory in UNIX System Services
LIBPATH to include the MQ Java libraries
402
FTE _PROD to point to the FTE production directory in UNIX System Services
FTE_CONFIG to point the WebSphere MQ FTE config directory under UNIX System
Services
After submitting the job, you can read the file transfer results in the job output.
Note: Because the command is submitted using a Java job, it requires a JVM startup. See
18.2, Stand-alone Java batch on page 339 for performance aspects of JVM startup.
<?xml version="1.0"?>
<project name="Project1" default="main" basedir="/u/strauer/ant"
xmlns:fte="antlib:com.ibm.wmqfte.ant.taskdefs">
<target name="init">
<property name="srcfile" value="file1.txt"/>
<property name="dstfile" value="file1_new.txt"/>
<property name="Name" value="Demo System"/>
</target>
<target name="step1" depends="init">
<echo>Starting build of ${Name}</echo>
</target>
<target name="step2" depends="step1">
<fte:filecopy src="CHICAGO.AGENT@MQH1" dst="CHICAGO.AGENT2@MQH2"
rcproperty="copy.result">
<fte:filespec srcfilespec="${srcfile}" dstfile="${dstfile}"/>
</fte:filecopy>
</target>
<target name="step3" depends="step2">
<echo>Finished build of ${Name}</echo>
</target>
<target name="main" description="runs this script">
<antcall target="step3"/>
</target>
</project>
Chapter 22. Reduce batch complexity by eliminating custom file transfer logic
403
//STRAUERB JOB
/*JOBPARM SYSAFF=SC49
//STEP1 EXEC PGM=BPXBATCH,REGION=0M,
// PARM='SH fteAnt -f /u/strauer/ant/antTest.xml'
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//*
This job calls the Ant script in a batch job.
Note: Using Ant and BPXBATCH also requires a JVM startup. See 18.2, Stand-alone
Java batch on page 339 for performance aspects of JVM startup.
22.4 Summary
WebSphere MQ FTE allows you to easily perform a file transfer that is completely managed.
For example, if a system in fails, WebSphere MQ FTE makes sure that the transfer is
completed later. Thus, you can reduce batch complexity by eliminating custom written file
transfer management logic. In addition, you can integrate WebSphere MQ FTE in batch using
a Java job or Ant.
404
23
Chapter 23.
Note: In this chapter the term OUTFIL means the OUTFIL statement that is used with the
DFSORT program. The term DFSORT OUTFIL is a more formal, equivalent term.
This chapter includes the following topics:
405
Sequential data sets, whether on disk or tape (including a member of a PDS or PDSE)
BatchPipes/MVS pipes
VSAM files
SPOOL files
Data can be Fixed, Variable, of Variable Spanned (except some types do not support Variable
Spanned data).
DFSORT has a good reputation for supporting new device types and data set configurations,
such as DFSMS Extended Format Sequential (which supports Striping and Compression) for
input and output data sets.
DFSORT cannot directly process database data, such as DB2 or IMS. Such data has to be
extracted to flat files first or written from flat files afterwards.
406
Where speed, simplicity, or maintainability are important, both new and existing application
components that meet this pattern should be examined to see whether DFSORT functions
are a good match.
In this section, we describe some of the more uncommon functions of DFSORT.
INCLUDE
INREC
Sort
SORTOUT
OUTFIL
INCLUDE 1
OUTFIL
INCLUDE 2
407
The following selection criteria can be used individually or together, using AND or OR logic.
Fields can be compared to other fields or to constant values, whether numeric or character
data.
Fields can be compared to dates and times, including using simple logic such as
comparing to yesterdays date.
Substring comparisons can be made, for when the exact position of a match isnt known in
a string.
Bit-level comparisons can be made.
Records can be selected based on whether they have valid EBCDIC or Packed-Decimal
numerics in a specific field, which can be especially helpful for checking whether data has
broken numerics in it, a common source of batch job failures.
The ICETOOL SELECT operator writes records that meet (or fail to meet) specific criteria
as a group of records, such as all records with duplicate values for a certain field occur in
more than one record (ALLDUPS). You can reformat the selected records.
With IFTHEN processing a flag can be conditionally injected into the records that can then
be used to keep or delete them.
408
23.3.3 Parsing
Traditionally, DFSORT and ICETOOL worked only with fields in fixed positions with fixed
lengths in the record. With PARSE and IFTHEN PARSE, you can extract up to 100 delimited
fields and use them wherever you previously used fixed fields.
A delimited field is one that begins somewhere after one delimiting character and ends
somewhere before another delimiting character.
Figure 23-2 shows how to use PARSE to move variable-position and variable-length fields
into fixed positions and edited to yield fixed-length fields.
Before Parse
Record 1
Record 2
Record 3
After Parse
Record 1
%00
%01
Record 2
%00
%01
Record 3
%00
%01
Figure 23-2 How PARSE moves and reformats fields to fixed positions
The following example, from the article DFSORT: Beyond Sorting, shows parsing and
reformatting comma separated values (CSV):
%01=(ENDBEFR=C',',FIXLEN=8),
%=(ENDBEFR=C','),
%03=(ENDBEFR=C',',FIXLEN=5),
%04=(FIXLEN=12)),
BUILD=(%01,14:%03,TRAN=LTOU,25:%04,UFF,TO=FS,LENGTH=15)
The PARSE operand defines the rules for extracting the delimited fields from each record into
%nn fixed parsed fields as follows:
The first CSV field is extracted into the 8-byte %01 field. If the extracted data is less than 8
bytes, it is padded on the right with blanks.
The second CSV field is ignored.
409
The third CSV field is extracted into the 5-byte %03 field. If the extracted data is less than
5 bytes, it is padded on the right with blanks.
The fourth CSV field is extracted into the 12-byte %04 field. If the extracted data is less
than 12 bytes, it is padded on the right with blanks.
The BUILD operand reformats the records using the %nn fields as follows:
Output positions 1-8 contains the data in the %01 parsed field.
Output positions 14-18 contains the data in the %03 parsed field translated from
lowercase to uppercase.
Output positions 25-39 contains the numeric digits from the %04 parsed field converted to
FS format.
410
ICETOOL SPLICE splices together fields from records that have duplicate numeric or
character field values. You can use this for situations where you need to join data sets or
look up values from another data set.
ICETOOL STATS prints messages containing the minimum, maximum, average and the
total of all the values for a specific numeric field.
ICETOOL UNIQUE prints a message containing the count of unique values in a numeric
or character field.
411
These techniques set a non-zero return code. An installation can automate based on such a
return code:
The same job can behave differently depending on the return code.
Automation can detect the return code and cause manual or automatic intervention if it is
non-zero.
412
/*
//SORTOUT DD SYSOUT=*
//SYSIN
DD *
OPTION COPY
INREC IFTHEN=(WHEN=(1,1,CH,EQ,C'A'),OVERLAY=(8:C'YES')),
IFTHEN=(WHEN=NONE,OVERLAY=(8:C'NO'))
/*
This sample treats records with the character A in position 1 differently from those with some
other character in the first position. The records with A have YES placed in position 8, and the
records without A have NO placed in position 8. This sample produces the following output:
AXLE
BOX
AERIAL
DEPOT
ASPIC
CARROT
YES
NO
YES
NO
YES
NO
Handling groups
Example 23-3 shows a JCL sample.
Example 23-3 Sample JCL
413
This example is a more complex example that illustrates the use of WHEN=GROUP with
additional post processing. This sample produces the following output:
AXLE
BOX
AERIAL
DEPOT
ASPIC
CARROT
1
2
1
2
3
4
1
1
2
2
2
2
In this output, the first column of numbers is the record number within a group. The second is
the groups identifier.
The input data in this example is a pair of groups of records. Each group is bracketed with
<GROUP> and </GROUP>.
The WHEN=GROUP clause recognizes the start and end of each group - with the strings
specified by BEGIN= and END=.
When a new group is encountered a new record sequence number within the group is placed
in positions 20 to 22 (specified by 20:SEQ=3). This sequence number is incremented by 1 for
each record in the group.
Specifying 25:ID=3 means the group number (starting at 1) is placed in positions 25 to 27.
The group number is incremented by 1 when a new group is encountered.
The OUTFIL OMIT statement removes the group start and end records, and reformats the
remaining data records:
The sequence number within group is decremented by 1 and reformatted to blank out
leading zeroes. (It has to be decremented by 1 because the <GROUP> record had
sequence number 1 and the first data record had sequence number 2.
The group identifier number is reformatted, suppressing its leading zeroes.
This example, admittedly, is a more complex example. In fact most of the complexity is in the
formatting in the OUTFIL statement.
23.4 Symbols
Symbols can make DFSORT and ICETOOL invocations more readable and maintainable.
Consider the following example:
SORT FIELDS=(12,8,CH,A,4,8,CH,A)
This code fragment is difficult to maintain if the input data changes format. This is particularly
the case when the same data set could be processed by more than one job.
Now consider the same example rewritten using Symbols. First, here is the SORT invocation
again:
SORT FIELDS=(SURNAME,A,FIRSTNAME,A)
414
So, DFSORT will understand the SURNAME and FIRSTNAME symbols and define them in a
SYMNAMES DD of the form:
//SYMNAMES DD *
FIRSTNAME,4,8,CH
SURNAME,12,8,CH
/*
This code is much more maintainable and the SORT statement is more comprehensible.
Rather than using SYMNAMES DD * for the SYMNAMES file consider using a permanent
data set (such as a PDS member). If more than one DFSORT invocation uses the same input
file, a change in file format requires that you change only one partthe SYMNAMES
permanent data set.
Note: Symbols are not attached to the data (as a variable would be). A symbol relates to
the same offset and length in the record throughout. So, for example, if you refer to a
symbol in a reformatting INREC statement it is likely the reformatting will move the field to
a different position in the record and the symbol will not adjust its position to match.
A useful technique is to define one set of symbols for each stage, perhaps prefixing each
set with additional underscore characters to keep the set unique.
A field can be mapped more than once. Consider the following example:
//SYMNAMES DD *
DATE,1,10,CH
YEAR,=,4,CH
SKIP,1
MONTH,*,2,CH
SKIP,1
DAY,*,2,CH
/*
The symbol DATE maps all 10 characters of a date field in the form YYYY-MM-DD.
The symbol YEAR maps the YYYY portion.
Each SKIP moves the cursor past a - portion of the field.
MONTH and DAY map the MM and DD portions of the field.
The equal sign character (=) in this example says start the YEAR symbol at the same
position as the previous symbol (in this case DATE).
The star character (*) in the definitions of MONTH and DAY means start the symbol just after
the previous symbol or SKIP.
415
01 PACKAGE-RECORD.
5 PACKAGE-HEADER.
10 PACKAGE-HEADER-1 PIC X(13).
10 FILLER PIC X.
10 PACKAGE-HEADER-2 PIC X(1).
10 FILLER PIC X.
10 PACKAGE-SEQUENCE PIC 9(8) COMP-3.
5 CUSTOMER-GROUP.
10 CG-NAME PIC X(3).
10 CG-COUNT PIC 9(10) COMP-3.
10 CG-DATE PIC 9(6) COMP.
10 CG-TIME PIC 9(8) COMP.
10 CG-TYPE PIC S9(2) COMP.
10 CG-LIMIT PIC S9(7).
10 CG-STATUS PIC X(8).
88 APPROVED VALUE 'APPROVED'.
88 DENIED VALUE 'DENIED '.
88 PENDING VALUE SPACES.
10 CG-COUNTY-NO PIC 99.
88 DUTCHESS VALUE 14.
88 KINGS VALUE 24.
88 NOCOUNTY VALUE ZERO.
Example 23-5 shows resulting DFSORT Symbols deck.
Example 23-5 Resulting DFSORT Symbols deck
POSITION,1
PACKAGE-RECORD,=,57,CH
PACKAGE-HEADER,=,21,CH
PACKAGE-HEADER-1,=,13,CH
SKIP,1
PACKAGE-HEADER-2,*,1,CH
SKIP,1
PACKAGE-SEQUENCE,*,5,PD
CUSTOMER-GROUP,*,36,CH
CG-NAME,=,3,CH
416
@1
@1
@1
@14
@15
@16
@17
@22
@22
CG-COUNT,*,6,PD
CG-DATE,*,4,BI
CG-TIME,*,4,BI
CG-TYPE,*,2,FI
CG-LIMIT,*,7,ZD
CG-STATUS,*,8,CH
APPROVED,'APPROVED'
DENIED,'DENIED '
PENDING,' '
CG-COUNTY-NO,*,2,ZD
DUTCHESS,14
KINGS,24
NOCOUNTY,0
@25
@31
@35
@39
@41
@48
@56
In this example, the @56 and similar comments denote the positions in the record to which the
symbol maps.
3
2
1
417
2. Sort the count records by count, and reformat the output to produce the report.
The output of the first operation is the input to the second, so we pass it by a transient data
set. This data set contains records each with two fields:
The 4-character (EBCDIC) string
A 4-byte integer count (binary)
Example 23-6 shows the JZOS DfSort class used to perform two DFSORT invocations within
the same program.
Example 23-6 Sample JZOS program to drive DFSORT: Ranking by frequency
dfSort2.addControlStatement("SORT FIELDS=(5,4,BI,D)");
dfSort2.addControlStatement("OUTREC "+
"FIELDS=(1,4,X,5,4,BI,EDIT=(IIIT))");
dfSort2.setSameAddressSpace(true);
dfSort2.execute();
}
}
Here are the steps involved in this program:
1. Generate a transient data set name.
In this case, we generate an unqualified data set name using a random number. (It would
best to create a temporary data set, but JZOS, which uses the BPXWDYN service, is
unable to create temporary data sets.)
2. Perform the first DFSORT invocation.
We create object dfSort1 of class DfSort to control the sort.
We add control statements using the addControlStatement() method and allocate
SORTIN and SORTOUT data sets using the addAllocation() method.
We ensure that DFSORT runs in the same address space, and we run DFSORT using the
execute() method.
Note: The DFSORT statements in the first invocation are as follows:
INREC OVERLAY=(5:X'00000001') which places a binary 1 in positions 5 to 8
SORT FIELDS=(1,4,CH,A) which sorts on the character field were counting
SUM FIELDS=(5,4,BI) which counts by summing the 1 values from INREC
3. Free the SORTOUT data set so we can reallocate it to the SORTIN DD in the second
DFSORT invocation.
4. Invoke DFSORT a second time.
This time, the SORTIN is the output of the first sort and the SORTOUT is our final report.
Note: The DFSORT statements in the second invocation are as follows:
SORT FIELDS=(5,4,BI,D) which sorts on the frequency field
OUTREC FIELDS=(1,4,X,5,4,BI,EDIT=(IIIT)) which formats the output
This example is fairly complex, but it does include two DFSORT invocations and lots of data
set management. To be fair, the JCL is simpler because there are no DD statements for the
data or the DFSORT control statements.
In both DFSORT invocations the program was instructed to run in the same address space.
This simplifies retrieving the messages DFSORT produces.
You can retrieve the DFSORT return code with the getReturnCode() method. In our example,
we did not do so.
Further integration between DFSORT and JZOS is possible. You can pass the
getChildStdinStream() and getChildStdoutStream() methods records to and from
DFSORT. These methods connect DFSORT to arbitrary sources of data and destinations,
using the standard Java BufferedInputStream and BufferedOutputStream classes.
419
420
Part 6
Part
Appendixes
421
422
Appendix A.
DB2 configuration
In this appendix, we describe the DB2 configuration for the samples using DB2. This
appendix includes the following topics:
Data Definition Language for Java stored procedure
Data Definition Language for stand-alone Java application
DB2 SQL Insert statements for sample data
423
NOT NULL
,FIRST_NAME
VARCHAR(20)
,LAST_NAME
VARCHAR(30)
,STREET_NAME VARCHAR(30)
,STREET_NO
SMALLINT
,ZIP
SMALLINT
,CITY
VARCHAR(20)
,STATE
CHAR(2)
,COUNTRY
VARCHAR(20)
,PRIMARY KEY (CUST_NO)
)
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NULL
NULL
NULL
NULL
NULL
NULL
NULL
NULL
;
-- CREATE TABLE ITEM
CREATE TABLE ITEMS
(ITEM_NO
INTEGER
NOT NULL
,DESCRIPTION VARCHAR(100)
NOT NULL
,SINGLE_PRICE DECIMAL(10, 2) NOT NULL
,PRIMARY KEY (ITEM_NO)
)
;
-- CREATE TABLE ORDER
CREATE TABLE ORDER
(ORDER_NO
INTEGER
NOT NULL
,POS_NO
SMALLINT
NOT NULL
,CUST_NO
INTEGER
NOT NULL
,ITEM_NO
INTEGER
NOT NULL
,QUANTITY
SMALLINT
NOT NULL
,PRIMARY KEY (ORDER_NO, POS_NO)
)
;
-- ADD FOREIGN KEYS
ALTER TABLE ORDER
ADD CONSTRAINT FK_ORDER_CUST
FOREIGN KEY (CUST_NO)
REFERENCES CUSTOMER
ON DELETE CASCADE
;
ALTER TABLE ORDER
ADD CONSTRAINT FK_ORDER_ITEM
FOREIGN KEY (ITEM_NO)
REFERENCES ITEMS
ON DELETE RESTRICT
;
-- GRANTS
GRANT SELECT, INSERT, UPDATE, DELETE
ON TABLE CUSTOMER
,ITEMS
,ORDER
TO PUBLIC
;
425
426
<DepNo>22</DepNo>
<Description>Development</Description>
<Employee>
<EmpNo>2</EmpNo>
<FirstName>Mike</FirstName>
<LastName>Rocket</LastName>
</Employee>
</Department>
</Company>
')
;
Example A-5 SQL statements to insert sample data for stand-alone Java application
427
428
Appendix B.
Source code
This appendix contains source code to which we refer in the chapters of this book. You can
find all source code for this book in the additional materials. For information about
downloading the additional materials, refer to Appendix C, Additional material on page 453.
429
package com.ibm.itso.sample;
import java.sql.SQLException;
public class GenPdf {
public static void runGenerate(String action, String pdfDir)
throws SQLException {
PdfCreator pdfc = new PdfCreator();
pdfc.generatePDF(action, pdfDir);
}
}
Example B-2 PdfCreator.java - Java Stored procedure
package com.ibm.itso.sample;
import
import
import
import
import
import
import
import
import
import
import
import
java.awt.Color;
java.io.ByteArrayInputStream;
java.io.ByteArrayOutputStream;
java.io.File;
java.io.FileOutputStream;
java.io.IOException;
java.io.InputStream;
java.sql.Connection;
java.sql.DriverManager;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
import
import
import
import
import
import
import
import
import
import
com.lowagie.text.Chunk;
com.lowagie.text.Document;
com.lowagie.text.DocumentException;
com.lowagie.text.Element;
com.lowagie.text.Font;
com.lowagie.text.FontFactory;
com.lowagie.text.Paragraph;
com.lowagie.text.pdf.PdfWriter;
com.lowagie.text.pdf.draw.LineSeparator;
com.lowagie.text.pdf.draw.VerticalPositionMark;
430
431
oldId = curId;
}
String CompanyName = rs.getString("COMPANY");
int curDeptNo = rs.getInt("DEPT_NO");
String DeptDesc = rs.getString("DEPT_DESCR");
int EmpNo = rs.getInt("EMP_NO");
String EmpFirstName = rs.getString("FIRST_NAME");
String EmpLastName = rs.getString("LAST_NAME");
// Heading
if (printHeading) {
document.add(separator);
Paragraph heading = new Paragraph();
heading.setAlignment(Element.ALIGN_LEFT);
heading.setSpacingAfter(3);
c = new Chunk("All Employees for company '" + CompanyName
+ "'\n", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.NORMAL, new Color(0, 0, 0)));
heading.add(new Chunk(c));
document.add(heading);
document.add(separator);
printHeading = false;
}
// print Employees
if (curDeptNo != oldDeptNo) {
// new Department
Paragraph department = new Paragraph();
department.setAlignment(Element.ALIGN_LEFT);
department.setSpacingBefore(15);
c = new Chunk("Department " + curDeptNo + ": " + DeptDesc
+ "\n", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.NORMAL, new Color(0, 0, 0)));
department.add(new Chunk(c));
document.add(department);
oldDeptNo = curDeptNo;
}
Paragraph employee = new Paragraph();
employee.setAlignment(Element.ALIGN_LEFT);
employee.setIndentationLeft(30);
c = new Chunk("EmpNo: " + EmpNo + ", " + EmpFirstName + " "
+ EmpLastName + "\n", FontFactory.getFont(
FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0,
0)));
employee.add(new Chunk(c));
document.add(employee);
}
rs.close();
ps.close();
// save last PDF in DB2 and/or File system
432
document.close();
this.savePdf(con, action, pdfDir, oldId, out);
} catch (DocumentException de) {
throw new SQLException("DocumentException: " + de.getMessage());
} catch (IOException ioe) {
throw new SQLException("IOException: " + ioe.getMessage());
}
}
private void savePdf(Connection con, String action, String pdfDir,
int oldId, ByteArrayOutputStream out) throws IOException, SQLException {
// handle PDF file depending on parameter 'action'
if (action.equalsIgnoreCase("store_fs")
|| action.equalsIgnoreCase("store_fs_db2")) {
// write PDF to file system
FileOutputStream fOut = new FileOutputStream(pdfDir
+ File.separator + "Report" + oldId + ".pdf");
out.writeTo(fOut);
fOut.close();
}
if (action.equalsIgnoreCase("store_db2")
|| action.equalsIgnoreCase("store_fs_db2")) {
// update current DB2 row and save PDF file as BLOB
String strSQL = "UPDATE BATCH.XML2PDF SET PDF_DATA = ? WHERE ID = ?";
PreparedStatement psUpd = con.prepareStatement(strSQL);
InputStream is = new ByteArrayInputStream(out.toByteArray());
psUpd.setBinaryStream(1, is, -1);
psUpd.setInt(2, oldId);
psUpd.execute();
psUpd.close();
}
// Close the document
out.close();
}
}
Example B-3 deploy.xml
433
434
package com.ibm.itso.sample;
import
import
import
import
import
java.sql.CallableStatement;
java.sql.Connection;
java.sql.DriverManager;
java.sql.SQLException;
java.sql.Types;
435
package com.ibm.itso.sample;
import
import
import
import
java.sql.CallableStatement;
java.sql.Connection;
java.sql.DriverManager;
java.sql.SQLException;
436
System.err.println(cnfe.getMessage());
cnfe.printStackTrace();
} catch (SQLException sqle) {
System.err.println(sqle.getMessage());
sqle.printStackTrace();
}
}
}
package com.ibm.itso.sample;
public class InvoiceCreator {
public static void main(String[] args) {
PdfCreator pdfc = new PdfCreator();
pdfc.createInvoice(args[0]);
}
}
Example B-8 PdfCreator.java
package com.ibm.itso.sample;
import
import
import
import
import
import
import
import
import
import
java.awt.Color;
java.io.FileOutputStream;
java.io.IOException;
java.math.BigDecimal;
java.sql.Connection;
java.sql.DriverManager;
java.sql.PreparedStatement;
java.sql.ResultSet;
java.sql.SQLException;
java.util.ArrayList;
import
import
import
import
import
import
import
import
import
import
import
import
com.lowagie.text.Chunk;
com.lowagie.text.Document;
com.lowagie.text.DocumentException;
com.lowagie.text.Element;
com.lowagie.text.Font;
com.lowagie.text.FontFactory;
com.lowagie.text.Paragraph;
com.lowagie.text.pdf.PdfPCell;
com.lowagie.text.pdf.PdfPTable;
com.lowagie.text.pdf.PdfWriter;
com.lowagie.text.pdf.draw.LineSeparator;
com.lowagie.text.pdf.draw.VerticalPositionMark;
437
438
439
cell.setMinimumHeight(25);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
c=new Chunk("Quantity", FontFactory.getFont(FontFactory.HELVETICA, 12,
Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
c=new Chunk("Description", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
c=new Chunk("Single price", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
c=new Chunk("Total price", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
BigDecimal total=new BigDecimal(0);
//Add order data from database
strSQL = "SELECT * FROM BATCH.ITEMS, BATCH.ORDER WHERE
BATCH.ITEMS.ITEM_NO = BATCH.ORDER.ITEM_NO AND BATCH.ORDER.ORDER_NO = "+
String.valueOf(currentOrderNo)+" ORDER BY BATCH.ORDER.POS_NO";
ps = con.prepareStatement(strSQL);
rs = ps.executeQuery();
while (rs.next()) {
int pos=rs.getInt("POS_NO");
int quantity=rs.getInt("QUANTITY");
String description=rs.getString("DESCRIPTION");
BigDecimal singlePrice=rs.getBigDecimal("SINGLE_PRICE");
BigDecimal totalPrice=new BigDecimal("0");
c=new Chunk(String.valueOf(pos),
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
table.addCell(cell);
c=new Chunk(String.valueOf(quantity),
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
table.addCell(cell);
c=new Chunk(description, FontFactory.getFont(FontFactory.HELVETICA,
12, Font.NORMAL, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
440
table.addCell(cell);
c=new Chunk(singlePrice.toString()+" USD",
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(cell);
totalPrice=singlePrice.multiply(new BigDecimal(quantity));
c=new Chunk(totalPrice.toString()+" USD",
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.NORMAL, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(cell);
total=total.add(totalPrice);
}
rs.close();
ps.close();
//Add table footer data
c=new Chunk("Total", FontFactory.getFont(FontFactory.HELVETICA, 12,
Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
cell.setMinimumHeight(25);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(""));
cell.setColspan(3);
table.addCell(cell);
c=new Chunk(total.toString()+" USD",
FontFactory.getFont(FontFactory.HELVETICA, 12, Font.BOLD, new Color(0, 0, 0)));
cell = new PdfPCell(new Paragraph(c));
cell.setHorizontalAlignment(Element.ALIGN_RIGHT);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
document.add(table);
//Add vertical line
document.add(new Chunk("\n"));
document.add(new Chunk("\n"));
document.add(separator);
c=new Chunk("Please read our terms and conditions.",
FontFactory.getFont(FontFactory.HELVETICA, 10, Font.ITALIC, new Color(0, 0, 0)));
document.add(new Paragraph (c));
//Close the document
document.close();
System.out.println("... invoice pdf file created.");
}
con.close();
} catch (DocumentException de) {
System.err.println(de.getMessage());
de.printStackTrace();
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
441
ioe.printStackTrace();
} catch (SQLException sqle) {
System.err.println(sqle.getMessage());
sqle.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
<?php
function getDb2Connection()
{
$dsn='odbc:DB9G';
$username='USER';
$passwd='PASSWORD';
$dbh = new PDO($dsn, $username, $passwd, array('PDO_ATTR_PERSISTENT' =>
false));
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
return $dbh;
}
?>
Example B-10 InvoiceCreator.php
<?php
require('../lib/fpdf.php');
require ('DbConnect.php');
try
{
//Connect to DB2 and retireve all orders
echo "Connecting to DB2 \n";
$con=getDb2Connection();
echo "... Connected \n";
$orderNos = array();
$i=0;
$sql = "SELECT DISTINCT Order_No FROM BATCH.ORDER";
foreach ($con->query($sql) as $row)
{
$orderNos[$i] = ($row[0]);
$i++;
}
$sql=NULL;
442
443
{
$pdf->SetFont('Times','',12);
$totalItem=$row["SINGLE_PRICE"]*$row[QUANTITY];
$pdf->Cell(13,7,$row["POS_NO"],1,0,'L');
$pdf->Cell(20,7,$row["QUANTITY"],1,0,'L');
$pdf->Cell(87,7,$row["DESCRIPTION"],1,0,'L');
$pdf->Cell(35,7,number_format($row["SINGLE_PRICE"],2).' USD ',1,0,'R');
$pdf->Cell(35,7,number_format($totalItem,2).' USD ',1,0,'R');
$pdf->Ln();
$linecount++;
$totalPrice=$totalPrice+$totalItem;
}
$sql=NULL;
444
package com.ibm.itso.sample;
import java.io.IOException;
import java.io.PrintWriter;
import
import
import
import
import
import
import
javax.ejb.CreateException;
javax.naming.InitialContext;
javax.rmi.PortableRemoteObject;
javax.servlet.ServletConfig;
javax.servlet.ServletException;
javax.servlet.http.HttpServletRequest;
javax.servlet.http.HttpServletResponse;
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doGet(HttpServletRequest request,
HttpServletResponse response)
445
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter writer = response.getWriter();
String parameter1 = request.getParameter("Parameter1");
String parameter2 = request.getParameter("Parameter2");
if (parameter1 == null && parameter2==null) {
writer.println("<html>");
writer.println("<title>Dynamic job submission on z/OS</title>");
writer.println("<body>");
writer.println("<h1>Welcome to the z/OS batch submitter
application</h1>");
writer.println("<p>Please enter all required parameters.</p>");
writer.println("<form method=\"get\">");
writer.println("<p>Parameter 1: <input name=\"Parameter1\"
type=\"text\" size=\"80\" maxlength=\"100\"></p>");
writer.println("<p>Parameter 2: <input name=\"Parameter2\"
type=\"text\" size=\"80\" maxlength=\"100\"></p>");
writer.println("<input type=\"submit\" value=\" Submit\">");
writer.println("<input type=\"reset\" value=\" Cancel\">");
writer.println("</form>");
writer.println("</body>");
writer.println("</html>");
} else {
writer.println("<html>");
writer.println("<title>Dynamic job submission on z/OS</title>");
writer.println("<body>");
writer.println("<h1>z/OS batch submitter application - Results</h1>");
String returnMessage="";
try {
TriggerBatch triggerBatch=batchHome.create();
String[] paramters= {parameter1, parameter2};
returnMessage=triggerBatch.execute(paramters);
if (returnMessage.indexOf("Error")==-1)
{
writer.println("<p>"+returnMessage+"</p>");
}
else
{
writer.println("<p><font
color=\"#FF0000\">"+returnMessage+"</font></p>");
}
} catch (CreateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
writer.println("<p><A HREF=\"javascript:history.back()\>
Back</a></p>");
writer.println("</body>");
writer.println("</html>");
}
writer.close();
}
446
/* (non-Java-doc)
* @see javax.servlet.http.HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
}
}
Example B-12 TriggerBatchBean.java
package com.ibm.itso.sample;
/**
* Bean implementation class for Enterprise Bean: TriggerBatch
*/
public class TriggerBatchBean implements javax.ejb.SessionBean {
static final long serialVersionUID = 3206093459760846163L;
private javax.ejb.SessionContext mySessionCtx;
/**
* getSessionContext
*/
public javax.ejb.SessionContext getSessionContext() {
return mySessionCtx;
}
/**
* setSessionContext
*/
public void setSessionContext(javax.ejb.SessionContext ctx) {
mySessionCtx = ctx;
}
/**
* ejbCreate
*/
public void ejbCreate() throws javax.ejb.CreateException {
}
/**
* ejbActivate
*/
public void ejbActivate() {
}
/**
* ejbPassivate
*/
public void ejbPassivate() {
}
/**
* ejbRemove
*/
public void ejbRemove() {
}
447
//*
//*
//XML2COB DD DSN=DTX.SDTXSAMP(DTXBMMVS),DISP=SHR
//*
The DD statement identifies the map as a member of
//*
a PDS and the command line identifies the map by its ddname:
//*
e.g. PARM='XML2COB <option> <option> etc.'
//*
//*
//MAPLIB
DD DSN=DTX.SDTXSAMP,DISP=SHR
//*
The DD statement identifies the PDS only and the member
//*
name is identified on the command line in parentheses
//*
following the ddname that identifies the PDS:
//*
e.g. PARM='MAPLIB(DTXBMMVS)'
//*
//XML2COB DD DISP=SHR,DSN=WAGNERA.WTX.MAPS(XML2COB)
//*
//* Sysout datasets. SYSPRINT, SYSOUT and CEEDUMP are required by
//* Language Environment.
//*
//DTXLOG
DD SYSOUT=*
Execution log
//DTXAUD
DD SYSOUT=*
Audit file
//DTXTRCE DD SYSOUT=*
Trace file
//SYSPRINT DD SYSOUT=*
//SYSOUT
DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//*
//* Define the input dataset
//INPUT
DD PATH='/u/wagnera/input.xml'
//*
//* Define the schema definition
//MAPXSD
DD PATH='/u/wagnera/input.xsd'
//*
//* Define the output dataset
//OUTPUT
DD DSN=WAGNERA.OUT.XML2COBO,
//
DCB=(RECFM=VB,LRECL=80),
//
UNIT=SYSDA,
//
SPACE=(TRK,(1,1),RLSE),
//
DISP=(NEW,CATLG,DELETE)
//* Static temporary file allocations (if you want temporary files to be
//* dynamically allocated, remove or comment out the following statements).
//* The maximum number of temporary files used by a map is (2 * number of
//* inputs) + (2 * number of outputs) + 1. The minimum is equal to the number
//* of inputs + the number of outputs + 1. If static temporary allocations
//* are to be used they must be defined temporary datasets with RECFM=FBS;
//* The record length should be as large as convenient but not larger than
//* 32K. The BUFNO parameter should not be used. The amount of space
//* used by temporary files varies greatly from map to map depending on
//* map complexity, the amount of data being processed and the paging
//* options chosen.
//*
//SYSTMP01 DD DSN=&&TEMP01,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP02 DD DSN=&&TEMP02,
//
DISP=(NEW,DELETE,DELETE),
449
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP03 DD DSN=&&TEMP03,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP04 DD DSN=&&TEMP04,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
//SYSTMP05 DD DSN=&&TEMP05,
//
DISP=(NEW,DELETE,DELETE),
//
DCB=(RECFM=FBS,LRECL=32760),
//
UNIT=SYSDA,
//
SPACE=(TRK,(5,1))
package com.ibm.itso.sample;
import java.sql.SQLException;
public class GenPdf {
public static void triggeredByMQ(String inMsg, String[] outMsg)
throws SQLException {
String
String
temp =
String
String
temp = inMsg;
jobID = temp.substring(0, temp.indexOf(":"));
temp.substring(temp.indexOf(":") + 1);
action = temp.substring(0, temp.indexOf(":"));
pdfDir = temp.substring(temp.indexOf(":") + 1);
450
package com.ibm.itso.sample;
import
import
import
import
java.sql.CallableStatement;
java.sql.Connection;
java.sql.DriverManager;
java.sql.SQLException;
451
sqle.printStackTrace();
}
}
}
452
Appendix C.
Additional material
This book refers to additional material that you can download from the Internet as described
in this appendix.
Description
COBOL_data_generator.zip
Java_STP_pdf_generator.zip
Java_pdf_generator.zip
PHP_pdf_generator.zip
453
DynamicBatchRADProject.zip
NativeJavaEjb.zip
The EJB that calls a z/OS batch job with native Java
technology from 14.1, Job submission with native Java
technology on page 224.
WTX_sample.zip
WXDCG_sample.zip
SchedulerWrapperProject.zip
STP_TriggeredByMQ.zip
STP_TriggeredByMQ_EJB.zip
454
Related publications
We consider the publications that we list in this section particularly suitable for a more
detailed discussion of the topics that we cover in this book.
Other publications
These publications are also relevant as further information sources:
Application Programming Guide and Reference for Java, SC18-9842
XML Guide, SC18-9858
DB2 9 Performance Monitoring and Tuning Guide, SC18-9851
WebSphere z/OS - The Value of Co-Location, WP101476
Enterprise COBOL for z/OS Programming Guide Version 4 Release 1, SC23-8529
Enterprise PL/I for z/OS Programming Guide Version 3 Release 8, SC27-1457
Pattern-Oriented Software Architecture: A System Of Patterns. West Sussex, England, ii.
Buschmann, F., R. Meunier, H. Rohnert, P. Sommerlad, and M. Stal, John Wiley & Sons
Ltd., 1996
455
Online resources
These Web sites are also relevant as further information sources:
IBM z/OS Java
http://www.ibm.com/servers/eserver/zseries/software/java/
JZOS
http://www.ibm.com/servers/eserver/zseries/software/java/products/jzos/overview
.html
JZOS Toolkit javadoc
http://www.ibm.com/developerworks/java/zos/javadoc/jzos/index.html
JZOS Sample applications
http://www.ibm.com/servers/eserver/zseries/software/java/products/jzos/jzossamp
.html
JZOS Cookbook
http://www.alphaworks.ibm.com/tech/zosjavabatchtk/download
z/OS Java 6.0 User Guide
http://download.boulder.ibm.com/ibmdl/pub/software/dw/jdk/diagnosis/diag60.pdf
z/OS Java 6.0 Diagnostics Guide
http://publib.boulder.ibm.com/infocenter/javasdk/v6r0/topic/com.ibm.java.doc.us
er.zos.60/collection-welcome.html
JinsightLive for IBM System z
http://www.alphaworks.ibm.com/tech/jinsightlive
iText Java PDF library
http://www.lowagie.com/iText/
FTP Ant task
http://ant.apache.org/manual/OptionalTasks/ftp.html
z/OS UNIX System Services Tools and toys
http://www.ibm.com/servers/eserver/zseries/zos/unix/tools/
PHP on z/OS
http://www.ibm.com/servers/eserver/zseries/zos/unix/ported/php/index.html
Eclipse PDT
http://www.eclipse.org/pdt/downloads/
FDPF PHP library
http://www.fpdf.org
WebSphere MQ File Transfer Edition Information Center
http://publib.boulder.ibm.com/infocenter/wmqfte/v7r0/index.jsp?topic=/com.ibm.w
mqfte.home.doc/help_home_wmqfte.htm
Managing Batch process in an SOA: Application Development Trends, The Lee, 2008
http://adtmag.com/Articles/2008/02/25/Managing-Batch-Processing-in-an-SOA.aspx?
Page=4
456
Related publications
457
458
Index
A
ADD CLONE 213
ALTER TABLE 213
Ant libraries, in Eclipse 72
B
Batch
tuning
DFSMShsm 352
IEFACTRT 353
Life Of A Data Set (LOADS) 347
OPEN and CLOSE of data sets 346
OPEN and CLOSE, non-VSAM data sets 346
OPEN and CLOSE, VSAM data sets 346
SMF 30-4 record 346
SMF 30-5 record 345
System Log (SYSLOG) 354
Tivoli Workload Scheduler 352
Batch window 11
Batch window, optimizing
Critical Path Analysis 304
data in memory (DIM) techniques 305
DB2 buffer pools 305
dependency diagram 303
DFSORT 305
Gantt chart 302
I/O 305
parallelism 305
Queued Sequential Access Method (QSAM), buffering 305
seven approaches 304
Virtual I/O (VIO) 305
VSAM Local Shared Resources, buffering 305
BatchPipes
advantages 311
BatchPipePlex 314
BatchPipeWorks 314, 316
connectors 314
CICS 314
DB2 Template Utility 314
FTP 314
data sets supported 311
fittings pipeline 316
half pipe 315
pipeline 315
setting up 313
SMF records 351
use ID access 313
using, blocksize 313
using, DD statement 313
Version 2 314
BatchPipes, and DFSORT 316
BatchPipeWorks 309
Binary (stream) mode 52
Copyright IBM Corp. 2009, 2012. All rights reserved.
Binder 34
BPXBATCH 78
BPXBATSL 78
Bulk processing reference architecture
Analytics 27
Bulk application container 2223
Bulk application development 26
Data access management services 22
Infrastructure services 22
Invocation and scheduling services 22
Invocation services 24
System management and operations 25
Business Action Language (BAL) 368
Business Object Model (BOM) 363
Business policy 360
Business Process Execution Language (BPEL) 17
Business Rule Management 360
Business Rule Management System (BRMS) 359360
Business rule mining 369
Business rules 360
C
Cache
removing data from 209
Climb Strategy 209
First In First Out (FIFO) 209
Least Frequently Used (LFU) 209
Least Recently Used (LRU) 209
Random 209
Caching 209
hardware 209
Caching, in DB2
dynamic statement cache 209
Caching, in WebSphere Application Server 209
Change Capture Agent 196
Checkpoint 24
Checkpoint interval 24
Classic Data Architect 196
Cleansing 191
CLOB (Character Large Object) 46
COBOL
XML support, built-in 36
ENCODING phrase 37
NAMESPACE-DECLARATION 37
NAMESPACE-DECLARATION XML 37
processing input 36
processing output 37
registers 37
XML GENERATE statement 37
XML PARSE statement 3637
XML-CODE 37
XML-EVENT 37
XML-NAMESPACE 37
XML-NAMESPACE-PREFIX 37
459
XML-NNAMESPACE 37
XML-NNAMESPACE-PREFIX 37
XML-NTEXT 37
XMLPARSE compiler option 36
XMLPARSE(COMPAT) compiler option 37
XMLPARSE(XMLSS) compiler option 36
XML-TEXT 37
COBOL and PL/I
C++ interoperability 35
Java interoperability 35
Unicode support 35
XML support 35
Codepage, UNIX System Services 54
Coupling Facility Resource Management (CFRM) 313
D
Data Mart 190
Data sources 195
Data Storage Area (DSA) 198
Data Warehouse 190
workloads, supported 190
Data Warehousing 189
Data Web Services (DWS) 280
Data, cleanse 194
Data, deliver 194
Data, extraction stage 193
Data, federation 195
Data, publication 196
Data, replication 196
Data, transform 194
Data, understand 194
DataStage 194
DataStage ETL Accelerator 202
DB2
explain, for access paths 212
multi-row processing 212
DB2 for z/OS
triggering a stored procedure
MQListener 270
Java code 272
JDBC drivers 276
remove tasks 275
starting tasks 274
stop/restart tasks 274
stored procedure, defining 272
stored procedure, testing locally 273
tasks, configuring 273
DB2 on z/OS
buffer pool, maximum size, in DB2 V9 218
buffer pool, size 218
checkpointing 221
clone tables 213
Data Set VSAM Control Interface (CI) size 219
DSNZPARMs 219
fast table append 217
index, when using expressions 217
Isolation Level 215
Cursor Stability (CS) 215
JDBC 216
Read Stability (RS) 215
460
E
EBCDIC, using PDF files in 171
Electronic Data Interchange (EDI) 374
ETL Accelerator 201
European Single Euro Payments Area (SEPA) 377
extract, transform, and load (ETL) 20, 189, 191, 198
cleansing 191
data refresh 192
data replication 192
extracting data faster 193
extraction process 191
file locking 198
load process 191
tools, on System z 193
transformation process 191
trickle feed 192
H
Health Insurance Portability and Accountability Act
(HIPAA) 374
Hibernate 60, 325
HiperSockets 201
I
IBM InfoSphere 194
IBM InfoSphere Datastage 189
IBM InfoSphere Information Server suite 194
IBM Rational Developer for System z 81
IBM WebSphere ILOG BRMS 360
IBM WebSphere ILOG BRMS (ILOG BRMS) 360
ICETOOL
checking data 411
OCCUR 410
RANGE 410
SELECT 410
SPLICE 411
STATS 411
UNIQUE 411
ILOG BRMS 360
Business Action Language (BAL) rules 364
Decision Services 364
Decision Validation Services (DVS) 364
JRules 364
Rule Execution Server 364
Rule Studio 362
Rule Team Server (RTS) 362
Rules for COBOL 364
IMS Database (IMS DB) 58
IMSDatabaseView object 59
Information Server Client Package interface 201
InfoSphere Change Data Capture 197198, 202
Q replication 199
SQL replication 199
InfoSphere Classic Data Event Publisher 196
InfoSphere Classic Federation 196
InfoSphere Classic Federation Data Server 196
InfoSphere Data Event Publisher 196
InfoSphere DataStage 200
parallel processing 204
J
Java EE batch application 100
Java EE environment, on z/OS 95
Java EE standard 94
Java Native Interface (JNI) 55
Java on z/OS
advantages 50
APIs, specific to z/OS 51
CICS 58
encoding 55
IMS 58
interoperability, with Enterprise COBOL 55
interoperability, with Enterprise PL/I 56
interoperability, with other languages 55
run times 51
Java on z/OS, stand-alone
invocation 78
tooling 80
Java Persistence API (JPA) 60
Java Persistence Architecture (JPA) 325
Java Record I/O library (JRIO) 52
Java Stored Procedure, in DB2
calling 64
configuring 65
creating 72
JAVAENV file 66
sample application 67
testing 75
WLM Application Environment 65
WLM Application Environment, refreshing 74
WLM environment startup procedure 65
Java stored procedure, in DB2 64
Java, in IMS 58
data access 58
development 63
interoperability, with other languages 63
Java Batch Processing (JBP) 60
checkpoints 62
example 62
restarting 62
starting 61
Java DataBase Connectivity (JDBC) 59
Java Message Processing (JMP) 60
Java, performance 338
Ahead-of-time (AOT) compilation 340
Index
461
Q
QualityStage 194
L
Language Environment 47
Load module 34
LOAD utility 202
Record mode 52
Redbooks Web site 457
Redbooks website
Contact us xv
Replication, modes 194
continuous mirroring 194
periodic mirroring 194
refresh 194
Resource broker 25
Rule Team Server (RTS), repository 363
M
Metadata Server 194
Modified Indirect Data Address Word (MIDAW) 218
Object code 34
Object-relational mapper 60
online transaction processing (OLTP) 20
online transaction processing (OLTP) system 191
OUTFIL
combining records 410
report writing 410
P
Performance instrumentation 341
SMF 342
PHP 158
PHP on z/OS
batch launcher options 159
DB2 on z/OS, access to 158
DB2, access to 168
development
462
subtype 13 351
subtype 14 351
subtype 15 351
Staging tables 198
straight through processing (STP) 20
Stream mode 52
Symbols, in DFSORT and ICETOOL 414
System Authorization Facility (SAF) 104
T
Text (stream) mode 52
Tivoli Dynamic Workload Broker (TDWB) 26
Tivoli Dynamic Workload Broker agent 264
Tivoli Workload Automation 264
Tivoli Workload Scheduler 11
Application Description (AD) 353
automatic job rerun 265
calendar and event based scheduling 263
Critical Path 265
fault tolerance 264
file transfer, integrated 266
high availability 264
integration
AF Operator 265
Tivoli System Automation for z/OS 265
interfaces 266
Query Current Plan (QCP) 353
reporting 266
scalability 264
Tivoli Enterprise Portal, integration 264
Workload Manager, integration 265
Tivoli Workload Scheduler for z/OS
strengths 263
Tools, for z/OS UNIX Systems Services 80
Trickle feed 192
W
Web 2.0 17
Web Services 17
WebSphere Application Server for z/OS 95
WebSphere Data Event Publisher 202
WebSphere Extended Deployment (XD) Compute Grid
for z/OS 93
Batch container 100
Batch Data Stream (BDS) 103
Batch Packager 119
BDS framework
ByteReaderPattern 115
ByteWriterPattern 115
FileReaderPattern 115
FileWriterPattern 115
JDBC, supported classes 114
JDBCReaderPattern 114
JDBCWriterPattern 114
JPAReaderPattern 115
JPAWriterPattern 115
RecordOrientedDatasetReaderPattern 115
RecordOrientedDatasetWriterPattern 115
components 99
Index
463
X
xJCL 99
XL/XP XML parser 42
XML Extender 46
XML in DB2
creating a table with XML 68
XMLTABLE function 71
XML Parser, C++ Edition 39
XML parsing on z/OS, with DB2 V9 44
XML parsing, issues 41
XML processing options on z/OS 36
XML support, in COBOL and PL/I 35
XML System Services 16
XML Toolkit for z/OS 39, 4142
XQuery 16
Z
z/OS BatchPipes 201
z/OS C/C++ library, I/O 52
z/OS XML parser 40
character encodings 40
specialty engine eligibility 40
464
(0.5 spine)
0.475<->0.873
250 <-> 459 pages
Back cover
Provides an overview
of current batch
processing
technology
Discusses how to use,
simplify, and improve
batch processing
Includes example
scenarios that use
batch processing
INTERNATIONAL
TECHNICAL
SUPPORT
ORGANIZATION
BUILDING TECHNICAL
INFORMATION BASED ON
PRACTICAL EXPERIENCE
IBM Redbooks are developed
by the IBM International
Technical Support
Organization. Experts from
IBM, Customers and Partners
from around the world create
timely technical information
based on realistic scenarios.
Specific recommendations
are provided to help you
implement IT solutions more
effectively in your
environment.
ISBN 0738436968