47 "REFUSESUBMITS mode=1" :
"REFUSESUBMITS mode=0");
49 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
55 const auto die = level ==
eDie;
56 string cmd(die ?
"SHUTDOWN SUICIDE" :
57 level == eShutdownImmediate ?
"SHUTDOWN IMMEDIATE" :
58 level ==
eDrain ?
"SHUTDOWN drain=1" :
"SHUTDOWN");
62 auto retry_guard = m_Impl->m_API->m_Service->CreateRetryGuard(retry_mode);
65 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
78 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
82 const string& description)
84 limits::Check<limits::SQueueName>(qname);
86 string cmd =
"QCRE " + qname;
90 if (!description.empty()) {
98 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
103 limits::Check<limits::SQueueName>(qname);
105 string cmd(
"QDEL " + qname);
107 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
116 while (
output.ReadLine(line))
122 string cmd(
"DUMP " + job_key);
124 return m_Impl->m_API->GetServer(job_key).ExecWithRetry(
cmd,
true);
130 if (job_statuses.empty()) {
131 cmd.assign(
"CANCELQ");
133 cmd.assign(
"CANCEL status=");
134 cmd.append(job_statuses);
137 m_Impl->m_API->m_Service.ExecOnAllServers(
cmd);
143 string cmd(
"VERSION");
145 m_Impl->m_API->m_Service.PrintCmdOutput(
cmd,
152 const string& start_after_job,
154 const string& job_statuses,
155 const string& job_group)
158 if (!job_statuses.empty()) {
159 cmd.append(
" status=");
160 cmd.append(job_statuses);
162 if (!start_after_job.empty()) {
163 cmd.append(
" start_after=");
164 cmd.append(start_after_job);
167 cmd.append(
" count=");
170 if (!job_group.empty()) {
171 limits::Check<limits::SJobGroup>(job_group);
172 cmd.append(
" group=");
173 cmd.append(job_group);
176 m_Impl->m_API->m_Service.PrintCmdOutput(
cmd,
182 const string& start_after_job,
185 const string& job_group)
191 job_statuses.clear();
194 DumpQueue(output_stream, start_after_job, job_count, job_statuses, job_group);
200 string qinf_cmd(
"QINF2 " + queue_name);
211 queue_info[field->name] = field->value;
228 GetQueueInfo(m_Impl->m_API->m_Service.Iterate().GetServer(),
229 queue_name, queue_info);
235 GetQueueInfo(server, m_Impl->m_API->m_Queue, queue_info);
240 GetQueueInfo(m_Impl->m_API->m_Queue, queue_info);
246 bool print_headers = m_Impl->m_API->m_Service.IsLoadBalanced();
251 output_stream <<
'[' << (*it).GetServerAddress() <<
']' <<
NcbiEndl;
255 GetQueueInfo(*it, queue_name, queue_info);
258 output_stream << qi->first <<
": " << qi->second <<
NcbiEndl;
269 list<SWorkerNodeInfo>& worker_nodes)
276 string cmd(
"GETCONF");
278 m_Impl->m_API->m_Service.PrintCmdOutput(
cmd,
285 string cmd(opt == eStatisticsBrief ?
"STAT" :
286 opt == eStatisticsClients ?
"STAT CLIENTS" :
"STAT ALL");
288 m_Impl->m_API->m_Service.PrintCmdOutput(
cmd,
294 string cmd(
"HEALTH");
296 m_Impl->m_API->m_Service.PrintCmdOutput(
cmd,
302 string cmd(
"STAT QUEUES");
314 while (cmd_output.
ReadLine(output_line))
316 output_line.length() >
sizeof(
"[queue "))
317 qlist.back().queues.push_back(output_line.substr(
318 sizeof(
"[queue ") - 1,
319 output_line.length() -
sizeof(
"[queue ")));
325 const string& affinity_token,
326 const string& job_group)
328 string cmd =
"STAT JOBS";
330 if (!affinity_token.empty()) {
331 limits::Check<limits::SAffinity>(affinity_token);
333 cmd.append(affinity_token);
336 if (!job_group.empty()) {
337 limits::Check<limits::SJobGroup>(job_group);
338 cmd.append(
" group=");
339 cmd.append(job_group);
351 (*it).ExecWithRetry(
cmd,
true));
353 while (cmd_output.
ReadLine(output_line))
355 status_map[st_str] +=
363 "Error while parsing STAT JOBS response");
Client API for NCBI NetSchedule server.
void ReloadServerConfig()
void GetQueueInfo(CNetServer server, const string &queue_name, TQueueInfo &queue_info)
void PrintServerStatistics(CNcbiOstream &output_stream, EStatisticsOptions opt=eStatisticsBrief)
void PrintServerVersion(CNcbiOstream &output_stream)
Print version string.
void DeleteQueue(const string &qname)
Delete queue Applicable only to queues, created through CreateQueue method.
void GetQueueList(TQueueList &result)
void SwitchToDrainMode(ESwitch on_off)
Enable server drain mode.
void CreateQueue(const string &qname, const string &qclass, const string &description=kEmptyStr)
Create an instance of the given queue class.
void PrintConf(CNcbiOstream &output_stream)
EShutdownLevel
Shutdown level.
void DumpJob(CNcbiOstream &out, const string &job_key)
void ShutdownServer(EShutdownLevel level=eNormalShutdown)
Shutdown the server daemon.
void StatusSnapshot(TStatusMap &status_map, const string &affinity_token=kEmptyStr, const string &job_group=kEmptyStr)
Returns statuses for a given affinity token.
void CancelAllJobs(const string &job_statuses=kEmptyStr)
Cancel all jobs in the queue (optionally with particular statuses).
void DumpQueue(CNcbiOstream &output_stream, const string &start_after_job=kEmptyStr, size_t job_count=0, const string &job_statuses=kEmptyStr, const string &job_group=kEmptyStr)
void PrintHealth(CNcbiOstream &output_stream)
void GetWorkerNodes(list< SWorkerNodeInfo > &worker_nodes)
void PrintQueueInfo(const string &queue_name, CNcbiOstream &output_stream)
list< SServerQueueList > TQueueList
NetSchedule internal exception.
bool ReadLine(string &output)
@ eMultilineOutput_NetCacheStyle
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
std::ofstream out("events_result.xml")
main entry point for tests
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_RETHROW(prev_exception, exception_class, err_code, message)
Generic macro to re-throw an exception.
EJobStatus
Job status codes.
static string StatusToString(EJobStatus status)
Printable status type.
@ eJobNotFound
No such job.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static CTempString TruncateSpaces_Unsafe(const CTempString str, ETrunc where=eTrunc_Both)
Truncate spaces in a string.
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 enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
@ eTrunc_Begin
Truncate leading spaces only.
const TArgs & GetArgs(void) const
Get the const list of arguments.
enum ENcbiSwitch ESwitch
Aux.
NetSchedule client specs.
static string s_MkQINFCmd(const string &queue_name)
void g_GetWorkerNodes(CNetScheduleAPI api, list< CNetScheduleAdmin::SWorkerNodeInfo > &worker_nodes)
static void s_ParseQueueInfo(const string &server_output, CNetScheduleAdmin::TQueueInfo &queue_info)
void g_AppendClientIPSessionIDHitID(string &cmd)
static SQLCHAR output[256]
CNetServer::SExecResult ConnectAndExec(const string &cmd, bool multiline_output, bool retry_on_exception=false)