1#ifndef __JRUNCONTROL__JCLIENT__
2#define __JRUNCONTROL__JCLIENT__
67 const std::string& __hostname,
68 const std::string& __start_command =
"") :
111 void stop(
const int signal = -9)
118 const string header =
"__header___";
119 const string trailer =
"__trailer__";
125 <<
"echo" <<
' ' << header <<
";"
126 <<
"ps hax -o '%p %a'" <<
";"
127 <<
"echo" <<
' ' << trailer
132 shell << os.str() << endl;
138 while (
getline(shell, buffer) && buffer.find(header) == string::npos) {}
142 while (
getline(shell, buffer) && buffer.find(trailer) == string::npos) {
149 if (is >> pid &&
getline(is >> ws, buffer)) {
153 <<
"kill " << signal <<
" " << pid <<
" </dev/null >&/dev/null"
161 if (os.str() !=
"") {
162 shell << os.str() << endl;
284 }
else if (tag == RC_REPLY) {
292 istringstream is(buffer);
298 if (is >> key >> ip >> name >> event >> state && key == RUN_CONTROL_CLIENT) {
421 in >> client.hostname;
425 getline(
in >> std::ws, client.start_command);
447 out << client.hostname;
449 out << client.start_command;
479 string::size_type pos =
name.find_last_of(CLIENTNAME_DELIMETER);
481 if (pos != string::npos) {
Shell interaction via I/O streams.
virtual void clear()
Clear status of reader.
Wrapper class around STL string class.
JString & replace(const char target, const char replacement, const std::size_t max=std::numeric_limits< std::size_t >::max())
Replace characters.
JString & trim()
Trim string.
Auxiliary class to specify white space character(s) in currect locale.
ControlHost client manager.
JSocketNonblockingWriter out
writer for outgoing messages
JSocketInputChannel_t in
reader for incoming messages
The JShell clas can be used to interact with the shell via I/O streams.
JShell & flush(std::ostream &out=null)
Extracts characters from this shell and flush them to the given output stream until the prompt is rea...
static JShell & getInstance()
Get reference to unique instance of this class object.
friend std::ostream & operator<<(std::ostream &out, const JClient &client)
Write client to output.
int getBorn() const
Get born count.
const std::string & getName() const
Get name of run control client.
const std::string & getStartCommand() const
Get start command of run control client.
bool isSleep() const
Check sleep mode.
void setMode(const JMode mode)
Set mode.
bool isActive() const
Check active mode.
JLANG::JString start_command
void start()
Start process.
bool isIgnore() const
Check ignore mode.
JMode getMode() const
Get mode.
JClient(const std::string &__name, const std::string &__hostname, const std::string &__start_command="")
Constructor.
static std::string SERVER
host name of message server
bool getAlive() const
Get alive status.
const std::string & getFullName() const
Get full name of run control client.
bool update(const JNET::JTag &tag, const std::string &buffer)
Update client.
static std::string LOGGER
host name of message logger
JClient()
Default constructor.
const std::string & getEventname() const
Get name of last event.
const std::string & getEventInfo() const
Get event information.
void stop(const int signal=-9)
Stop process.
int getDied() const
Get died count.
void configure()
Configure client parameters.
friend std::istream & operator>>(std::istream &in, JClient &client)
Read client from input.
const std::string & getHostname() const
Get host name of run control client.
const std::string & getStatename() const
Get name of current state.
bool isIllegal() const
Check illegal mode.
void setAlive(const bool alive)
Set alive status.
@ UNKNOWN
Unknown scattering type.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
static const JTag DISPTAG_Born("Born")
static const JTag DISPTAG_Died("Died")
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
KM3NeT DAQ data structures and auxiliaries.
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.
Auxiliary class for handling event name and optional static information.