KSquare Utilities
KKJobManagment::KKJobManager Class Referenceabstract

Responsable for keeping track of a list of jobs. More...

#include <KKJobManager.h>

+ Inheritance diagram for KKJobManagment::KKJobManager:

Public Types

typedef KKJobManagerJobManagerPtr
 
- Public Types inherited from KKJobManagment::KKJob
typedef map< KKStr, ConstructorPtrConstructorIndex
 
typedef KKJobPtr(* ConstructorPtr) (JobManagerPtr _manager)
 
enum  JobStatus {
  jsNULL, jsOpen, jsStarted, jsDone,
  jsExpanded
}
 
enum  JobTypes { jtNULL, jtBinaryCombo, jtMultiClass, jtRandomSplit }
 
typedef KKJobKKJobPtr
 

Public Member Functions

 KKJobManager (const KKJobManager &j)
 
 KKJobManager (JobManagerPtr _manager, kkint32 _jobId, kkint32 _parentId, kkint32 _numPorcessesAllowed, const KKStr &_managerName, kkint32 _numJobsAtATime, RunLog &_log)
 
 ~KKJobManager ()
 
kkint32 AllocateNextJobId ()
 
bool AreAllJobsDone ()
 
void Block ()
 
double CpuTimeTotalUsed () const
 
virtual KKJobPtr Duplicate () const =0
 
void EndBlock ()
 
kkint32 ExpansionCount () const
 
kkint32 GetNextJobId ()
 
void InitilizeJobManager (bool &successful)
 Initialize the KKJobManager object. More...
 
KKJobListPtr Jobs () const
 
virtual const char * JobType () const
 
const KKStr & ManagerName () const
 
kkint32 NextJobId () const
 
bool QuitRunning () const
 
void Restart ()
 
void Run ()
 
void SetQuitRunningFlag ()
 
bool SupportCompletedJobData () const
 
void SupportCompletedJobData (bool _supportCompletedJobData)
 
void Update (JobManagerPtr p)
 
- Public Member Functions inherited from KKJobManagment::KKJob
 KKJob (const KKJob &j)
 
 KKJob (JobManagerPtr _manager, kkint32 _jobId, kkint32 _parentId, kkint32 _numPorcessesAllowed, RunLog &_log)
 
 KKJob (JobManagerPtr _manager)
 
 ~KKJob ()
 
void AddPrerequisites (kkint32 _prerequisite)
 
void AddPrerequisites (VectorInt _prerequisites)
 
virtual void CompletedJobDataRead (istream &i)
 Works with 'WriteCompletedJobData'; You use this to load in data written by 'WriteCompletedJobData'. More...
 
virtual void CompletedJobDataWrite (ostream &o)
 Write out completed job results to status file. More...
 
bool InPrerequisites (kkint32 _jobId)
 
kkint32 JobId () const
 
void JobId (kkint32 _jobId)
 
RunLog & Log ()
 
JobManagerPtr Manager () const
 
kkint32 ParentId () const
 
const VectorInt & Prerequisites () const
 
virtual void ProcessNode ()
 
virtual void ProcessStatusField (const KKStr &fieldName, const KKStr &fieldValue)
 Imjpelmentation specific field processing. More...
 
virtual void ReFresh (KKJob &j)
 
JobStatus Status () const
 
void Status (JobStatus _status)
 
KKStr StatusStr () const
 

Protected Member Functions

virtual void StatusFileProcessLine (const KKStr &ln, istream &statusFile)
 
virtual void StatusFileProcessLineJobStatusChange (KKStr &statusLineStr)
 
virtual KKStr ToStatusStr ()
 
- Protected Member Functions inherited from KKJobManagment::KKJob
void PrerequisitesFromStr (const KKStr &s)
 
KKStr PrerequisitesToStr () const
 
void ProcessStatusStr (const KKStr &statusStr)
 

Additional Inherited Members

- Static Public Member Functions inherited from KKJobManagment::KKJob
static KKJobPtr CallAppropriateConstructor (JobManagerPtr _manager, const KKStr &_jobTypeName, const KKStr &_statusStr)
 
static JobStatus JobStatusFromStr (const KKStr &statusStr)
 
static KKStr JobStatusToStr (JobStatus status)
 
static void JobTypeFromStr (const KKStr &s)
 
static KKStr JobTypeToStr (JobTypes jt)
 
static void RegisterConstructor (const KKStr &_name, ConstructorPtr _constructor)
 
- Public Attributes inherited from KKJobManagment::KKJob
RunLog & log
 
- Static Public Attributes inherited from KKJobManagment::KKJob
static ConstructorIndex registeredConstructors
 
- Protected Attributes inherited from KKJobManagment::KKJob
kkint32 jobId
 
JobManagerPtr manager
 
kkint32 numPorcessesAllowed
 
kkint32 numProcessors
 
kkint32 parentId
 
VectorInt prerequisites
 
JobStatus status
 

Detailed Description

Responsable for keeping track of a list of jobs.

See the application called RandomSplitsJobManager. It is the first alplication to use this library; any class that is derived from this class are required to implement these method "StatusFileProcessLine", "StatusFileProcessLineJobStatusChange", "ToStatusStr"

Definition at line 29 of file KKJobManager.h.

Member Typedef Documentation

Constructor & Destructor Documentation

KKJobManager::KKJobManager ( const KKJobManager j)

Definition at line 43 of file KKJobManager.cpp.

References KKJobManagment::KKJob::AddPrerequisites(), KKB::DateTime::DateTime(), KKJobManagment::KKJob::KKJob(), KKJobManagment::KKJobList::KKJobList(), and KKB::KKStr::KKStr().

43  :
44  KKJob (j),
45 
46  cpuTimeLastReported (j.cpuTimeLastReported),
47  cpuTimeTotalUsed (j.cpuTimeTotalUsed),
48  dateTimeStarted (j.dateTimeStarted),
49  dateTimeEnded (j.dateTimeEnded),
50  dateTimeFirstOneFound (j.dateTimeFirstOneFound),
51  jobs (NULL),
52 
53  blockLevel (j.blockLevel),
54  lockFile (j.lockFile),
55  lockFileName (j.lockFileName),
56  lockFileOpened (j.lockFileOpened),
57  managerName (j.managerName),
58  expansionCount (j.expansionCount),
59  expansionFirstJobId (j.expansionFirstJobId),
60  nextJobId (j.nextJobId),
61  numJobsAtATime (j.numJobsAtATime),
62  procId (j.procId),
63  quitRunning (j.quitRunning),
64  restart (j.restart),
65  statusFileName (j.statusFileName),
66  statusFileNextByte (j.statusFileNextByte),
67  supportCompletedJobData (j.supportCompletedJobData)
68 
69 {
70  jobs = new KKJobList (*j.jobs);
71 }
KKJob(const KKJob &j)
Definition: KKJob.cpp:42
KKJobManagment::KKJobManager::KKJobManager ( JobManagerPtr  _manager,
kkint32  _jobId,
kkint32  _parentId,
kkint32  _numPorcessesAllowed,
const KKStr &  _managerName,
kkint32  _numJobsAtATime,
RunLog &  _log 
)
Parameters
_managerPtr to job that is managing this 'KKJobManager'
_managerNameName of this 'KKJobManager' ; status and lock file will be based on it.
_numJobsAtATimeThe number of jobs that can be allocatd at one time for a single process to execute.
KKJobManager::~KKJobManager ( )

Definition at line 126 of file KKJobManager.cpp.

127 {
128  delete jobs;
129  //EndBlock ();
130 }

Member Function Documentation

kkint32 KKJobManager::AllocateNextJobId ( )

Definition at line 709 of file KKJobManager.cpp.

710 {
711  kkint32 jobId = nextJobId;
712  nextJobId++;
713  return jobId;
714 }
__int32 kkint32
Definition: KKBaseTypes.h:88
bool KKJobManager::AreAllJobsDone ( )

Definition at line 954 of file KKJobManager.cpp.

References KKJobManagment::KKJobList::AreAllJobsDone().

955 {
956  if (jobs)
957  {
958  return jobs->AreAllJobsDone ();
959  }
960  else
961  {
962  // Will assume false for now.
963  return false;
964  }
965 } /* AreAllJobsAreDone */
void KKJobManager::Block ( )

Definition at line 191 of file KKJobManager.cpp.

References KKB::osSleep().

Referenced by InitilizeJobManager(), Run(), and SetQuitRunningFlag().

192 {
193  blockLevel++;
194  log.Level (20) << "KKJobManager::Block blockLevel[" << blockLevel << "]" << endl;
195  if (blockLevel > 1)
196  {
197  // We already have a Block established; so there is no need to establish it now.
198  return;
199  }
200 
201 
202  if (lockFileOpened)
203  {
204  // We have out Lock and EndLock calls out of order.
205  log.Level (-1) << endl << endl
206  << "KKJobManager::Block *** WE ALREADY HAVE A BLOCK ESTABLISHED ***." << endl
207  << endl;
208  return;
209  }
210 
211  kkint32 count = 0;
212 
213  do {
214  lockFile = open (lockFileName.Str (), O_WRONLY | O_CREAT | O_EXCL);
215  if (lockFile < 0)
216  {
217  count++;
218  float zed = (float)((procId + rand ()) % 10) + 2.0f;
219  log.Level (10) << "KKJobManager::Block - We are locked out[" << count << "] for [" << zed << "] secs." << endl;
220  osSleep (zed);
221  }
222  } while (lockFile < 0);
223 
224  if (count > 0)
225  log.Level (10) << "KKJobManager::Block Lock has been established." << endl;
226 
227  lockFileOpened = true;
228 
229  log.Level (20) << "KKJobManager::Block - Lock is Established." << endl;
230 } /* Block */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
void osSleep(float numOfSecs)
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
double KKJobManagment::KKJobManager::CpuTimeTotalUsed ( ) const
inline

Definition at line 65 of file KKJobManager.h.

65 {return cpuTimeTotalUsed;}
virtual KKJobPtr KKJobManagment::KKJobManager::Duplicate ( ) const
pure virtual

Create a duplicate instance.

Reimplemented from KKJobManagment::KKJob.

void KKJobManager::EndBlock ( )

Definition at line 235 of file KKJobManager.cpp.

Referenced by InitilizeJobManager(), Run(), SetQuitRunningFlag(), and StatusFileProcessLineJobStatusChange().

236 {
237  blockLevel--;
238 
239  #ifndef WIN32
240  kkint32 returnCd;
241  #endif
242 
243 
244  log.Level (20) << "KKJobManager::EndBlock - Ending Block blockLevel[" << blockLevel << "]" << endl;
245 
246  if (blockLevel > 0)
247  {
248  // We are still nested in Block Levels. must reach 'blockLevel == 0' before we can UnBlock.
249  return;
250  }
251 
252  if (!lockFileOpened)
253  {
254  log.Level (-1) << endl << endl << endl
255  << "KKJobManager::EndBlock *** Lock file is not opened ***" << endl;
256  return;
257  }
258 
259  close (lockFile);
260  lockFileOpened = false;
261 
262  #ifdef WIN32
263  if (!DeleteFile (lockFileName.Str ()))
264  {
265  DWORD fileAttributes = GetFileAttributes (lockFileName.Str ());
266  fileAttributes = FILE_ATTRIBUTE_NORMAL;
267  if (!SetFileAttributes (lockFileName.Str (), fileAttributes))
268  {
269  DWORD lastErrorNum = GetLastError ();
270  log.Level (-1) << "KKJobManager::EndBlock - *** ERROR *** Could not set Lock File to Normal." << endl;
271  }
272  else
273  {
274  if (!DeleteFile (lockFileName.Str ()))
275  {
276  DWORD lastErrorNum = GetLastError ();
277  log.Level (-1) << "KKJobManager::EndBlock - Error[" << (kkuint32)lastErrorNum << "] deleting Lock File." << endl;
278  }
279  }
280  }
281  #else
282  returnCd = unlink (lockFileName.Str ());
283  #endif
284 
285  log.Level (20) << "EndBlock - Unlocking" << endl;
286  return;
287 } /* EndBlock */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
unsigned __int32 kkuint32
Definition: KKBaseTypes.h:89
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
const char * Str() const
Returns a pointer to a ascii string.
Definition: KKStr.h:422
kkint32 KKJobManagment::KKJobManager::ExpansionCount ( ) const
inline

Definition at line 66 of file KKJobManager.h.

66 {return expansionCount;}
kkint32 KKJobManager::GetNextJobId ( )

Definition at line 292 of file KKJobManager.cpp.

293 {
294  kkint32 jobIdToReturn = nextJobId;
295  nextJobId++;
296  return jobIdToReturn;
297 }
__int32 kkint32
Definition: KKBaseTypes.h:88
void KKJobManager::InitilizeJobManager ( bool &  successful)

Initialize the KKJobManager object.

This is the first Method that needs to be called right after the object is constructed.

Definition at line 134 of file KKJobManager.cpp.

References Block(), KKB::KKStr::Concat(), EndBlock(), KKB::osFileExists(), and KKB::osGetSystemTimeUsed().

135 {
136  successful = true;
137  Block ();
138 
139  cpuTimeLastReported = osGetSystemTimeUsed ();
140 
141  if (!osFileExists (statusFileName))
142  {
143  try
144  {
145  LoadRunTimeData ();
146  }
147  catch (KKStr errorMsg)
148  {
149  log.Level (-1) << endl << endl
150  << "KKJobManager::InitilizeJobManager ***ERROR*** Load of 'LoadRunTimeData' Failed." << endl
151  << endl
152  << errorMsg << endl
153  << endl;
154  successful = false;
155  return;
156  }
157  StatusFileInitialize ();
158  }
159  else
160  {
161  StatusFileLoad ();
162  try
163  {
164  LoadRunTimeData ();
165  }
166  catch (KKStr errorMsg)
167  {
168  log.Level (-1) << endl << endl
169  << "KKJobManager::InitilizeJobManager ***ERROR*** Load of 'LoadRunTimeData' Failed." << endl
170  << endl
171  << errorMsg << endl
172  << endl;
173  successful = false;
174  return;
175  }
176  }
177 
178  EndBlock ();
179 } /* InitilizeJobManager */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
double osGetSystemTimeUsed()
Returns the number of CPU seconds used by current process.
bool osFileExists(const KKStr &_fileName)
Definition: OSservices.cpp:568
KKJobListPtr KKJobManagment::KKJobManager::Jobs ( ) const
inline

Definition at line 67 of file KKJobManager.h.

67 {return jobs;}
const char * KKJobManager::JobType ( ) const
virtual

Allows us to know which specific implementaion of 'KKJob' an instance really is.

Reimplemented from KKJobManagment::KKJob.

Definition at line 184 of file KKJobManager.cpp.

185 {
186  return "KKJobManager";
187 }
const KKStr& KKJobManagment::KKJobManager::ManagerName ( ) const
inline

Definition at line 68 of file KKJobManager.h.

68 {return managerName;}
kkint32 KKJobManagment::KKJobManager::NextJobId ( ) const
inline

Definition at line 69 of file KKJobManager.h.

69 {return nextJobId;}
bool KKJobManagment::KKJobManager::QuitRunning ( ) const
inline

Definition at line 70 of file KKJobManager.h.

70 {return quitRunning;}
void KKJobManagment::KKJobManager::Restart ( )
void KKJobManager::Run ( )

Definition at line 970 of file KKJobManager.cpp.

References KKJobManagment::KKJob::AddPrerequisites(), Block(), KKJobManagment::KKJob::Duplicate(), EndBlock(), KKJobManagment::KKJobList::JobsStillRunning(), KKJobManagment::KKJob::jsDone, KKJobManagment::KKJobList::KKJobList(), KKJobManagment::KKJob::ProcessNode(), KKJobManagment::KKJobList::PushOnBack(), and KKJobManagment::KKJob::status.

971 {
972  log.Level (10) << "KKJobManager::Run." << endl;
973 
974  bool keepOnRunning = true;
975 
976  KKJobListPtr executedJobs = NULL;
977  KKJobListPtr jobsToExecute = GetNextSetOfJobs (NULL);
978 
979  while (keepOnRunning && (!quitRunning))
980  {
981  if (jobsToExecute)
982  {
983  delete executedJobs; executedJobs = NULL;
984 
985  executedJobs = new KKJobList (this);
986  executedJobs->Owner (true);
987 
988  KKJobList::iterator idx;
989  for (idx = jobsToExecute->begin (); idx != jobsToExecute->end (); idx++)
990  {
991  KKJobPtr j = *idx;
992  j->ProcessNode ();
993  executedJobs->PushOnBack (j->Duplicate ());
994  }
995  delete jobsToExecute; jobsToExecute = NULL;
996  }
997  else
998  {
999  if (!(jobs->JobsStillRunning ()))
1000  {
1001  keepOnRunning = false;
1002  }
1003  else
1004  {
1005  // We will sleep for a bit until there are more jobs to run
1006  log.Level (10) << "KKJobManager::Run No jobs avaialble to run; will sleep a bit." << endl;
1007  osSleep ((float)(30 + rand () % 10));
1008  }
1009  }
1010 
1011  if (keepOnRunning)
1012  jobsToExecute = GetNextSetOfJobs (executedJobs);
1013 
1014  delete executedJobs; executedJobs = NULL;
1015  }
1016 
1017 
1018  Block ();
1019  StatusFileRefresh ();
1020  if ((!quitRunning) && (status != KKJob::jsDone))
1021  {
1022  if (status != KKJob::jsDone)
1023  {
1024  GenerateFinalResultsReport ();
1025 
1027 
1028  ofstream* statusFile = StatusFileOpen (ios::app);
1029 
1030  *statusFile << "Status" << "\t" << StatusStr () << endl;
1031 
1032  ReportCpuTimeUsed (statusFile);
1033 
1034  statusFile->close ();
1035  delete statusFile;
1036  }
1037  }
1038  EndBlock ();
1039 
1040 
1041  log.Level (10) << "KKJobManager::Run Exiting." << endl;
1042 } /* Run */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
virtual void ProcessNode()
Definition: KKJob.cpp:119
KKStr StatusStr() const
Definition: KKJob.cpp:218
virtual KKJobPtr Duplicate() const
Definition: KKJob.cpp:112
void osSleep(float numOfSecs)
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
JobStatus status
Definition: KKJob.h:224
void PushOnBack(KKJobPtr j)
Definition: KKJob.cpp:456
void KKJobManager::SetQuitRunningFlag ( )

Definition at line 785 of file KKJobManager.cpp.

References Block(), and EndBlock().

786 {
787  Block ();
788  ofstream* statusFile = StatusFileOpen (ios::app);
789 
790  *statusFile << "QuitRunning" << endl;
791  quitRunning = true;
792 
793  statusFile->flush ();
794  statusFile->close ();
795  delete statusFile; statusFile = NULL;
796 
797  EndBlock ();
798 } /* SetQuitRunningFlag */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
void KKJobManager::StatusFileProcessLine ( const KKStr ln,
istream &  statusFile 
)
protectedvirtual

Definition at line 341 of file KKJobManager.cpp.

References KKJobManagment::KKJob::AddPrerequisites(), KKJobManagment::KKJob::CallAppropriateConstructor(), KKB::KKStr::CompareIgnoreCase(), KKB::KKStr::Concat(), KKB::DateTime::DateTime(), KKB::KKStr::Empty(), KKB::KKStr::EqualIgnoreCase(), KKB::KKStr::ExtractToken2(), KKB::KKStr::ExtractTokenDouble(), KKB::KKStr::ExtractTokenInt(), KKJobManagment::KKJob::JobId(), KKJobManagment::KKJob::JobStatusFromStr(), KKB::KKStr::KKStr(), KKJobManagment::KKJobList::LookUpByJobId(), KKB::KKStr::operator=(), KKB::DateTime::operator=(), KKB::KKStr::operator==(), KKJobManagment::KKJobList::PushOnBack(), KKJobManagment::KKJob::ReFresh(), KKJobManagment::KKJob::status, StatusFileProcessLineJobStatusChange(), KKB::KKStr::SubStrPart(), KKB::KKStr::ToInt(), KKB::KKStr::TrimLeft(), and KKB::KKStr::TrimRight().

344 {
345  if (ln.SubStrPart (0, 1) == "//")
346  {
347  // A coment line; we can ignore it.
348  return;
349  }
350 
351  KKStr statusStr (ln);
352  KKStr fieldName = statusStr.ExtractToken2 ("\t");
353  if (fieldName.Empty ())
354  {
355  // A empty line we will ignore it.
356  return;
357  }
358 
359  statusStr.TrimLeft ("\n\r\t ");
360  statusStr.TrimRight ("\n\r\t ");
361 
362  if (fieldName.CompareIgnoreCase ("JOB") == 0)
363  {
364  // We have a KKJob entr line; the next field determines JobType fllowed by parameters for that JobType constructor.
365  KKStr jobTypeName = fieldName = statusStr.ExtractToken2 ("\t");
366 
367  KKJobPtr j = KKJob::CallAppropriateConstructor (this, jobTypeName, statusStr);
368  KKJobPtr existingJob = jobs->LookUpByJobId (j->JobId ());
369  if (existingJob)
370  {
371  existingJob->ReFresh (*j);
372  delete j; j = NULL;
373  }
374  else
375  {
376  jobs->PushOnBack (j);
377  }
378  }
379 
380  else if (fieldName.EqualIgnoreCase ("CPUTIMEUSED"))
381  {
382  double cpuTimeUsed = statusStr.ExtractTokenDouble ("\t");
383  cpuTimeTotalUsed += cpuTimeUsed;
384  }
385 
386  else if (fieldName.EqualIgnoreCase ("CURRENTDATETIME"))
387  {
388  KKB::DateTime dateTime = KKB::DateTime (statusStr);
389  if (!dateTimeFirstOneFound)
390  {
391  dateTimeFirstOneFound = true;
392  dateTimeStarted = dateTime;
393  }
394  dateTimeEnded = dateTime;
395  }
396 
397  else if (fieldName.EqualIgnoreCase ("ExpansionCount"))
398  expansionCount = statusStr.ToInt ();
399 
400  else if (fieldName.EqualIgnoreCase ("ExpansionFirstJobId"))
401  expansionFirstJobId = statusStr.ToInt ();
402 
403  else if (fieldName.EqualIgnoreCase ("JobStatusChange"))
405 
406  else if (fieldName.EqualIgnoreCase ("NextJobId"))
407  nextJobId = statusStr.ExtractTokenInt ("\t");
408 
409  else if (fieldName.EqualIgnoreCase ("QuitRunning"))
410  quitRunning = true;
411 
412  else if (fieldName.EqualIgnoreCase ("Restart"))
413  restart = false;
414 
415  else if (fieldName.EqualIgnoreCase ("Status"))
416  status = KKJob::JobStatusFromStr (statusStr);
417 
418  else
419  {
420  log.Level (-1) << "KKJobManager::StatusFileProcessLine Invalid Field Name[" << fieldName << "]." << endl;
421  }
422 } /* StatusFileProcessLine */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
kkint32 CompareIgnoreCase(const KKStr &s2) const
Compares with another KKStr, ignoring case.
Definition: KKStr.cpp:919
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
static JobStatus JobStatusFromStr(const KKStr &statusStr)
Definition: KKJob.cpp:198
bool EqualIgnoreCase(const KKStr &s2) const
Definition: KKStr.cpp:1250
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
static KKJobPtr CallAppropriateConstructor(JobManagerPtr _manager, const KKStr &_jobTypeName, const KKStr &_statusStr)
Definition: KKJob.cpp:145
virtual void StatusFileProcessLineJobStatusChange(KKStr &statusLineStr)
JobStatus status
Definition: KKJob.h:224
void TrimLeft(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1745
bool Empty() const
Definition: KKStr.h:241
kkint32 JobId() const
Definition: KKJob.h:118
virtual void ReFresh(KKJob &j)
Definition: KKJob.cpp:163
void PushOnBack(KKJobPtr j)
Definition: KKJob.cpp:456
KKStr SubStrPart(kkint32 firstChar) const
returns a SubString consisting of all characters starting at index &#39;firstChar&#39; until the end of the s...
Definition: KKStr.cpp:2780
KKJobPtr LookUpByJobId(kkint32 jobId)
Definition: KKJob.cpp:391
void KKJobManager::StatusFileProcessLineJobStatusChange ( KKStr statusLineStr)
protectedvirtual

Definition at line 302 of file KKJobManager.cpp.

References KKJobManagment::KKJob::AddPrerequisites(), KKB::KKStr::Concat(), EndBlock(), KKB::KKStr::ExtractToken2(), KKB::KKStr::ExtractTokenInt(), KKJobManagment::KKJob::JobStatusFromStr(), KKJobManagment::KKJob::jsNULL, KKJobManagment::KKJobList::LookUpByJobId(), KKB::osWaitForEnter(), KKJobManagment::KKJob::Status(), KKB::KKStr::TrimLeft(), and KKB::KKStr::TrimRight().

Referenced by StatusFileProcessLine().

303 {
304  kkint32 expandedJobId = statusLineStr.ExtractTokenInt ("\t");
305  KKJobPtr j = jobs->LookUpByJobId (expandedJobId);
306  if (!j)
307  {
308  log.Level (-1) << endl << endl << endl
309  << "ProcessStatusLineJobStatusChange ***Error*** Could not locate Expanded" << endl
310  << endl
311  << " JobId[" << expandedJobId << "]" << endl
312  << endl;
313  EndBlock ();
314  osWaitForEnter ();
315  exit (-1);
316  }
317 
318  KKStr statusStr = statusLineStr.ExtractToken2 ("\t");
319  statusStr.TrimLeft ();
320  statusStr.TrimRight ();
322  if (status == jsNULL)
323  {
324  log.Level (-1) << endl << endl << endl
325  << "ProcessStatusLineJobStatusChange ***Error*** Invalid Status Specified" << endl
326  << endl
327  << " JobId[" << expandedJobId << "]" << endl
328  << " Status[" << statusStr << "]" << endl
329  << endl;
330  EndBlock ();
331  osWaitForEnter ();
332  exit (-1);
333  }
334 
335  j->Status (status);
336 } /* ProcessStatusLineJobStatusChange */
HTMLReport &__cdecl endl(HTMLReport &htmlReport)
Definition: HTMLReport.cpp:240
__int32 kkint32
Definition: KKBaseTypes.h:88
KKStr & TrimRight(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1695
KKStr ExtractToken2(const char *delStr="\n\t\r ")
Extract first Token from the string.
Definition: KKStr.cpp:3026
void osWaitForEnter()
static JobStatus JobStatusFromStr(const KKStr &statusStr)
Definition: KKJob.cpp:198
RunLog & Level(kkint32 _level)
Definition: RunLog.cpp:220
JobStatus status
Definition: KKJob.h:224
void TrimLeft(const char *whiteSpaceChars="\n\r\t ")
Definition: KKStr.cpp:1745
JobStatus Status() const
Definition: KKJob.h:123
kkint32 ExtractTokenInt(const char *delStr)
Definition: KKStr.cpp:3129
KKJobPtr LookUpByJobId(kkint32 jobId)
Definition: KKJob.cpp:391
bool KKJobManagment::KKJobManager::SupportCompletedJobData ( ) const
inline

Definition at line 60 of file KKJobManager.h.

60 {return supportCompletedJobData;}
void KKJobManagment::KKJobManager::SupportCompletedJobData ( bool  _supportCompletedJobData)
inline

Definition at line 62 of file KKJobManager.h.

62 {supportCompletedJobData = _supportCompletedJobData;}
KKStr KKJobManager::ToStatusStr ( )
protectedvirtual

derived classes should implement this method. They need to return a tab delimietd string with all there parameters <FieldName1> <> <FieldValue1> <> <fieldName2> <> <FieldValue2> etc etc etc ... They should call the base Class version of this method and return that string first. ex: return KKJobManager::ToStatusStr () + "\t" + "FieldName1" + "\t" + "Value1" + "\t" + "FieldName2" + "\t" + "Value2";

Reimplemented from KKJobManagment::KKJob.

Definition at line 728 of file KKJobManager.cpp.

References KKJobManagment::KKJob::AddPrerequisites(), KKB::KKStr::Concat(), KKJobManagment::KKJob::JobStatusToStr(), KKB::KKStr::KKStr(), KKJobManagment::KKJob::status, and KKJobManagment::KKJob::ToStatusStr().

729 {
730  KKStr statusStr (200); // PreAllocate 200 bytes
731 
732  statusStr << KKJob::ToStatusStr () << "\t"
733  << "Status" << "\t" << KKJob::JobStatusToStr (status) << "\t"
734  << "NextJobId" << "\t" << nextJobId << "\t"
735  << "ExpansionCount" << "\t" << expansionCount << "\t"
736  << "ExpansionFirstJobId" << "\t" << expansionFirstJobId;
737 
738  return statusStr;
739 } /* ToStatusStr */
static KKStr JobStatusToStr(JobStatus status)
Definition: KKJob.cpp:178
JobStatus status
Definition: KKJob.h:224
virtual KKStr ToStatusStr()
Definition: KKJob.cpp:261
void KKJobManager::Update ( JobManagerPtr  p)

Definition at line 719 of file KKJobManager.cpp.

References KKJobManagment::KKJob::status.

720 {
721  status = p->status;
722 }
JobStatus status
Definition: KKJob.h:224

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