Client data structure.
More...
#include <JClient.hh>
Client data structure.
Definition at line 28 of file JClient.hh.
◆ JMode
Client modi.
| Enumerator |
|---|
| UNKNOWN | |
| SLEEP | |
| ACTIVE | |
| IGNORE | |
| ILLEGAL | |
Definition at line 39 of file JClient.hh.
@ UNKNOWN
Unknown scattering type.
◆ JClient() [1/2]
| KM3NETDAQ::JClient::JClient |
( |
| ) |
|
|
inline |
Default constructor.
Definition at line 45 of file JClient.hh.
45 :
56 {}
JLANG::JString start_command
◆ JClient() [2/2]
| KM3NETDAQ::JClient::JClient |
( |
const std::string & | __name, |
|
|
const std::string & | __hostname, |
|
|
const std::string & | __start_command = "" ) |
|
inline |
Constructor.
- Parameters
-
| __name | name of client |
| __hostname | host name |
| __start_command | start command |
Definition at line 66 of file JClient.hh.
◆ start()
| void KM3NETDAQ::JClient::start |
( |
| ) |
|
|
inline |
Start process.
The start command is issued on the (remote) host.
Definition at line 88 of file JClient.hh.
89 {
92
93 if (start_command != "") {
94
96
99 }
100 }
Template definition of a multi-dimensional oscillation probability interpolation table.
The JShell clas can be used to interact with the shell via I/O streams.
static JShell & getInstance()
Get reference to unique instance of this class object.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
◆ stop()
Stop process.
A kill command is issued on the (remote) host. To determine the PID for the kill command, the start command is compared to the output of a ps command on the (remote) host.
- Parameters
-
Definition at line 111 of file JClient.hh.
112 {
115
116 if (start_command != "") {
117
118 const string header = "__header___";
119 const string trailer =
"__trailer__";
120
121 ostringstream os;
122
124 << "\""
125 << "echo" << ' ' << header << ";"
126 << "ps hax -o '%p %a'" << ";"
128 << "\"";
129
131
133
134 os.str("");
135
136 string buffer;
137
138 while (
getline(
shell, buffer) && buffer.find(header) == string::npos) {}
139
141
143
144 is.clear();
145 is.str(buffer);
146
147 int pid;
148
149 if (is >> pid &&
getline(is >> ws, buffer)) {
152 << "\""
153 << "kill " << signal << " " << pid << " </dev/null >&/dev/null"
154 << "\"";
155 }
156 }
157 }
158
160
161 if (os.str() != "") {
164 }
165 }
166 }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
◆ getName()
| const std::string & KM3NETDAQ::JClient::getName |
( |
| ) |
const |
|
inline |
Get name of run control client.
- Returns
- name
Definition at line 174 of file JClient.hh.
◆ getHostname()
| const std::string & KM3NETDAQ::JClient::getHostname |
( |
| ) |
const |
|
inline |
Get host name of run control client.
- Returns
- host name
Definition at line 185 of file JClient.hh.
◆ getFullName()
| const std::string & KM3NETDAQ::JClient::getFullName |
( |
| ) |
const |
|
inline |
Get full name of run control client.
- Returns
- full name
Definition at line 196 of file JClient.hh.
◆ getStartCommand()
| const std::string & KM3NETDAQ::JClient::getStartCommand |
( |
| ) |
const |
|
inline |
Get start command of run control client.
- Returns
- name
Definition at line 207 of file JClient.hh.
◆ isSleep()
| bool KM3NETDAQ::JClient::isSleep |
( |
| ) |
const |
|
inline |
Check sleep mode.
- Returns
- true if sleep; else false
Definition at line 218 of file JClient.hh.
◆ isActive()
| bool KM3NETDAQ::JClient::isActive |
( |
| ) |
const |
|
inline |
Check active mode.
- Returns
- true if active; else false
Definition at line 229 of file JClient.hh.
◆ isIgnore()
| bool KM3NETDAQ::JClient::isIgnore |
( |
| ) |
const |
|
inline |
Check ignore mode.
- Returns
- true if ignore; else false
Definition at line 240 of file JClient.hh.
◆ isIllegal()
| bool KM3NETDAQ::JClient::isIllegal |
( |
| ) |
const |
|
inline |
Check illegal mode.
- Returns
- true if illegal; else false
Definition at line 251 of file JClient.hh.
◆ update()
Update client.
The client parameters are updated according to the ControlHost tag and message.
- Parameters
-
- Returns
- true if OK; else false
Definition at line 265 of file JClient.hh.
266 {
269
271
274
275 return true;
276
278
281
282 return true;
283
284 } else if (tag == RC_REPLY) {
285
287 string ip;
289 JEvent_t event;
290 string state;
291
292 istringstream is(buffer);
293
294 const locale
loc(is.getloc(),
new JWhiteSpacesFacet(is.getloc(), TOKEN_DELIMETER));
295
297
298 if (is >> key >> ip >> name >> event >> state && key == RUN_CONTROL_CLIENT) {
299
303
304 return true;
305 }
306 }
307
308 return false;
309 }
Auxiliary class to specify white space character(s) in currect locale.
static const JTag DISPTAG_Born("Born")
static const JTag DISPTAG_Died("Died")
◆ getStatename()
| const std::string & KM3NETDAQ::JClient::getStatename |
( |
| ) |
const |
|
inline |
Get name of current state.
- Returns
- state name
Definition at line 317 of file JClient.hh.
◆ getEventname()
| const std::string & KM3NETDAQ::JClient::getEventname |
( |
| ) |
const |
|
inline |
Get name of last event.
- Returns
- event name
Definition at line 328 of file JClient.hh.
◆ getEventInfo()
| const std::string & KM3NETDAQ::JClient::getEventInfo |
( |
| ) |
const |
|
inline |
Get event information.
- Returns
- event information
Definition at line 339 of file JClient.hh.
◆ getAlive()
| bool KM3NETDAQ::JClient::getAlive |
( |
| ) |
const |
|
inline |
Get alive status.
- Returns
- true if alive; else false
Definition at line 350 of file JClient.hh.
◆ setAlive()
Set alive status.
- Parameters
-
Definition at line 361 of file JClient.hh.
◆ getMode()
| JMode KM3NETDAQ::JClient::getMode |
( |
| ) |
const |
|
inline |
◆ setMode()
◆ getBorn()
| int KM3NETDAQ::JClient::getBorn |
( |
| ) |
const |
|
inline |
Get born count.
- Returns
- number of times born
Definition at line 394 of file JClient.hh.
◆ getDied()
| int KM3NETDAQ::JClient::getDied |
( |
| ) |
const |
|
inline |
Get died count.
- Returns
- number of times died
Definition at line 405 of file JClient.hh.
◆ configure()
| void KM3NETDAQ::JClient::configure |
( |
| ) |
|
|
inlineprotected |
Configure client parameters.
In this, the following tokens in the start command are substituted: $HOST$ by <host name>; $NAME$ by <process name>; $SERVER$ by JClient::SERVER; $LOGGER$ by JClient::LOGGER; $ARGS$ by part following last '/' in <process name>;
Definition at line 465 of file JClient.hh.
466 {
467 using std::string;
468
470
473
478
479 string::size_type pos =
name.find_last_of(CLIENTNAME_DELIMETER);
480
481 if (pos != string::npos) {
483 }
484 }
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.
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.
◆ operator>>
Read client from input.
- Parameters
-
- Returns
- istream
Definition at line 418 of file JClient.hh.
419 {
421 in >> client.hostname;
422
424
425 getline(
in >> std::ws, client.start_command);
426
428
429 client.configure();
430 }
431
433 }
JSocketInputChannel_t in
reader for incoming messages
◆ operator<<
Write client to output.
- Parameters
-
- Returns
- ostream
Definition at line 443 of file JClient.hh.
444 {
447 out << client.hostname;
449 out << client.start_command;
450
452 }
JSocketNonblockingWriter out
writer for outgoing messages
◆ SERVER
| std::string KM3NETDAQ::JClient::SERVER |
|
static |
host name of message server
- Author
- mdejong
Definition at line 32 of file JClient.hh.
◆ LOGGER
| std::string KM3NETDAQ::JClient::LOGGER |
|
static |
host name of message logger
Definition at line 33 of file JClient.hh.
◆ name
| std::string KM3NETDAQ::JClient::name |
|
protected |
◆ hostname
| std::string KM3NETDAQ::JClient::hostname |
|
protected |
◆ start_command
◆ full_name
| std::string KM3NETDAQ::JClient::full_name |
|
protected |
◆ mode
| JMode KM3NETDAQ::JClient::mode |
|
protected |
◆ born
| int KM3NETDAQ::JClient::born |
|
protected |
◆ died
| int KM3NETDAQ::JClient::died |
|
protected |
◆ is_alive
| bool KM3NETDAQ::JClient::is_alive |
|
protected |
◆ state_name
| std::string KM3NETDAQ::JClient::state_name |
|
protected |
◆ event_name
| std::string KM3NETDAQ::JClient::event_name |
|
protected |
◆ event_info
| std::string KM3NETDAQ::JClient::event_info |
|
protected |
The documentation for this class was generated from the following files: