& description) :
72 "Check of data retrieval from Cassandra DB"),
74 "Check of data retrieval from LMDB"),
76 "Check of data retrieval from WGS"),
78 "Check of data retrieval from CDD"),
80 "Check of data retrieval from SNP"),
82 "Check that the number of client connections is within the soft limit")
88 if(
check.Id ==
id) {
94 "Cannot find a description of the check '"+
id+
"'");
101 if(
check.Id ==
"cassandra") {
106 if(
check.Id ==
"lmdb") {
111 if(
check.Id ==
"wgs") {
116 if(
check.Id ==
"cdd") {
121 if(
check.Id ==
"snp") {
126 if(
check.Id ==
"connections") {
127 check.HealthCommand =
"";
134TPSG_Https::SetDefault(
true);
146shared_ptr<CPSGS_Reply> reply)
155shared_ptr<CPSGS_Reply> reply)
164shared_ptr<CPSGS_Reply> reply)
173shared_ptr<CPSGS_Reply> reply)
182shared_ptr<CPSGS_Reply> reply)
184 autonow = psg_clock_t::now();
199reply->GetBytesSent());
205reply->GetBytesSent());
210vector<string> exclude_checks;
218 size_tcritical_check_count = 0;
219 size_tnon_critical_check_count = 0;
220 boolis_critical =
false;
229exclude_checks, is_critical)) {
235 check.HealthCommandTimeout,
239++critical_check_count;
240final_critical_http_status =
max(final_critical_http_status,
243++non_critical_check_count;
244final_non_critical_http_status =
max(final_non_critical_http_status,
249checks_node.
Append(check_node);
256 if((critical_check_count + non_critical_check_count) == 0) {
259final_json_node.
SetString(
"message",
"All checks were skipped");
263 if(critical_check_count > 0) {
264final_http_status = final_critical_http_status;
266final_http_status = final_non_critical_http_status;
271final_json_node.
SetByKey(
"checks", checks_node);
276reply->SetContentLength(content.size());
280reply->SetContentLength(0);
285final_http_status, reply->GetBytesSent());
292 constvector<string> & exclude_checks,
298 if(find(exclude_checks.begin(),
299exclude_checks.end(),
323shared_ptr<CPSGS_Reply> reply)
333shared_ptr<CPSGS_Reply> reply)
343shared_ptr<CPSGS_Reply> reply)
353shared_ptr<CPSGS_Reply> reply)
363shared_ptr<CPSGS_Reply> reply)
373shared_ptr<CPSGS_Reply> reply)
384shared_ptr<CPSGS_Reply> reply,
385 const string& check_id)
387 autonow = psg_clock_t::now();
402reply->GetBytesSent());
405 if(check_id !=
"connections") {
409reply->GetBytesSent());
425check_node.
SetString(
"id", check_id);
426check_node.
SetString(
"name",
"unknown");
427check_node.
SetString(
"description",
"unknown");
428check_node.
SetString(
"status",
"fail");
429check_node.
SetString(
"message",
"Cannot find the check description");
437 check.HealthCommand,
438 check.HealthCommandTimeout,
446checks_node.
Append(check_node);
447ret_node.
SetByKey(
"checks", checks_node);
452reply->SetContentLength(content.size());
456reply->SetContentLength(0);
461http_status, reply->GetBytesSent());
470 autoreply_status = reply->GetStatus(health_timeout);
477err_msg =
"Timeout on getting a reply status";
482 for(
automessage = reply->GetNextMessage(); message;
483message = reply->GetNextMessage()) {
484 if(!err_msg.empty()) {
491err_msg =
"Unknown error on reply completion";
494 if(reply_http_code >= 200) {
505 const string& check_id,
507 const string& check_description,
509 const string& health_command,
517node.
SetString(
"description", check_description);
518node.
SetString(
"health-command", health_command);
523 if(check_id ==
"connections") {
530node.
SetString(
"message",
"Current number of client connections is "+
531to_string(current_conn_num) +
", which is " 532 "over the soft limit of "+
539node.
SetString(
"message",
"The check has succeeded");
548 stringerr_msg =
"";
553 boolrequest_context_ro = request_context->
GetReadOnly();
554 if(request_context_ro)
559(health_command,
nullptr, request_context);
566err_msg =
"Timeout on sending a request";
568 for(
autoitem = reply->GetNextItem(health_timeout);
570item = reply->GetNextItem(health_timeout)) {
578 autoitem_status = item->GetStatus(health_timeout);
581err_msg =
"Timeout on getting an item status";
587 for(
automessage = item->GetNextMessage(); message;
588message = item->GetNextMessage()) {
589 if(!err_msg.empty()) {
594 if(err_msg.empty()) {
595err_msg =
"Unknown error on item completion";
603 if(request_context_ro)
609node.
SetString(
"message",
"The check has succeeded");
622shared_ptr<CPSGS_Reply> reply)
624 autonow = psg_clock_t::now();
638ret_node.
SetString(
"message",
"Currently does nothing");
643reply->SetContentLength(content.size());
647reply->SetContentLength(0);
660shared_ptr<CPSGS_Reply> reply,
661 const string* payload)
663 switch(http_status) {
665 if(payload !=
nullptr) { reply->SendOk(payload->data(), payload->size(),
false); }
666 else{ reply->SendOk(
"", 0,
true); }
669 if(payload !=
nullptr) { reply->Send400(payload->c_str()); }
670 else{ reply->Send400(
""); }
673 if(payload !=
nullptr) { reply->Send401(payload->c_str()); }
674 else{ reply->Send401(
""); }
677 if(payload !=
nullptr) { reply->Send404(payload->c_str()); }
678 else{ reply->Send404(
""); }
681 if(payload !=
nullptr) { reply->Send409(payload->c_str()); }
682 else{ reply->Send409(
""); }
685 if(payload !=
nullptr) { reply->Send500(payload->c_str()); }
686 else{ reply->Send500(
""); }
689 if(payload !=
nullptr) { reply->Send502(payload->c_str()); }
690 else{ reply->Send502(
""); }
693 if(payload !=
nullptr) { reply->Send503(payload->c_str()); }
694 else{ reply->Send503(
""); }
698 string msg=
"Not supported z end pint http status "+
699to_string(http_status);
701reply->SetContentLength(
msg.size());
702reply->Send503(
msg.c_str());
static CJsonNode NewArrayNode()
Create a new JSON array node.
string Repr(TReprFlags flags=0) const
Return a string representation of this node.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
static CJsonNode NewObjectNode()
Create a new JSON object node.
void Append(CJsonNode::TInstance value)
For an array node, add a new element at the end of the array.
@ ePSGS_ReadyZConnectionsRequest
@ ePSGS_ReadyZCassandraRequest
@ ePSGS_ReadyZLMDBRequest
@ ePSGS_DeepHealthRequest
static shared_ptr< CPSG_Request > CreateRawRequest(string abs_path_ref, shared_ptr< void > user_context, CRef< CRequestContext > request_context)
static int GetReplyHttpCode(const shared_ptr< CPSG_Reply > &reply)
A queue to retrieve data (accession resolution info; bio-sequence; annotation blobs) from the storage...
shared_ptr< CPSG_Reply > SendRequestAndGetReply(shared_ptr< CPSG_Request > request, CDeadline deadline)
Push request into the queue and get corresponding reply.
static TApiLock GetApiLock()
@ eEndOfReply
No more items expected in the (overall!) reply.
void x_InitialzeZEndPointData(void)
int OnReadyzConnections(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
unique_ptr< CHttpDaemon > m_HttpDaemon
void x_SendZEndPointReply(CRequestStatus::ECode http_status, shared_ptr< CPSGS_Reply > reply, const string *payload)
CRequestStatus::ECode x_SelfZEndPointCheckImpl(CRef< CRequestContext > &context, const string &check_id, const string &check_name, const string &check_description, bool verbose, const string &health_command, const CTimeout &health_timeout, CJsonNode &node)
bool x_GetExcludeChecks(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply, const psg_time_point_t &now, vector< string > &exclude_checks)
int OnHealthz(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnReadyzCassandra(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
CPSG_Queue::TApiLock m_PSGAPILock
int x_SelfZEndPointCheck(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply, const string &health_command)
void x_PrintRequestStop(CRef< CRequestContext > &context, CPSGS_Request::EPSGS_Type request_type, CRequestStatus::ECode status, size_t bytes_sent)
SPubseqGatewaySettings m_Settings
int OnReadyzWGS(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
bool x_NeedReadyZCheckPerform(const string &check_name, bool verbose, const vector< string > &exclude_checks, bool &is_critical)
int OnHealth(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnReadyzLMDB(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
CRef< CRequestContext > x_CreateRequestContext(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
unique_ptr< CPSGSCounters > m_Counters
int x_ReadyzHealthzImplementation(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnDeepHealth(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
bool x_IsConnectionAboveSoftLimitForZEndPoints(shared_ptr< CPSGS_Reply > reply, bool verbose)
bool x_IsShuttingDownForZEndPoints(shared_ptr< CPSGS_Reply > reply, bool verbose)
bool x_GetVerboseParameter(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply, const psg_time_point_t &now, bool &verbose)
int OnReadyzSNP(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnReadyzCDD(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnLivez(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
int OnReadyz(CHttpRequest &req, shared_ptr< CPSGS_Reply > reply)
CTimeout â Timeout interval.
bool GetReadOnly(void) const
Get current read-only flag.
void SetReadOnly(bool read_only)
Switch request context to read-only mode.
@ e503_ServiceUnavailable
@ e500_InternalServerError
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
@ eSuccess
Successfully retrieved.
@ eInProgress
Retrieval is not finalized yet, more info may come.
#define PSG_ERROR(message)
Defines CRequestContext class for NCBI C++ diagnostic API.
static bool check_name(const char *name)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
CTimeout HealthCommandTimeout
SCheckDescription(const string &id, const string &name, const string &description)
double m_CassandraHealthTimeoutSec
string m_WGSProcessorHealthCommand
vector< string > m_CriticalDataSources
string m_SNPProcessorHealthCommand
string m_CassandraProcessorHealthCommand
double m_LMDBHealthTimeoutSec
unsigned short m_HttpPort
double m_SNPHealthTimeoutSec
double m_WGSHealthTimeoutSec
string m_LMDBProcessorHealthCommand
int64_t m_TcpMaxConnSoftLimit
string m_CDDProcessorHealthCommand
double m_CDDHealthTimeoutSec
static CS_CONTEXT * context
CRequestStatus::ECode OnReplyComplete(const shared_ptr< CPSG_Reply > &reply, const CTimeout &health_timeout, string &err_msg)
static vector< SCheckDescription > s_CheckDescription
SCheckDescription FindCheckDescription(const string &id)
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