OpendTect-6_4  6.4
jobrunner.h
Go to the documentation of this file.
1 #ifndef jobrunner_h
2 #define jobrunner_h
3 
4 /*+
5 ________________________________________________________________________
6 
7  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
8  Author: A.H.Bril
9  Date: Oct 2004
10  RCS: $Id$
11 ________________________________________________________________________
12 
13 -*/
14 
15 #include "mmprocmod.h"
16 #include "executor.h"
17 #include "jobinfo.h"
18 
19 class BufferStringSet;
20 class FilePath;
21 class HostData;
22 class JobDescProv;
23 class JobIOMgr;
24 class StatusInfo;
25 
31 { mODTextTranslationClass(HostNFailInfo);
32 public:
33  HostNFailInfo( const HostData& hd )
34  : hostdata_(hd)
35  , nrfailures_(0)
36  , nrsucces_(0)
37  , lastsuccess_(0)
38  , starttime_(0)
39  , inuse_(false) {}
40 
43  int nrsucces_;
44  int starttime_;
46  bool inuse_;
47 };
48 
49 
56 public:
57 
58  JobRunner(JobDescProv*,const char* cmd);
60  ~JobRunner();
61 
62  const JobDescProv* descProv() const { return descprov_; }
63 
64  const ObjectSet<HostNFailInfo>& hostInfo() const { return hostinfo_; }
65  bool addHost(const HostData&);
66  void removeHost(int);
67  void pauseHost(int,bool);
68  bool stopAll();
69  bool hostFailed(int) const;
70  bool isPaused(int) const;
71  bool isAssigned( const JobInfo& ji ) const;
72 
73  int nrJobs( bool failed=false ) const
74  { return (failed ? failedjobs_ : jobinfos_)
75  .size(); }
76  const JobInfo& jobInfo( int idx, bool failed=false ) const
77  { return *(failed ? failedjobs_ : jobinfos_)
78  [idx]; }
79 
80  int jobsDone() const;
81  int jobsInProgress() const;
82  int jobsLeft() const
83  { return jobinfos_.size() - jobsDone(); }
84  int totalJobs() const
85  { return jobinfos_.size()+failedjobs_.size(); }
86  JobInfo* currentJob(const HostNFailInfo*) const;
87 
88  int nextStep() { return doCycle(); }
89  od_int64 nrDone() const { return jobsDone(); }
90  od_int64 totalNr() const { return totalJobs(); }
91  uiString uiMessage() const;
92  uiString nrDoneMessage() const;
93 
94  // Set these before first step
95  void setFirstPort( int n ) { firstport_ = n; }
96  void setRshComm( const char* s ) { rshcomm_ = s; }
97  void setProg( const char* s ) { prog_ = s; }
98  // Set this anytime
99  void setNiceNess( int n );
100 
101  void showMachStatus( BufferStringSet& ) const;
102  const FilePath& getBaseFilePath(JobInfo&, const HostData&);
103 
108 
109  const JobInfo& curJobInfo() const { return *curjobinfo_; }
110  IOPar& curJobIOPar() { return curjobiop_; }
111  const FilePath& curJobFilePath() { return curjobfp_; }
112  int getLastReceivedTime(JobInfo&);
113 
114  const char* procDir() const { return procdir_.buf(); }
115  // processing directory on local machine
116  uiString errorMsg() const;
117 
118 protected:
119 
129 
130  JobIOMgr& iomgr();
132 
133  int niceval_;
145 
146  int doCycle();
147  HostNFailInfo* hostNFailInfoFor(const HostData*) const;
148 
149  void updateJobInfo();
150  void handleStatusInfo( StatusInfo& );
151  JobInfo* gtJob( int descnr );
152 
153  void failedJob( JobInfo&, JobInfo::State );
154 
155  enum StartRes { Started, NotStarted, JobBad, HostBad };
156  StartRes startJob( JobInfo& ji, HostNFailInfo& jhi );
157  bool runJob(JobInfo&,const HostData&);
158 
159 
160  enum AssignStat { NotReady, BadHost, JobStarted, NoJobs };
161  AssignStat assignJob(HostNFailInfo&);
162  bool haveIncomplete() const;
163 
164  enum HostStat { OK = 0, SomeFailed = 1, HostFailed = 2 };
165  HostStat hostStatus(const HostNFailInfo*) const;
166  void handleExitStatus(JobInfo&);
167 };
168 
169 #endif
#define mExpClass(module)
Definition: commondefs.h:160
int nextStep()
Definition: jobrunner.h:88
od_int64 totalNr() const
Definition: jobrunner.h:90
int nrJobs(bool failed=false) const
Definition: jobrunner.h:73
const JobInfo & curJobInfo() const
Definition: jobrunner.h:109
IOPar & curJobIOPar()
Definition: jobrunner.h:110
uiString errmsg_
Definition: jobrunner.h:144
int failtimeout_
Definition: jobrunner.h:140
#define mODTextTranslationClass(clss)
Definition: uistring.h:38
void setRshComm(const char *s)
Definition: jobrunner.h:96
int nrfailures_
Reset to 0 at every success.
Definition: jobrunner.h:42
Encapsulates status message from a running client.
Definition: jobiomgr.h:38
BufferString rshcomm_
Definition: jobrunner.h:135
#define od_int64
Definition: plftypes.h:36
JobInfo * curjobinfo_
Definition: jobrunner.h:128
Definition: jobrunner.h:160
const FilePath & curJobFilePath()
Definition: jobrunner.h:111
int wrapuptimeout_
Definition: jobrunner.h:141
Handles starting & stopping of jobs on client machines. Sets up a separate thread to maintain contact...
Definition: jobiomgr.h:62
int starttime_
Set whenever host added.
Definition: jobrunner.h:44
Definition: uistring.h:89
int starttimeout_
Definition: jobrunner.h:139
const JobDescProv * descProv() const
Definition: jobrunner.h:62
Set of BufferString objects.
Definition: bufstringset.h:28
const ObjectSet< HostNFailInfo > & hostInfo() const
Definition: jobrunner.h:64
int hosttimeout_
Definition: jobrunner.h:142
BufferString procdir_
Definition: jobrunner.h:125
int maxhostfailures_
host failrs B4 host bad
Definition: jobrunner.h:136
JobDescProv * descprov_
Definition: jobrunner.h:120
int jobsLeft() const
Definition: jobrunner.h:82
HostStat
Definition: jobrunner.h:164
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:47
Interface for providing parameter files for jobs (job descriptions). Two implementations are pre-cook...
Definition: jobdescprov.h:27
Notifier< JobRunner > postJobStart
Definition: jobrunner.h:105
int descnr
Definition: jobiomgr.h:48
FilePath & curjobfp_
Definition: jobrunner.h:126
AssignStat
Definition: jobrunner.h:160
bool inuse_
Definition: jobrunner.h:46
int firstport_
Definition: jobrunner.h:134
Multi Machine Processing.
Definition: mmassetmgr.h:23
const char * procDir() const
Definition: jobrunner.h:114
Holds host-specific status information.
Definition: jobrunner.h:30
ObjectSet< JobInfo > jobinfos_
Definition: jobrunner.h:121
ObjectSet< HostNFailInfo > hostinfo_
Definition: jobrunner.h:122
const HostData & hostdata_
Definition: jobrunner.h:41
File pathname tools.
Definition: filepath.h:34
Notifier< JobRunner > msgAvail
Definition: jobrunner.h:107
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:40
IOPar & curjobiop_
Definition: jobrunner.h:127
int startwaittime_
wait B4 next client start
Definition: jobrunner.h:143
int totalJobs() const
Definition: jobrunner.h:84
Runs all jobs defined by JobDescProv.
Definition: jobrunner.h:54
BufferString prog_
Definition: jobrunner.h:124
int maxjobfailures_
job related job failrs
Definition: jobrunner.h:137
int maxjobhstfails_
host related job failrs
Definition: jobrunner.h:138
Notifier< JobRunner > preJobStart
Definition: jobrunner.h:104
HostNFailInfo(const HostData &hd)
Definition: jobrunner.h:33
int nrsucces_
Definition: jobrunner.h:43
Host name and aliases.
Definition: hostdata.h:36
od_int64 nrDone() const
Definition: jobrunner.h:89
StartRes
Definition: jobrunner.h:155
ObjectSet< JobInfo > failedjobs_
Definition: jobrunner.h:123
JobIOMgr * iomgr_
Definition: jobrunner.h:131
void setFirstPort(int n)
Definition: jobrunner.h:95
void setProg(const char *s)
Definition: jobrunner.h:97
int niceval_
Definition: jobrunner.h:133
All information on a job.
Definition: jobinfo.h:24
int lastsuccess_
timestamp
Definition: jobrunner.h:45
Notifier< JobRunner > jobFailed
Definition: jobrunner.h:106
Specification to enable chunkwise execution of a process.
Definition: executor.h:39
State
Definition: jobinfo.h:29
const JobInfo & jobInfo(int idx, bool failed=false) const
Definition: jobrunner.h:76

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019