Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

Slave Class Reference

#include <Slave.h>

Inheritance diagram for Slave:

Object List of all members.

Public Methods

 Slave (int catchSignal=0)
 ~Slave ()
void startSlave ()
void startTask ()
void endTask (int err)
void startTimer ()
void startcbTaskStop ()
void startcbTaskCtrl ()
int sndTaskFinish (const char *datares)
int sndTaskMove ()
int sndTaskStatus (TaskId *taskId, task_state stat, char *error=0)
int sndSlaveStatus ()
void setTaskStop (void(*cb)(void))
void setTaskCtrl (void(*cb)(const char *arg))
int put_data (const char *fileName, const char *url_upload, int taskId0)
int get_data (const char *fileName, const char *url_download, int taskId0)
char * get_tmp_dir ()
long get_max_runtime ()
virtual int compare (Object *)
virtual ObjectCopy ()

Private Methods

void stopTask ()
void dispatchMsg (XMLData *msg)
void msgTaskInit (XMLData *msg)
void msgTaskCtrl (XMLData *msg)
void msgTaskCtrl_Stop ()
void msgSlaveCtrl (XMLData *msg)
int getLibrary (const char *taskURL, char *taskLib, char *err_buff)
void detectSlaveInfo (SlaveInfo *slaveInfo)
void detectCPU (int &freq)
void detectMemory (double &mem)
void detectDisk (double &disk)
int detectUserStat ()
int slaveUpgrade (char *oldSlave, char *newSlave)

Private Attributes

PostOfficepo
Address master
Address remote
int firsttime
char data [UDP_MAXSIZE]
char datares [UDP_MAXSIZE]
char userdata [UDP_MAXSIZE]
long max_runtime
Lock lock
Semaphore sem
slave_state status
int catchSignal
TaskId taskId
char taskLib [FILENAME_MAX]
LIB_HANDLE taskHnd
int(* taskExec )(const char *data, char *datares, char *userdata)
SlaveInfo slaveInfo
THRD_HANDLE taskThread
THRD_HANDLE timerThread
THRD_HANDLE cbTaskStopThread
THRD_HANDLE cbTaskCtrlThread
void(* cbTaskStop )(void)
void(* cbTaskCtrl )(const char *arg)
const char * taskctrl_arg
int master_local
char * master_addr
int master_timeout
long slave_status_interval
long cbtaskstop_timeout
char * def_cpu
char * def_os
char * tmp_dir
p_multi_str software
p_multi_str softversion
p_multi_str softdetect
p_multi_str softdetrow
p_multi_str softdetword

Constructor & Destructor Documentation

Slave::Slave int    catchSignal = 0
 

Definition at line 116 of file Slave.cpp.

References catchSignal, cbTaskCtrl, cbTaskStop, cbtaskstop_timeout, DBUG_PRINT, DBUG_SETFILE, def_cpu, def_os, DEFAULT_CBTASKSTOP_TIMEOUT, DEFAULT_CPU, DEFAULT_MASTER_HOST, DEFAULT_MASTER_TIMEOUT, DEFAULT_OS, DEFAULT_SLAVE_CONFIG_FILE, DEFAULT_SLAVE_DBUG_FILE, DEFAULT_SLAVE_HTTP_ROOT, DEFAULT_SLAVESTATUS_INTERVAL, DEFAULT_TMP_DIR, detectSlaveInfo(), DIR_MKDIR, firsttime, Address::getIP(), PostOffice::initialized(), K_CBTASKSTOP_TIMEOUT, K_CPU, K_MASTER_HOST, K_MASTER_PORT, K_MASTER_TIMEOUT, K_OS, K_SLAVE_DBUG_FILE, K_SLAVE_HTTP_ROOT, K_SLAVESTATUS_INTERVAL, K_SOFTDETECT, K_SOFTDETROW, K_SOFTDETWORD, K_SOFTVERSION, K_SOFTWARE, K_TMP_DIR, LONG_KEYWORD, master, master_addr, master_local, MASTER_PORT, master_timeout, multi_str_count(), MULTISTRING_KEYWORD, N_SLAVE_CFG_KWS, po, read_config(), remote, Address::setHost(), Address::setPort(), PostOffice::setRemote(), SLAVE_HTTP_PORT, SLAVE_PORT, SLAVE_QADPZ_VERSION, slave_ready, slave_status_interval, slave_version, slaveInfo, softdetect, softdetrow, softdetword, softversion, software, status, STRING_KEYWORD, taskExec, taskHnd, taskThread, timer_entry(), timerThread, tmp_dir, and UDP_PORT_ITERATE.

Slave::~Slave  
 

Definition at line 237 of file Slave.cpp.

References free_messages(), po, PostOffice::release_sockets(), taskThread, and THRD_KILL.


Member Function Documentation

virtual int Object::compare Object   [inline, virtual, inherited]
 

To ensure a consistent comparison interface and to allow comparison of all kinds of different objects, we will define a comparison functions.

Definition at line 31 of file Object.h.

virtual Object* Object::Copy   [inline, virtual, inherited]
 

To allow a deep copy of data structures we will define a standard interface... This member will return a copy of itself, freshly allocated and deep copied.

Reimplemented in List.

Definition at line 37 of file Object.h.

Referenced by List::Copy(), and List::operator=().

void Slave::detectCPU int &    freq [private]
 

Definition at line 1311 of file Slave.cpp.

References TestCPU().

Referenced by detectSlaveInfo().

void Slave::detectDisk double &    disk [private]
 

Definition at line 1329 of file Slave.cpp.

References TestDisk(), and tmp_dir.

Referenced by detectSlaveInfo().

void Slave::detectMemory double &    mem [private]
 

Definition at line 1320 of file Slave.cpp.

References TestMemory().

Referenced by detectSlaveInfo().

void Slave::detectSlaveInfo SlaveInfo   slaveInfo [private]
 

Definition at line 1019 of file Slave.cpp.

References SlaveInfo::_cs_cpu(), SlaveInfo::_cs_os(), SlaveInfo::addr, bDebug, SlaveInfo::cpu(), SlaveInfo::cpu_speed, DBUG_CLOSEFILE, DBUG_PRINT, def_cpu, def_os, detectCPU(), detectDisk(), detectMemory(), SlaveInfo::disk, SlaveInfo::disk_unit, PostOffice::getLocalPort(), SlaveInfo::mem, SlaveInfo::mem_unit, multi_str_count(), SoftwareInfo::name(), mss::next, SlaveInfo::nSoftInfos, SlaveInfo::os(), po, SLAVE_QADPZ_VERSION, SLEEP_MSEC, softdetect, softdetrow, softdetword, softversion, software, SlaveInfo::softwareInfos, split_arguments, status, mss::str, tmp_dir, SoftwareInfo::version(), and SlaveInfo::version().

Referenced by Slave().

int Slave::detectUserStat   [private]
 

Definition at line 1297 of file Slave.cpp.

References TestProcess().

Referenced by startSlave().

void Slave::dispatchMsg XMLData   msg [private]
 

Definition at line 547 of file Slave.cpp.

References DBUG_PRINT, XMLData::getAttrib(), Lock::lock(), lock, msgSlaveCtrl(), msgTaskCtrl(), msgTaskInit(), msgType(), CharStr::str, and Lock::unlock().

Referenced by startSlave().

void Slave::endTask int    err
 

Definition at line 361 of file Slave.cpp.

References data, datares, DBUG_PRINT, FILE_UNLINK, LIB_UNLOAD, slave_ready, SLEEP_SEC, sndSlaveStatus(), sndTaskFinish(), sndTaskStatus(), status, task_crashed, taskHnd, taskId, taskLib, taskThread, and UDP_MAXSIZE.

Referenced by startTask().

int Slave::get_data const char *    fileName,
const char *    url_download,
int    taskId0
 

Definition at line 1369 of file Slave.cpp.

References DBUG_PRINT, TaskId::id, JobId::id, TaskId::jId, JobId::name(), postURL(), taskId, and tmp_dir.

Referenced by q2adpz_slv_get_data().

long Slave::get_max_runtime   [inline]
 

Definition at line 143 of file Slave.h.

References max_runtime.

Referenced by q2adpz_slv_get_max_runtime().

char* Slave::get_tmp_dir   [inline]
 

Definition at line 141 of file Slave.h.

References tmp_dir.

Referenced by q2adpz_slv_get_tmpdir().

int Slave::getLibrary const char *    taskURL,
char *    taskLib,
char *    err_buff
[private]
 

Definition at line 975 of file Slave.cpp.

References DBUG_PRINT, getURL(), taskLib, and tmp_dir.

Referenced by msgTaskInit().

void Slave::msgSlaveCtrl XMLData   msg [private]
 

Definition at line 797 of file Slave.cpp.

References DBUG_PRINT, XMLData::getString(), getURL(), MAXERR_URL, msgTaskCtrl_Stop(), new_file, run_file, slave_busy, slave_disabled, slave_off, slave_ready, slaveUpgrade(), sndSlaveStatus(), status, and CharStr::str.

Referenced by dispatchMsg().

void Slave::msgTaskCtrl XMLData   msg [private]
 

Definition at line 679 of file Slave.cpp.

References cbTaskCtrlThread, cbtaskstop_entry(), DBUG_PRINT, XMLData::getString(), TaskId::id, slave_disabled, slave_ready, sndSlaveStatus(), sndTaskStatus(), status, CharStr::str, XMLData::sub(), task_refused, taskctrl_arg, taskId, and x2o().

Referenced by dispatchMsg().

void Slave::msgTaskCtrl_Stop   [private]
 

Definition at line 756 of file Slave.cpp.

References cbtaskstop_entry(), cbtaskstop_timeout, cbTaskStopThread, DBUG_PRINT, FILE_UNLINK, LIB_UNLOAD, sem, SEM_TIMEOUT, slave_ready, status, taskHnd, taskLib, taskThread, THRD_KILL, and Semaphore::wait().

Referenced by msgSlaveCtrl(), and startSlave().

void Slave::msgTaskInit XMLData   msg [private]
 

Definition at line 572 of file Slave.cpp.

References XMLData::CDATA, data, DBUG_PRINT, CharStr::Error, getLibrary(), XMLData::getLong(), XMLData::getString(), LIB_ERROR, LIB_LOAD, LIB_SYMBOL, max_runtime, MAXERR_URL, slave_busy, slave_disabled, slave_ready, sndTaskStatus(), status, CharStr::str, XMLData::sub(), task_entry(), task_refused, task_started, taskExec, taskHnd, taskId, taskLib, taskThread, userdata, and x2o().

Referenced by dispatchMsg().

int Slave::put_data const char *    fileName,
const char *    url_upload,
int    taskId0
 

Definition at line 1340 of file Slave.cpp.

References DIR_CHDIR, FILE_UNLINK, TaskId::id, JobId::id, TaskId::jId, JobId::name(), postURL(), taskId, and tmp_dir.

Referenced by q2adpz_slv_put_data().

void Slave::setTaskCtrl void(*    cb)(const char *arg)
 

Definition at line 964 of file Slave.cpp.

References cbTaskCtrl.

Referenced by q2adpz_slv_setcb_task_ctrl().

void Slave::setTaskStop void(*    cb)(void)
 

Definition at line 957 of file Slave.cpp.

References cbTaskStop.

Referenced by q2adpz_slv_setcb_task_stop().

int Slave::slaveUpgrade char *    oldSlave,
char *    newSlave
[private]
 

Definition at line 1404 of file Slave.cpp.

References DBUG_CLOSEFILE, DBUG_PRINT, FILE_CLOSE, FILE_OPEN, FILE_UNLINK, SLEEP_SEC, try_file_new, try_file_old, try_max, and try_sleep.

Referenced by msgSlaveCtrl().

int Slave::sndSlaveStatus  
 

Definition at line 940 of file Slave.cpp.

References XMLData::add(), o2x(), po, remote, PostOffice::send(), slaveInfo, status, and xmlmsg().

Referenced by endTask(), msgSlaveCtrl(), msgTaskCtrl(), startSlave(), and startTimer().

int Slave::sndTaskFinish const char *    datares
 

Definition at line 890 of file Slave.cpp.

References XMLData::add(), XMLData::CDATA, datares, TaskId::id, o2x(), po, remote, PostOffice::send(), slave_ready, SLEEP_MSEC, status, taskId, and xmlmsg().

Referenced by endTask().

int Slave::sndTaskMove  
 

int Slave::sndTaskStatus TaskId   taskId,
task_state    stat,
char *    error = 0
 

Definition at line 918 of file Slave.cpp.

References XMLData::add(), o2x(), po, remote, PostOffice::send(), and xmlmsg().

Referenced by endTask(), msgTaskCtrl(), msgTaskInit(), and q2adpz_slv_task_status().

void Slave::startcbTaskCtrl  
 

Definition at line 458 of file Slave.cpp.

References cbTaskCtrl, sigThread(), and taskctrl_arg.

void Slave::startcbTaskStop  
 

Definition at line 446 of file Slave.cpp.

References cbTaskStop, Semaphore::post(), sem, and sigThread().

void Slave::startSlave  
 

Definition at line 478 of file Slave.cpp.

References DBUG_PRINT, detectUserStat(), dispatchMsg(), firsttime, Address::getHost(), master, msgTaskCtrl_Stop(), XMLData::Nil, po, PostOffice::receive_any(), remote, slave_busy, slave_disabled, slave_ready, sndSlaveStatus(), status, and PostOffice::Timeout.

Referenced by execSlave().

void Slave::startTask  
 

Definition at line 262 of file Slave.cpp.

References catchSignal, data, datares, DBUG_PRINT, endTask(), env, sigcatch(), taskExec, and userdata.

void Slave::startTimer  
 

Definition at line 408 of file Slave.cpp.

References DBUG_PRINT, firsttime, Address::getIP(), Address::host, Lock::lock(), lock, master, master_addr, master_local, po, remote, Address::setHost(), PostOffice::setRemote(), sigThread(), slave_status_interval, SLEEP_SEC, sndSlaveStatus(), uint, and Lock::unlock().

void Slave::stopTask   [private]
 

Definition at line 470 of file Slave.cpp.

References taskThread, and THRD_KILL.


Member Data Documentation

int Slave::catchSignal [private]
 

Definition at line 43 of file Slave.h.

Referenced by Slave(), and startTask().

void(* Slave::cbTaskCtrl)(const char *arg) [private]
 

Referenced by setTaskCtrl(), Slave(), and startcbTaskCtrl().

THRD_HANDLE Slave::cbTaskCtrlThread [private]
 

Definition at line 71 of file Slave.h.

Referenced by msgTaskCtrl().

void(* Slave::cbTaskStop)(void) [private]
 

Referenced by setTaskStop(), Slave(), and startcbTaskStop().

long Slave::cbtaskstop_timeout [private]
 

Definition at line 86 of file Slave.h.

Referenced by msgTaskCtrl_Stop(), and Slave().

THRD_HANDLE Slave::cbTaskStopThread [private]
 

Definition at line 70 of file Slave.h.

Referenced by msgTaskCtrl_Stop().

char Slave::data[UDP_MAXSIZE] [private]
 

Definition at line 29 of file Slave.h.

Referenced by endTask(), msgTaskInit(), and startTask().

char Slave::datares[UDP_MAXSIZE] [private]
 

Definition at line 30 of file Slave.h.

Referenced by endTask(), sndTaskFinish(), and startTask().

char* Slave::def_cpu [private]
 

Definition at line 87 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

char* Slave::def_os [private]
 

Definition at line 88 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

int Slave::firsttime [private]
 

Definition at line 24 of file Slave.h.

Referenced by Slave(), startSlave(), and startTimer().

Lock Slave::lock [private]
 

Definition at line 35 of file Slave.h.

Referenced by dispatchMsg(), and startTimer().

Address Slave::master [private]
 

Definition at line 22 of file Slave.h.

Referenced by Slave(), startSlave(), and startTimer().

char* Slave::master_addr [private]
 

Definition at line 81 of file Slave.h.

Referenced by Slave(), and startTimer().

int Slave::master_local [private]
 

Definition at line 79 of file Slave.h.

Referenced by Slave(), and startTimer().

int Slave::master_timeout [private]
 

Definition at line 84 of file Slave.h.

Referenced by Slave().

long Slave::max_runtime [private]
 

Definition at line 33 of file Slave.h.

Referenced by get_max_runtime(), and msgTaskInit().

PostOffice* Slave::po [private]
 

Definition at line 21 of file Slave.h.

Referenced by detectSlaveInfo(), Slave(), sndSlaveStatus(), sndTaskFinish(), sndTaskStatus(), startSlave(), startTimer(), and ~Slave().

Address Slave::remote [private]
 

Definition at line 23 of file Slave.h.

Referenced by Slave(), sndSlaveStatus(), sndTaskFinish(), sndTaskStatus(), startSlave(), and startTimer().

Semaphore Slave::sem [private]
 

Definition at line 38 of file Slave.h.

Referenced by msgTaskCtrl_Stop(), and startcbTaskStop().

long Slave::slave_status_interval [private]
 

Definition at line 85 of file Slave.h.

Referenced by Slave(), and startTimer().

SlaveInfo Slave::slaveInfo [private]
 

Definition at line 65 of file Slave.h.

Referenced by Slave(), and sndSlaveStatus().

p_multi_str Slave::softdetect [private]
 

Definition at line 92 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

p_multi_str Slave::softdetrow [private]
 

Definition at line 93 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

p_multi_str Slave::softdetword [private]
 

Definition at line 94 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

p_multi_str Slave::softversion [private]
 

Definition at line 91 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

p_multi_str Slave::software [private]
 

Definition at line 90 of file Slave.h.

Referenced by detectSlaveInfo(), and Slave().

slave_state Slave::status [private]
 

Definition at line 42 of file Slave.h.

Referenced by detectSlaveInfo(), endTask(), msgSlaveCtrl(), msgTaskCtrl(), msgTaskCtrl_Stop(), msgTaskInit(), Slave(), sndSlaveStatus(), sndTaskFinish(), and startSlave().

const char* Slave::taskctrl_arg [private]
 

Definition at line 76 of file Slave.h.

Referenced by msgTaskCtrl(), and startcbTaskCtrl().

int(* Slave::taskExec)(const char *data, char *datares, char *userdata) [private]
 

Referenced by msgTaskInit(), Slave(), and startTask().

LIB_HANDLE Slave::taskHnd [private]
 

Definition at line 47 of file Slave.h.

Referenced by endTask(), msgTaskCtrl_Stop(), msgTaskInit(), and Slave().

TaskId Slave::taskId [private]
 

Definition at line 45 of file Slave.h.

Referenced by endTask(), get_data(), msgTaskCtrl(), msgTaskInit(), put_data(), and sndTaskFinish().

char Slave::taskLib[FILENAME_MAX] [private]
 

Definition at line 46 of file Slave.h.

Referenced by endTask(), getLibrary(), msgTaskCtrl_Stop(), and msgTaskInit().

THRD_HANDLE Slave::taskThread [private]
 

Definition at line 67 of file Slave.h.

Referenced by endTask(), msgTaskCtrl_Stop(), msgTaskInit(), Slave(), stopTask(), and ~Slave().

THRD_HANDLE Slave::timerThread [private]
 

Definition at line 68 of file Slave.h.

Referenced by Slave().

char* Slave::tmp_dir [private]
 

Definition at line 89 of file Slave.h.

Referenced by detectDisk(), detectSlaveInfo(), get_data(), get_tmp_dir(), getLibrary(), put_data(), and Slave().

char Slave::userdata[UDP_MAXSIZE] [private]
 

Definition at line 31 of file Slave.h.

Referenced by msgTaskInit(), and startTask().


The documentation for this class was generated from the following files:
Generated on Mon Nov 25 12:46:40 2002 for qadpz by doxygen1.2.18