1 #ifndef __JRUNCONTROL__JCLIENT__
2 #define __JRUNCONTROL__JCLIENT__
93 if (start_command !=
"") {
97 shell << start_command << endl;
111 void stop(
const int signal = -9)
116 if (start_command !=
"") {
118 const string header =
"__header___";
119 const string trailer =
"__trailer__";
123 os <<
"ssh " << hostname <<
' '
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)) {
150 if (start_command.find(buffer) != string::npos) {
151 os <<
"ssh " << hostname <<
' '
153 <<
"kill " << signal <<
" " << pid <<
" </dev/null >&/dev/null"
161 if (os.str() !=
"") {
162 shell << os.str() << endl;
209 return start_command;
220 return mode == SLEEP;
231 return mode == ACTIVE;
242 return mode == IGNORE;
253 return mode == ILLEGAL;
272 this->is_alive =
true;
279 this->is_alive =
false;
292 istringstream
is(buffer);
300 this->event_name =
event.getName();
301 this->event_info =
event.getInfo();
302 this->state_name = state;
421 in >> client.hostname;
425 getline(in >> std::ws, client.start_command);
447 out << client.hostname;
449 out << client.start_command;
471 start_command = start_command.trim();
472 start_command = start_command.replace(
" ",
" ");
474 start_command.replace(
"$HOST$", hostname);
475 start_command.replace(
"$NAME$",
name);
476 start_command.replace(
"$SERVER$",
SERVER);
477 start_command.replace(
"$LOGGER$",
LOGGER);
481 if (pos != string::npos) {
482 start_command.replace(
"$ARGS$",
name.substr(pos + 1));
JSocketNonblockingWriter out
writer for outgoing messages
The JShell clas can be used to interact with the shell via I/O streams.
bool isIgnore() const
Check ignore mode.
static const JTag DISPTAG_Died("Died")
Wrapper class around STL string class.
bool update(const JNET::JTag &tag, const std::string &buffer)
Update client.
friend std::istream & operator>>(std::istream &in, JClient &client)
Read client from input.
const std::string & getStatename() const
Get name of current state.
bool getAlive() const
Get alive status.
then echo Variable JPP_DIR undefined exit fi source $JPP_DIR setenv sh $JPP_DIR &dev null set_variable SERVER localhost define_variable LOGGER if do_usage *then usage $script< server >[logger] fi case set_variable LOGGER
ControlHost client manager.
static std::string LOGGER
host name of message logger
const std::string & getEventInfo() const
Get event information.
int getDied() const
Get died count.
then echo Enter input within $TIMEOUT_S seconds echo n User name
static const std::string TOKEN_DELIMETER
void start()
Start process.
void setMode(const JMode mode)
Set mode.
int getBorn() const
Get born count.
JLANG::JString start_command
bool isActive() const
Check active mode.
friend std::ostream & operator<<(std::ostream &out, const JClient &client)
Write client to output.
static const std::string RUN_CONTROL_CLIENT
void setAlive(const bool alive)
Set alive status.
JSocketInputChannel_t in
reader for incoming messages
static const JNET::JTag RC_REPLY
void stop(const int signal=-9)
Stop process.
then echo Test string reversed by client(hit< return > to continue)." $DIR/JProcess -c "$DIR/JEcho-r" -C fi if (( 1 ))
JMode getMode() const
Get mode.
static const std::string CLIENTNAME_DELIMETER
const std::string & getFullName() const
Get full name of run control client.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
bool isSleep() const
Check sleep mode.
Auxiliary class for handling event name and optional static information.
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 const JTag DISPTAG_Born("Born")
bool isIllegal() const
Check illegal mode.
Auxiliary class to specify white space character(s) in currect locale.
const std::string & getHostname() const
Get host name of run control client.
const std::string & getName() const
Get name of run control client.
static JShell & getInstance()
Get reference to unique instance of this class object.
Shell interaction via I/O streams.
static std::string SERVER
host name of message server
JClient(const std::string &__name, const std::string &__hostname, const std::string &__start_command="")
Constructor.
const std::string & getEventname() const
Get name of last event.
std::string getFullName(const std::string &hostname, const std::string &name)
Get full name of run control client.
void configure()
Configure client parameters.
JClient()
Default constructor.
const std::string & getStartCommand() const
Get start command of run control client.