From ff13bc48609516df8156c8bc53fac6900a6c154c Mon Sep 17 00:00:00 2001 From: Fons Rademakers <Fons.Rademakers@cern.ch> Date: Wed, 30 Jan 2008 12:22:11 +0000 Subject: [PATCH] From Anar Manafov: plugin for gLite using TGrid interface. The TGLite class defines an interface to gLite GRID services. This class is a part of RGlite plug-in developed at GSI, Darmstadt. The RGLite plug-in uses glite-api-wrapper library (GAW) to perform Grid operations and provides the following featuries: - Workload Management System operations - File Catalog operations (gLite/LCG LFC API) - An executive logging - Support of an external xml configuration file with according XML schema git-svn-id: http://root.cern.ch/svn/root/trunk@21921 27541ba8-7e3a-0410-8455-c3a389f83636 --- Makefile | 5 +- alien/inc/TAlien.h | 1 - config/Makefile.in | 5 + configure | 29 ++ etc/plugins/TGrid/P020_TGLite.C | 5 + glite/Module.mk | 67 ++++ glite/inc/LinkDef.h | 12 + glite/inc/TGLite.h | 78 ++++ glite/inc/TGLiteJob.h | 46 +++ glite/inc/TGLiteJobStatus.h | 51 +++ glite/inc/TGLiteResult.h | 61 +++ glite/src/TGLite.cxx | 644 ++++++++++++++++++++++++++++++++ glite/src/TGLiteJob.cxx | 116 ++++++ glite/src/TGLiteJobStatus.cxx | 106 ++++++ glite/src/TGLiteResult.cxx | 223 +++++++++++ 15 files changed, 1447 insertions(+), 2 deletions(-) create mode 100644 etc/plugins/TGrid/P020_TGLite.C create mode 100644 glite/Module.mk create mode 100644 glite/inc/LinkDef.h create mode 100644 glite/inc/TGLite.h create mode 100644 glite/inc/TGLiteJob.h create mode 100644 glite/inc/TGLiteJobStatus.h create mode 100644 glite/inc/TGLiteResult.h create mode 100644 glite/src/TGLite.cxx create mode 100644 glite/src/TGLiteJob.cxx create mode 100644 glite/src/TGLiteJobStatus.cxx create mode 100644 glite/src/TGLiteResult.cxx diff --git a/Makefile b/Makefile index 01f39a545f7..51b97a90073 100644 --- a/Makefile +++ b/Makefile @@ -120,6 +120,9 @@ endif ifeq ($(BUILDG4ROOT),yes) MODULES += g4root endif +ifeq ($(BUILDGLITE),yes) +MODULES += glite +endif ifeq ($(BUILDCHIRP),yes) MODULES += chirp endif @@ -230,7 +233,7 @@ MODULES += unix winnt x11 x11ttf win32gdk gl ftgl rfio castor \ ldap mlp krb5auth rpdutils globusauth pyroot ruby gfal \ qt qtroot qtgsi xrootd netx proofx alien clarens peac oracle \ xmlparser mathcore mathmore reflex cintex roofitcore roofit \ - minuit2 monalisa fftw odbc unuran gdml eve g4root cint7 + minuit2 monalisa fftw odbc unuran gdml eve g4root cint7 glite MODULES := $(sort $(MODULES)) # removes duplicates endif diff --git a/alien/inc/TAlien.h b/alien/inc/TAlien.h index f32fd3d5fc7..31d236adb36 100644 --- a/alien/inc/TAlien.h +++ b/alien/inc/TAlien.h @@ -19,7 +19,6 @@ // // // Class defining interface to TAlien GRID services. // // // -// // ////////////////////////////////////////////////////////////////////////// #ifndef ROOT_TGrid diff --git a/config/Makefile.in b/config/Makefile.in index ee010b2eade..23ea4738c2e 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -135,6 +135,11 @@ G4LIBDIR := @g4libdir@ G4INCDIR := $(filter-out /usr/include, @g4incdir@) CLHEPINCDIR := $(filter-out /usr/include, @clhepincdir@) +BUILDGLITE := @buildglite@ +GLITELIBDIR := @glitelibdir@ +GAWLIB := @glitelib@ +GAW_CPPFLAGS := $(filter-out /usr/include, @gaw_cppflags@) + BUILDCHIRP := @buildchirp@ CHIRPLIBDIR := @chirplibdir@ CHIRPCLILIB := @chirplib@ diff --git a/configure b/configure index d7aa2e65111..7caff36872c 100755 --- a/configure +++ b/configure @@ -50,6 +50,7 @@ options=" \ enable_gdml \ enable_gfal \ enable_g4root \ + enable_glite \ enable_globus \ enable_krb5 \ enable_ldap \ @@ -143,6 +144,7 @@ ALIEN \ ASIMAGE \ LDAP \ GLOBUS_LOCATION \ +GLITE \ MONALISA \ SRP \ SSL \ @@ -885,6 +887,7 @@ enable/disable options, prefix with either --enable- or --disable- gfal GFAL support, requires libgfal g4root GEANT4 navigator based on TGeo, requires GEANT4 installed globus Globus authentication support, requires Globus toolkit + glite gLite support, requires libglite-api-wrapper v.3 from GSI (https://subversion.gsi.de/trac/dgrid/wiki) krb5 Kerberos5 support, requires Kerberos libs ldap LDAP support, requires (Open)LDAP libs mathcore Build the new libMathCore math library @@ -2566,6 +2569,28 @@ fi check_explicit "$enable_chirp" "$enable_chirp_explicit" \ "Explicitly required Chirp dependencies not fulfilled" +###################################################################### +# +### echo %%% gLite Support - Third party libraries +# +# (See https://subversion.gsi.de/trac/dgrid/wiki) +# +# Check for libglite-api-wrapper +# +if test ! "x$enable_glite" = "xno" ; then + check_library "libglite-api-wrapper" "$enable_shared" "$glitelibdir" \ + $GAW_LOCATION $GLITE $GLITE/lib ~/GAW/lib /usr/local/lib /usr/lib + glitelib=$found_lib + glitelibdir=$found_dir + gaw_cppflags="${GAW_CPPFLAGS}" + + if test "x$glitelib" = "x"; then + enable_glite="no" + fi +fi +check_explicit "$enable_glite" "$enable_glite_explicit" \ + "Explicitly required gLite dependencies not fulfilled" + ###################################################################### # ### echo %%% AliEn Support - Third party libraries @@ -4557,6 +4582,9 @@ sed -e "s|@aclocaldir@|$aclocaldir|" \ -e "s|@g4libdir@|$g4libdir|" \ -e "s|@clhepincdir@|$clhepincdir|" \ -e "s|@enable_xft@|$enable_xft|" \ + -e "s|@glitelib@|$glitelib|" \ + -e "s|@glitelibdir@|$glitelibdir|" \ + -e "s|@gaw_cppflags@|$gaw_cppflags|" \ < Makefile.tmp > Makefile.tmpp mv Makefile.tmpp Makefile.tmp @@ -4690,6 +4718,7 @@ sed -e "s|@srcdir@|$srcdir|" \ -e "s|@buildxrdgsi@|$buildxrdgsi|" \ -e "s|@buildclarens@|$enable_clarens|" \ -e "s|@buildpeac@|$buildpeac|" \ + -e "s|@buildglite@|$enable_glite|" \ < Makefile.tmp > $MAKEOUT rm -f Makefile.tmp diff --git a/etc/plugins/TGrid/P020_TGLite.C b/etc/plugins/TGrid/P020_TGLite.C new file mode 100644 index 00000000000..289f1f9e88f --- /dev/null +++ b/etc/plugins/TGrid/P020_TGLite.C @@ -0,0 +1,5 @@ +void P020_TGLite() +{ + gPluginMgr->AddHandler("TGrid", "^glite", "TGLite", + "RgLite", "TGLite(const char*,const char*,const char*,const char*)"); +} diff --git a/glite/Module.mk b/glite/Module.mk new file mode 100644 index 00000000000..fe8a1a36341 --- /dev/null +++ b/glite/Module.mk @@ -0,0 +1,67 @@ +# Module.mk for glite module +# Copyright (c) 2002 Rene Brun and Fons Rademakers +# +# Author: Fons Rademakers, 12/5/2002 + +MODDIR := glite +MODDIRS := $(MODDIR)/src +MODDIRI := $(MODDIR)/inc + +GLITEDIR := $(MODDIR) +GLITEDIRS := $(GLITEDIR)/src +GLITEDIRI := $(GLITEDIR)/inc + +##### libRgLite ##### +GLITEL := $(MODDIRI)/LinkDef.h +GLITEDS := $(MODDIRS)/G__gLite.cxx +GLITEDO := $(GLITEDS:.cxx=.o) +GLITEDH := $(GLITEDS:.cxx=.h) + +GLITEH := $(filter-out $(MODDIRI)/LinkDef%,$(wildcard $(MODDIRI)/*.h)) +GLITES := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx)) +GLITEO := $(GLITES:.cxx=.o) + +GLITEDEP := $(GLITEO:.o=.d) $(GLITEDO:.o=.d) + +GLITELIB := $(LPATH)/libRgLite.$(SOEXT) +GLITEMAP := $(GLITELIB:.$(SOEXT)=.rootmap) + +# used in the main Makefile +ALLHDRS += $(patsubst $(MODDIRI)/%.h,include/%.h,$(GLITEH)) +ALLLIBS += $(GLITELIB) +ALLMAPS += $(GLITEMAP) + +# include all dependency files +INCLUDEFILES += $(GLITEDEP) + +##### local rules ##### +include/%.h: $(GLITEDIRI)/%.h + cp $< $@ + +$(GLITELIB): $(GLITEO) $(GLITEDO) $(ORDER_) $(MAINLIBS) $(GLITELIBDEP) + @$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \ + "$(SOFLAGS)" libRgLite.$(SOEXT) $@ "$(GLITEO) $(GLITEDO)" \ + "$(GLITELIBEXTRA) $(GLITELIBDIR) $(GAWLIB)" + +$(GLITEDS): $(GLITEH) $(GLITEL) $(ROOTCINTTMPEXE) + @echo "Generating dictionary $@..." + $(ROOTCINTTMP) -f $@ -c $(GLITEH) $(GLITEL) + +$(GLITEMAP): $(RLIBMAP) $(MAKEFILEDEP) $(GLITEL) + $(RLIBMAP) -o $(GLITEMAP) -l $(GLITELIB) \ + -d $(GLITELIBDEPM) -c $(GLITEL) + +all-glite: $(GLITELIB) $(GLITEMAP) + +clean-glite: + @rm -f $(GLITEO) $(GLITEDO) + +clean:: clean-glite + +distclean-glite: clean-glite + @rm -f $(GLITEDEP) $(GLITEDS) $(GLITEDH) $(GLITELIB) $(GLITEMAP) + +distclean:: distclean-glite + +##### extra rules ###### +$(GLITEO) $(GLITEDO): CXXFLAGS += $(GAW_CPPFLAGS) diff --git a/glite/inc/LinkDef.h b/glite/inc/LinkDef.h new file mode 100644 index 00000000000..adaf7f6c2ba --- /dev/null +++ b/glite/inc/LinkDef.h @@ -0,0 +1,12 @@ +#ifdef __CINT__ + +#pragma link off all globals; +#pragma link off all classes; +#pragma link off all functions; + +#pragma link C++ class TGLite; +#pragma link C++ class TGLiteJob+; +#pragma link C++ class TGLiteJobStatus+; +#pragma link C++ class TGLiteResult+; + +#endif diff --git a/glite/inc/TGLite.h b/glite/inc/TGLite.h new file mode 100644 index 00000000000..922c9d5ffc7 --- /dev/null +++ b/glite/inc/TGLite.h @@ -0,0 +1,78 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-03-20 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLite.h +Interface of the class which +defines interface to gLite GRID services. *//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-03-20 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +#ifndef ROOT_TGLite +#define ROOT_TGLite + +////////////////////////////////////////////////////////////////////////// +// // +// TGLite // +// // +// Class defining interface to gLite GRID services. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGrid +#include "TGrid.h" +#endif + +class TGLite: public TGrid +{ +public: + TGLite(const char *_gridurl, const char* /*_uid*/ = NULL, const char* /*_passwd*/ = NULL, const char* /*_options*/ = NULL); + virtual ~TGLite(); + +public: + virtual Bool_t IsConnected() const; + + virtual void Shell(); + virtual void Stdout(); + virtual void Stderr(); + + virtual TGridResult* Command(const char* /*command*/, Bool_t /*interactive*/ = kFALSE, UInt_t /*stream*/ = 2); + virtual TGridResult* Query(const char *_path, const char *_pattern = NULL, const char* /*conditions*/ = "", const char* /*options*/ = ""); + virtual TGridResult* LocateSites(); + + //--- Catalogue Interface + virtual TGridResult* Ls(const char *_ldn = "", Option_t* /*options*/ = "", Bool_t /*verbose*/ = kFALSE); + virtual const char* Pwd(Bool_t /*verbose*/ = kFALSE); + virtual Bool_t Cd(const char *_ldn = "", Bool_t /*verbose*/ = kFALSE); + virtual Bool_t Mkdir(const char *_ldn = "", Option_t* /*options*/ = "", Bool_t /*verbose*/ = kFALSE); + virtual Bool_t Rmdir(const char *_ldn = "", Option_t* /*options*/ = "", Bool_t /*verbose*/ = kFALSE); + virtual Bool_t Register(const char *_lfn, const char *_turl , Long_t /*size*/ = -1, const char *_se = 0, const char *_guid = 0, Bool_t /*verbose*/ = kFALSE); + virtual Bool_t Rm(const char *_lfn, Option_t* /*option*/ = "", Bool_t /*verbose*/ = kFALSE); + + //--- Job Submission Interface + virtual TGridJob* Submit(const char *_jdl); + virtual TGridJDL* GetJDLGenerator(); + virtual Bool_t Kill(TGridJob *_gridjob); + virtual Bool_t KillById(TString _id); + +private: + std::string fFileCatalog_WrkDir; + + ClassDef(TGLite, 1) // Interface to gLite Grid services +}; + +#endif diff --git a/glite/inc/TGLiteJob.h b/glite/inc/TGLiteJob.h new file mode 100644 index 00000000000..6edc02d9521 --- /dev/null +++ b/glite/inc/TGLiteJob.h @@ -0,0 +1,46 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-04-10 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteJob.h +gLite implentation of TGridJob*//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-04-10 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +#ifndef ROOT_TGLiteJob +#define ROOT_TGLiteJob + +#ifndef ROOT_TGridJob +#include "TGridJob.h" +#endif + +class TGLiteJob : public TGridJob +{ + +public: + TGLiteJob(TString jobID) : TGridJob(jobID) {} + virtual ~TGLiteJob() {} + + virtual TGridJobStatus* GetJobStatus() const; + Int_t GetOutputSandbox(const char *_localpath, Option_t* /*opt*/ = 0); + virtual Bool_t Resubmit(); + virtual Bool_t Cancel(); + + ClassDef(TGLiteJob, 1) // gLite implementation of TGridJob +}; + +#endif diff --git a/glite/inc/TGLiteJobStatus.h b/glite/inc/TGLiteJobStatus.h new file mode 100644 index 00000000000..0c53580d97b --- /dev/null +++ b/glite/inc/TGLiteJobStatus.h @@ -0,0 +1,51 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-04-10 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteJobStatus.h +gLite implementation of TGridJobStatus*//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-04-10 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +#ifndef ROOT_TGLiteJobStatus +#define ROOT_TGLiteJobStatus + +#ifndef ROOT_TGridJobStatus +#include "TGridJobStatus.h" +#endif + +#ifndef ROOT_TGridJob +#include "TGridJob.h" +#endif + +class TGLiteJobStatus : public TGridJobStatus +{ +public: + TGLiteJobStatus() {} + TGLiteJobStatus(TString jobID); + virtual ~TGLiteJobStatus() {} + +public: + virtual EGridJobStatus GetStatus() const; + +private: + std::string m_sJobID; + + ClassDef(TGLiteJobStatus, 1) // gLite implementation of TGridJobStatus +}; + +#endif diff --git a/glite/inc/TGLiteResult.h b/glite/inc/TGLiteResult.h new file mode 100644 index 00000000000..1a7dead9f1e --- /dev/null +++ b/glite/inc/TGLiteResult.h @@ -0,0 +1,61 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-07-30 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteresult.h +*//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-07-30 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006 GSI GridTeam. All rights reserved. +*************************************************************************/ + +#ifndef ROOT_TGLiteResult +#define ROOT_TGLiteResult + +////////////////////////////////////////////////////////////////////////// +// // +// TGLiteResult // +// // +// Class defining interface to a gLite result set. // +// Objects of this class are created by TGrid methods. // +// // +// Related classes are TGLite. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGridResult +#include "TGridResult.h" +#endif + +class TGLiteResult : public TGridResult +{ +public: + virtual void DumpResult(); + + virtual const char* GetFileName(UInt_t i) const; // returns the file name of list item i + virtual const char* GetFileNamePath(UInt_t i) const; // returns the full path + file name of list item i + virtual const char* GetPath(UInt_t i) const; // returns the file path of list item i + virtual const char* GetKey(UInt_t i, const char *key) const; // returns the key value of list item i + + virtual Bool_t SetKey(UInt_t i, const char *key, const char *value); // set the key value of list item i + virtual TList* GetFileInfoList() const; // returns a new allocated List of TFileInfo Objects + + void Print(Option_t *option = "") const; + void Print(Option_t *wildcard, Option_t *option) const; + + ClassDef(TGLiteResult, 1) // gLite query result set +}; + +#endif diff --git a/glite/src/TGLite.cxx b/glite/src/TGLite.cxx new file mode 100644 index 00000000000..83b30259475 --- /dev/null +++ b/glite/src/TGLite.cxx @@ -0,0 +1,644 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-03-20 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLite.cxx + Implementation of the class which + defines interface to gLite GRID services. */ /* + + version number: $LastChangedRevision: 1688 $ + created by: Anar Manafov + 2006-03-20 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-23 13:42:32 +0100 (Wed, 23 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +//*-- Last Update : $LastChangedDate: 2008-01-23 13:42:32 +0100 (Wed, 23 Jan 2008) $ by $LastChangedBy: manafov $ +//*-- Author : Anar Manafov (A.Manafov@gsi.de) 2006-03-20 +//*-- Copyright: Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. + +// glite-api-wrapper +#include <glite-api-wrapper/gLiteAPIWrapper.h> +// ROOT +#include "TMap.h" +#include "TObjString.h" +// ROOT RGLite +#include "TGLiteResult.h" +#include "TGLiteJob.h" +#include "TGLite.h" + +//////////////////////////////////////////////////////////////////////////////// +/* BEGIN_HTML +The TGLite class defines an interface to <A href="http://glite.web.cern.ch/glite/" name="gLite GRID services">gLite GRID services</A>. This class is a part of RGlite plug-in developed at <A href="http://www.gsi.de" name="GSI, Darmstadt">GSI, Darmstadt</A>.<br> +The RGLite plug-in uses <A href="https://subversion.gsi.de/trac/dgrid/wiki">glite-api-wrapper library (GAW)</A> to perform Grid operations and provides the following featurs: +<ul> +<li>Workload Management System operations: +<ul> + <li>job submission - normal, DAG and parametric jobs (gLite WMProxy API),</li> + <li>smart look-up algorithm for WMP-Endpoints,</li> + <li>job status querying (gLite LB API),</li> + <li>job output retrieving (Globus GridFTP).</li> +</ul> +</li> +<li>File Catalog operations (gLite/LCG LFC API): +<ul> + <li>smart session manager,</li> + <li>set/query the current working catalog directory,</li> + <li>list files, directories and their stats,</li> + <li>add/remove files in a catalog namespace,</li> + <li>add/remove directories,</li> + <li>add/remove replicas from a given file.</li> +</ul> +</li> +<li>An executive logging.</li> +<li>Support of an external xml configuration file with according XML schema.</li> +</ul> + +<h3>Content</h3> +<ol style="list-style-type: upper-roman;"> + <li><a href="#requarements">Requirements</a></li> + <li><a href="#conf">Configuration</a></li> + <li><a href="#usage">Usage</a> + <ol> + <li><a href="#usage:job_opt">Job operations</a></li> + <li><a href="#usage:file_catalog_opt">File Catalog operations</a></li> + </ol> + </li> +</ol> +<br> + +<h3><a name="requarements">Requirements</a></h3> +<ol> + <li><A href="http://glite.web.cern.ch/glite/packages/userInterface.asp">gLite UI 3.1</A></li> + <li><A href="https://subversion.gsi.de/trac/dgrid/wiki">glite-api-wrapper library</A></li> + <li>A Grid proxy (in order to perform gLite operations RGLite requires a Grid proxy, users therefore should create the Grid proxy before using the plug-in. One can create the Grid proxy with help of <em>voms-proxy-init</em> command, for example)</li> +</ol> + +<h3><a name="conf">Configuration</a></h3> +Since RGLite plug-in is based on <A href="https://subversion.gsi.de/trac/dgrid/wiki">glite-api-wrapper library</A> one should use GAW configuration file for tuning RGLite options up. Please refer to <A href="https://subversion.gsi.de/trac/dgrid/wiki">a GAW Trac</A> for more information. + +<h3><a name="usage">Usage</a></h3> +Be advised that the call of <em>TGrid::Connect("glite")</em> should be the very first one. It initializes RGLite plug-in and assigns a global variable <em>gGrid</em> with a pointer to the RGLite plug-in object. The plug-in on his side will initialize a GAW singleton and the <em>TGrid::Connect("glite")</em> call therefore can be performed only once. If you successfully "connected" to gLite, you can call other methods of TGrid interface. Please see the following examples. +<h4><a name="usage:job_opt">Job operations</a></h4> +<table width="100%" border="0"> + <tbody bgcolor="#ffdca8"> + <tr> + <td> + <font color="Green">// loading RGLite plug-in</font><br> + TGrid::Connect("glite");<br> + <font color="Green">// submitting Grid job</font><br> + TGridJob *job = gGrid->Submit("JDLs/simple.jdl");<br> + <font color="Green">// getting status object</font><br> + TGridJobStatus *status = job->GetJobStatus();<br> + <font color="Green">// getting status of the job.</font><br> + TGridJobStatus::EGridJobStatus st( status->GetStatus() );<br> + <font color="Green">// when the st is TGridJobStatus::kDONE you can retrieve job's output</font><br> + job->GetOutputSandbox("/tmp");<br> + </td> + </tr> + </tbody> +</table> +<h4><a name="usage:file_catalog_opt">File Catalog operations</a></h4> +<h5>Cd, Pwd, Ls</h5> +<table width="100%"> + <tbody bgcolor="#ffdca8"> + <tr> + <td> + <font color="Green">// loading RGLite plug-in</font><br> + TGrid::Connect("glite");<br> + <font color="Green">// current Catalog directory</font><br> + cout << "Working Directory is " << gGrid->Pwd() << endl; + <br> + <font color="Green">// listing the current directory</font><br> + TGridResult* result = gGrid->Ls();<br> + result->Print("all");<br> + <font color="Green">// changing the current directory to "dech"</font><br> + gGrid->Cd("dech");<br> + <font color="Green">// listing only file names</font><br> + TGridResult * res = gGrid->Ls();<br> + Int_t i = 0;<br> + while ( res->GetFileName( i ) ) + <br> + cout << "File: " << res->GetFileName( i++ ) << endl; + <br> + </td> + </tr> + </tbody> +</table> + +<h5>Mkdir, Rmdir</h5> + +<table width="100%"> + <tbody bgcolor="#ffdca8"> + <tr> + <td> + <font color="Green">// loading RGLite plug-in</font><br> + TGrid::Connect("glite");<br> + <font color="Green">// changing the current directory to "/grid/dech"</font><br> + gGrid->Cd("/grid/dech");<br> + <font color="Green">// using Mkdir to create a new directory</font><br> + Bool_t b = gGrid->Mkdir("root_test2");<br> + <font color="Green">// listing the current directory</font><br> + TGridResult* result = gGrid->Ls();<br> + <font color="Green">// full file information</font><br> + result->Print("all");<br> + <font color="Green">// removing the directory </font><br> + b = gGrid->Rmdir("root_test2");<br> + </td> + </tr> + </tbody> +</table> +END_HTML */ +//////////////////////////////////////////////////////////////////////////////// + +ClassImp(TGLite) + +using namespace std; +using namespace glite_api_wrapper; +using namespace LFCHelper; +using namespace MiscCommon; + +template<class _T> +void add_map_element(TMap *_map, const string &_key, const _T &_value) +{ + ostringstream ss; + ss << _value; + TObjString * key(new TObjString(_key.c_str())); + TObjString *value(new TObjString(ss.str().c_str())); + _map->Add(dynamic_cast<TObject*>(key), dynamic_cast<TObject*>(value)); +} + +struct SAddRepInfo: public binary_function<SLFCRepInfo_t, TMap*, bool> { + bool operator()(first_argument_type _rep, second_argument_type m_Map) const { + ostringstream strSFN; + strSFN << "sfn" << _rep.id; + stringstream strHost; + strHost << "host" << _rep.id; + add_map_element(m_Map, strSFN.str(), _rep.sfn); + add_map_element(m_Map, strHost.str(), _rep.host); + return true; + } +}; + +struct SAddMapElementFunc: public binary_function<SLFCFileInfo_t, TGLiteResult*, bool> { + bool operator()(first_argument_type _lfc_info, second_argument_type _Result) const { + TMap * map = new TMap(); + + add_map_element(map, "fileid", _lfc_info.m_nFileID); + add_map_element(map, "name", _lfc_info.m_sName); + add_map_element(map, "size", _lfc_info.m_nSize); + add_map_element(map, "guid", _lfc_info. m_sGUID); + add_map_element(map, "rep_count", _lfc_info.m_LFCRepInfoVector.size()); + + // Add replication info + for_each(_lfc_info.m_LFCRepInfoVector.begin(), + _lfc_info.m_LFCRepInfoVector.end(), + bind2nd(SAddRepInfo(), map)); + + _Result->Add(map); + return true; + } +}; + +//______________________________________________________________________________ +TGLite::TGLite(const char */*_gridurl*/, const char* /*uid*/, const char* /*passwd*/, const char* /*options*/) +{ + // Initializing the RGLite plug-in and making a connection to gLite UI. + // INPUT: + // _gridurl [in] - must be a "glite" string. + // NOTE: + // The other parameters are unsupported. + + if (!CGLiteAPIWrapper::Instance().Init()) { + gGrid = this; + fPort = 0; // Will be used in TGLite::IsConnected + Info("TGLite", "gLite API Wrapper engine has been successfully initialized."); + } else { + // failed to connect to gLite + fPort = -1; + } +} + + +//______________________________________________________________________________ +TGLite::~TGLite() +{ + // Destructor +} + + +//______________________________________________________________________________ +Bool_t TGLite::IsConnected() const +{ + // Use this method to find out whether the RGLite plug-in is connected to gLite UI or not. + // RETURN: + // kTRUE if connected and kFALSE otherwise. + + return (-1 == fPort ? kFALSE : kTRUE); +} + + +//______________________________________________________________________________ +void TGLite::Shell() +{ + // Not implemented for RGLite + + MayNotUse("Shell"); +} + + +//______________________________________________________________________________ +void TGLite::Stdout() +{ + // Not implemented for RGLite + + MayNotUse("Stdout"); +} + + +//______________________________________________________________________________ +void TGLite::Stderr() +{ + // Not implemented for RGLite + + MayNotUse("Stderr"); +} + + +//______________________________________________________________________________ +TGridResult* TGLite::Command(const char* /*command*/, Bool_t /*interactive*/, UInt_t /*stream*/) +{ + // Not implemented for RGLite + + MayNotUse("Command"); + return NULL; +} + + +//______________________________________________________________________________ +TGridResult* TGLite::Query(const char *_path, const char *_pattern /*= NULL*/, const char* /*conditions*/, const char* /*options*/) +{ + // A File Catalog method. Quering a File Catalog. + // INPUT: + // _path [in] - a File Catalog directory which queary will be executed on. + // _pattern [in] - a POSIX regular expression pattern. + // If a NULL value provided the default pattern will be used, + // which is ".*" - match any. + // NOTE: + // The third and the forth parameters are unsupported. + // RETURN: + // A TGridResult object, which holds the result of the query. + + if (!_path) + return NULL; // TODO: msg me! + + // Call for a Catalog manager + CCatalogManager * pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return NULL; // TODO: Log me! + + LFCFileInfoVector_t container; + gaw_lfc_ls ls; + ls.m_dir = _path; + if (_pattern) + ls.m_pattern = _pattern; + try { + pCatalog->Run(ls, &container); + } catch (const exception &e) { + Error("Query", "Exception: %s", e.what()); + return NULL; + } + + // Creating ROOT containers to store the resultset + TGLiteResult *result = new TGLiteResult(); + for_each(container.begin(), container.end(), bind2nd(SAddMapElementFunc(), result)); + + return result; +} + + +//______________________________________________________________________________ +TGridResult* TGLite::LocateSites() +{ + // Not implemented for RGLite + + MayNotUse("LocalSites"); + return NULL; +} + +//______________________________________________________________________________ +//--- Catalogue Interface +TGridResult* TGLite::Ls(const char *_ldn, Option_t* /*options*/, Bool_t /*verbose*/) +{ + // A File Catalog method. Listing content of the current working directory. + // INPUT: + // _ldn [in] - a logical name of the directory to list. + // NOTE: + // The other parameters are unsupported. + // RETURN: + // A TGridResult object, which holds the result of the listing. + // The method returns NULL in case of if an error occured. + + if (!_ldn) + return NULL; // TODO: report error + + // Call for a Catalog manager + CCatalogManager * pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return NULL; // TODO: Log me! + + LFCFileInfoVector_t container; + gaw_lfc_ls ls; + ls.m_dir = _ldn; + try { + pCatalog->Run(ls, &container); + } catch (const exception &e) { + Error("Ls", "Exception: %s", e.what()); + return NULL; + } + + // Creating a ROOT container to store the resultset + TGLiteResult *result = new TGLiteResult(); + for_each(container.begin(), container.end(), bind2nd(SAddMapElementFunc(), result)); + + return result; +} + + +//______________________________________________________________________________ +const char* TGLite::Pwd(Bool_t /*verbose*/) +{ + // A File Catalog method. Retrieving a name of the current working directory. + // NOTE: + // The parameter is unsupported. + // RETURN: + // a logical name of the new current working directory. + + + // Call for a Catalog manager + CCatalogManager *pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return NULL; // TODO: Log me! + + gaw_lfc_pwd pwd; + try { + pCatalog->Run(pwd, &fFileCatalog_WrkDir); + } catch (const exception &e) { + Error("Pwd", "Exception: %s", e.what()); + return NULL; + } + + return fFileCatalog_WrkDir.c_str(); +} + + +//______________________________________________________________________________ +Bool_t TGLite::Cd(const char *_ldn, Bool_t /*verbose*/) +{ + // A File Catalog method. Changing the current working directory. + // INPUT: + // _ldn [in] - a logical name of the destination directory + // NOTE: + // The other parameter is unsupported. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + + if (!_ldn) + return kFALSE; + + // Call for a Catalog manager + CCatalogManager * pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return kFALSE; // TODO: Log me! + + gaw_lfc_cwd cwd; + cwd.m_dir = _ldn; + try { + pCatalog->Run(cwd); + } catch (const exception &e) { + Error("Cd", "Exception: %s", e.what()); + return kFALSE; + } + + return kTRUE; +} + + +//______________________________________________________________________________ +Bool_t TGLite::Mkdir(const char *_ldn, Option_t* /*options*/, Bool_t /*verbose*/) +{ + // A File Catalog method. Create a new directory on the name server. + // INPUT: + // _ldn [in] - a logical name of the directory to create. + // NOTE: + // The other parameters are unsupported. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + if (!_ldn) + return kFALSE; + + // Call for a Catalog manager + // TODO: implement *options* in order to use mkdir with "mode" and "guid" + CCatalogManager *pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return kFALSE; // TODO: Log me! + + gaw_lfc_mkdir mkdir; + mkdir.m_dir = _ldn; + try { + pCatalog->Run(mkdir); + } catch (const exception &e) { + Error("Mkdir", "Exception: %s", e.what()); + return kFALSE; + } + + return kTRUE; +} + + +//______________________________________________________________________________ +Bool_t TGLite::Rmdir(const char *_ldn, Option_t* /*options*/, Bool_t /*verbose*/) +{ + // A File Catalog method, it removes a directory from the name server if it is an empty one. + // INPUT: + // _ldn [in] - a logical name of the directory to remove. + // NOTE: + // The other parameters are unsupported. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + if (!_ldn) + return kFALSE; + + // Call for a Catalog manager + CCatalogManager * pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return kFALSE; // TODO: Log me! + + gaw_lfc_rmdir rmdir; + rmdir.m_dir = _ldn; + try { + pCatalog->Run(rmdir); + } catch (const exception &e) { + Error("Rmdir", "Exception: %s", e.what()); + return kFALSE; + } + + return kTRUE; +} + + +//______________________________________________________________________________ +Bool_t TGLite::Register(const char *_lfn, const char *_turl , Long_t /*size*/, const char *_se, const char *_guid, Bool_t /*verbose*/) +{ + // A File Catalog method, it creates a new LFC file in the name server and registering a replication. + // INPUT: + // _lfn [in] - a logical file name of the file to create. + // _turl [in] - Storage File Name - is either the Site URL or + // the Physical File Name for the replica. + // _se [in] - either the Storage Element fully qualified hostname or the disk server. + // _guid [in] - a GUID for the new file. + // NOTE: + // The other parameters are unsupported. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + // Call for a Catalog manager + CCatalogManager *pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return kFALSE; // TODO: Log me! + + gaw_lfc_register reg; + reg.m_file_name = _lfn; + reg.m_guid = _guid; + reg.m_SE_server = _se; + reg.m_sfn = _turl; + try { + pCatalog->Run(reg); + } catch (const exception &e) { + Error("Register", "Exception: %s", e.what()); + return kFALSE; + } + + return kTRUE; +} + + +//______________________________________________________________________________ +Bool_t TGLite::Rm(const char *_lfn, Option_t* /*option*/, Bool_t /*verbose*/) +{ + // A File Catalog method, it removes an LFC file entry from the name server. + // The methods delets all replicas from the file. + // INPUT: + // _lfn [in] - a logical name of the file to remove. + // NOTE: + // The other parameters are unsupported. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + if (!_lfn) + return kFALSE; + + // Call for a Catalog manager + // TODO: Implement "-f" option, which will force to remove all replicas from the file, + // otherwise file will be deleted only if no replicas exist + // Currently "-f" is by default. Now Rm deletes all file's replicas and the file itself from catalog namespace. + CCatalogManager * pCatalog(&CGLiteAPIWrapper::Instance().GetCatalogManager()); + if (!pCatalog) + return kFALSE; // TODO: Log me! + + gaw_lfc_rm rm; + rm.m_file_name = _lfn; + try { + pCatalog->Run(rm); + } catch (const exception &e) { + Error("Rm", "Exception: %s", e.what()); + return kFALSE; + } + + return kTRUE; +} + + +//______________________________________________________________________________ +//--- Job Submission Interface +TGridJob* TGLite::Submit(const char *_jdl) +{ + // A Grid Job operations method, it processes a job submission. + // INPUT: + // _jdl [in] - a name of the job description file (JDL). The JDL file path can contain environment variables and a "~" (home) symbol. + // RETURN: + // a TGridJob object, which represents the newly submited job. + // The method returns NULL in case if an error occured. + + if (!_jdl) + return NULL; // TODO: msg me! + + try { + // Call for a job submission + CGLiteAPIWrapper::Instance().GetJobManager().DelegationCredential(); + + string strVer; + CGLiteAPIWrapper::Instance().GetJobManager().GetVersion(&strVer); + Info("Submit", "GAW Job Manager uses WMProxy version: %s", strVer.c_str()); + + string sJobID; + CGLiteAPIWrapper::Instance().GetJobManager().JobSubmit(_jdl, &sJobID); + Info("Submit", "Job successfully submitted. Job ID \"%s\"", sJobID.c_str()); + return dynamic_cast<TGridJob*>(new TGLiteJob(sJobID.c_str())); + } catch (const exception &e) { + Error("Submit", "Exception: %s", e.what()); + return NULL; + } +} + + +//______________________________________________________________________________ +TGridJDL* TGLite::GetJDLGenerator() +{ + // Not implemented for RGLite. + + MayNotUse("GetJDLGenerator"); + return 0; +} + + +//______________________________________________________________________________ +Bool_t TGLite::Kill(TGridJob *_gridjob) +{ + // A Grid Job operations method, it cancels a given gLite job. + // INPUT: + // _gridjob [in] - a TGridJob object. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + if (!_gridjob) + return kFALSE; + + return _gridjob->Cancel(); +} + + +//______________________________________________________________________________ +Bool_t TGLite::KillById(TString _id) +{ + // A Grid Job operations method, it cancels a gLite job by the given id. + // INPUT: + // _id [in] - a gLite job ID. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + TGLiteJob gridjob(_id); + return gridjob.Cancel(); +} diff --git a/glite/src/TGLiteJob.cxx b/glite/src/TGLiteJob.cxx new file mode 100644 index 00000000000..9ba6f7dd994 --- /dev/null +++ b/glite/src/TGLiteJob.cxx @@ -0,0 +1,116 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-04-10 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteJob.cxx +gLite implentation of TGridJob*//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-04-10 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +// glite-api-wrapper +#include <glite-api-wrapper/gLiteAPIWrapper.h> +// ROOT RGLite +#include "TGLiteJob.h" +#include "TGLiteJobStatus.h" + +////////////////////////////////////////////////////////////////////////// +// +// The TGLiteJob class is a part of RGLite plug-in and +// represents a Grid job and offers a posibility to +// query the job status and retrieve its output sandbox. +// +// Related classes are TGLite. +// +////////////////////////////////////////////////////////////////////////// + +ClassImp(TGLiteJob) + +using namespace std; +using namespace glite_api_wrapper; +using namespace MiscCommon; + +//______________________________________________________________________________ +TGridJobStatus* TGLiteJob::GetJobStatus() const +{ + // The GetJobStatus() method queries the job for its status. + // RETURN: + // a TGridJobStatus object. + + // Returns 0 in case of failure. + return dynamic_cast<TGridJobStatus*>(new TGLiteJobStatus(fJobID)); +} + + +//______________________________________________________________________________ +Int_t TGLiteJob::GetOutputSandbox(const char* _localpath, Option_t* /*opt*/) +{ + // Retrieving the output sandbox files. + // INPUT: + // _localpath [in] - a local destination path for output sandbox. + // NOTE: + // The other parameter is unsupported. + // RETURN: + // The method returns -1 in case of errors and 0 otherwise. + + // TODO: Add Info message; + // TODO: Add option "nopurge" to TGLiteJob::GetOutputSandbox, since it's supported now by glite-api-wrapper + try { + CJobManager::delivered_output_t joboutput_path; + CGLiteAPIWrapper::Instance().GetJobManager().JobOutput(string(fJobID), _localpath, &joboutput_path); + + // Print all output directories + CJobManager::delivered_output_t::const_iterator iter = joboutput_path.begin(); + CJobManager::delivered_output_t::const_iterator iter_end = joboutput_path.end(); + Info("GetOutputSandbox", "The output has been delivered [ job ] -> [local output directory]"); + for (; iter != iter_end; ++iter) { + stringstream ss; + ss << "[" << iter->first << "] -> [" << iter->second << "]"; + Info("GetOutputSandbox", ss.str().c_str()); + } + return 0; + } catch (const exception &_e) { + Error("GetOutputSandbox", "Exception: %s", _e.what()); + return -1; + } +} + + +//______________________________________________________________________________ +Bool_t TGLiteJob::Resubmit() +{ + // Not implemented for RGLite. + + MayNotUse("Resubmit"); + return kFALSE; +} + + +//______________________________________________________________________________ +Bool_t TGLiteJob::Cancel() +{ + // The Cancel() method cancels a gLite job, which was assigned to the class. + // RETURN: + // kTRUE if succeded and kFALSE otherwise. + + try { + CGLiteAPIWrapper::Instance().GetJobManager().JobCancel(string(fJobID)); + } catch (const exception &_e) { + Error("Cancel", "Exception: %s", _e.what()); + return kFALSE; + } + return kTRUE; +} diff --git a/glite/src/TGLiteJobStatus.cxx b/glite/src/TGLiteJobStatus.cxx new file mode 100644 index 00000000000..a5b0efed3ff --- /dev/null +++ b/glite/src/TGLiteJobStatus.cxx @@ -0,0 +1,106 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-04-10 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteJobStatus.h +Class defining interface to a gLite result set. +Objects of this class are created by TGrid methods.*//* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-04-10 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006-2008 GSI GridTeam. All rights reserved. +*************************************************************************/ + +//glite-api-wrapper +#include <glite-api-wrapper/gLiteAPIWrapper.h> +// STD +#include <string> +// ROOT +#include "TGridJobStatus.h" +#include "TGLiteJobStatus.h" +////////////////////////////////////////////////////////////////////////// +// +// The TGLiteJobStatus class is a part of RGLite plug-in and +// represents a status of Grid jobs. +// Actually this class is responsible to retrieve a Grid job status and +// translate it to a TGridJobStatus::EGridJobStatus statuses. +// +// Related classes are TGLite. +// +////////////////////////////////////////////////////////////////////////// + +ClassImp(TGLiteJobStatus) + +using namespace std; +using namespace glite_api_wrapper; + + +//______________________________________________________________________________ +TGLiteJobStatus::TGLiteJobStatus(TString _jobID): m_sJobID(_jobID) +{ +} + + +//______________________________________________________________________________ +TGridJobStatus::EGridJobStatus TGLiteJobStatus::GetStatus() const +{ + // The GetStat() method retrievs a gLite job status and + // translates it to a TGridJobStatus::EGridJobStatus type. + // RETURN: + // a TGridJobStatus::EGridJobStatus status value. + + string sStatusName; + string sStatusString; + // Gets the status of the job reduced to the subset defined in TGridJobStatus. + glite::lb::JobStatus::Code code(glite::lb::JobStatus::UNDEF); + try { + code = CGLiteAPIWrapper::Instance().GetJobManager().JobStatus(m_sJobID, &sStatusName, &sStatusString); + } catch (const exception &e) { + Error("GetStatus", "Exception: %s", e.what()); + return kUNKNOWN; + } + + Info("GetStatus", "JobID = %s", m_sJobID.c_str()); + Info("GetStatus", + "Job status is [%d]; gLite status code is \"%s\"; gLite status string is \"%s\"", + code, sStatusName.c_str(), sStatusString.c_str()); + switch (code) { + case glite::lb::JobStatus::DONE: + case glite::lb::JobStatus::CLEARED: + case glite::lb::JobStatus::PURGED: + Info("GetStatus", "Job status is kDONE"); + return kDONE; + case glite::lb::JobStatus::SUBMITTED: + case glite::lb::JobStatus::WAITING: + case glite::lb::JobStatus::READY: + Info("GetStatus", "Job status is kWAITING"); + return kWAITING; + case glite::lb::JobStatus::SCHEDULED: + case glite::lb::JobStatus::RUNNING: + Info("GetStatus", "Job status is kRUNNING"); + return kRUNNING; + case glite::lb::JobStatus::ABORTED: + Info("GetStatus", "Job status is kABORTED"); + return kABORTED; + case glite::lb::JobStatus::CANCELLED: + Info("GetStatus", "Job status is kFAIL"); + return kFAIL; + default: + // glite::lb::JobStatus::CODE_MAX: + // glite::lb::JobStatus::UNKNOWN: + // glite::lb::JobStatus::UNDEF: + Info("GetStatus", "Job status is kUNKNOWN"); + return kUNKNOWN; + } +} diff --git a/glite/src/TGLiteResult.cxx b/glite/src/TGLiteResult.cxx new file mode 100644 index 00000000000..ea502a617d9 --- /dev/null +++ b/glite/src/TGLiteResult.cxx @@ -0,0 +1,223 @@ +// @(#) root/glite:$Id$ +// Author: Anar Manafov <A.Manafov@gsi.de> 2006-07-30 + +/************************************************************************* + * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +/************************************************************************/ +/*! \file TGLiteresult.cxx + */ /* + + version number: $LastChangedRevision: 1678 $ + created by: Anar Manafov + 2006-07-30 + last changed by: $LastChangedBy: manafov $ $LastChangedDate: 2008-01-21 18:22:14 +0100 (Mon, 21 Jan 2008) $ + + Copyright (c) 2006 GSI GridTeam. All rights reserved. +*************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// +// The TGLiteResult class is a part of RGLite plug-in and +// defines an interface to a gLite result set. +// Objects of this class are created by TGrid methods. +// +// Related classes are TGLite. +// +////////////////////////////////////////////////////////////////////////// + + +#include "TGLiteResult.h" +#include "TObjString.h" +#include "TMap.h" +#include "Riostream.h" +#include "TSystem.h" +#include "TUrl.h" +#include "TFileInfo.h" + +ClassImp(TGLiteResult) + +//______________________________________________________________________________ +void TGLiteResult::DumpResult() +{ + // Dump result set. + + cout << "BEGIN DUMP" << endl; + cout << "END DUMP" << endl; +} + +//______________________________________________________________________________ +const char *TGLiteResult::GetFileName(UInt_t i) const +{ + //return a file name + if (At(i)) { + TObjString * entry; + if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("name"))) { + return entry->GetName(); + } + } + return 0; +} + +//______________________________________________________________________________ +const char *TGLiteResult::GetFileNamePath(UInt_t i) const +{ + //return file name path + if (At(i)) { + TObjString * entry; + if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("name"))) { + TObjString * path; + if ((path = (TObjString*)((TMap*) At(i)) ->GetValue("path"))) { + TString fFilePath(TString(path->GetName()) + TString(entry->GetName())); + return fFilePath; + } + } + } + return 0; +} + +//______________________________________________________________________________ +const char *TGLiteResult::GetPath(UInt_t i) const +{ + //return path + if (At(i)) { + TObjString * entry; + if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue("path"))) { + return entry->GetName(); + } + } + return 0; +} + +//______________________________________________________________________________ +const char *TGLiteResult::GetKey(UInt_t i, const char* key) const +{ + //return the key + if (At(i)) { + TObjString * entry; + if ((entry = (TObjString*)((TMap*) At(i)) ->GetValue(key))) { + return entry->GetName(); + } + } + return 0; +} + +//______________________________________________________________________________ +Bool_t TGLiteResult::SetKey(UInt_t i, const char* key, const char* value) +{ + //set the key + if (At(i)) { + TPair * entry; + if ((entry = (TPair*)((TMap*) At(i)) ->FindObject(key))) { + TObject * val = ((TMap*) At(i)) ->Remove((TObject*) entry->Key()); + if (val) { + delete val; + } + } + ((TMap*) At(i)) ->Add((TObject*)(new TObjString(key)), + (TObject*)(new TObjString(value))); + return kTRUE; + } + return kFALSE; +} + +//______________________________________________________________________________ +TList *TGLiteResult::GetFileInfoList() const +{ + //return a file info list + TList * newfileinfolist = new TList(); + + + // TODO: Revise me!!! (according to what TGlite::Ls returns) + + newfileinfolist->SetOwner(kTRUE); + + for (Int_t i = 0; i < GetSize(); i++) { + + Long64_t size = -1; + if (GetKey(i, "size")) + size = atol(GetKey(i, "size")); + + const char* md5 = GetKey(i, "md5"); + const char* uuid = GetKey(i, "guid"); + const char* msd = GetKey(i, "msd"); + + if (md5 && !strlen(md5)) + md5 = 0; + if (uuid && !strlen(uuid)) + uuid = 0; + if (msd && !strlen(msd)) + msd = 0; + + TString turl = GetKey(i, "turl"); + + if (msd) { + TUrl urlturl(turl); + TString options = urlturl.GetOptions(); + options += "&msd="; + options += msd; + urlturl.SetOptions(options); + turl = urlturl.GetUrl(); + } + Info("GetFileInfoList", "Adding Url %s with Msd %s\n", turl.Data(), msd); + newfileinfolist->Add(new TFileInfo(turl, size, uuid, md5)); + } + return newfileinfolist; +} + +//______________________________________________________________________________ +void TGLiteResult::Print(Option_t * /*wildcard*/, Option_t *option) const +{ + //print the GLiteResult info + + if (TString(option) != TString("all")) { + // TODO: Complete me! + // Long64_t totaldata = 0; + // Int_t totalfiles = 0; + // // the default print out format is for a query + // for (Int_t i = 0; i< GetSize(); i++) { + // if (TString(option) == TString("l") ) { + // printf("( %06d ) LFN: %-80s Size[Bytes]: %10s GUID: %s\n",i,GetKey(i,"lfn"),GetKey(i,"size"),GetKey(i,"guid")); + // } else { + // printf("( %06d ) LFN: .../%-48s Size[Bytes]: %10s GUID: %s\n",i,gSystem->BaseName(GetKey(i,"lfn")),GetKey(i,"size"),GetKey(i,"guid")); + // } + // if (GetKey(i, "size")) { + // totaldata += atol(GetKey(i,"size")); + // totalfiles++; + // } + // } + // printf("------------------------------------------------------------\n"); + // printf("-> Result contains %.02f MB in %d Files.\n",totaldata/1024./1024.,totalfiles); + } else { + TIter next(this); + TMap *map; + for (Int_t count = 0; (map = dynamic_cast<TMap*>(next())); ++count) { + TIter next2(map->GetTable()); + TPair *pair; + cout << "# " << setiosflags(ios::left) << setw(6) << count << " ------------------------------------------------------------" << endl; + while ((pair = dynamic_cast< TPair*>(next2()))) { + TObjString * keyStr = dynamic_cast<TObjString*>(pair->Key()); + TObjString* valueStr = dynamic_cast<TObjString*>(pair->Value()); + if (keyStr && valueStr) { + cout + << setw(16) << keyStr->GetName() + << valueStr->GetName() + << endl; + } + } + cout << endl; + } + } +} + +//______________________________________________________________________________ +void TGLiteResult::Print(Option_t *option) const +{ + //print the GLiteResult info + Print("", option); +} -- GitLab