Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Job.h

00001 #ifndef  EDG_WORKLOAD_USERINTERFACE_CLIENT_JOB_H
00002 #define EDG_WORKLOAD_USERINTERFACE_CLIENT_JOB_H
00003 /*
00004  * Job.h
00005  * Copyright (c) 2001 The European Datagrid Project - IST programme, all rights reserved.
00006  * Contributors are mentioned in the code where appropriate.
00007  */
00008 #include <map>
00009 #include <vector>
00010 #include "edg/workload/common/utilities/result_codes.h"
00011 #include "edg/workload/userinterface/client/UserCredential.h"
00012 #include "edg/workload/logging/client/consumer.h"
00013 #include "edg/workload/userinterface/client/Shadow.h"
00014 #define EMPTY_STRING              ""
00015 #define LB_DGLOG_PROT           "x-dglog://"
00016 #define LB_DEFAULT_PROT        "https://"
00017 #define DGLB_SOURCE_UI          "UserInterface"
00018 #define EDG_WLU_SOURCE_NS "NetworkServer"
00019 #define CHAR_BUFFER_SIZE      1024
00020 #define JOB_CANCEL_ERR             -1
00021 #define EDG_WL_LOG_DESTINATION "EDG_WL_LOG_DESTINATION"
00022 
00023 
00024 namespace edg{
00025    namespace  workload{
00026      // NS
00027      namespace  networkserver{    namespace client {          class NSClient ;         }      }
00028      // LB
00029      namespace logging { namespace client { class JobStatus ; class Event ; } }
00030      // ChkPt
00031      namespace checkpointing {   class JobState ; }
00032      // ---  Common  ---
00033      namespace  common{
00034      // JobId
00035         namespace jobid {           class JobId ;      }
00036      // JobAd
00037         namespace requestad {    class JobAd ;   class Ad ;    }
00038      }
00039    } // namespace workload
00040 } //namespace edg
00041 
00042 USERINTERFACE_NAMESPACE_BEGIN//Defining UserInterFace NameSpace
00043 
00045         enum jType {
00047                 JOB_NONE,
00049                 JOB_AD,
00051                 JOB_ID,
00053                 JOB_SUBMITTED,
00055                 JOB_CANCELLED
00056         } ;
00057 
00058 class Listener;
00059 class Shadow ;
00061 typedef std::vector <edg::workload::logging::client::Event> Events ;
00063 typedef edg::workload::logging::client::JobStatus Status ;
00064 
00085 class Job{
00086         public:
00090                 Job();
00093                 Job(const edg::workload::common::jobid::JobId& id);
00096                 Job(const edg::workload::common::requestad::JobAd& ad);
00098                 Job(const Job& job) ;
00100                 ~Job();
00102                 void operator=(const Job& job );
00107                 static void initialise () ;
00109 
00114                 edg::workload::common::jobid::JobId* getJobId() ;
00117                 edg::workload::common::requestad::JobAd* getJobAd() ;
00120                 void setCredPath(const std::string cp) ;
00122                 void unsetCredPath() ;
00126                 void setLoggerLevel ( int level ) ;
00129                 void setJobAd(const edg::workload::common:: requestad::JobAd& ad);
00132                 void setJobId(const edg::workload::common::jobid::JobId& id);
00134                 void retrieveJobAd() ;
00136                 jType getType ()  {  return jobType ; };
00138 
00145                 edg::workload::checkpointing::JobState getState(unsigned int step = 0) ;
00151                 int attach ( Listener* , int port = 0)  ;
00153 
00159                 Status getStatus(bool ad = true)  ;
00163                 Events getLogInfo() ;
00165 
00174                 void submit(const std::string& nSHost , int nsPort , const std::string& lbHost , int lbPort ,const std::string& ce_id= "" )  ;
00183                 void submit (const std::string& ns_host, int ns_port, const std::string& lbHost , int lbPort ,
00184                         edg::workload::checkpointing::JobState *state , Listener *ls , const std::string& ce_id="" )  ;
00189                 std::vector<std::pair <std::string , double> > listMatchingCE(const std::string& host , int port) ;
00192                 edg::workload::common::utilities::ResultCode cancel ( ) ;  //Result code?
00193 
00196                 void getOutput(const std::string& dir_path);
00197 
00199 
00217                 static edg::workload::common::jobid::JobId* submit(
00218                                         const std::string& host , int port ,
00219                                         const std::string& lbHost , int lbPort,
00220                                         const std::string& executable ,
00221                                         const std::string& stdOutput ,
00222                                         const std::string& stdErr ,
00223                                         const std::string& outputDir= "/tmp",
00224                                         const std::string& ce_id = "",
00225                                         int timeout =  10,
00226                                         int time_interval = 60) ;
00228 
00229         private:
00231                 void shadow     (char*  shHost , int shPort )     ;
00233                 void lbInit   (const std::string& nsHost)     ;
00235                 void nsInit   (const std::string& host, int port)     ;
00237                 void nsList   (std::vector<std::pair <std::string , double> > &resources)   ;
00239                 void nsSubmit (const std::string&  lb_addr  )  ;
00241                 void nsOutput ( const std::string& dir )   ;
00242                 jType jobType;
00243                 static pthread_mutex_t dgtransfer_mutex;
00244                 /* Internal JobId instance pointer*/
00245                 edg::workload::common::jobid::JobId* jid;
00246                 /*Internal JobAd instance pointer  */
00247                 edg::workload::common::requestad::JobAd* jad;
00248                 /*Stores the path of the proxy (if different from the default)*/
00249                 std::string cred_path  ;
00250                 /* Allow perform interactive Jobs */
00251                 Shadow sh ;
00252                 /*Allow to perform NS operation    */
00253                 edg::workload::networkserver::client::NSClient *nsClient ;
00254                 /*Allow to perform LB operation*/
00255                 edg_wll_Context ctx ;
00256                 //   edg::workload::logging::client::Job    lbJob;
00257                 /* To Check if the credential are OK */
00258                 UserCredential userCred ;
00259                 /* JobCollection managment*/
00260                 bool jCollect ;
00261                 unsigned int loggerLevel ;
00262                 // NS host:port
00263                 std::string nsHost ;
00264                 //LB contact:
00265                 std::string lbHost ; // keep the lb host retrieved from NS
00266                 int lbPort ,nsPort; // keep the lb port retrieved from NS
00267                 void setCollect()  {   jCollect = true ;  }
00268                 // JobCollection has full access to all Job private members
00269                 friend class JobCollection ;
00270 };
00271 
00272 USERINTERFACE_NAMESPACE_END } //Closing  UserInterFace NameSpace
00273 #endif
00274 

Generated on Fri May 14 14:19:39 2004 for USERINTERFACE C++ API by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002