the caffeinated mainframer
DESCRIPTION
This was presented at the IBM Innovate Conference in June 2013. We cover IBM's strategy and support for Java on the mainframe, including using WebSphere Batch runtime, using Java in the Unix System Services area, and the JZOS api. The JZOS api is part of the IBM Java Virtual Machine for z/OS, and with it you can manipulate assets in MVS through the ISPF gateway, including allocating and deleting datasets, writing to Sequential and Partitioned datasets, and integrate with modern Java frameworks. We cover how Rational Developer for Enterprise is positioned for Java development on the mainframe by combining Rational Application Developer and Rational Developer for System z features into a single interface. We cover several features of RAD such as code coverage, unit testing, and software analysis. We also cover some best practices using Java on the mainframe and incorporating it with other Java frameworks such as Spring, CDI, JPA, Mockito, and others.TRANSCRIPT
The Caffeinated Mainframer
Kenny Smith
Principal Consultant
Strongback Consulting
twitter: @smithkenny
Matthew Hardin
Senior Consultant
1
About Us: Strongback Consulting
IBM Advanced Business Partner
– Rational, WebSphere, Lotus, Information Management SVP certified
– Strongly focused on Enterprise Modernization and application lifecycle management
– Key Industries Served: Finance, Insurance, Healthcare, Manufacturing, Government
– Rational Design Partner for HATS and other Rational enterprise modernization technologies
Discover us at:
http://www.strongback.us
Subscribe to us at
http://blog.strongbackconsulting.com
Socialize with us on Facebook & LinkedIn
http://www.facebook.com/StrongbackConsulting
http://www.linkedin.com/company/290754
Why Java on System z?
3
Abundance of Java and Java skills
zAAP Processors - cost effective workload
mgmt
Combining of traditional batch with modern
frameworks
Access to MVS using the JZOS API
Abundance of Java
#2 Programming language – Tiobe– February 2013
–C ranks #1 (frequently trades places with Java)
–COBOL ranks #24
–Assembler ranks #19
Ubiquity of architectural frameworks
–Unit testing, relational object mapping, security, dependency injection, etc.
Language learning resources are abundant
–Free tutorials available on http://www.ibm.com/developerworks
–More free tutorials at Sun’s… err … <cough> Oracle’s </cough> website
–Required course of most computer science programs
4 *http://www.langpop.com/
zAAP Processors – Cost Effective Solution
A specialty z processor engine
Provides an attractively priced execution environment for web-based
applications and SOA-based technologies, such as XML and Java
Simplifies and reduces server infrastructures
Maximizes the value of your mainframe investments
– increased system productivity by reducing the demands and capacity
requirements on general purpose processors which may then be available for
reallocation to other mainframe workloads.
Lowers the overall cost of computing for WebSphere Application Server
and other Java technology-based applications
–hardware, software and maintenance savings.
JIT on the z has greatly increased performance on the z.
5
WebSphere App Server for z/OS
Exploit the benefits of z/OS
WLM
–configure down to the request level, not just app level with special tags
SAF (RACF) - provides security definition and security
enforcement for the product
RRS—used for global syncpoint coordination between WAS z/OS
and other participants in two-phase commit global transactions
Cross memory communications
–JDBC type 2 uses this for comms to DB2
6
Java Batch Processing in OLTP Runtime
Running Java batch in the same execution runtime as Java OLTP
– provides an opportunity to mix and manage the two processing types together under the same
management model.
WebSphere Application Server allows the WAS platform to mix and manage the two
workload types.
WebSphere Compute Grid now included in WebSphere App Server 8.5
7
Web Container EJB Container Batch Container
WebSphere Application Server
WebSphere Modern Batch
Container managed execution of batch jobs: Provides the structure and support function
that Java batch applications require, and helps you avoid the “custom middleware trap.”
Job control interface: An XML file that describes the Java class files that are used in a
batch step and the steps that are included in the batch job.
8
Job checkpoint and restart
capability: Ability to create
checkpoints on the basis of record
count or time. This enables
restarting a job from a known
checkpoint.
Common batch data stream
(BDS): Contains functions that
abstract data into easily accessible
record formats so that the batch
programming can focus on the
business functions rather than
basic code that reads and writes
the data.
WebSphere Application v8.5 Infrastructure What’s New…
IBM Workload Deployer
IBM JVM
WebSphere Application Server Foundation
WebSphere eXtreme Scale
Rational Application Developer
Tools
Runtime
WAS Dev Tools for Eclipse
DataPower XC10
WebSphere Compute Grid
WebSphere Virtual
Enterprise
Intelligent Management
Pack
Pattern for Web
Applications WAS HV
Eclipse
Fit for Purpose
Application Foundation
Cloud & Operational Management & Efficiency
IBM Worklight
Studio
WebSphere Application Server V8.5
( WVE and WCG Included with WAS ND and WAS for zOS
& Liberty profile with all editions)
WAS HV V8.5
(Intelligent Management)
Mobile Apps (Web, Hybrid,
Native)
IBM Worklight Server
Eclipse
IBM PureApplication System
Intelligent Routing
Health Management
Application Edition
Management
Dynamic Clustering
Batch processing
WebSphere Batch
WebSphere Virtual Enterprise
Refresher on V8.5 – Intelligent Management
Enables interruption free application rollout
Monitors the status of your applications with the ability to sense and respond to problem areas
Dynamically provision and start/stop new instances of app server based on workload demands
Ensures priority is given to business critical applications via administrator defined rules
Support that leverages your existing Java online transaction processing (OLTP) infrastructure to support new Java batch workloads
Batch
Modules
Better TCO through management efficiency and performance, Intelligent Management
delivers the ability to sense and respond quickly to changes
Java Frameworks
Don't reinvent the wheel, just
realign it. Anthony J. D'Angelo, The
College Blue Book
11
JNI = Java Native Interface
The Java Native Interface is a programming framework that enables Java code running in a
Java Virtual Machine to call, and to be called by, native applications and libraries written in
other languages such as C, C++ and assembly.
Get a little close to the metal with JNI
Extend functionality of JZOS, or write functions to cover custom software
12
JZOS Java API for developers
A framework acquired by IBM
Now part of the IBM JVM
Preferred method for MVS file access, data type conversion,
MVS Console, etc
Includes a batch launcher
Uses JNI / C to access MVS datasets, VSAM files, QSAM
files, etc.
13
Calling Java in batch
BPXBATCH
–The “original” batch java caller.
–Best to run non-Java shell commands on Unix System Services
–The STDOUT and STDERR DD names are not allocated as MVS data
sets
JZOS
–The modern batch caller
–Uses a specific JVM load module
JZOS Batch
Jobs are zAAP eligible
IDE Integration with RDz, RAD
Can run Java based servers as started tasks
Full integration into the Job Entry System
Jobs run in the same address space
Support for DD statements
Move stdin, stdout, and stderr to an MVS Dataset
Gives a valid return code (other than just 1)
Unix System Services
JZOS API
MVS
Calling JZOS Batch
JVMLDMxx
JZOS PROC
JZOS JCL
Java Runtime
Java class
PDS
JES
MC
Programmer
writes and
submits the
JCL
JZOS JCL Skeleton
Job Card
Location of the
JVM Proc
Execute the
generic proc with
vars
Location of the
output
Java shell
environment setup
Java Generic PROC
A parameterized procedure makes it easier to standardize the
environment
A sample is included in the JDK for z/OS
Found under /usr/lpp/java/J7.0_64/mvstools/samples/jcl
–Good for most usage, customize for a given specific instance
Class API Overview:
Access MVS Datasets
–com.ibm.jzos.Zfile – thin wrapper for JNI calls to C I/O library
–com.ibm.jzos.FileFactory - platform-portable file access
Access HFS/zFS files
– java.io, java.nio – standard Java API
–com.ibm.jzos.FileFactory
Access the MVS Console
–com.ibm.jzos.MvsConsole – interface to MVS console and job log
Various z/OS native functions
–com.ibm.jzos.ZUtil
ZFile
com.ibm.jzos.Zfile
Thin JNI wrapper for "C" library I/O routines
Constructor: file name and a mode
–zFile = new ZFile(clusterName, "ab+,type=record");
–ZFile dd = new ZFile("//DD:MYDD", "r");
–ZFile dsn = new ZFile("//'SYS1.HELP(ACCOUNT)'", "rt,type=record");
File name can be a PDS, a PDS member, a DD name, or a VSAM cluster
Accessing VSAM Data
Use Zfile for KSDS, LSDS type VSAM files
String filename = "//DD:KSDS";
String options = "ab+,type=record";
int lrecl = 80;
int keyLen = 8;
ZFile zfile = new ZFile(filename, options)
Methods:
– write(), locate(), read(), update
Zfile: Transaction mode
Open a transaction record dataset:
–ZFile dsn = new ZFile("//SEQ", “rb,type=record,noseek");
–Opens a transaction record for read in binary mode
–“noseek” provides optimal performance for sequential access
FileFactory
• Platform-portable BufferedReader, BufferedWriter, InputStream, or
OutputStream on a text file or a MVS dataset.
rdr = FileFactory.newBufferedReader(“//ZNDVR.PROCLIB”);
wtr = FileFactory.newBufferedWriter(“/home/proclib.txt”);
• Examples:
–/etc/profile
–//DD:INPUT
–//'SYS1.MACLIB(ABEND)'
–//MY.DATASET
Accessing ZFS/HFS Data
Use java.io packages
–Just like accessing distributed data
java.nio
– Improved performance in the areas of buffer management, scalable network and
file I/O, character-set support, and regular-expression matching
Use FileFactory if you need portability
–Test locally on Windows , run in dev/prod against PDS/VSAM data
Data Type Conversion
ByteUtil
–Use to convert bytes from packed decimal to Java long, integer, etc
AssemblerDataTypeFactory, CobolDataTypeFactory
–Works as a Factory pattern to create convenience class objects
Convenience classes for conversion to/from Packed Decimals:
–PackedDecimalAsBigDecimalField
–PackedDecimalAsBigIntegerField
–PackedDecimalAsIntField
–PackedDecimalAsLongField
Creating Data Object from Copybooks
JZOS Record Generator Class
–Found in /<cics_installation_directory>/cics/jzos_recgen.jar
–com.ibm.jzos.recordgen.cobol.RecordClassGenerator
Creates convenience classes that represent data in Copybooks
Uses com.ibm.jzos.fields package to get/set data
Much faster than hand coding
less error prone
Run from JCL Batch, or USS command line
Example Conversion
COBOL Copybook Java Class
MvsConsole Operations
MvsConsole.wto = write to operator
– Writes to the system log file in z/OS
MvsConsole.registerMvsCommandCallback Register call back commands
– Allows running batch jobs to receive commands from the system operator
– start (S) , stop (P) , modify (F)
Access Method Services (IDCAMS)
IDCAMS is primarily used to manage VSAM Files
– Can also access catalog facilities
Typically used via JCL files, but can be called using Java (via JZOS)
Getting the JZOS Jar
Included in the IBM Java SDK for z/OS
Download the JAR file from /usr/lpp/java/J6.0/lib/ext/ibmjzos.jar
– FTP
– …or RDz to drag/drop to your project
Put in lib folder of your project
Or create a user library
Must be in classpath at least
Setup the project for usage
User library makes it easy to reuse the JAR file for multiple projects
During export, the jar is copied with the project artifacts
Must have this jar for syntax check and code assist of JZOS objects!
Rational Developer for the Enterprise Tooling
32
Rational Developer for the Enterprise 9.0
Rational Developer for the Enterprise
Rational
Application
Developer for
WebSphere
Software 9.0
Rational
Application
Developer
Rational
Developer for
System z 9.0
Rational
Developer for
System z
Rational
Developer for
AIX and Linux
9.0
C/C++ Edition
AIX COBOL
Edition
Rational Developer
for i 9.0
RPG and COBOL Tools
RPG and COBOL +
Modernization Tools, Java
Edition
RPG and COBOL +
Modernization Tools, EGL
Edition
Rational Business Developer
Rational
Business
Developer 9.0
Rational Business
Developer
RDz Enterprise Tools: Software Analysis
Allows you to run a static analysis of the resources with which you are working to detect
violations of rules and rule categories.
Detects violations of specific programming rules and rule categories and generates a report
in the Software Analyzer Results view
Code can be viewed in a single interface to analyze each component in a multi-language
application…. Java, Cobol and others.
35
RDz Enterprise Tools: Unit Testing
JUnit: A unit test framework for Java
Built into RAD / Eclipse
Tests either pass or fail
Testing in isolation: using Mockito
Mockito is a Java based mocking framework
Only stub what you need, no need to stub everything
Clean and simple syntax
All required documentation can be found in the Javadoc
– EXCELLENT documentation!
– A great example of how to do Java doc right!
Can also create partial mocks
RDz Enterprise Tools: Refactoring
38
Refactoring: make system-wide code changes without
affecting the behavior of the program.
Refactoring commands are available from the context
menus of several Java views (e.g. Package Explorer,
Outline) and editors. Many "apparently simple"
commands, such as Move and Rename, are actually
refactoring operations, since moving and renaming Java
elements often require changes in dependent files.
• Extract a class, method, constant or local variable
• Rename a method, variable or class
• Change a method signature
• Many, many other refactoring actions
Operations can be previewed for all of the changes
resulting from a refactoring action before you choose to
carry them out.
Can be performed by scripts.
Code Coverage
Determines what is tested
Answers the question “Have
I tested enough?”
Enforces governance
among the developers for
unit testing
39
Code Coverage
40
You can customize acceptable coverage levels:
• Type coverage: The percentage of Java types that are
covered in a class
• Method coverage: The percentage of methods that are
covered in a class
• Line coverage: The percentage of lines of code that are
covered in the class file
• Block coverage: The percentage of blocks that are
covered in a class file. A block refers to an executable
unit.
Custom filters control what classes get instrumented in
your project (i.e. filter out POJO classes, etc)
Code Coverage statistics available in multiple views
41
• Java-based, platform-independent, open source build tool
• Similar to the make tool used in C programming.
• Platform independent,
• Build your projects on any Java platform
• Trivia: ANT is an acronym for “Another Neat Tool”
42
RDz Enterprise Tools: Automation: Using Ant
ANT View
Similar to Outline view
Open build files and double click
targets to run
Different tool bar options
44
Gotchas
JZOS calls run through the ISPF gateway
–Multi-dialog type commands cannot be used (i.e. calling REXX functions)
–Keep in mind security and custom user security exits
Don’t try to substitute all your code with Java
–Some apps are better as COBOL, HLASM, or LE
Use the correct JZOS jar for what you expect to run in PROD
– the API has changed slightly from release to release
–Don’t run Java 7 JZOS jar on a Java 6 JVM
45
Best Practices
Make use of the RAD Java tooling
– Refactoring
– Unit Testing
– ANT for build automation, compilation, unit testing, packaging, and deployment
Let JZOS API do the data type conversions
– Understand the Java BigDecimal class and how it relates to currency
Unit testing:
– Use Mockito to mock non-JZOS calls
– Use PowerMock to mock static JZOS calls (Mockito cannot do this, but it otherwise easier to use)
Modify the Java PROC to suit your environment
– You don’t have to use the one provided
– You can create different procs for different situations
Use Team Concert for SCM of the entire application
– Batch JCL scripts, Java classes, web projects
– RTC can do build, promotion & deployment on ALL the artifacts at once 46
Key points to take away
There are many programming options for Java on z/OS
Java is cost-competitive with COBOL, HLASM, and PL/I
loads
Java batch allows you to mix and match batch and OLTP
workloads
Batch loads can be reworked and be more flexible for
your business needs
The JZOS API gives the developer a full range of access
to many MVS subsystems
Rational Developer for the Enterprise is a complete
package for Java development on system z
47
48
Resources
Check out all our links for our presentations, including this one
–https://delicious.com/strongback/tag_bundle/Innovate2013
–“one link to rule them all”
49
About Us: Strongback Consulting
IBM Advanced Business Partner
– Rational, WebSphere, Lotus, Information Management SVP certified
– Strongly focused on Enterprise Modernization and application lifecycle management
– Key Industries Served: Finance, Insurance, Healthcare, Manufacturing, Government
– Rational Design Partner for HATS and other Rational enterprise modernization technologies
Discover us at:
http://www.strongback.us
Subscribe to us at
http://blog.strongbackconsulting.com
Socialize with us on Facebook & LinkedIn
http://www.facebook.com/StrongbackConsulting
http://www.linkedin.com/company/290754