-->

How to implement File Update logic in Chunk Proces

2019-08-24 04:36发布

问题:

I am trying to develop a Java batch program using the IBM's JSR352 Implementation. Since the batch job involves iteratively processing huge number of records, I chose to implement it as Chunk Processing job.

This job involves of 3 steps which keeps repeated for each records in File 1

  1. Reader Class: Read content from File 1 to form a key text
  2. Processor Class: Look-up the Key text in File 2
  3. Writer Class: Update the text in File 2 where key text was found with a custom text

From the processor to writer, I can return all line numbers where the key text matches were found. But, without RandomAccess to file, how can i update those specific line numbers in File 2 from my Writer?

Since I am restricted to use only these Input/Outputstreams for file handling I am unable to split the Lookup & Update logic between processor & writer classes. How can i achieve this ?

This is because the code will be developed in a windows machine but, finally executed in a mainframe (z/os) server.

回答1:

The processor is technically optional, so you could merge the lookup/update logic in just the writer class. That might help.

On z/OS this is easier to do with a VSAM dataset (also accessible via the JZOS ZFile APIs). But that's going to be hard to develop/test on Windows. I suppose you could keep the ZFile calls separate and on Windows replace them with some rigged up emulation that would work well enough for testing purposes.



回答2:

I finally had to drop the JZOS FileFactory based approach and use the JZOS ZFile's locate API to find the the specific lines (using keys) and update it from the writer.