XRootD
XrdXrootdJob2Do Class Reference
+ Inheritance diagram for XrdXrootdJob2Do:
+ Collaboration diagram for XrdXrootdJob2Do:

Public Types

enum  JobStatus {
  Job_Active ,
  Job_Cancel ,
  Job_Done ,
  Job_Waiting
}
 

Public Member Functions

 XrdXrootdJob2Do (XrdXrootdJob *job, int jnum, const char **args, XrdXrootdResponse *Resp, int opts)
 
 ~XrdXrootdJob2Do ()
 
void DoIt ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Public Attributes

XrdSys::RAtomic< JobStatusStatus
 
- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 

Friends

class XrdXrootdJob
 

Detailed Description

Definition at line 53 of file XrdXrootdJob.cc.

Member Enumeration Documentation

◆ JobStatus

Enumerator
Job_Active 
Job_Cancel 
Job_Done 
Job_Waiting 

Definition at line 60 of file XrdXrootdJob.cc.

Constructor & Destructor Documentation

◆ XrdXrootdJob2Do()

XrdXrootdJob2Do::XrdXrootdJob2Do ( XrdXrootdJob job,
int  jnum,
const char **  args,
XrdXrootdResponse Resp,
int  opts 
)

Definition at line 123 of file XrdXrootdJob.cc.

128  : XrdJob(job->JobName)
129 {
130  int i;
131  for (i = 0; i < argvnum && args[i]; i++) theArgs[i] = strdup(args[i]);
132  for ( ; i < argvnum; i++) theArgs[i] = (char *)0;
133  theJob = job;
134  JobRC = 0;
135  JobNum = jnum;
136  JobMark = 0;
137  numClients = 0;
138  theResult = 0;
139  doRedrive = 0;
141  addClient(resp, opts);
142 }
struct myOpts opts
XrdJob(const char *desc="")
Definition: XrdJob.hh:51
XrdSys::RAtomic< JobStatus > Status
Definition: XrdXrootdJob.cc:62

References Job_Waiting, opts, and Status.

◆ ~XrdXrootdJob2Do()

XrdXrootdJob2Do::~XrdXrootdJob2Do ( )

Definition at line 148 of file XrdXrootdJob.cc.

149 {
150  int i;
151 
152  for (i = 0; i < numClients; i++)
153  if (!Client[i].isSync) {sendResult(0, 1); break;}
154 
155  for (i = 0; i < argvnum; i++)
156  if (theArgs[i]) free(theArgs[i]);
157 }

Member Function Documentation

◆ DoIt()

void XrdXrootdJob2Do::DoIt ( )
virtual

Implements XrdJob.

Definition at line 166 of file XrdXrootdJob.cc.

167 {
168  static const char *TraceID = "jobXeq";
169  XrdXrootdJob2Do *jp = 0;
170  const char *endStat = " completed";
171  char *lp = 0;
172  int i, rc = 0;
173 
174 // While we were waiting to run we may have been cancelled. If we were not then
175 // perform the actual function and get the result and send to any async clients
176 //
177  if (Status != Job_Cancel)
178  {TRACE(REQ, "Job "<<jobInfo<<" started");
179  if ((rc = theJob->theProg->Run(&jobStream, theArgs[1], theArgs[2],
180  theArgs[3], theArgs[4])))
181  {Status = Job_Cancel;
182  endStat= " failed";
183  lp = jobStream.GetLine();
184  theJob->myMutex.Lock();
185  }
186  else {lp = jobStream.GetLine();
187  rc = theJob->theProg->RunDone(jobStream);
188  theJob->myMutex.Lock();
189  if ((rc && rc != -EPIPE) || (rc == -EPIPE && (!lp || !(*lp))))
190  {Status = Job_Cancel; endStat = " failed";}
191  else if (Status != Job_Cancel)
192  {Status = Job_Done;
193  for (i = 0; i < numClients; i++)
194  if (!Client[i].isSync) {sendResult(lp); break;}
195  }
196  }
197  } else {
198  endStat = " cancelled";
199  theJob->myMutex.Lock();
200  }
201 
202 // Produce a trace record
203 //
204  TRACE(REQ, "Job "<<jobInfo<<endStat);
205 
206 // If the number of jobs > than the max allowed, then redrive a waiting job
207 // if in fact we represent a legitimate job slot (this could a phantom slot
208 // due to ourselves being cancelled.
209 //
210  if (doRedrive)
211  {if (theJob->numJobs > theJob->maxJobs) Redrive();
212  theJob->numJobs--;
213  }
214 
215 // If there are no polling clients left or we have been cancelled, then we
216 // will delete ourselves and, if cancelled, send a notofication to everyone
217 //
218  if (Status != Job_Cancel && numClients) theResult = lp;
219  else {if (Status == Job_Cancel) sendResult(lp, (rc ? -1 : 1), rc);
220  jp = theJob->JobTable.Remove(JobNum);
221  }
222 
223 // At this point we may need to delete ourselves. If so, jp will not be zero.
224 // This must be the last action in this method.
225 //
226  theJob->myMutex.UnLock();
227  if (jp) delete jp;
228 }
#define TRACE(act, x)
Definition: XrdTrace.hh:63
#define jobInfo
int RunDone(XrdOucStream &cmd) const
Definition: XrdOucProg.cc:257
int Run(XrdOucStream *Sp, const char *argV[], int argc=0, const char *envV[]=0) const
Definition: XrdOucProg.cc:108
char * GetLine()
T * Remove(int Tnum)
Definition: XrdOucTable.hh:132

References XrdOucStream::GetLine(), Job_Cancel, Job_Done, jobInfo, XrdSysMutex::Lock(), XrdOucTable< T >::Remove(), XrdOucProg::Run(), XrdOucProg::RunDone(), Status, TRACE, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ XrdXrootdJob

friend class XrdXrootdJob
friend

Definition at line 56 of file XrdXrootdJob.cc.

Member Data Documentation

◆ Status

XrdSys::RAtomic<JobStatus> XrdXrootdJob2Do::Status

Definition at line 62 of file XrdXrootdJob.cc.

Referenced by XrdXrootdJob2Do(), DoIt(), XrdXrootdJob::Schedule(), and XrdXrootdJobWaiting().


The documentation for this class was generated from the following file: