Tags:
, view all tags

[ WORK IN PROGRESS ]

Preliminaries: build machine configuration

Before developing a CREAM's CLI you must configure properly a SL5_64bit machine with EPEL repositories and basic EMI1 software. Instructions are here:

http://wiki.italiangrid.org/twiki/bin/view/CREAM/SystemAdministratorGuideForEMI1#1_3_Installation .

Here are summarized all the steps described in the link above plus some more rpm to install and other settings:

\rm /etc/yum.repos.d/dag.repo
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://emisoft.web.cern.ch/emisoft/dist/EMI/1/sl5/x86_64/base/emi-release-1.0.0-1.sl5.noarch.rpm
yum -y install ./emi-release-1.0.0-1.sl5.noarch.rpm
wget http://repository.egi.eu/sw/production/cas/1/current/repo-files/egi-trustanchors.repo -O /etc/yum.repos.d/egi-trustanchors.repo
wget http://forge.cnaf.infn.it/frs/download.php/101/disable_yum.sh
chmod +x disable_yum.sh
./ disable_yum.sh
yum clean all; yum update all
yum -y install yum-protectbase.noarch
yum -y install ca-policy-egi-core
yum -y install glite-ce-cream-client-api-c.x86_64
yum -y install glite-lbjp-common-gsoap-plugin
yum -y install boost-devel
yum -y install voms-devel voms-clients

Then, download, build and install gSOAP 2.7.6b from this URL:

https://etics-repository.cern.ch/repository/download/registered/externals/gsoap/2.7.6b/src/

Now create these symlinks:

ln -s /usr/lib64/liblog4cpp.so.4 /usr/lib64/liblog4cpp.so
ln -s /usr/lib64/libclassad.so.1 /usr/lib64/libclassad.so
ln -s /usr/lib64/libclassad_ns.so.1 /usr/lib64/libclassad_ns.so
ln -s /usr/lib64/libcares.so.2 /usr/lib64/libcares.so
ln -s /usr/lib64/libglobus_common.so.0 /usr/lib64/libglobus_common.so
ln -s /usr/lib64/libglobus_gsi_callback.so.0 /usr/lib64/libglobus_gsi_callback.so
ln -s /usr/lib64/libglobus_gssapi_gsi.so.4 /usr/lib64/libglobus_gssapi_gsi.so
ln -s /usr/lib64/libglobus_gsi_credential.so.1 /usr/lib64/libglobus_gsi_credential.so
ln -s /usr/lib64/libltdl.so.3 /usr/lib64/libltdl.so
ln -s /usr/lib64/libglobus_oldgaa.so.0 /usr/lib64/libglobus_oldgaa.so
ln -s /usr/lib64/libglobus_proxy_ssl.so.1 /usr/lib64/libglobus_proxy_ssl.so
ln -s /usr/lib64/libglobus_openssl_error.so.0 /usr/lib64/libglobus_openssl_error.so
ln -s /usr/lib64/libglobus_gsi_proxy_core.so.0 /usr/lib64/libglobus_gsi_proxy_core.so
ln -s /usr/lib64/libglobus_gsi_cert_utils.so.0 /usr/lib64/libglobus_gsi_cert_utils.so
ln -s /usr/lib64/libglobus_gsi_sysconfig.so.1 /usr/lib64/libglobus_gsi_sysconfig.so
ln -s /usr/lib64/libglobus_openssl.so.0 /usr/lib64/libglobus_openssl.so

CLI Development

Building of the example source code (see attachments)

In the attachments you can find small examples that explain how to use the CREAM Client API C++. You can build them by issuing the commands:

COMPILATION:
g++ -c -I/usr/local/include <EXAMPLE>.cpp
LINKING:
g++ -o <EXAMPLE> <EXAMPLE>.o -lglite_security_gsoap_plugin_276b \
   -lglite_ce_cream_client_soap -lglite_ce_cream_client_util \
   /usr/local/lib/libgsoap++.a -lboost_thread -llog4cpp \
   -lvomsapi -lclassad_ns -lgridsite -lboost_regex

Quick overview of the API

Currently, the C++ API implements the following operations:

The API architecture is founded on a super and abstract class AbsCreamProxy that exposes 3 relevant public methods: AbsCreamProxy::setCredential(...), AbsCreamProxy::setConnectionTimeout(...), AbsCreamProxy::execute(...). The method execute(...) is pure virtual.

There're several AbsCreamProxy's subclasses, one for each operation mentioned above: CreamProxy _Start, CreamProxy _Register, CreamProxy _Cancel, and so on. Each of them implements its own execute(...) method, specific for the kind of operation the subclass itself represents; this implementation is responsible for the connection to the remote Web Service (CREAM), sending the SOAP request, receiving the SOAP response and unserializing it and hides the user from any SOAP communication and authentication detail. All the subclasses have protected constructors, so the developer cannot directly create a subclass, but she/he must use a special factory named CreamProxyFactory. For each operation the factory has a make_<OPERATION_NAME>(...) method. The factory's 'make' methods return a pointer to an AbsCreamProxy object (polimorphic object) that allows the developer to handle more instances of different subclasses in the same way (for example to put all of them in a container). The 'make' methods take different parameters depending on the kind of operation is performed by the returned object.

When the user got a pointer to AbsCreamProxy she/he has to invoke the setCredential(...) method in order to set the authentication credentials, optionally invoke the setConnectionTimeout(...) in order to set a maximum socket timeout for the connections with the CREAM service, and then must invoke execute(...) to actually communicate with the service (send SOAP request, receive and parse SOAP response).

It is clear that the developer has to know nothing about subclasses: she/he just uses factory's make methods and the two methods setCredential(...) and execute(...); then the subclasses are not documented at all. The API documentation only describes the AbsCreamProxy, the factory and the data structures to pass as argument of the 'make' methods of the factory.

At the end, the user must delete the pointer to AbsCreamProxy in order to free the heap-memory that the factory allocated.

Step by step Job Submission explanation

Proxy Delegation

In order to register a job, the user must previously delegate a proxy into the remote CREAM CE service. The procedure is a matter of a few steps:

  • define an arbitrary string containing a delegation identifier (it will be used later as job parameter for registration of one or more jobs); please consider the importance of re-use a single delegation identifier for multiple job submissions; in fact the delegation process takes some time and can be a large overhead for the submission process
  • create an instance of a subclass of AbsCreamProxy with the invocation of the static method CreamProxyFactory::make_CreamProxyDelegate(...)
  • invoke the setCredential(...) method on the instance created above
  • invoke the execute(...) method on the instance created above
  • delete the AbsCreamProxy instance
Download the example code in attach ( tryDelegate.cpp ) and build it with the instructions described above.

Job Registration

The steps for the 'JobRegister operation are:

  • Prepare one or more strings containing the JDL descriptions of one or more jobs to submit
  • Obtain a delegation identifier of a pre-delegated proxy (see Proxy Delegation)
  • Prepare one JobDescriptionWrapper object for each job to submit to the CREAM CE
  • Put all the JobDescriptionWrapper objects in a list (see below)
  • Create an instance of a subclass of AbsCreamProxy with the invocation of the static method CreamProxyFactory::make_CreamProxyRegister(...)
  • Invoke the setCredential(...) method on the instance created above
  • Invoke the execute(...) method on the instance created above
  • Process the output
  • Delete the AbsCreamProxy instance
The input and output arguments of the CreamProxyFactory::make_CreamProxyRegister(...) are a bit more complicated than in the case of the Proxy Delegation. As described in the API reference, the input and output arguments are: They are typedef for (respectively): The first one is simply a C++ STL list where the user has to insert pointers to JobDescriptionWrapper objects; the second one is a complex structure based on the boost::tuple library. Each JobDescriptionWrapper object is built with a JobDescription identifier (an arbitrary string chosen by user) and other parameters that can been seen in example source code tryRegister.cpp. After the invocation of the execute(...) method, the second argument (passed to the CreamProxyFactory::make_CreamProxyRegister(...) function as output parameter) will be filled as follows:
  • The key of the map is the JobDescription identifier (as defined by the user)
  • The value corresponding to the key is a boost::tuple;
this tuple groups three elements:
  • The result of the operation, JobIdWrapper::RESULT
  • The Job (represented by a JobIdWrapper object, use the getCreamJobID method to obtain the Cream Job ID that you will need to start later)
  • A string representing an error message (non empty if the first element is different than JobIdWrapper::OK)
As shown in the example source code tryRegister.cpp, a mandatory argument is autostart. In the example it is set to false; this means that the job is ONLY REGISTERED and NOT STARTED. Below it is explained the usefulness of autostart set to false. If she/he needs to start the job immediately after registration she/he can set to true the autostart parameter. An array of properties (implemented as a std::map < string, string >, i.e. couples key -> value ) is embedded in the JobIdWrapper object returned by JobRegister operation. At the moment the only relevant property returned by CREAM is the remote path in the CE the user can send its InputSandbox to.

  • Example code for single job submission is here
  • Example code for multiple job registration with a single remote call is here

Job start

In the previous example, jobs are simply registered in the CREAM CE (autostart is set to false). This is useful if the user needs to do something between job registration and job start (e.g.: sending an input sandbox in the remote path specified by the CREAM CE for each job after the registration). To explicitly start a job the user must:

  • Obtain the Cream Job IDs of the jobs to start (as result of JobRegister operation)
  • Build the JobIdWrapper object representing the jobs to start (one for each Cream Job ID to start)
  • Define a time range (specified by two variables fromDate and toDate) which will allow her/him to only start the jobs that were registered in the time range [fromDate, toDate]
  • Build a JobFilterWrapper with all the JobIdWrapper objects representing the jobs to start, and the time range
  • Create the proper subclass of AbsCreamProxy by invoking the static factory method CreamProxyFactory::make_CreamProxyStart(...)
  • Invoke, as usual, the setCredential(...) and execute(...) methods on the previously created AbsCreamProxy's instance
To start all her/his jobs, the user has to use an empty vector of JobIdWrapper objects as argument of the JobFilterWrapper's costructor.

[ TO BE CONTINUED ... ]

-- AlviseDorigo - 2011-06-14

Topic attachments
I Attachment Action Size Date Who Comment
C source code filecpp tryCancel.cpp manage 4.3 K 2011-06-20 - 08:29 AlviseDorigo  
C source code filecpp tryDelegate.cpp manage 1.3 K 2011-06-15 - 07:03 AlviseDorigo  
C source code filecpp tryInfo.cpp manage 4.6 K 2011-06-20 - 08:29 AlviseDorigo  
C source code filecpp tryList.cpp manage 1.2 K 2011-06-20 - 08:29 AlviseDorigo  
C source code filecpp tryMultipleRegister.cpp manage 4.7 K 2011-07-06 - 12:55 AlviseDorigo  
C source code filecpp tryRegister.cpp manage 3.6 K 2011-06-15 - 07:03 AlviseDorigo  
C source code filecpp tryServiceInfo.cpp manage 1.6 K 2011-06-20 - 08:29 AlviseDorigo  
C source code filecpp tryStart.cpp manage 4.6 K 2011-06-15 - 07:03 AlviseDorigo  
C source code filecpp tryStatus.cpp manage 4.5 K 2011-06-20 - 08:29 AlviseDorigo  
Edit | Attach | PDF | History: r11 | r8 < r7 < r6 < r5 | Backlinks | Raw View | More topic actions...
Topic revision: r6 - 2011-07-06 - AlviseDorigo
 

  • Edit
  • Attach
This site is powered by the TWiki collaboration platformCopyright © 2008-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback