|
||||||||||||
|
OverviewFor this practical we will be focusing on the client API provided by GridSAM, building on the concepts introduced in the Introductory Practical. For those interested, the GridSAM client docs contains a wealth of information concerning GridSAM to do with deployment strategies, development, quality assurance and use cases. Developing GridSAM Java clients in OMIIThe GridSAM client itself is built around a Java API, and the documentation provided by GridSAM includes JavaDocs which you can use as a reference for this practical. This practical will introduce the Java API with the following example: Basically, the example involves submitting JSDL that executes which is constructed in-program to a GridSAM server, and monitoring the job until completion. For this tutorial, you will need an FTP server running to service the staging out requests required by the JSDL (much like in the Introductory Practical): cd <omii_client_home>/gridsam/bin ./gridsam-ftp-server -d ../data/examples/examples -p <port_number> Ensure that <port_number> is different to those also on the same machine as you e.g. 55521, 55522, 55523, etc... You need to create a directory in <omii_client_home>, ensuring it is different to directories created by other users on your machine, eg: mkdir /usr/local/OMIICLIENT/user1 The tutorial materials will now be download, compiled and run in here. We'll refer to this directory as user1 from now on, but you should substitute this with the directory name you have used. The materials necessary for this practical can be found on the website. You can download the materials package either by:
Or:
Then, use the following commands to unpack that archive: cd <omii_client_home>/user1 tar -xzf GSExample-linux.tar.gz You should find the following files:
Before we delve into the API mechanics required to develop code that conducts job submission and monitoring, let us compile and run the code and see what happens. Compile the JavaIt's already compiled, but why not compile it again - at least to verify the compilation script works on your machine before you make big changes to the code. You'll need to edit the file GSExample.java so that it points to the correct server where GridSAM is installed. Change the string omiitest12.omii.ac.uk:18080 to point to the demo GridSAM server (using <server> and <port>). You can then compile the Java: cd <omii_client_home>/user1 ./GSExampleCompile The script looks like this: #!/bin/sh export OMII_CLIENT_HOME=.. export MY_CLASSPATH=.:${OMII_CLIENT_HOME}/gridsam/lib:${OMII_CLIENT_HOME}/conf: for j in `ls ${OMII_CLIENT_HOME}/gridsam/lib/*.jar`; do MY_CLASSPATH=${j}:${MY_CLASSPATH} done echo Compiling the GridSAM client javac -classpath ${MY_CLASSPATH} GSExample.java Which basically compiles GSExample.java against the GridSAM libraries. Run the JavaPrior to running the example client, you also need to define the location of your local FTP server - i.e. your local machine hostname and FTP port, so the GridSAM server is able to stage the output file back to you. You need to change the GSExampleRun script which looks like this: #!/bin/sh export OMII_CLIENT_HOME=.. export ENDORSED=-Djava.endorsed.dirs="${OMII_CLIENT_HOME}/endorsed" export MY_CLASSPATH=.:${OMII_CLIENT_HOME}/gridsam/lib:${OMII_CLIENT_HOME}/lib:${OMII_CLIENT_HOME}/nonPBAC-conf: for j in `ls ${OMII_CLIENT_HOME}/gridsam/lib/*.jar`; do MY_CLASSPATH=${j}:${MY_CLASSPATH} done echo Run the GridSAM client example... java ${ENDORSED} -cp ${MY_CLASSPATH} -Dftp.server="omiitest12.omii.ac.uk:55521" GSExample Therefore, you need to edit it and change the ftp.server property to point to your local FTP server e.g. yourmachine.full.domain:55521. You can then run the script using the simple command: ./GSExampleRun You should see the following output: Run the GridSAM client example... Creating a new client Job Manager... Creating JSDL description... Submitting job to Job Manager... Monitor urn:gridsam:18ce6dda0bf0fd73010bf74b54420043 until completion... -> Current status of urn:gridsam:18ce6dda0bf0fd73010bf74b54420043: staging-out States: pending, staging-in, staged-in, active, executed, staging-out, -> Current status of urn:gridsam:18ce6dda0bf0fd73010bf74b54420043: done States: pending, staging-in, staged-in, active, executed, staging-out, staged-out, done, Example complete - you can view the output stdout.txt and stderr.txt in your FTP datastaging directory. Like the GridSAM status command, you can see the various stages the job has traversed, except this client operates for the lifetime of the job and continually outputs the job status. Typical Java Client Development ProcessThe process, from a client point of view, to achieve submitting a job and monitoring it until completion is as follows:
We'll now look at each of these activities and how they are achieved. The JavaYou should be able to determine the rationale behind the following yourself:
ExercisesDevelop the Java client:
|
|||||||||||
|
||||||||||||