pos =
m_Host.find_first_of(
':');
82 if(pos != string::npos) {
88os <<
"ERR:Shutdown access denied.\n";
100 virtual void Process(
const string& request,
104 if(request.find(
"SUICIDE") !=
NPOS) {
106 "Shutdown request has been received from host: "<<
m_Host);
112 if(request.find(
"IMMEDIATE") !=
NPOS)
116 LOG_POST_X(13,
"Shutdown request has been received from host "<<
128 boolpullback =
NStr::Find(request.c_str(),
"pullback") !=
NPOS;
130 unsignedtimeout = 0;
132 if(timeout_str !=
NPOS)
134timeout_str +
sizeof(
"timeout=") - 1,
138 " (pullback="<< (pullback ?
"ON":
"OFF") <<
139 ", timeout="<< timeout <<
')');
170os <<
"OK:Application: "<< node.
GetAppName() <<
171 "\nVersion: "<<
version.first <<
172 "\nBuild date: "<<
version.second.date <<
173 "\nBuild tag: "<<
version.second.tag <<
"\n";
175 for(
const auto& p :
version.second.m_extra) {
192GetService()->GetClientName() <<
197 "\nMaximum job threads: "<< node.
GetMaxThreads() <<
"\n";
200os <<
"The node is suspended\n";
203os <<
"The node is shutting down\n";
206os <<
"The node is processing an exclusive job\n";
210os <<
"NetSchedule service: "<<
213os <<
"NetSchedule servers:";
217os <<
' '<< (*it).GetServerAddress();
224os <<
"Preferred affinities:";
246 const string& queue,
253os <<
"ERR:Wrong client name. Required: "<<
261os <<
"ERR:Wrong queue name. Required: "<<
275os <<
"OK:"<< load <<
"\n";
292 auto registry= node->m_SynRegistry;
296reply <<
"OK:END\n";
312 auto registry= node->m_SynRegistry;
315 const stringkAlertIDPrefix =
" alert_";
319reply <<
"ERR:Alert ID is required\n";
327reply <<
"ERR:Failed to find an alert with such ID ("<<
id<<
")\n";
336 virtual void Process(
const string& request,
340os <<
"ERR:Unknown command -- "<< request <<
"\n";
383 unsigned short& start_port,
unsigned shortend_port)
407 unsigned shortstart_port,
408 unsigned shortend_port) :
409m_WorkerNode(worker_node),
410m_ShutdownRequested(
false),
446 stringret(
size,
'\0');
469 ERR_POST_X(15,
"Exception in the control server: "<<
msg);
471socket.
Write(&err[0], err.size());
477}
catch(exception& ex) {
503unique_ptr<CWorkerNodeControlServer::IRequestProcessor>
507processor->Process(request, os, &
m_Server);
510socket.
Write(s.data(), s.size());
static const NStr::TNumToStringFlags kFlags
void Process(const string &request, CNcbiOstream &reply, CWorkerNodeControlServer *control_server) override
virtual bool Authenticate(const string &host, const string &, const string &, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
void Process(const string &request, CNcbiOstream &reply, CWorkerNodeControlServer *control_server) override
virtual bool Authenticate(const string &, const string &auth, const string &queue, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
virtual void Process(const string &, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
virtual void Process(const string &, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
virtual void Process(const string &, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
CWNJobWatcher & GetJobWatcher()
void RequestShutdown(CNetScheduleAdmin::EShutdownLevel level)
Request node shutdown.
static CGridGlobals & GetInstance()
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Client API for NCBI NetSchedule server.
EShutdownLevel
Shutdown level.
@ eNormalShutdown
Normal shutdown was requested.
@ eShutdownImmediate
Urgent shutdown was requested.
Smart pointer to a part of the NetSchedule API that does job retrieval and processing on the worker n...
const string & GetServiceName() const
virtual void Process(const string &, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
virtual void Process(const string &request, CNcbiOstream &os, CWorkerNodeControlServer *)
virtual void Process(const string &request, CNcbiOstream &os, CWorkerNodeControlServer *control_server)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
virtual void Process(const string &request, CNcbiOstream &os, CWorkerNodeControlServer *)
CWNCTConnectionFactory(CWorkerNodeControlServer &server, unsigned short &start_port, unsigned short end_port)
virtual EListenAction OnFailure(unsigned short *port)
Return desired action if the port, mentioned in AddListener is busy.
virtual IServer_ConnectionHandler * Create(void)
CWorkerNodeControlServer & m_Server
virtual void OnOpen(void)
Runs in response to an external event [asynchronous].
void x_ProcessQueue(BUF buffer)
void x_ProcessAuth(BUF buffer)
virtual ~CWNCTConnectionHandler()
void x_ProcessRequest(BUF buffer)
CWorkerNodeControlServer & m_Server
void(CWNCTConnectionHandler::* m_ProcessMessage)(BUF buffer)
CWNCTConnectionHandler(CWorkerNodeControlServer &server)
virtual void OnMessage(BUF buffer)
void CheckForInfiniteLoop()
void Print(CNcbiOstream &os) const
unsigned GetJobsRunningNumber() const
virtual void ProcessTimeout(void)
Runs synchronously when no socket activity has occurred in a while (as determined by m_AcceptTimeout)...
CGridWorkerNode GetWorkerNode()
volatile bool m_ShutdownRequested
unsigned short GetControlPort() const
virtual bool ShutdownRequested(void)
Runs synchronously between iterations.
static IRequestProcessor * MakeProcessor(const string &cmd)
CWorkerNodeControlServer(SGridWorkerNodeImpl *worker_node, unsigned short start_port, unsigned short end_port)
virtual ~CWorkerNodeControlServer()
IServer_ConnectionFactory::
IServer_ConnectionHandler::
static string s_ReadStrFromBUF(BUF buf)
static void s_HandleError(CSocket &socket, const string &msg)
static STimeout kAcceptTimeout
const string & GetProgramExecutablePath(EFollowLinks follow_links=eIgnoreLinks) const
Get the application's executable path.
static CNcbiApplicationGuard InstanceGuard(void)
Singleton method.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
size_t BUF_Read(BUF buf, void *data, size_t size)
#define LOG_POST_X(err_subcode, message)
CDiagContext & GetDiagContext(void)
Get diag context instance.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
const string & GetUsername(void) const
Get username.
void Warning(CExceptionArgs_Base &args)
void Info(CExceptionArgs_Base &args)
bool IsHostInAdminHostsList(const string &host) const
TVersion GetAppVersion() const
CNetCacheAPI GetNetCacheAPI() const
pair< string, SBuildInfo > TVersion
unsigned int GetMaxThreads() const
Get the maximum threads running simultaneously.
CNetScheduleExecutor GetNSExecutor() const
string GetAppName() const
CNetScheduleAPI GetNetScheduleAPI() const
void Suspend(bool pullback, unsigned timeout)
static TPid GetPid(void)
Get process identifier (pid) for the current process.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string gethostname(ESwitch log=eOff)
Return empty string on error.
void DisableOSSendDelay(bool on_off=true)
void GetPeerAddress(unsigned int *host, unsigned short *port, ENH_ByteOrder byte_order) const
Get peer address.
EIO_Status Write(const void *buf, size_t size, size_t *n_written=0, EIO_WriteMethod how=eIO_WritePersist)
Write to socket.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
NCBI_NS_STD::string::size_type SIZE_TYPE
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static SIZE_TYPE FindCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case sensitive search.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
static string URLEncode(const CTempString str, EUrlEncode flag=eUrlEnc_SkipMarkChars)
URL-encode string.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ fAllowTrailingSymbols
Ignore trailing non-numerics characters.
@ eNocase
Case insensitive compare.
EListenAction
What to do if the port is busy.
const STimeout * accept_timeout
Maximum t between exit checks.
void AddListener(IServer_ConnectionFactory *factory, unsigned short port)
Register a listener.
unsigned short m_Port
TCP port to listen on.
void SetParameters(const SServer_Parameters &new_params)
unsigned int max_threads
Maximum simultaneous threads.
CSocket & GetSocket(void)
Get underlying socket.
unsigned int init_threads
Number of initial threads.
static string ExtraName(EExtra key)
#define TEMP_STRING_CTOR(str)
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines process management classes.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
CSynRegistry::TPtr m_SynRegistry
bool IsExclusiveMode() const
const string & GetQueueName() const
const string & GetClientName() const
CFastMutex m_PreferredAffMutex
set< string > m_PreferredAffinities
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4