L&B Java API
From EUAGwiki
Contents |
[edit] LB Java API
[edit] Lectured by
Giuseppe LA ROCCA
Italian National Institute of Nuclear Physics
Italy
mailto:giuseppe.larocca@ct.infn.it
[edit] About this page
Goal of this wiki page is to provide some hints and examples about how to interact with the Logging and Bookkeeping (L&B) service using the dedicated Java API exposed by the web server. Logging and Bookkeeping (L&B) service keeps track of grid jobs. The service receives job events from various components of the Workload Management System, stores them, and derives then the corresponding job states. Job information is fed into LB through a logging interface (legacy C and shell API) and it is not exposed as a web service yet.
The users may query job states or retrieve LB events either via the same C/C++ interface or via this web-service interface.
Besides querying for the job state actively the user may also register for receiving notifications on particular job state changes. This functionality is supported only in the legacy C/C++ interface.
[edit] Provided interfaces
- legacy interface - custom protocol, using libraries in C language on client side;
- webservice interface - anything supporting SSL compatible with Globus on client side.
Webservices are provided by gSoap (written in C language).
[edit] Needed packages
Copy the following files to lib/ directory:
AXIS
* axis-ant.jar * axis.jar * commons-discovery-0.2.jar * commons-logging-1.0.4.jar * jaxrpc.jar * log4j.properties * log4j-1.2.13.jar * saaj.jar * wsdl4j-1.5.1.jar
trustmanager
* glite-security-trustmanager.jar * glite-security-util-java.jar
[edit] How to generate stubs
export COG_LIB=./cog-lib export AXIS_LIB=$COG_LIB export AXISCLASSPATH=$AXIS_LIB/axis.jar:$AXIS_LIB/commons-discovery.jar:$AXIS_LIB/commons-logging.jar:$AXIS_LIB/jaxrpc.jar:$AXIS_LIB/saaj.jar:$AXIS_LIB/log4j-1.2.8.jar:$AXIS_LIB/wsdl4j.jar export COGCLASSPATH=$COG_LIB/cog-axis.jar:$COG_LIB/cog-jglobus.jar:$COG_LIB/cog-url.jar:$COG_LIB/cryptix32.jar:$COG_LIB/cryptix-asn1.jar:$COG_LIB/puretls.jar:$COG_LIB/jce-jdk13-131.jar # # Generate the stubs from the LB WSDLs via Axis # java -cp $AXISCLASSPATH org.apache.axis.wsdl.WSDL2Java LB.wsdl
[edit] How to build the example
javac -classpath $AXISCLASSPATH:$COGCLASSPATH holders/*.java \
org/glite/wsdl/*/lb/*.java \
org/glite/wsdl/types/lb/holders/*.java \
LBGetJobStatus.java
java -cp $AXISCLASSPATH:$COGCLASSPATH:. LBGetJobStatus \
https://glite-wms.grid.itb.ac.id:9003 \ <== Customize here!!
$X509_USER_PROXY \
$1
[edit] Material and instructions for use
In attach you can find a tarball with the JAVA source files implementing what described above. If you have a shell on a linux machine, download the tar ball with the examples typing
wget http://grid.ct.infn.it/api-java/Api-Java-LB.tar.gz
Uncompress the tar in your working directory using the command:
$ tar zxvf Api-Java-LB.tar.gz Api-Java-LB/ Api-Java-LB/cog-lib/ Api-Java-LB/cog-lib/addressing-1.0.jar Api-Java-LB/cog-lib/axis-url.jar Api-Java-LB/cog-lib/axis.jar Api-Java-LB/cog-lib/bootstrap.jar Api-Java-LB/cog-lib/cog-axis.jar Api-Java-LB/cog-lib/cog-jglobus.jar [cut ..]
These are the files you should find in the working directory
$ cd Api-Java-LB $ ls -al drwxr-xr-x 2 larocca users 8192 Oct 10 2008 cog-lib -rwxr-xr-x 1 larocca users 788 Jan 16 10:56 generate.sh drwxr-xr-x 2 larocca users 8192 Oct 12 11:36 help drwxr-xr-x 2 larocca users 8192 Oct 12 11:44 holders -rw-r--r-- 1 larocca users 8922 Jan 15 17:14 LBGetJobStatus.java -rw-r--r-- 1 larocca users 76703 Jun 24 2008 LBTypes.wsdl -rw-r--r-- 1 larocca users 11555 Jun 24 2008 LB.wsdl drwxr-xr-x 3 larocca users 8192 Oct 10 2008 org
In order to make easier the properly set up of the environment and to build all the source files, the following bash script has been create
$ cat generate.sh
unset CLASSPATH
export CLASSPATH=.:./cog-lib/axis.jar:./cog-lib/commons-discovery.jar:./cog-lib/commons-logging.jar:./cog-lib/jaxrpc.jar:./cog-lib/saaj.jar:./cog-lib/log4j-1.2.8.jar:./cog-lib/wsdl4j.jar:./cog-lib/cog-axis.jar:./cog-lib/cog-jglobus.jar:./cog-lib/cog-url.jar:./cog-lib/cryptix32.jar:./cog-lib/cryptix-asn1.jar:./cog-lib/puretls.jar:./cog-lib/jce-jdk13-131.jar
#
# Generate the stubs from the LB WSDLs via Axis
#
#java -cp $AXISCLASSPATH org.apache.axis.wsdl.WSDL2Java LB.wsdl
javac -classpath $CLASSPATH holders/*.java \
org/glite/wsdl/*/lb/*.java \
org/glite/wsdl/types/lb/holders/*.java \
LBGetJobStatus.java
if [ "X$1" != "X" ] ; then
java -cp $CLASSPATH:. LBGetJobStatus \
https://glite-wms.grid.itb.ac.id:9003 \ <== Customize here!!
$X509_USER_PROXY \
$1
else
echo "JobID is missing."
fi
Before to start don't forget to create your proxy
$ voms-proxy-init --voms euasia Cannot find file or dir: /home/larocca/.glite/vomses Enter GRID pass phrase: Your identity: /C=IT/O=INFN/OU=Personal Certificate/L=Catania/CN=Giuseppe La Rocca Creating temporary proxy ......................................................... Done Contacting voms.grid.sinica.edu.tw:15015 [/C=TW/O=AS/OU=GRID/CN=voms.grid.sinica.edu.tw] "euasia" Done Creating proxy ................................................... Done Your proxy is valid until Mon Jan 18 21:46:41 2010
$ voms-proxy-info --all subject : /C=IT/O=INFN/OU=Personal Certificate/L=Catania/CN=Giuseppe La Rocca/CN=proxy issuer : /C=IT/O=INFN/OU=Personal Certificate/L=Catania/CN=Giuseppe La Rocca identity : /C=IT/O=INFN/OU=Personal Certificate/L=Catania/CN=Giuseppe La Rocca type : proxy strength : 1024 bits path : /tmp/x509up_u560 timeleft : 11:59:57 === VO euasia extension information === VO : euasia subject : /C=IT/O=INFN/OU=Personal Certificate/L=Catania/CN=Giuseppe La Rocca issuer : /C=TW/O=AS/OU=GRID/CN=voms.grid.sinica.edu.tw attribute : /euasia/Role=NULL/Capability=NULL timeleft : 11:59:57 uri : voms.grid.sinica.edu.tw:15015
[edit] Example of API usage
Submit a simple job using CL interface or WMProxy Java API, then check the status of your job as follow:
$ ./generate.sh https://glite-wms.grid.itb.ac.id:9000/zFOt6qJJUKxFT_2tj5aWAg Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. [main] INFO LBGetJobStatus - endpoint being used https://glite-wms.grid.itb.ac.id:9003 [main] INFO LBGetJobStatus - proxy location being used /tmp/x509up_u512 [main] INFO LBGetJobStatus - proxy DN = /C=IT/O=INFN/OU=Personal Certificate/L=INFN Catania/CN=Giuseppe La Rocca [main] INFO LBGetJobStatus - service name LoggingAndBookkeeping [main] INFO LBGetJobStatus - LB version 1.9.2 [main] INFO LBGetJobStatus - |---------------------------------------------------------------------------------------------------------| [main] INFO LBGetJobStatus - Status info for the Job : https://glite-wms.grid.itb.ac.id:9000/zFOt6qJJUKxFT_2tj5aWAg [main] INFO LBGetJobStatus - Owner : /C=IT/O=GILDA/OU=Personal Certificate/L=INFN Catania/CN=Giuseppe La Rocca [main] INFO LBGetJobStatus - Current Status : DONE [main] INFO LBGetJobStatus - Status Reason : Job terminated successfully [main] INFO LBGetJobStatus - Exit Code : 0 [main] INFO LBGetJobStatus - Destination : lcg00125.grid.sinica.edu.tw:2119/jobmanager-lcgpbs-euasia [main] INFO LBGetJobStatus - |---------------------------------------------------------------------------------------------------------|
[edit] Api Documentation
http://egee.cesnet.cz/mediawiki/index.php/Webservice_interfaces:LB
[edit] References
http://egee.cesnet.cz/mediawiki/index.php/Webservice_interfaces
