Reading MVS Datasets via Java Servlets

General discussion on the JZOS batch launcher and toolkit
Post Reply
mwilliam
Posts: 37
Joined: Mon Oct 11, 2004 3:21 pm

Reading MVS Datasets via Java Servlets

Post by mwilliam »

Please note, I’m coming from a tradition mainframe CICS and Batch background, so I’m not sure how to handle native VSAM access via Tomcat or Jetty. However, I have worked with Java & JDBC.

As for reading MVS Datasets in a Batch Java process appears straight forward, because there is usually one instance for any particular file being processed, however I had concerns about using Java Servlets for similar processing.

For example, if two or more Servlets are processing the same file, do I instantiate separate versions of the same ZFile per Servlet or do I create one instance of particular ZFile and share it between Servlets?

Because under OS/390, the JVM is a single address space and with each thread attempting access the same VSAM file (for example), does each occurrence of the file access effect each other even when I/O doesn’t occur on the same record?

Has anyone coding anything different for handling the issue of concurrency? Or is this transparent their online applications?
dovetail
Site Admin
Posts: 2022
Joined: Thu Jul 29, 2004 12:12 pm

Post by dovetail »

If you want to allow servlets to access a VSAM dataset, there are several considerations:

1) Do you want to the VSAM file to be opened more than once simultaneously (each time you process a servlet request)? Probably not.... you would likely want to have the VSAM file opened only once at a time.

2) Will you wish to leave the cluster open between servlet requests?

3) Assuming that the cluster is opened once, will you allow simultaneous requests (from different threads) for reads and writes? (In z/OS Java, each thread is a separate TCB)

Once possible design would be:

- Have a "broker" class which handles I/O to the VSAM cluster. The class will use a singleton pattern so that only once instance will be created at a time. That instance will have an open ZFile instance on the VSAM cluster. The static "getInstance()" method will return the instance, but if it doesn't exist it will create one which will cause the file to be opened.

- A daemon timer Thread will be responsible for closing the instance after some period of inactivity. A shutdown hook will be registered to do the same.

- Servlets that need to read/write the dataset will use the Broker instance to do it; access methods on the Broker class will be synchronized so that only one I/O will be allowed at a time.
Post Reply