OpendTect  6.3
jobiomgr.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*+
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H.Lammertink
8  Date: Oct 2004
9 ________________________________________________________________________
10 
11 -*/
12 
13 #include "mmprocmod.h"
14 
15 #include "bufstring.h"
16 #include "callback.h"
17 #include "oscommand.h"
18 
19 class CommandString;
20 class HostData;
21 class JobInfo;
22 class JobIOHandler;
23 class od_ostream;
24 namespace File { class Path; }
25 template <class T> class ObjQueue;
26 
39 {
40 public:
41  StatusInfo( char tg, int desc, int stat, int pid,
42  const char* mg, const char* hostname,
43  int time )
44  : tag(tg), descnr(desc), status(stat), msg(mg)
45  , hostnm(hostname), timestamp(time), procid(pid) {}
46 
47  char tag;
48  int descnr;
49  int status;
50  int timestamp;
51  int procid;
54 };
55 
56 
63 {
64 public:
65  enum Mode { Work, Pause, Stop };
66 
67  JobIOMgr(int firstport=19345,float priority=-1.f,
68  od_ostream* logstrm=0);
69  virtual ~JobIOMgr();
70 
71  const char* peekMsg() { if ( msg_.size() ) return msg_; return 0; }
72  void fetchMsg( BufferString& bs ) { bs = msg_; msg_ = "";}
73 
74  bool startProg(const char*,IOPar&,const File::Path&,
75  const JobInfo&,const char*);
76 
77  void setPriority( float p );
78  void reqModeForJob(const JobInfo&,Mode);
79  void removeJob(const char*,int);
80  bool isReady() const;
81 
82  ObjQueue<StatusInfo>& statusQueue();
83 
84  static bool mkIOParFile(const File::Path& basefnm,
85  const HostData&,const IOPar&,
86  File::Path&,BufferString& msg);
87  static BufferString mkRexecCmd(const char* prognm,
88  const HostData& machine,
89  const HostData& localhost);
98 protected:
99 
100  JobIOHandler& iohdlr_;
104 
105  void mkCommand(OS::MachineCommand&,const HostData&,
106  const char* progname,const File::Path& basefp,
107  const File::Path& iopfp,const JobInfo&,
108  const char* rshcomm);
109 
110 };
111 
112 
113 mGlobal(MMProc) const OD::String& getTempBaseNm();
114 mGlobal(MMProc) int mkTmpFileNr();
115 
116 
118 {
119 public:
120  CommandString(const HostData& targetmachine,
121  const char* init=0);
122 
123  CommandString& operator=(const char*);
124 
125  void addFlag(const char* flag,const char* value);
126  void addFlag(const char* flag,int value);
127  void addFilePath(const File::Path&);
128 
129  const OD::String& string() { return cmd_; }
130 
131 private:
132 
133  void add(const char*);
134 
137 
138 };
#define mExpClass(module)
Definition: commondefs.h:157
Interface for several file and directory related services.
Definition: file.h:29
Inherit from this class to be able to send and/or receive CallBacks.
Definition: callback.h:182
BufferString cmd_
Definition: jobiomgr.h:135
OD class for stream write common access to the user log file, or std::cout in batch progs...
Definition: od_ostream.h:25
Specifies how to execute a command.
Definition: oscommand.h:31
#define mGlobal(module)
Definition: commondefs.h:160
Encapsulates status message from a running client.
Definition: jobiomgr.h:38
bool init()
Encapsulates an actual command to execute + the machine to run it on.
Definition: oscommand.h:77
int status
Definition: jobiomgr.h:49
Definition: jobiomgr.h:117
int mkTmpFileNr()
Handles starting & stopping of jobs on client machines. Sets up a separate thread to maintain contact...
Definition: jobiomgr.h:62
File pathname tools.
Definition: filepath.h:35
Queue of objects.
Definition: queue.h:37
const OD::String & string()
Definition: jobiomgr.h:129
const OD::String & getTempBaseNm()
JobIOHandler & iohdlr_
Definition: jobiomgr.h:100
OS::CommandExecPars execpars_
Definition: jobiomgr.h:102
BufferString msg_
Definition: jobiomgr.h:101
Generalized set of parameters of the keyword-value type.
Definition: iopar.h:53
void fetchMsg(BufferString &bs)
Definition: jobiomgr.h:72
encapsulates the read-access-only part of strings in OD.
Definition: odstring.h:29
int descnr
Definition: jobiomgr.h:48
char tag
Definition: jobiomgr.h:47
Mode
Definition: jobiomgr.h:65
Multi Machine Processing.
Definition: mmassetmgr.h:21
Definition: jobiomgr.h:65
const char * peekMsg()
Definition: jobiomgr.h:71
BufferString msg
Definition: jobiomgr.h:53
BufferString hostnm
Definition: jobiomgr.h:52
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size...
Definition: bufstring.h:38
int timestamp
Definition: jobiomgr.h:50
int procid
Definition: jobiomgr.h:51
OpendTect.
Definition: commontypes.h:25
StatusInfo(char tg, int desc, int stat, int pid, const char *mg, const char *hostname, int time)
Definition: jobiomgr.h:41
const HostData & hstdata_
Definition: jobiomgr.h:136
Host name and aliases.
Definition: hostdata.h:34
#define mClass(module)
Definition: commondefs.h:161
void add(T *item)
item becomes MINE!
Definition: queue.h:43
od_ostream * logstrm_
Definition: jobiomgr.h:103
All information on a job.
Definition: jobinfo.h:22

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