Go to the documentation of this file. 1 #ifndef __JRUNCONTROL__JCLIENT__
2 #define __JRUNCONTROL__JCLIENT__
66 const std::string& __hostname,
67 const std::string& __start_command =
"") :
92 if (start_command !=
"") {
96 shell << start_command << endl;
110 void stop(
const int signal = -9)
115 if (start_command !=
"") {
117 const string header =
"__header___";
118 const string trailer =
"__trailer__";
122 os <<
"ssh " << hostname <<
' '
124 <<
"echo" <<
' ' << header <<
";"
125 <<
"ps hax -o '%p %a'" <<
";"
126 <<
"echo" <<
' ' << trailer
131 shell << os.str() << endl;
137 while (
getline(shell, buffer) && buffer.find(header) == string::npos) {}
141 while (
getline(shell, buffer) && buffer.find(trailer) == string::npos) {
148 if (is >> pid &&
getline(is >> ws, buffer)) {
149 if (start_command.find(buffer) != string::npos) {
150 os <<
"ssh " << hostname <<
' '
152 <<
"kill " << signal <<
" " << pid <<
" </dev/null >&/dev/null"
160 if (os.str() !=
"") {
161 shell << os.str() << endl;
208 return start_command;
219 return mode == SLEEP;
230 return mode == ACTIVE;
241 return mode == IGNORE;
252 return mode == ILLEGAL;
271 this->is_alive =
true;
278 this->is_alive =
false;
291 istringstream is(buffer);
299 this->event_name =
event.getName();
300 this->event_number =
event.getNumber();
301 this->state_name = state;
420 in >> client.hostname;
424 getline(
in >> std::ws, client.start_command);
446 out << client.hostname;
448 out << client.start_command;
470 start_command = start_command.trim();
471 start_command = start_command.replace(
" ",
" ");
473 start_command.replace(
"$HOST$", hostname);
474 start_command.replace(
"$NAME$", name);
475 start_command.replace(
"$SERVER$", SERVER);
476 start_command.replace(
"$LOGGER$", LOGGER);
480 if (pos != string::npos) {
481 start_command.replace(
"$ARGS$", name.substr(pos + 1));
virtual void clear()
Clear status of reader.
bool update(const JNET::JTag &tag, const std::string &buffer)
Update client.
bool isSleep() const
Check sleep mode.
static const std::string TOKEN_DELIMETER
const std::string & getStartCommand() const
Get start command of run control client.
bool isIgnore() const
Check ignore mode.
const std::string & getName() const
Get name of run control client.
JClient()
Default constructor.
const std::string & getStatename() const
Get name of current state.
The JShell clas can be used to interact with the shell via I/O streams.
bool getAlive() const
Get alive status.
void start()
Start process.
JLANG::JString start_command
static const std::string CLIENTNAME_DELIMETER
int getDied() const
Get died count.
static const JNET::JTag RC_REPLY
ControlHost client manager.
int getBorn() const
Get born count.
friend std::ostream & operator<<(std::ostream &out, const JClient &client)
Write client to output.
Auxiliary class to specify white space character(s) in currect locale.
static const std::string RUN_CONTROL_CLIENT
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void configure()
Configure client parameters.
const std::string & getHostname() const
Get host name of run control client.
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.
Wrapper class around STL string class.
static const JTag DISPTAG_Died("Died")
JShell & flush(std::ostream &out=null)
Extracts characters from this shell and flush them to the given output stream until the prompt is rea...
const std::string & getFullName() const
Get full name of run control client.
Auxiliary class for handling event name and optional number.
static std::string SERVER
host name of message server
int getEventnumber() const
Get number of last event.
KM3NeT DAQ data structures and auxiliaries.
void stop(const int signal=-9)
Stop process.
JMode getMode() const
Get mode.
void setAlive(const bool alive)
Set alive status.
JSocketInputChannel_t in
reader for incoming messages
JSocketNonblockingWriter out
writer for outgoing messages
static JShell & getInstance()
Get reference to unique instance of this class object.
const std::string & getEventname() const
Get name of last event.
bool isActive() const
Check active mode.
static const JTag DISPTAG_Born("Born")
JClient(const std::string &__name, const std::string &__hostname, const std::string &__start_command="")
Constructor.
friend std::istream & operator>>(std::istream &in, JClient &client)
Read client from input.
bool isIllegal() const
Check illegal mode.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
void setMode(const JMode mode)
Set mode.
static std::string LOGGER
host name of message logger