Practical using C++ WMProxy API

annuncio pubblicitario
Practical using
C++ WMProxy API
advanced job submission
Emidio Giorgio – [email protected]
Primo Corso INFN per il Porting delle Applicazioni su Grid
Martina Franca 14 November 2007
www.ccr.infn.it
Martina Franca 14 Novembre 2007
http://grid.infn.it/
Scope
•
The practical exercises are to illustrate “how”
– Not using typical jobs for running on a grid!!
– But to show how EGEE grid services are used, jobs are
submitted, output retrieved…and how they can be accessed
from your own programs
•
We will use the Application Programming Interfaces
on a “User Interface” (UI) machine
– “UI” is your interface to the [GILDA] Grid


Where your digital credentials are held
Client tools and libraries are already installed
www.ccr.infn.it
Martina Franca214 Novembre 2007
http://grid.infn.it/
WMProxy
• WMProxy (Workload Manager Proxy)
– is a new service providing access to the gLite Workload
Management System (WMS) functionality through a simple Web
Services based interface.
– has been designed to efficiently handle a large number of
requests for job submission and control to the WMS
– the service interface addresses the Web Services and SOA
(Service Oriented Architecture) architecture standards
– Beside the “classical” Command Line Interface has a complete
set of API through which it can be accessed
– APIs are available for Java, Python, C++
www.ccr.infn.it
Martina Franca314 Novembre 2007
http://grid.infn.it/
API WMProxy usage
overview
• A small set of “external” (to gLite) libraries are needed
in order to succesfully compile
• Everything needed for compilation and execution can
is provided in the attached tarball
• Examples are just examples……you may need to do
some of operations and checks that are normally done
automatically from CLI
• Not all the functions are implemented by the “official”
API….has been necessary to add something….
• Wiki page
– http://repository.gs.ba.infn.it/twiki/bin/view/GILDA/
WMProxyCPPAPI
www.ccr.infn.it
Martina Franca414 Novembre 2007
http://grid.infn.it/
New request types
•
•
•
•
•
Direct Acyclic Graphs of jobs (DAG): set of jobs where the input,
output, or execution of one or more jobs depends on one or more
other jobs
Parametric Jobs: they have one or more parametric attributes in
the JDL, whose values vary according to a parameter
Job Collection : a set of independent jobs that for some reason
(known to the user) have to be submitted, monitored and
controlled as a single request
JDL has been extended to allow specification of the input
sandbox at the level of the compound request (i.e. DAGs,
Collections and Parametric jobs)
Input Sandbox can
–
Be shared among nodes of collection/DAG  saving bandwidth use
–
Contain URI pointing to files on a remote gridFTP server
www.ccr.infn.it
Martina Franca514 Novembre 2007
http://grid.infn.it/
Introduction to the API WMP
practical
• You will:
– Compile a C++ source code which queries WMS on available
resources
– Compile a C++ source code which submit a simple job (not
compound) to the WMS
• Download the tar ball exercise
– http://repository.gs.ba.infn.it/twiki/pub/GILDA/WMProxyCPPAPI/
wmproxy-api-examples.tar.gz
– uncompress it, enter the directory and just type make
– check out executables with --help to see parameters
GLITE_WMPROXY_ENDPOINT=
https://wms1.gs.ba.infn.it:7443/glite_wms_wmproxy_server
6 www.ccr.infn.it
Martina Franca 14 Novembre 2007
http://grid.infn.it/
WMS : References
• WMS User's Guide
– https://edms.cern.ch/file/572489/1/EGEE-JRA1-TEC-572489-WMSguide-v0-2.pdf
• WM Proxy quick start
– http://trinity.datamat.it/projects/EGEE/wiki/wiki.php?
n=WMProxyClient.QuickStart
• WM Proxy API documentation
– http://trinity.datamat.it/projects/EGEE/wiki/wiki.php?
n=WMProxyAPI.APIDocumentation
• JDL Attributes Specification for WM Proxy
– https://edms.cern.ch/file/590869/1/EGEE-JRA1-TEC-590869-JDLAttributes-v0-8.pdf
7 www.ccr.infn.it
Martina Franca 14 Novembre 2007
http://grid.infn.it/
WMProxy Java API
ver 3.1.0
thanks Giuseppe La ROCCA and Tony Calanducci
for slides and examples
Overview of the WMProxy Java API
Software Requirements
Class org.glite.wms.wmproxy.WMProxyAPI
An use case
www.ccr.infn.it
Evento, Luogo,
8 Data odierna -
http://grid.infn.it/
The WMProxy WMS front-end
• The Workload Manager Proxy (WMProxy in short) is the
service responsible to provide access to the WMS
functionality through a Web Service Interface
• The gLite WMProxy services can be either accessed
directly through the published WSDL, the C++ command
line interface, or the API
• You can submit and control the following type of Jobs:
– Job: a simple application
– DAG: a direct acyclic graph of dependent jobs
– Collection: a set of independent jobs
www.ccr.infn.it
Evento, Luogo,
9 Data odierna -
http://grid.infn.it/
Installation guide API JAVA /2
• Axis (http://ws.apache.org/axis/)
where the needed jars are:
axis-ant.jar
axis.jar
jaxrpc.jar
commons-discovery-0.2.jar
commons-logging-1.0.4.jar
log4j-1.2.8.jar
log4j.properties
saaj.jar
wsdl4j-1.5.1.jar
www.ccr.infn.it
dcache-client-1.7.0-31.i586.rpm
Evento, Luogo,
10 Data odierna -
http://grid.infn.it/
Installation guide API JAVA /3
• BouncyCastle (http://www.bouncycastle.org/)
where the needed jar is:
bcprov-jdk14-122.jar
glite-essentials-java-1.2.0-2_EGEE
W A R N I N G
Make sure all the listed jar(s) are included in your
CLASSPATH environment variable !!
11 www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
Installation guide API JAVA /4
• 2.) Install the following component(s) from the latest
gLite release (http://glite.web.cern.ch/glite/
packages):
glite-security-test-utils
glite-security-util-java
glite-security-delegation-java
glite-security-trustmanager
glite-wms-wmproxy-api-java
www.ccr.infn.it
Evento, Luogo,
12 Data odierna -
http://grid.infn.it/
Software Requirements /1
• Verify that your User Interface (UI) or workstation
contains the following rpm package(s):
glite-wms-wmproxy-api-java-3.1.1-1_N20061202.noarch.rpm
glite-wms-ui-api-java-3.1.1-1_N20061202.i386.rpm
glite-security-util-java-1.3.8-1_N20061202.noarch.rpm
glite-security-trustmanager-1.8.8-1_N20061202.noarch.rpm
glite-security-delegation-java-1.4.1-1_N20061202.noarch.rpm
glite-jdl-api-java-3.1.3-1_N20061202.i386.rpm
• If these rpm package(s) are not installed you can
downloaded them from this web page
http://lxb2071.cern.ch:8080/etics/index.jsp
www.ccr.infn.it
Evento, Luogo,
13 Data odierna -
http://grid.infn.it/
WMProxy Java APIs tarball
• WMProxy Java APIs are pure Java APIs
– They can be used from any platform where a Java Virtual
Machine is available and the needer JARs files are found
– You need a proxy anyway
– You can download a tarball with all the req jars at:
•
 https://grid.ct.infn.it/twiki/bin/viewfile/GILDA/ApiJavaWMProxy?
rev=1;filename=WMProxy-api-JARS.tar.gz
export CLASSPATH=glite-wms-ui-api-java.jar:cryptix32.jar:cryptixasn1.jar:puretls.jar:classad.jar:bcprovjdk14-122.jar:saaj.jar:commons-logging-1.1.jar:glite-wmswmproxy-api-java.jar:axis.jar:axis-ant.jar:commonsdiscovery-0.2.jar:glite-security-delegation-java.jar:glite-securitytrustmanager.jar:glite-security-utiljava.jar:jaxrpc.jar:log4j-1.2.8.jar:wsdl4j-1.5.1.jar:glite-jdl-apijava.jar:cog-jglobus.jar:glite-wms-wmproxy-api-java.jar:.
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
org.glite.wms.wmproxy.WMProxyAPI
• The main Java class of this Java API is:
org.glite.wms.wmproxy.WMProxyAPI;
• The class WMProxyAPI provides a set of methods
that allow :
–
–
–
–
–
–
–
–
delegating the credential ;
registering and submitting jobs ;
cancelling the job during its life-cycle ;
retrieving information on the location where the job input
sandbox files can be stored ;
retrieving the output sandbox files list ;
retrieving a list of possible matching Computer Elements ;
getting JDL templates ;
getting information on the user disk quota on the server .
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
WMProxyAPI constructors
• A client object can be created using one of these
following constructor(s):
public WMProxyAPI(String url, String proxyFile)
public WMProxyAPI(String url, String proxyFile,
String certsPath)
where:
– url: the WMProxy server URL to be contacted
(e.g. https://<host>:<port>glite_wms_wmproxy_server);
– proxyFile: the pathname to a valid user proxy;
for the default value (/tmp/x509up_u<UID>)
– certPath: the path of a local CA directory
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
org.glite.wms.wmproxy.WMProxyAPI
Therefore, using one of the constructors
WMProxyAPI Client = new WMProxyAPI( … );
allow the creation of a new instance. This instance will
be used to invoke any other WMProxy methods.
For example:
WMProxyAPI Client = new WMProxyAPI(
https://
trinity.datamat.it:7443/glite_wms_wmproxy_server,
“/x509up_u504”); // replace with your WMProxy endpoint
jobIDs = Client.jobSubmit(jdlString, delegationID);
www.ccr.infn.it
Evento, Luogo,
17 Data odierna -
http://grid.infn.it/
org.glite.wms.wmproxy.WMProxyAPI
• In case of failure, one of the following exceptions is
thrown:
org.glite.wms.wmproxy.AuthenticationFaultType
org.glite.wms.wmproxy.JobUnknownFaultType
org.glite.wms.wmproxy.InvalidArgumentFaultType
org.glite.wms.wmproxy.NoSuitableResourcesFaultType
org.glite.wms.wmproxy.GetQuotaManagementFaultType
org.glite.wms.wmproxy.ProxyFileException
org.glite.wms.wmproxy.GrstDelegationException
org.glite.wms.wmproxy.GenericFaultType
org.gridsite.www.namespaces.delegation_1.DelegationExceptionType
www.ccr.infn.it
Evento, Luogo,
18 Data odierna -
http://grid.infn.it/
JDL Basic Requirement
• The JDL to be matched must contains some mandatory
Requirements and Rank attributes;
– when using command line interface these are added by
default by the UI, but in our case user has to take care to
check if his/her JDL file contains them:
Requirements = (other.GlueCEStateStatus == "Production");
Rank = (-other.GlueCEStateEstimatedResponseTime);
www.ccr.infn.it
Evento, Luogo,
19 Data odierna -
http://grid.infn.it/
Delegation of user credential
• Before calling submission or list match services, client proxy
credentials are requested to be transferred from the client to the
server through a delegation process.
• The following Java code performs this delegation process :
String delegationId = “larocca”;
WMProxyAPI client = new WMProxyAPI
wmproxy_url,user_proxy,CAcertsPath);
/*Get a proxy identified by the delegationID String*/
proxy = client.grstGetProxyReq (delegationId);
/* Allows delegating user’s credential to the WMProxy */
client.grstPutProxy(delegationId, proxy);
The obtained delegation identifier can be reused for several calls to
the WMProxy server;
www.ccr.infn.it
Evento, Luogo,
20 Data odierna -
http://grid.infn.it/
Difference between submission and
registration /1
• Submission of simple jobs, DAGs, collections and parametric jobs
to the WMProxy service requires as input a job description file in
which job characteristics and requirements are expressed by
means of Condor class-ad-like expressions.
• In this description the users can specify some files that are
needed by the submitted jobs during the execution on the remote
Worker Node. These files are listed in the JDL InputSandbox
attribute specifying for each of them the complete URI of its
location.
• If the job does NOT have any file in the InputSandbox to be
transferred from the submitting machine to the WMProxy node,
the submission can be performed a calling the jobSubmit method:
jobIds = client.jobSubmit(jdlString, delegationId);
www.ccr.infn.it
Evento, Luogo,
21 Data odierna -
http://grid.infn.it/
Difference between submission and
registration /2
Otherwise, these following steps are needed:
• a preliminary server registration:
jobId = client.jobRegister(jdlString, delegationId);
• transfer of files listed in the InputSandbox from the
client machine to the WMS node;
• call the jobStart method to trigger the submission:
client.jobStart(jobId);
www.ccr.infn.it
Evento, Luogo,
22 Data odierna -
http://grid.infn.it/
Difference between submission and
registration /2
Otherwise, these following steps are needed:
• a preliminary server registration:
jobId = client.jobRegister(jdlString, delegationId);
• transfer of files listed in the InputSandbox from the
client machine to the WMS node;
• call the jobStart method to trigger the submission:
client.jobStart(jobId);
www.ccr.infn.it
Evento, Luogo,
22 Data odierna -
http://grid.infn.it/
Software Requirements /3
• In order to allow grid user to invoke, within Java code,
the UrlCopy class to copy files from the WMS Server to
the UI and vice versa the following Java package is
requested
cog-jglobus-1.4-bin.tar.gz
The above package, with all the needed
documentation, can be downloaded from this web
page http://dev.globus.org/wiki/CoG_JGlobus_1.4
www.ccr.infn.it
Evento, Luogo,
23 Data odierna -
http://grid.infn.it/
for (int index = 0; index < InputSandboxFiles.length; index++)
{
String toURL = front + “2811” + rear;
toURL = toURL + "/" + InputSandboxFiles[index];
fromURL = "file:///" + InputSandboxFiles[index];
Specify the Destination
and Source URL(s)
try {
GlobusURL from = new GlobusURL(fromURL);
GlobusURL to = new GlobusURL(toURL);
Copy file(s) from the UI to
the Resource Broker
UrlCopy uCopy = new UrlCopy();
uCopy.setDestinationUrl(to);
uCopy.setSourceUrl(from);
uCopy.setUseThirdPartyCopy(true);
uCopy.copy();
} catch (Exception e) {System.err.println(e.getMessage());}
}
The script, thanks to the UrlCopy Class, performs the copy of the InputSandbox files to
the reduced path of the WMS as you can see:
[root@glite-rb2 root]# cd /var/glite/SandboxDir/XA/
[root@glite-rb2 root]# ll https_3a_2f_2fglite-rb2.ct.infn.it_3a9000_2fXAoY7FZgLJgC4U9grsBw/input/
www.ccr.infn.it
Evento, Luogo,
24 Data odierna -
http://grid.infn.it/
org.glite.wms.wmproxy.WMProxyAPI
• In the following tarball:
 https://grid.ct.infn.it/twiki/bin/viewfile/GILDA/ApiJavaWMProxy?
rev=1;filename=WMProxy-api-JARS.tar.gz
• two examples are available (thanks again to
Giuseppe La Rocca):
– WMProxyGetProxyAndSubmit
 Create delegation, transfer InputSandBox files, submit the job
– WMProxyGetOutputAndPurge
 Get OutputSandbox and Purge it
• To set the CLASSPATH properly, use source
setcp.sh
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
Submit a new request to WMProxy /1
[larocca@glite-tutor:~/API]$ java WMProxyGetProxyAndSubmit
WMProxyGetProxyAndSubmit.java
"A simple client to interact with the WMProxy Server."
Author: Giuseppe La Rocca ([email protected])
I.N.F.N. - Sez. of Catania - ITALY
Via S.Sofia, 64 - 95123 Catania
Phone: +39.095.378.53.74
Usage :
java WMProxyGetProxyAndSubmit -h[elp]
java WMProxyGetProxyAndSubmit <user_proxy> <delegation_id> <wmproxy_server>
<InputSandboxFiles>
<jdl_file> <CAcertsPath> [CAs paths (optional)]
where:
<user_proxy>
... the file containing the user's credentials
<delegation_id>
... the string used to save the user's delegation
<wmproxy_server>
... the entry point of the WMProxy Server to contact
(e.g. : https://glite-rb3.ct.infn.it:7443/glite_wms_wmproxy_server
<InputSandboxFiles> ... The list of file(s) to transfer to the WMProxy Server
<jdl_file>
... the jdl file to submit to the grid
<CAcertsPath>
... the path location of the directory containing all the Certificate
Authorities files
www.ccr.infn.it
Evento, Luogo,
26 Data odierna -
http://grid.infn.it/
Retrieve output file(s)
When the job finishes you can retrieve the output file(s) as follow:
[larocca@glite-tutor:~/API]$ java WMProxyGetOutputAndPurge
Usage :
java WMProxyGetOutputAndPurge -h[elp]
java WMProxyGetOutputAndPurge <user_proxy> <wmproxy_server> <jobId>
<dirPath> <CAcertsPath> [CAs paths (optional)]
+------------------------------------------------------------------------+
WMProxy URL = [https://glite-rb2.ct.infn.it:7443/glite_wms_wmproxy_server]
proxyFile
= [/tmp/x509up_u512]
JobID
= [https://glite-rb2.ct.infn.it:9000/XAoY7FZgLJjgCp4U9grsBw]
dirPath
= [/home/larocca/API/]
CA certs
= [/etc/grid-security/certificates/]
+------------------------------------------------------------------------+
Start downloading output file(s)..
file n. 1
-------------------------------------------name = [gsiftp://glite-rb2.ct.infn.it:2811/var/glite/SandboxDir/XA/https_3a_2f_2fgliterb2.ct.infn.it_3a9000_2fXAoY7FZgLJjgCp4U9grsBw/output/hostname.err]
size = [0]
List of file(s) retrieved from to the
Resource Broker to the user’s
account
file n. 2
-------------------------------------------name = [gsiftp://glite-rb2.ct.infn.it:2811/var/glite/SandboxDir/XA/https_3a_2f_2fgliterb2.ct.infn.it_3a9000_2fXAoY7FZgLJjgCp4U9grsBw/output/hostname.out]
size = [28]
www.ccr.infn.it
Evento, Luogo,
27 Data odierna -
http://grid.infn.it/
Monitoring jobs status
• Job status information are not accessible via WMProxy
services
• They are registered into the Logging and Bookkeeping
(LB) server.
• Another set of APIs is available to interact with the LB
(Java/C++/Python)
– Python/Java ones are wrapper around the C++ native libraries,
so those APIs are not portable (works on SLC UI)
– but the WSDL is available, so users can generate their own code
starting from those.
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
LB Java APIs
• The ones needed by WMProxy, plus:
– glite-wms-ui-api-java.jar (org.glite.wmsui.apij.*)
• Javadoc is available here:
– http://egee-jra1-wm.mi.infn.it/egee-jra1-wm/api_doc/
wmsui_apijava/index.html
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
JobStatus example
import org.glite.wmsui.apij.*;
public class JobStatus {
public static void main(String[] args) throws Exception {
try{
String jid = args[0] ;
JobId jobid = new JobId(jid);
Job job = new Job(jobid);
Result res = job.getStatus(false) ;
System.out.println(res.toString());
}catch(UnsupportedOperationException exc){
........
}catch(java.io.FileNotFoundException exc){
}catch(org.globus.gsi.GlobusCredentialException exc) {
}catch(Exception exc){
}
}
}
www.ccr.infn.it
Evento, Luogo, Data odierna -
http://grid.infn.it/
References
• API Documentation
http://trinity.datamat.it/projects/EGEE/wiki/apidoc/3.1/
htmljava/index.html
• Datamat – WMProxy quickstart
http://trinity.datamat.it/projects/EGEE/wiki/wiki.php?
n=WMProxyClient.QuickStart
• JDL Attributes guide for WMProxy
https://edms.cern.ch/document/590869/1
• WMProxy user guide
https://edms.cern.ch/document/674643/1
www.ccr.infn.it
Evento, Luogo,
31 Data odierna -
http://grid.infn.it/
Scarica