00001 #ifndef __XRDXROOTDJOB_HH_ 00002 #define __XRDXROOTDJOB_HH_ 00003 /******************************************************************************/ 00004 /* */ 00005 /* X r d X r o o t d J o b . h h */ 00006 /* */ 00007 /* (c) 2006 by the Board of Trustees of the Leland Stanford, Jr., University */ 00008 /* All Rights Reserved */ 00009 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 00010 /* DE-AC02-76-SFO0515 with the Department of Energy */ 00011 /******************************************************************************/ 00012 00013 // $Id: XrdXrootdJob.hh 22437 2008-03-04 14:35:16Z rdm $ 00014 00015 #include <sys/types.h> 00016 00017 #include "Xrd/XrdJob.hh" 00018 #include "XrdOuc/XrdOucTList.hh" 00019 #include "XrdSys/XrdSysPthread.hh" 00020 #include "XrdOuc/XrdOucTable.hh" 00021 00022 class XrdOucProg; 00023 class XrdLink; 00024 class XrdScheduler; 00025 class XrdXrootdJob2Do; 00026 class XrdXrootdResponse; 00027 00028 // Definition of options that can be passed to Schedule() 00029 // 00030 #define JOB_Sync 0x0001 00031 #define JOB_Unique 0x0002 00032 00033 class XrdXrootdJob : public XrdJob 00034 { 00035 friend class XrdXrootdJob2Do; 00036 public: 00037 00038 int Cancel(const char *jkey=0, XrdXrootdResponse *resp=0); 00039 00040 void DoIt(); 00041 00042 // List() returns a list of all jobs in xml format 00043 // 00044 XrdOucTList *List(void); 00045 00046 // args[0] if not null if prefixes the response 00047 // args[1-n] are passed to the prgram 00048 // The return value is whatever resp->Send() returns 00049 // 00050 int Schedule(const char *jkey, // Job Identifier 00051 const char **args, // Zero terminated arglist 00052 XrdXrootdResponse *resp, // Response object 00053 int Opts=0);// Options (see above) 00054 00055 XrdXrootdJob(XrdScheduler *schp, // -> Scheduler 00056 XrdOucProg *pgm, // -> Program Object 00057 const char *jname, // -> Job name 00058 int maxjobs=4); // Maximum simultaneous jobs 00059 ~XrdXrootdJob(); 00060 00061 private: 00062 void CleanUp(XrdXrootdJob2Do *jp); 00063 int sendResult(XrdXrootdResponse *resp, 00064 const char *rpfx, 00065 XrdXrootdJob2Do *job); 00066 00067 static const int reScan = 15*60; 00068 00069 XrdSysMutex myMutex; 00070 XrdScheduler *Sched; 00071 XrdOucTable<XrdXrootdJob2Do> JobTable; 00072 XrdOucProg *theProg; 00073 char *JobName; 00074 int maxJobs; 00075 int numJobs; 00076 }; 00077 #endif