xrootd
XrdXrootdJob.hh
Go to the documentation of this file.
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 /* This file is part of the XRootD software suite.                            */
00013 /*                                                                            */
00014 /* XRootD is free software: you can redistribute it and/or modify it under    */
00015 /* the terms of the GNU Lesser General Public License as published by the     */
00016 /* Free Software Foundation, either version 3 of the License, or (at your     */
00017 /* option) any later version.                                                 */
00018 /*                                                                            */
00019 /* XRootD is distributed in the hope that it will be useful, but WITHOUT      */
00020 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or      */
00021 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public       */
00022 /* License for more details.                                                  */
00023 /*                                                                            */
00024 /* You should have received a copy of the GNU Lesser General Public License   */
00025 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file  */
00026 /* COPYING (GPL license).  If not, see <http://www.gnu.org/licenses/>.        */
00027 /*                                                                            */
00028 /* The copyright holder's institutional names and contributor's names may not */
00029 /* be used to endorse or promote products derived from this software without  */
00030 /* specific prior written permission of the institution or contributor.       */
00031 /******************************************************************************/
00032 
00033 #include <sys/types.h>
00034   
00035 #include "Xrd/XrdJob.hh"
00036 #include "XrdOuc/XrdOucTList.hh"
00037 #include "XrdSys/XrdSysPthread.hh"
00038 #include "XrdOuc/XrdOucTable.hh"
00039 
00040 class XrdOucProg;
00041 class XrdLink;
00042 class XrdScheduler;
00043 class XrdXrootdJob2Do;
00044 class XrdXrootdResponse;
00045 
00046 // Definition of options that can be passed to Schedule()
00047 //
00048 #define JOB_Sync   0x0001
00049 #define JOB_Unique 0x0002
00050 
00051 class XrdXrootdJob : public XrdJob
00052 {
00053 friend class XrdXrootdJob2Do;
00054 public:
00055 
00056 int      Cancel(const char *jkey=0, XrdXrootdResponse *resp=0);
00057 
00058 void     DoIt();
00059 
00060 // List() returns a list of all jobs in xml format
00061 //
00062 XrdOucTList *List(void);
00063 
00064 // args[0]   if not null if prefixes the response
00065 // args[1-n] are passed to the prgram
00066 // The return value is whatever resp->Send() returns
00067 //
00068 int      Schedule(const char         *jkey,   // Job Identifier
00069                   const char        **args,   // Zero terminated arglist
00070                   XrdXrootdResponse  *resp,   // Response object
00071                   int                 Opts=0);// Options (see above)
00072 
00073          XrdXrootdJob(XrdScheduler *schp,       // -> Scheduler
00074                       XrdOucProg   *pgm,        // -> Program Object
00075                       const char   *jname,      // -> Job name
00076                       int           maxjobs=4); // Maximum simultaneous jobs
00077         ~XrdXrootdJob();
00078 
00079 private:
00080 void CleanUp(XrdXrootdJob2Do *jp);
00081 int  sendResult(XrdXrootdResponse *resp,
00082                 const char        *rpfx,
00083                 XrdXrootdJob2Do   *job);
00084 
00085 static const int              reScan = 15*60;
00086 
00087 XrdSysMutex                   myMutex;
00088 XrdScheduler                 *Sched;
00089 XrdOucTable<XrdXrootdJob2Do>  JobTable;
00090 XrdOucProg                   *theProg;
00091 char                         *JobName;
00092 int                           maxJobs;
00093 int                           numJobs;
00094 };
00095 #endif