Hello, I am new to Coz:Launcher and DataSet pipes. So I thought I would outline my needs so if any of you could advise better ways or best practices, I would really appreciate it
1) There's n no of JCL steps and the nth step produces an output file
2) I need to use this output file as input to a Java program running on a z/Linux virtual server on System z (not z/OS, but z/Linux)
It would be nice if I could pass the input file name as a parameter (arg[0]) to the Java program from the JCL
From what little I've read, it look likes I can use the Coz:Launcher (COZPROC) to communicate to z/Linux server. Will I need to specify a shell script or can I specify a Java program? Should I use the fromdsn dataset pipe command to pass the file name as args[0] for the Java program? Thanks for your time.
Executing a Java program on z/Linux from a JCL
I'm not sure if I understand your requirements exactly, but I assume that you would want a job that has a step that creates a dataset (this could be a temporary dataset that is "passed" to the second step).
The second step would execute the Co:Z Launcher and would have a DD that refers back to the passed dataset. This step would run the java program on the remote Linux box and use the "fromdsn" command to pipe the passed dataset into stdin (in Java, this would be the System.in InputStream).
Example:
Of course, it doesn't have to be a java program. Any program running on Linux can be piped the output of fromdsn as input. An interesting benefit of this approach is that the java program is reading the output of the fromdsn command at the same time that the fromdsn command is downloading more data - you don't have to wait until the file is transferred to start processing it.
Hope this helps.
The second step would execute the Co:Z Launcher and would have a DD that refers back to the passed dataset. This step would run the java program on the remote Linux box and use the "fromdsn" command to pipe the passed dataset into stdin (in Java, this would be the System.in InputStream).
Example:
Code: Select all
// EXEC PGM=MYPROG
//OUTPUT DD DSN=&&TEMP1,DISP=(NEW,PASS),
// DCB=...,SPACE=...
// EXEC PGM=COZPROC,ARGS='myuid@mylinux.myco.com'
//INPUT DD DSN=&&TEMP1,DISP=(OLD,DELETE)
//STDIN DD *
export CLASSPATH=...
fromdsn //DD:INPUT | java MyClass
//
Hope this helps.
Thanks Dovetail. That's what I want. I do have some questions though
1) Is there a way to pass arguments to the Java program, like args[0] etc.,
2) I hope the Java program will wait until the file is done downloading because the file is an XML file and if the Java program starts processing while the download is still in progress, then it's not going to like the XML document
Thanks again
1) Is there a way to pass arguments to the Java program, like args[0] etc.,
2) I hope the Java program will wait until the file is done downloading because the file is an XML file and if the Java program starts processing while the download is still in progress, then it's not going to like the XML document
Thanks again
I'm not sure what I'm doing wrong here, but it looks like the data in the mainframe dataset is not going over to zLinux because I'm getting a NullPointerException when trying to write out1. If any of you guys out there could throw a pointer to what I'm doing wrong, I would really appreciate it...
Here's my Java code:
[code]
BufferedReader in1 = null;
BufferedWriter out1 = null;
try {
in1 = new BufferedReader(new InputStreamReader(System.in));
out1 = new BufferedWriter(new FileWriter("/test/zLinux.txt", true));
String str = "";
while (str != null) {
str = in1.readLine();
out1.write(str); //NullPointerException on this line
}
} catch (IOException e)
[/code]
Here's my JCL:
[code]
//RUNCOZ EXEC PROC=COZPROC,ARGS='test1@xxx.yyy.zzz.xxx'
//INPUT DD DISP=SHR,DSN=TEST.DATASET.NAME
//STDOUT DD SYSOUT=*
//COZCFG DD *
ssh-options=-F /u/cs@sdf/config
//STDIN DD *
fromdsn //DD:INPUT | java -jar /opt/java/jar/TestJar.jar
[/code]
And this is the error I'm seeing in STDERR
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Writer.java:147)
at dp.TestJar.main(TestJar.java:20)
I can execute java programs, but it's the data transfer part I'm stuck with.
Thanks!
Here's my Java code:
[code]
BufferedReader in1 = null;
BufferedWriter out1 = null;
try {
in1 = new BufferedReader(new InputStreamReader(System.in));
out1 = new BufferedWriter(new FileWriter("/test/zLinux.txt", true));
String str = "";
while (str != null) {
str = in1.readLine();
out1.write(str); //NullPointerException on this line
}
} catch (IOException e)
[/code]
Here's my JCL:
[code]
//RUNCOZ EXEC PROC=COZPROC,ARGS='test1@xxx.yyy.zzz.xxx'
//INPUT DD DISP=SHR,DSN=TEST.DATASET.NAME
//STDOUT DD SYSOUT=*
//COZCFG DD *
ssh-options=-F /u/cs@sdf/config
//STDIN DD *
fromdsn //DD:INPUT | java -jar /opt/java/jar/TestJar.jar
[/code]
And this is the error I'm seeing in STDERR
Exception in thread "main" java.lang.NullPointerException
at java.io.Writer.write(Writer.java:147)
at dp.TestJar.main(TestJar.java:20)
I can execute java programs, but it's the data transfer part I'm stuck with.
Thanks!
Can you transfer the file independently to the target system and run your Java program with it?
cat file | java -jar /opt/java/jar/TestJar.jar
Or, instead of piping the file directly from fromdsn, put it into an intermediate file so that when your Java program fails, you can look at the file you are processing to see what is the matter:
Of course, its better not to use an intermediate file so as to overlap transfer with processing, but with the above change if you Java program blows up, you know that is has nothing to do with Co:Z
cat file | java -jar /opt/java/jar/TestJar.jar
Or, instead of piping the file directly from fromdsn, put it into an intermediate file so that when your Java program fails, you can look at the file you are processing to see what is the matter:
Code: Select all
//RUNCOZ EXEC PROC=COZPROC,ARGS='test1@xxx.yyy.zzz.xxx'
//INPUT DD DISP=SHR,DSN=TEST.DATASET.NAME
//STDOUT DD SYSOUT=*
//COZCFG DD *
ssh-options=-F /u/cs@sdf/config
//STDIN DD *
fromdsn //DD:INPUT > /tmp/testfile.txt
cat /tmp/testfile.txt | java -jar /opt/java/jar/TestJar.jar
Of course, its better not to use an intermediate file so as to overlap transfer with processing, but with the above change if you Java program blows up, you know that is has nothing to do with Co:Z
Thanks to Dovetail, this problem has been resolved. The change we had to make was to add
to
Since we were using hipersockets and the transaction always stayed inside the z, we didn't have a problem turning ssh-tunnel to false.
Code: Select all
ssh-tunnel=false
Code: Select all
//COZCFG DD *
ssh-options=-F /u/cs@sdf/config