NCBI C++ ToolKit
Classes | Macros | Typedefs | Enumerations | Enumerator | Functions | Variables | Friends
Service Support
+ Collaboration diagram for Service Support:

Classes

struct  SHEAP_Block
 
struct  SHINFO_Params
 Host parameters. More...
 
struct  SHINFO_PortUsage
 Port usage. More...
 
struct  SSERV_NcbidInfo
 
struct  SSERV_StandaloneInfo
 
struct  SSERV_HttpInfo
 
struct  SSERV_FirewallInfo
 
struct  SSERV_DnsInfo
 
union  USERV_Info
 
struct  SSERV_Info
 
class  CUsageReportBase
 CUsageReportBase:: Base class to define common types for CUsageReport API. More...
 
class  CUsageReportAPI
 CUsageReportAPI:: Global settings related to the usage reporting. More...
 
class  CUsageReportParameters
 CUsageReportParameters:: More...
 
class  CUsageReportJob
 CUsageReportJob:: More...
 
class  CUsageReport
 CUsageReport:: More...
 

Macros

#define SERV_DEFAULT_ALGO   eSERV_Regular
 
#define SERV_MINIMAL_RATE   0.001
 
#define SERV_MAXIMAL_RATE   100000.0
 
#define SERV_MINIMAL_BONUS   0.01
 
#define SERV_MAXIMAL_BONUS   100.0
 
#define SERV_NCBID_ARGS(ui)   ((char*)(ui) + (ui)->args)
 
#define SERV_HTTP_PATH(ui)   ((char*)(ui) + (ui)->path)
 
#define SERV_HTTP_ARGS(ui)   ((char*)(ui) + (ui)->args)
 
#define SERV_CLIENT_REVISION_MAJOR   7
 Revision 7.0. More...
 
#define SERV_CLIENT_REVISION_MINOR   0
 
#define SERV_LOCALHOST   ((unsigned int)(~0UL))
 Special values for the "preferred_host" parameter. More...
 
#define SERV_ANYHOST   0
 
#define NCBI_REPORT_USAGE(event, ...)   __NCBI_REPORT_USAGE(event, __VA_ARGS__)
 Convenience macro to log "jsevent" usage statistics (asynchronously). More...
 
#define __NCBI_REPORT_USAGE(event, args)
 
#define NCBI_REPORT_USAGE_START   CUsageReportAPI::SetEnabled()
 Enable usage statistics reporting (globally for all reporters). More...
 
#define NCBI_REPORT_USAGE_WAIT   CUsageReport::Instance().Wait()
 Wait until all reports via NCBI_REPORT_USAGE will be processed. More...
 
#define NCBI_REPORT_USAGE_FINISH   CUsageReport::Instance().Finish()
 Finishing reporting via NCBI_REPORT_USAGE and global usage reporter,. More...
 

Typedefs

typedef struct SHEAP_tagHEAP
 
typedef void *(* FHEAP_Resize) (void *old_base, TNCBI_Size new_size, void *auxarg)
 
typedef struct SHostInfoTagHOST_INFO
 Handle for the user code use. More...
 
typedef unsigned short TNcbiArch
 
typedef unsigned short TNcbiCapacity
 
typedef unsigned short TNcbiOSType
 
typedef unsigned char TSERV_Algo
 
typedef unsigned char TSERV_Mode
 
typedef unsigned char TSERV_Site
 
typedef struct SSERV_IterTagSERV_ITER
 Iterator through the servers. More...
 
typedef const SSERV_InfoSSERV_InfoCPtr
 Simplified (uncluttered) SSERV_Info pointer type. More...
 
typedef unsigned int TSERV_Type
 Bitwise OR of ESERV_Type[Special]. More...
 
typedef unsigned short TSERV_TypeOnly
 Server type only, w/o specials. More...
 
typedef int CUsageReportBase::TWhat
 Binary OR of "EWhat". More...
 
using CUsageReport::TJobPtr = CUsageReportJob *
 

Enumerations

enum  ENcbiArch { fArch_Virtual = 1 , fArch_Unknown = 0 }
 
enum  ENcbiCapacity { fCapacity_Unknown , fCapacity_32 , fCapacity_64 , fCapacity_32_64 }
 
enum  ENcbiOSType {
  fOS_Unknown , fOS_IRIX = 8 , fOS_Solaris = 16 , fOS_BSD = 32 ,
  fOS_Darwin = 36 , fOS_Windows = 64 , fOS_WindowsServer = 96 , fOS_Linux = 128
}
 
enum  ESERV_Type {
  fSERV_Ncbid = 0x01 , fSERV_Standalone = 0x02 , fSERV_HttpGet = 0x04 , fSERV_HttpPost = 0x08 ,
  fSERV_Http = fSERV_HttpGet | fSERV_HttpPost , fSERV_Firewall = 0x10 , fSERV_Dns = 0x20
}
 
enum  ESERV_Algo { eSERV_Regular = 0 , eSERV_Blast = 1 }
 
enum  ESERV_Mode { fSERV_Stateful = 1 , fSERV_Secure = 2 }
 
enum  ESERV_Site { fSERV_Local = 1 , fSERV_Private = 2 , fSERV_Interzone = 4 , fSERV_ZoneMask = 0xF0 }
 
enum  ESERV_TypeSpecial {
  fSERV_Any = 0 , fSERV_All = 0x00007FFF , fSERV_Stateless = 0x00008000 , fSERV_Reserved = 0x00100000 ,
  fSERV_DelayOpen = 0x00400000 , fSERV_ReverseDns = 0x00800000 , fSERV_IncludeDown = 0x08000000 , fSERV_IncludeStandby = 0x10000000 ,
  fSERV_IncludeReserved = 0x20000000 , fSERV_IncludeSuppressed = 0x40000000 , fSERV_IncludeInactive = 0x70000000 , fSERV_IncludePrivate = 0x80000000 ,
  fSERV_Promiscuous = 0xF8000000
}
 Special "type" bit values that may be combined with server types. More...
 
enum  CUsageReportBase::EWhat {
  CUsageReportBase::fNone = 0 , CUsageReportBase::fAppName = 1 << 1 , CUsageReportBase::fAppVersion = 1 << 2 , CUsageReportBase::fOS = 1 << 3 ,
  CUsageReportBase::fHost = 1 << 4 , CUsageReportBase::fDefault = fAppName | fAppVersion | fOS
}
 Defines what information should be reported by default by all reporters, in addition to passed parameters for Send() method. More...
 
enum  CUsageReportJob::EState {
  CUsageReportJob::eCreated , CUsageReportJob::eQueued , CUsageReportJob::eRunning , CUsageReportJob::eCompleted ,
  CUsageReportJob::eFailed , CUsageReportJob::eCanceled , CUsageReportJob::eRejected
}
 Job state. More...
 

Functions

HEAP HEAP_Create (void *base, TNCBI_Size size, TNCBI_Size chunk_size, FHEAP_Resize resize, void *auxarg)
 
HEAP HEAP_Attach (const void *base, TNCBI_Size maxsize, int serial)
 
HEAP HEAP_AttachFast (const void *base, TNCBI_Size size, int serial)
 
SHEAP_BlockHEAP_Alloc (HEAP heap, TNCBI_Size size, int hint)
 
void HEAP_Free (HEAP heap, SHEAP_Block *ptr)
 
void HEAP_FreeFast (HEAP heap, SHEAP_Block *ptr, const SHEAP_Block *prev)
 
SHEAP_BlockHEAP_Walk (const HEAP heap, const SHEAP_Block *prev)
 
SHEAP_BlockHEAP_Next (const HEAP heap, const SHEAP_Block *prev)
 
HEAP HEAP_Trim (HEAP heap)
 
HEAP HEAP_Copy (const HEAP orig, size_t extra, int serial)
 
unsigned int HEAP_AddRef (HEAP heap)
 
unsigned int HEAP_Detach (HEAP heap)
 
unsigned int HEAP_Destroy (HEAP heap)
 
void * HEAP_Base (const HEAP heap)
 
TNCBI_Size HEAP_Size (const HEAP heap)
 
TNCBI_Size HEAP_Used (const HEAP heap)
 
TNCBI_Size HEAP_Idle (const HEAP heap)
 
int HEAP_Serial (const HEAP heap)
 
void HEAP_Options (ESwitch fast, ESwitch unused)
 
unsigned int HINFO_HostAddr (const HOST_INFO host_info)
 Get the official host address. More...
 
int HINFO_CpuCount (const HOST_INFO host_info)
 Get CPU count (number of logical cores, hyper-threaded included). More...
 
int HINFO_CpuUnits (const HOST_INFO host_info)
 Get physical CPU count (number of physical cores, not packages). More...
 
double HINFO_CpuClock (const HOST_INFO host_info)
 Get CPU clock rate. More...
 
int HINFO_TaskCount (const HOST_INFO host_info)
 Get task count. More...
 
int HINFO_Memusage (const HOST_INFO host_info, double memusage[5])
 Get memory usage data. More...
 
int HINFO_MachineParams (const HOST_INFO host_info, SHINFO_Params *params)
 Get host parameters. More...
 
int HINFO_PortUsage (const HOST_INFO host_info, SHINFO_PortUsage ports[], size_t count)
 Obtain host port usage (currently only 4 first ports are published). More...
 
int HINFO_LoadAverage (const HOST_INFO host_info, double lavg[2])
 Obtain host load averages. More...
 
int HINFO_Status (const HOST_INFO host_info, double status[2])
 Obtain LB host availability status. More...
 
const char * HINFO_Environment (const HOST_INFO host_info)
 Obtain and return LB host environment. More...
 
const char * HINFO_AffinityArgument (const HOST_INFO host_info)
 Obtain the affinity argument that has keyed the service selection (if argument affinities have been used at all). More...
 
const char * HINFO_AffinityArgvalue (const HOST_INFO host_info)
 Obtain the affinity argument's value that has keyed the service selection (if argument affinities have been used at all). More...
 
const char * SERV_TypeStr (ESERV_Type type)
 
const char * SERV_ReadType (const char *str, ESERV_Type *type)
 
SSERV_InfoSERV_CreateNcbidInfo (unsigned int host, unsigned short port, const char *args)
 
SSERV_InfoSERV_CreateStandaloneInfo (unsigned int host, unsigned short port)
 
SSERV_InfoSERV_CreateHttpInfo (ESERV_Type type, unsigned int host, unsigned short port, const char *path, const char *args)
 
SSERV_InfoSERV_CreateFirewallInfo (unsigned int host, unsigned short port, ESERV_Type type)
 
SSERV_InfoSERV_CreateDnsInfo (unsigned int host)
 
char * SERV_WriteInfo (const SSERV_Info *info)
 
SSERV_InfoSERV_ReadInfo (const char *info_str)
 
SSERV_InfoSERV_CopyInfo (const SSERV_Info *info)
 
size_t SERV_SizeOfInfo (const SSERV_Info *info)
 
int SERV_EqualInfo (const SSERV_Info *info1, const SSERV_Info *info2)
 
SERV_ITER SERV_OpenEx (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip)
 Create an iterator for sequential server lookup. More...
 
SERV_ITER SERV_Open (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
 Same as "SERV_OpenEx(., ., ., ., 0, 0)" – i.e. More...
 
SERV_ITER SERV_OpenSimple (const char *service)
 Allocate an iterator and consult either local databases (if any present), or network database, using all default communication parameters found both in the registry and the environment variables (as if having an implicit parameter "net_info" created with "ConnNetInfo_Create(service)"). More...
 
SSERV_InfoCPtr SERV_GetNextInfoEx (SERV_ITER iter, HOST_INFO *host_info)
 Get the next server meta-address, optionally accompanied by the host parameters made available by the LB daemon (LBSMD). More...
 
SSERV_InfoCPtr SERV_GetNextInfo (SERV_ITER iter)
 Same as "SERV_GetNextInfoEx(., 0)" – i.e. More...
 
SSERV_InfoSERV_GetInfoEx (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info, SSERV_InfoCPtr skip[], size_t n_skip, HOST_INFO *host_info)
 A "fast track" routine equivalent to creating of an iterator as with SERV_OpenEx(), and then taking an info as with SERV_GetNextInfoEx(). More...
 
SSERV_InfoSERV_GetInfo (const char *service, TSERV_Type types, unsigned int preferred_host, const SConnNetInfo *net_info)
 Same as "SERV_GetInfoEx(., ., ., ., 0, 0, 0)" – i.e. More...
 
SSERV_InfoSERV_GetInfoSimple (const char *service)
 Equivalent to "SERV_GetInfo(., fSERV_Any, SERV_ANYHOST, ConnNetInfo_Create(service))", but it takes care not to leak its last "net_info" parameter, which it builds on the fly. More...
 
int SERV_Penalize (SERV_ITER iter, double fine)
 Penalize the server returned last from SERV_GetNextInfo[Ex](). More...
 
int SERV_Rerate (SERV_ITER iter, double rate)
 Rerate the server returned last from SERV_GetNextInfo[Ex](). More...
 
void SERV_Reset (SERV_ITER iter)
 Reset the iterator to the state as if it has just been opened. More...
 
void SERV_Close (SERV_ITER iter)
 Deallocate the iterator. More...
 
unsigned short SERV_ServerPort (const char *name, unsigned int host)
 Obtain a port number that corresponds to the named (standalone) service declared at the specified host (per the LB configuration information). More...
 
int SERV_SetImplicitServerType (const char *service, ESERV_Type type)
 Set a server type to use when a service mapper returns typeless entries for the given service name (typed entries retain their types as received). More...
 
ESERV_Type SERV_GetImplicitServerType (const char *service)
 Get a server type that would be assigned to typeless entries for the given service name. More...
 
static void CUsageReportAPI::SetEnabled (bool enable=true)
 Enable or disable usage statistics reporting globally for all reporters. More...
 
static bool CUsageReportAPI::IsEnabled (void)
 Indicates whether global application usage statistics collection is enabled. More...
 
static void CUsageReportAPI::SetDefaultParameters (TWhat what=fDefault)
 Set default reporting parameters. More...
 
static TWhat CUsageReportAPI::GetDefaultParameters (void)
 
static void CUsageReportAPI::SetURL (const string &url)
 Change CGI URL for reporting usage statistics. More...
 
static string CUsageReportAPI::GetURL (void)
 
static void CUsageReportAPI::SetAppName (const string &name)
 Set application name for the usage reporters. More...
 
static string CUsageReportAPI::GetAppName (void)
 
static void CUsageReportAPI::SetAppVersion (const string &version)
 Set application version for the usage reporter(s). More...
 
static void CUsageReportAPI::SetAppVersion (const CVersionInfo &version)
 
static string CUsageReportAPI::GetAppVersion (void)
 
static void CUsageReportAPI::SetMaxQueueSize (unsigned n)
 Declare the maximum reporting jobs queue size per reporter. More...
 
static unsigned CUsageReportAPI::GetMaxQueueSize ()
 
 CUsageReportParameters::CUsageReportParameters (void)
 
CUsageReportParametersCUsageReportParameters::Add (const string &name, const string &value)
 Add argument Name must contain only alphanumeric chars or '_'. More...
 
CUsageReportParametersCUsageReportParameters::Add (const string &name, const char *value)
 
template<typename TValue >
CUsageReportParametersCUsageReportParameters::Add (const string &name, TValue value)
 
string CUsageReportParameters::ToString () const
 Convert parameters to string. URL-encode all values. More...
 
 CUsageReportParameters::CUsageReportParameters (const CUsageReportParameters &other)
 Copy constructor. More...
 
CUsageReportParametersCUsageReportParameters::operator= (const CUsageReportParameters &other)
 Copy assignment operator. More...
 
void CUsageReportParameters::x_CopyFrom (const CUsageReportParameters &other)
 Copy parameters to another objects. More...
 
 CUsageReportJob::CUsageReportJob (void)
 Default constructor. More...
 
virtual CUsageReportJob::~CUsageReportJob (void)
 Destructor. More...
 
EState CUsageReportJob::GetState ()
 Return current job state. More...
 
virtual void CUsageReportJob::OnStateChange (EState)
 Callback for async reporting. More...
 
 CUsageReportJob::CUsageReportJob (const CUsageReportJob &other)
 Copy constructor. More...
 
CUsageReportJobCUsageReportJob::operator= (const CUsageReportJob &other)
 Copy assignment operator. More...
 
void CUsageReportJob::x_SetState (EState state)
 Set new job state. More...
 
void CUsageReportJob::x_CopyFrom (const CUsageReportJob &other)
 Copy data from 'other' job. More...
 
static CUsageReportCUsageReport::Instance (void)
 Return global instance of CUsageReport. More...
 
 CUsageReport::CUsageReport (TWhat what=fDefault, const string &url=string(), unsigned max_queue_size=0)
 Constructor. More...
 
virtual CUsageReport::~CUsageReport (void)
 Destructor. More...
 
void CUsageReport::SetEnabled (bool enable=true)
 Enable or disable usage reporter (current instance only). More...
 
bool CUsageReport::IsEnabled (void)
 Indicates whether application usage statistics collection is enabled for a current reporter instance. More...
 
void CUsageReport::Send (void)
 Report usage statistics (asynchronously), default parameters. More...
 
void CUsageReport::Send (CUsageReportParameters &params)
 Report usage statistics (asynchronously). More...
 
template<typename TJob >
void CUsageReport::Send (TJob &job)
 Report usage statistics (asynchronously) (advanced version). More...
 
unsigned CUsageReport::GetQueueSize (void)
 Get number of jobs in the queue – number of unprocessed yet jobs. More...
 
void CUsageReport::ClearQueue (void)
 Remove all unprocessed reporting jobs from queue. More...
 
void CUsageReport::Wait (void)
 Wait until all queued jobs starts to process and queue is empty. More...
 
void CUsageReport::Finish (void)
 Finish reporting for the current reporting object. More...
 
 CUsageReport::CUsageReport (const CUsageReport &)=delete
 Prevent copying. More...
 
CUsageReportCUsageReport::operator= (const CUsageReport &)=delete
 
bool CUsageReport::x_Send (const string &extra_params)
 Send parameters string synchronously. More...
 
void CUsageReport::x_SendAsync (TJobPtr job_ptr)
 Send job asynchronously. More...
 
void CUsageReport::x_ThreadHandler (void)
 Handler for asynchronous job reporting. More...
 
void CUsageReport::x_ClearQueue (void)
 Remove all unprocessed reporting jobs from queue - internal version. More...
 

Variables

unsigned int SHEAP_Block::flag
 
TNCBI_Size SHEAP_Block::size
 
TNcbiArch SHINFO_Params::arch
 Architecture ID, see enum, 0=unknown. More...
 
TNcbiCapacity SHINFO_Params::bits
 Platform bitness, 32/64/32+64/0=unknown. More...
 
TNcbiOSType SHINFO_Params::ostype
 OS type ID, see enum, 0=unknown. More...
 
unsigned short   SHINFO_Params::major
 
unsigned short   SHINFO_Params::minor
 
unsigned short   SHINFO_Params::patch
 
struct {
   unsigned short   SHINFO_Params::major
 
   unsigned short   SHINFO_Params::minor
 
   unsigned short   SHINFO_Params::patch
 
SHINFO_Params::kernel
 Kernel/OS version #, if available. More...
 
size_t SHINFO_Params::pgsize
 Hardware page size in bytes, if known. More...
 
TNCBI_Time SHINFO_Params::bootup
 System boot time, time_t-compatible. More...
 
TNCBI_Time SHINFO_Params::startup
 LBSMD start time, time_t-compatible. More...
 
unsigned short   SHINFO_Params::major
 
unsigned short   SHINFO_Params::minor
 
unsigned short   SHINFO_Params::patch
 
struct {
   unsigned short   SHINFO_Params::major
 
   unsigned short   SHINFO_Params::minor
 
   unsigned short   SHINFO_Params::patch
 
SHINFO_Params::daemon
 LBSMD daemon version. More...
 
unsigned short SHINFO_Params::svcpack
 Kernel service pack (Hi=major, Lo=minor) More...
 
unsigned short SHINFO_PortUsage::port
 Port number, host byte order. More...
 
double SHINFO_PortUsage::used
 Port usage as percentage, [0..100]. More...
 
TNCBI_Size SSERV_NcbidInfo::args
 
char SSERV_StandaloneInfo::_pad
 
TNCBI_Size SSERV_HttpInfo::path
 
TNCBI_Size SSERV_HttpInfo::args
 
ESERV_Type SSERV_FirewallInfo::type
 
unsigned char SSERV_DnsInfo::name
 
SSERV_NcbidInfo USERV_Info::ncbid
 
SSERV_StandaloneInfo USERV_Info::standalone
 
SSERV_HttpInfo USERV_Info::http
 
SSERV_FirewallInfo USERV_Info::firewall
 
SSERV_DnsInfo USERV_Info::dns
 
ESERV_Type SSERV_Info::type
 
unsigned int SSERV_Info::host
 
unsigned short SSERV_Info::port
 
TSERV_Mode SSERV_Info::mode
 
TSERV_Site SSERV_Info::site
 
TNCBI_Time SSERV_Info::time
 
double SSERV_Info::coef
 
double SSERV_Info::rate
 
EMIME_Type SSERV_Info::mime_t
 
EMIME_SubType SSERV_Info::mime_s
 
EMIME_Encoding SSERV_Info::mime_e
 
TSERV_Algo SSERV_Info::algo
 
TNCBI_IPv6Addr SSERV_Info::addr
 
unsigned char SSERV_Info::vhost
 
unsigned short SSERV_Info::extra
 
USERV_Info SSERV_Info::u
 
std::map< string, stringCUsageReportParameters::m_Params
 Stored parameters. More...
 
EState CUsageReportJob::m_State
 Job state. More...
 
bool CUsageReport::m_IsEnabled
 Enable/disable status. More...
 
bool CUsageReport::m_IsFinishing
 TRUE if Finish() has called and reporting thread should terminate. More...
 
string CUsageReport::m_DefaultParams
 Default parameters to report, concatenated and URL-encoded. More...
 
string CUsageReport::m_URL
 Reporting URL. More...
 
std::thread CUsageReport::m_Thread
 Reporting thread. More...
 
list< TJobPtrCUsageReport::m_Queue
 Job queue. More...
 
unsigned CUsageReport::m_MaxQueueSize
 Maximum allowed queue size. More...
 
std::mutex CUsageReport::m_Usage_Mutex
 MT-protection to access members. More...
 
std::condition_variable CUsageReport::m_ThreadSignal
 Signal conditional variable for reporting thread synchronization. More...
 
std::mutex CUsageReport::m_ThreadSignal_Mutex
 

Friends

class CUsageReportParameters::CUsageReport
 
class CUsageReportJob::CUsageReport
 
class CUsageReport::CUsageReportAPI
 

Detailed Description

Macro Definition Documentation

◆ __NCBI_REPORT_USAGE

#define __NCBI_REPORT_USAGE (   event,
  args 
)
Value:
{ \
CUsageReport& reporter = CUsageReport::Instance(); \
if (reporter.IsEnabled()) { \
CUsageReportParameters params; \
params.Add("jsevent", (event)) args; \
reporter.Send(params); \
} \
}
static CUsageReport & Instance(void)
Return global instance of CUsageReport.

Definition at line 614 of file ncbi_usage_report.hpp.

◆ NCBI_REPORT_USAGE

#define NCBI_REPORT_USAGE (   event,
  ... 
)    __NCBI_REPORT_USAGE(event, __VA_ARGS__)

Convenience macro to log "jsevent" usage statistics (asynchronously).

Parameters
eventValue for "jsevent" parameter. Automatically set "jsevent=...".
argsA chain of additional parameters to report. Optional. You can list as many .Add() calls here as you want, or drop this parameter at all. See usage example.
Usage example:
This example demonstrates how to log usage, with and without arguments.
NCBI_REPORT_USAGE("tools", .Add("tool_name", "XYZ") .Add("tool_version", 1));
.Add("tool_name", "XYZ")
.Add("tool_version", 2));
#define NCBI_REPORT_USAGE(event,...)
Convenience macro to log "jsevent" usage statistics (asynchronously).

Definition at line 612 of file ncbi_usage_report.hpp.

◆ NCBI_REPORT_USAGE_FINISH

#define NCBI_REPORT_USAGE_FINISH   CUsageReport::Instance().Finish()

Finishing reporting via NCBI_REPORT_USAGE and global usage reporter,.

Definition at line 634 of file ncbi_usage_report.hpp.

◆ NCBI_REPORT_USAGE_START

#define NCBI_REPORT_USAGE_START   CUsageReportAPI::SetEnabled()

Enable usage statistics reporting (globally for all reporters).

Definition at line 626 of file ncbi_usage_report.hpp.

◆ NCBI_REPORT_USAGE_WAIT

#define NCBI_REPORT_USAGE_WAIT   CUsageReport::Instance().Wait()

Wait until all reports via NCBI_REPORT_USAGE will be processed.

Definition at line 630 of file ncbi_usage_report.hpp.

◆ SERV_ANYHOST

#define SERV_ANYHOST   0

Definition at line 55 of file ncbi_service.h.

◆ SERV_CLIENT_REVISION_MAJOR

#define SERV_CLIENT_REVISION_MAJOR   7

Revision 7.0.

Definition at line 47 of file ncbi_service.h.

◆ SERV_CLIENT_REVISION_MINOR

#define SERV_CLIENT_REVISION_MINOR   0

Definition at line 48 of file ncbi_service.h.

◆ SERV_DEFAULT_ALGO

#define SERV_DEFAULT_ALGO   eSERV_Regular

Definition at line 54 of file ncbi_server_info.h.

◆ SERV_HTTP_ARGS

#define SERV_HTTP_ARGS (   ui)    ((char*)(ui) + (ui)->args)

Definition at line 138 of file ncbi_server_info.h.

◆ SERV_HTTP_PATH

#define SERV_HTTP_PATH (   ui)    ((char*)(ui) + (ui)->path)

Definition at line 137 of file ncbi_server_info.h.

◆ SERV_LOCALHOST

#define SERV_LOCALHOST   ((unsigned int)(~0UL))

Special values for the "preferred_host" parameter.

See also
SERV_OpenEx, SERV_GetInfoEx

Definition at line 54 of file ncbi_service.h.

◆ SERV_MAXIMAL_BONUS

#define SERV_MAXIMAL_BONUS   100.0

Definition at line 58 of file ncbi_server_info.h.

◆ SERV_MAXIMAL_RATE

#define SERV_MAXIMAL_RATE   100000.0

Definition at line 56 of file ncbi_server_info.h.

◆ SERV_MINIMAL_BONUS

#define SERV_MINIMAL_BONUS   0.01

Definition at line 57 of file ncbi_server_info.h.

◆ SERV_MINIMAL_RATE

#define SERV_MINIMAL_RATE   0.001

Definition at line 55 of file ncbi_server_info.h.

◆ SERV_NCBID_ARGS

#define SERV_NCBID_ARGS (   ui)    ((char*)(ui) + (ui)->args)

Definition at line 127 of file ncbi_server_info.h.

Typedef Documentation

◆ FHEAP_Resize

typedef void*(* FHEAP_Resize) (void *old_base, TNCBI_Size new_size, void *auxarg)

Definition at line 80 of file ncbi_heapmgr.h.

◆ HEAP

typedef struct SHEAP_tag* HEAP

Definition at line 53 of file ncbi_heapmgr.h.

◆ HOST_INFO

typedef struct SHostInfoTag* HOST_INFO

Handle for the user code use.

Definition at line 60 of file ncbi_host_info.h.

◆ SERV_ITER

typedef struct SSERV_IterTag* SERV_ITER

Iterator through the servers.

Definition at line 66 of file ncbi_service.h.

◆ SSERV_InfoCPtr

Simplified (uncluttered) SSERV_Info pointer type.

Definition at line 70 of file ncbi_service.h.

◆ TJobPtr

Definition at line 562 of file ncbi_usage_report.hpp.

◆ TNcbiArch

typedef unsigned short TNcbiArch

Definition at line 151 of file ncbi_host_info.h.

◆ TNcbiCapacity

typedef unsigned short TNcbiCapacity

Definition at line 160 of file ncbi_host_info.h.

◆ TNcbiOSType

typedef unsigned short TNcbiOSType

Definition at line 174 of file ncbi_host_info.h.

◆ TSERV_Algo

typedef unsigned char TSERV_Algo

Definition at line 87 of file ncbi_server_info.h.

◆ TSERV_Mode

typedef unsigned char TSERV_Mode

Definition at line 94 of file ncbi_server_info.h.

◆ TSERV_Site

typedef unsigned char TSERV_Site

Definition at line 103 of file ncbi_server_info.h.

◆ TSERV_Type

typedef unsigned int TSERV_Type

Bitwise OR of ESERV_Type[Special].

Definition at line 94 of file ncbi_service.h.

◆ TSERV_TypeOnly

typedef unsigned short TSERV_TypeOnly

Server type only, w/o specials.

Definition at line 95 of file ncbi_service.h.

◆ TWhat

Binary OR of "EWhat".

Definition at line 92 of file ncbi_usage_report.hpp.

Enumeration Type Documentation

◆ ENcbiArch

enum ENcbiArch
Enumerator
fArch_Virtual 

Set when a VM.

fArch_Unknown 

Unknown/undefined CPU type.

Definition at line 146 of file ncbi_host_info.h.

◆ ENcbiCapacity

Enumerator
fCapacity_Unknown 
fCapacity_32 

32 bits only

fCapacity_64 

64 bits, but 32-bit backward compatible

fCapacity_32_64 

32 bits, but 64-bit forward compatible

Definition at line 154 of file ncbi_host_info.h.

◆ ENcbiOSType

Enumerator
fOS_Unknown 
fOS_IRIX 
fOS_Solaris 
fOS_BSD 
fOS_Darwin 
fOS_Windows 
fOS_WindowsServer 
fOS_Linux 

Definition at line 164 of file ncbi_host_info.h.

◆ ESERV_Algo

enum ESERV_Algo
Enumerator
eSERV_Regular 
eSERV_Blast 

Definition at line 83 of file ncbi_server_info.h.

◆ ESERV_Mode

enum ESERV_Mode
Enumerator
fSERV_Stateful 
fSERV_Secure 

Definition at line 90 of file ncbi_server_info.h.

◆ ESERV_Site

enum ESERV_Site
Enumerator
fSERV_Local 
fSERV_Private 
fSERV_Interzone 
fSERV_ZoneMask 

Definition at line 97 of file ncbi_server_info.h.

◆ ESERV_Type

enum ESERV_Type
Enumerator
fSERV_Ncbid 
fSERV_Standalone 
fSERV_HttpGet 
fSERV_HttpPost 
fSERV_Http 
fSERV_Firewall 
fSERV_Dns 

Definition at line 68 of file ncbi_server_info.h.

◆ ESERV_TypeSpecial

Special "type" bit values that may be combined with server types.

Note
MSW should be maintained compatible with EMGHBN_Option.
See also
ESERV_Type, ESERV_OpenEx, SERV_GetInfoEx
Enumerator
fSERV_Any 
fSERV_All 

Server type mask.

fSERV_Stateless 

Stateless servers only.

fSERV_Reserved 

Reserved, MBZ.

fSERV_DelayOpen 

Don't open service until use.

fSERV_ReverseDns 

LB-DNS translation.

fSERV_IncludeDown 
fSERV_IncludeStandby 
fSERV_IncludeReserved 
Note
Not yet implemented
fSERV_IncludeSuppressed 
fSERV_IncludeInactive 
fSERV_IncludePrivate 
fSERV_Promiscuous 

Evrthng and the kitchen sink.

Definition at line 78 of file ncbi_service.h.

◆ EState

Job state.

Enumerator
eCreated 

Initial state, not reported to OnStateChange()

eQueued 

Added to queue (sending temporary postpones)

eRunning 

Ready to send.

eCompleted 

Result: successfully sent.

eFailed 

Result: send failed.

eCanceled 

Result: canceled / removed from queue.

eRejected 

Result: rejected / too many requests.

Definition at line 319 of file ncbi_usage_report.hpp.

◆ EWhat

Defines what information should be reported by default by all reporters, in addition to passed parameters for Send() method.

See also
CUsageReportAPI::SetDefaultParameters(), CUsageReport
Enumerator
fNone 

No defaults, all parameters should be specified via CUsageReportParameters directly.

fAppName 

Application name ("appname")

fAppVersion 

Application version ("version")

fOS 

OS name ("os")

fHost 

Host name ("host")

fDefault 

Definition at line 82 of file ncbi_usage_report.hpp.

Function Documentation

◆ Add() [1/3]

CUsageReportParameters & CUsageReportParameters::Add ( const string name,
const char *  value 
)

Definition at line 225 of file ncbi_usage_report.cpp.

References CUsageReportParameters::Add(), and rapidjson::value.

◆ Add() [2/3]

CUsageReportParameters & CUsageReportParameters::Add ( const string name,
const string value 
)

Add argument Name must contain only alphanumeric chars or '_'.

CUsageReportParameters::

Value will be automatically URL-encoded before printing.

Definition at line 216 of file ncbi_usage_report.cpp.

References NStr::eUrlEnc_URIQueryName, NStr::eUrlEnc_URIQueryValue, CUsageReportParameters::m_Params, NStr::URLEncode(), and rapidjson::value.

Referenced by CUsageReportParameters::Add(), CBlastUsageReport::AddParam(), CUsageReportSampleApp::Pattern_2_MultipleReporters(), and s_AddDefaultParam().

◆ Add() [3/3]

template<typename TValue >
CUsageReportParameters& CUsageReportParameters::Add ( const string name,
TValue  value 
)
inline

Definition at line 273 of file ncbi_usage_report.hpp.

References CUsageReportParameters::Add(), and rapidjson::value.

Referenced by CUsageReportParameters::Add().

◆ ClearQueue()

void CUsageReport::ClearQueue ( void  )

Remove all unprocessed reporting jobs from queue.

See also
Finish(), WaitAndFinish()

Definition at line 491 of file ncbi_usage_report.cpp.

References MT_GUARD, and CUsageReport::x_ClearQueue().

◆ CUsageReport() [1/2]

CUsageReport::CUsageReport ( const CUsageReport )
privatedelete

Prevent copying.

◆ CUsageReport() [2/2]

CUsageReport::CUsageReport ( TWhat  what = fDefault,
const string url = string(),
unsigned  max_queue_size = 0 
)

Constructor.

Creates new reporting instance. For general case we still recommend to use a single global usage reporter, one per application, accessible via CUsageReport::Instance(). But, if you need to use different reporting URL or default parameters for each reporter, you can create new instance yourself with needed arguments.

Parameters
whatSet of parameters that should be reported by default. If fDefault, global default API setting will be used, see CUsageReportAPI::SetDefaultParameters().
urlReporting URL. If not specified or empty, global API setting will be used, see CUsageReportAPI::SetURL().
max_queue_sizeMaximum reporting jobs queue size. If not specified or zero, global API setting will be used, see CUsageReportAPI::SetMaxQueueSize().
See also
TWhat, Instance(), CUsageReportAPI::SetDefaultParameters(), CUsageReportAPI::SetURL(), CUsageReportAPI::SetMaxQueueSize()

Definition at line 352 of file ncbi_usage_report.cpp.

References CUsageReportBase::fAppName, CUsageReportBase::fAppVersion, CUsageReportBase::fDefault, CUsageReportBase::fHost, CUsageReportBase::fOS, CUsageReportAPI::GetAppName(), CUsageReportAPI::GetAppVersion(), CUsageReportAPI::GetDefaultParameters(), CUsageReportAPI::GetMaxQueueSize(), CUsageReportAPI::GetURL(), CUsageReport::m_DefaultParams, CUsageReport::m_IsEnabled, CUsageReport::m_IsFinishing, CUsageReport::m_MaxQueueSize, CUsageReport::m_URL, s_AddDefaultParam(), s_GetHost(), and CUsageReportParameters::ToString().

Referenced by CUsageReport::Instance().

◆ CUsageReportJob() [1/2]

CUsageReportJob::CUsageReportJob ( const CUsageReportJob other)
inline

Copy constructor.

Definition at line 348 of file ncbi_usage_report.hpp.

References CUsageReportJob::m_State.

◆ CUsageReportJob() [2/2]

CUsageReportJob::CUsageReportJob ( void  )
inline

Default constructor.

Definition at line 330 of file ncbi_usage_report.hpp.

Referenced by CUsageReportJob::ReportUsage().

◆ CUsageReportParameters() [1/2]

CUsageReportParameters::CUsageReportParameters ( const CUsageReportParameters other)
inline

Copy constructor.

Definition at line 279 of file ncbi_usage_report.hpp.

References CUsageReportParameters::x_CopyFrom().

◆ CUsageReportParameters() [2/2]

CUsageReportParameters::CUsageReportParameters ( void  )
inline

Definition at line 264 of file ncbi_usage_report.hpp.

◆ Finish()

void CUsageReport::Finish ( void  )

Finish reporting for the current reporting object.

All reporting jobs in the queue will be discarded and reporting thread destroyed. If you want to wait all queued requests to finish, call Wait() just before Finish().

Note
Only queued requests will be discarded. It doesn't affect already started job, that is sending at the current moment (if any). Reporting thread will be destroyed immediately after finishing sending last started job.
The reporter become invalid after this call and shouldn't be used anymore.
See also
ClearQueue(), Wait()

Definition at line 553 of file ncbi_usage_report.cpp.

References CUsageReport::m_IsFinishing, CUsageReport::m_Thread, CUsageReport::m_ThreadSignal, MT_GUARD, and CUsageReport::x_ClearQueue().

Referenced by CUsageReportSampleApp::Pattern_2_MultipleReporters(), CBlastUsageReport::~CBlastUsageReport(), and CUsageReport::~CUsageReport().

◆ GetAppName()

string CUsageReportAPI::GetAppName ( void  )
static

◆ GetAppVersion()

string CUsageReportAPI::GetAppVersion ( void  )
static

◆ GetDefaultParameters()

CUsageReportAPI::TWhat CUsageReportAPI::GetDefaultParameters ( void  )
static

Definition at line 92 of file ncbi_usage_report.cpp.

References gs_DefaultParams().

Referenced by CUsageReport::CUsageReport().

◆ GetMaxQueueSize()

unsigned CUsageReportAPI::GetMaxQueueSize ( void  )
static

Definition at line 190 of file ncbi_usage_report.cpp.

References NCBI_PARAM_TYPE.

Referenced by CUsageReport::CUsageReport().

◆ GetQueueSize()

unsigned CUsageReport::GetQueueSize ( void  )

Get number of jobs in the queue – number of unprocessed yet jobs.

Definition at line 481 of file ncbi_usage_report.cpp.

References CUsageReport::m_Queue, and MT_GUARD.

◆ GetState()

EState CUsageReportJob::GetState ( )
inline

Return current job state.

See also
EState

Definition at line 336 of file ncbi_usage_report.hpp.

References CUsageReportJob::m_State.

◆ GetURL()

string CUsageReportAPI::GetURL ( void  )
static

Definition at line 159 of file ncbi_usage_report.cpp.

References NCBI_PARAM_TYPE.

Referenced by CUsageReport::CUsageReport().

◆ HEAP_AddRef()

unsigned int HEAP_AddRef ( HEAP  heap)

Definition at line 1291 of file ncbi_heapmgr.c.

References assert, heap, and HEAP_CHECK.

Referenced by s_GetHeapCopy().

◆ HEAP_Alloc()

SHEAP_Block* HEAP_Alloc ( HEAP  heap,
TNCBI_Size  size,
int  hint 
)

◆ HEAP_Attach()

HEAP HEAP_Attach ( const void *  base,
TNCBI_Size  maxsize,
int  serial 
)

◆ HEAP_AttachFast()

HEAP HEAP_AttachFast ( const void *  base,
TNCBI_Size  size,
int  serial 
)

◆ HEAP_Base()

void* HEAP_Base ( const HEAP  heap)

◆ HEAP_Copy()

HEAP HEAP_Copy ( const HEAP  orig,
size_t  extra,
int  serial 
)

◆ HEAP_Create()

HEAP HEAP_Create ( void *  base,
TNCBI_Size  size,
TNCBI_Size  chunk_size,
FHEAP_Resize  resize,
void *  auxarg 
)

◆ HEAP_Destroy()

unsigned int HEAP_Destroy ( HEAP  heap)

Definition at line 1317 of file ncbi_heapmgr.c.

References CORE_LOGF_X, eLOG_Error, heap, HEAP_CHECK, HEAP_Detach(), s_HEAP_Id(), and verify.

Referenced by LBSM_Shmem_Destroy(), s_Fini(), and s_GetHeapCopy().

◆ HEAP_Detach()

unsigned int HEAP_Detach ( HEAP  heap)

◆ HEAP_Free()

void HEAP_Free ( HEAP  heap,
SHEAP_Block ptr 
)

◆ HEAP_FreeFast()

void HEAP_FreeFast ( HEAP  heap,
SHEAP_Block ptr,
const SHEAP_Block prev 
)

◆ HEAP_Idle()

TNCBI_Size HEAP_Idle ( const HEAP  heap)

◆ HEAP_Next()

SHEAP_Block* HEAP_Next ( const HEAP  heap,
const SHEAP_Block prev 
)

◆ HEAP_Options()

void HEAP_Options ( ESwitch  fast,
ESwitch  unused 
)

Definition at line 1400 of file ncbi_heapmgr.c.

References eOff, eOn, and s_HEAP_fast.

◆ HEAP_Serial()

int HEAP_Serial ( const HEAP  heap)

◆ HEAP_Size()

TNCBI_Size HEAP_Size ( const HEAP  heap)

Definition at line 1342 of file ncbi_heapmgr.c.

References heap, HEAP_CHECK, and HEAP_EXTENT.

Referenced by LBSM_Shmem_Update(), and s_VerifyChecksum().

◆ HEAP_Trim()

HEAP HEAP_Trim ( HEAP  heap)

◆ HEAP_Used()

TNCBI_Size HEAP_Used ( const HEAP  heap)

Definition at line 1351 of file ncbi_heapmgr.c.

References heap, HEAP_CHECK, and HEAP_EXTENT.

◆ HEAP_Walk()

SHEAP_Block* HEAP_Walk ( const HEAP  heap,
const SHEAP_Block prev 
)

◆ HINFO_AffinityArgument()

const char* HINFO_AffinityArgument ( const HOST_INFO  host_info)

Obtain the affinity argument that has keyed the service selection (if argument affinities have been used at all).

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
NULL if no affinity has been found/used (in the latter case HINFO_AffinityArgvalue() would also return NULL); otherwise, a non-NULL pointer to a '\0'-terminated string that remains valid until the handle "host_info" gets free()'d by the application.
See also
HINFO_AffinityArgvalue, SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 179 of file ncbi_host_info.c.

References SHostInfoTag::arg, HINFO_MAGIC, and SHostInfoTag::pad.

◆ HINFO_AffinityArgvalue()

const char* HINFO_AffinityArgvalue ( const HOST_INFO  host_info)

Obtain the affinity argument's value that has keyed the service selection (if argument affinities have been used at all).

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
NULL if there was no particular value matched but the argument (as returned by HINFO_AffinityArgument()) played alone; "" if the value has been used empty, or any other substring from the host environment that keyed the selection decision. The non-NULL pointer remains valid until the handle "host_info" gets free()'d by the application.
See also
HINFO_AffinityArgument, HINFO_Environment, SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 187 of file ncbi_host_info.c.

References HINFO_MAGIC, SHostInfoTag::pad, and SHostInfoTag::val.

◆ HINFO_CpuClock()

double HINFO_CpuClock ( const HOST_INFO  host_info)

Get CPU clock rate.

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
CPU clock rate (in MHz), or 0.0 if failed to determine, or a negative value if an error occurred.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 105 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_CpuClock(), and SHostInfoTag::pad.

◆ HINFO_CpuCount()

int HINFO_CpuCount ( const HOST_INFO  host_info)

Get CPU count (number of logical cores, hyper-threaded included).

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
CPU count, or 0 when failed to determine, or -1 if an error occurred.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 89 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_CpuCount(), and SHostInfoTag::pad.

◆ HINFO_CpuUnits()

int HINFO_CpuUnits ( const HOST_INFO  host_info)

Get physical CPU count (number of physical cores, not packages).

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
The number of physical CPU units, 0 if the number cannot be determined, or -1 if an error occurred.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 97 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_CpuUnits(), and SHostInfoTag::pad.

◆ HINFO_Environment()

const char* HINFO_Environment ( const HOST_INFO  host_info)

Obtain and return LB host environment.

LB host environment is a sequence of lines (separated by \n), all having form of "name=value", which is provided to and stored by the Load-Balancing and Service Mapping Daemon (LBSMD) in the configuration file on that host.

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
NULL if the host environment either cannot be obtained or does not exist; otherwise, a non-NULL pointer to a '\0'-terminated string that contains the environment, which remains valid until the handle "host_info" gets free()'d by the application.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 171 of file ncbi_host_info.c.

References SHostInfoTag::env, HINFO_MAGIC, and SHostInfoTag::pad.

◆ HINFO_HostAddr()

unsigned int HINFO_HostAddr ( const HOST_INFO  host_info)

Get the official host address.

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
Official host address, or 0 if unknown.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 81 of file ncbi_host_info.c.

References SHostInfoTag::addr, HINFO_MAGIC, and SHostInfoTag::pad.

◆ HINFO_LoadAverage()

int HINFO_LoadAverage ( const HOST_INFO  host_info,
double  lavg[2] 
)

Obtain host load averages.

Parameters
host_infoHOST_INFO as returned by the SERV API.
lavgLoad averages to fill in upon return:
  • [0] = The standard 1-minute load average;
  • [1] = Instant (a.k.a. Blast) load average (averaged over runnable count).
Returns
Non-zero on success and store load averages in the provided array "lavg", or 0 on error ("lavg" cleared).
See also
HINFO_Status, SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 151 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_LoadAverage(), and SHostInfoTag::pad.

◆ HINFO_MachineParams()

int HINFO_MachineParams ( const HOST_INFO  host_info,
SHINFO_Params params 
)

Get host parameters.

Parameters
host_infoHOST_INFO as returned by the SERV API.
paramsHost parameters to fill in upon return.
Returns
Non-zero on success, 0 on error ("params" cleared).
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 131 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_MachineParams(), and SHostInfoTag::pad.

◆ HINFO_Memusage()

int HINFO_Memusage ( const HOST_INFO  host_info,
double  memusage[5] 
)

Get memory usage data.

Parameters
host_infoHOST_INFO as returned by the SERV API.
memusageMemory usage in MB (filled in upon return):
  • [0] = total RAM;
  • [1] = discardable RAM (cached);
  • [2] = free RAM;
  • [3] = total swap;
  • [4] = free swap.
Returns
Non-zero on success and store memory usage (MB, in the provided array "memusage"), or 0 if an error occurred ("memusage" cleared).
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 121 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_Memusage(), and SHostInfoTag::pad.

◆ HINFO_PortUsage()

int HINFO_PortUsage ( const HOST_INFO  host_info,
SHINFO_PortUsage  ports[],
size_t  count 
)

Obtain host port usage (currently only 4 first ports are published).

Parameters
host_infoHOST_INFO as returned by the SERV API.
portsUsage information to fill out
countNumber of array elements in "ports"
Returns
Return the number of port usage slots reported (may be zero if the host reports no port usage, can be less than "count" – remaining array elements cleared; or more than "count" if the host requires a bigger array that the one provided – all "count" elements have been filled in), or -1 when an error occurred ("ports" cleared).
Note
You may call this function with "ports" and "count" passed as 0 to learn how many array elements to expect.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 141 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_PortUsage(), and SHostInfoTag::pad.

◆ HINFO_Status()

int HINFO_Status ( const HOST_INFO  host_info,
double  status[2] 
)

Obtain LB host availability status.

Parameters
host_infoHOST_INFO as returned by the SERV API.
statusStatus values to fill in upon return:
  • [0] = status based on the standard load average;
  • [1] = status based on the instant load average.
Returns
Non-zero on success and store host status values in the provided array "status", or 0 on error ("status" cleared).
Note
Status may get returned as 0.0 if either the host does not provide such information, or if the host is overloaded (unavailable).
See also
HINFO_LoadAverage, SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 161 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_Status(), and SHostInfoTag::pad.

Referenced by CDBLB_ServiceMapper::GetServerOptions().

◆ HINFO_TaskCount()

int HINFO_TaskCount ( const HOST_INFO  host_info)

Get task count.

Parameters
host_infoHOST_INFO as returned by the SERV API.
Returns
Task count (incl. 0 when failed to determine), or -1 if an error occurred.
See also
SERV_GetInfoEx, SERV_GetNextInfoEx

Definition at line 113 of file ncbi_host_info.c.

References HINFO_MAGIC, LBSM_HINFO_TaskCount(), and SHostInfoTag::pad.

◆ Instance()

CUsageReport & CUsageReport::Instance ( void  )
static

Return global instance of CUsageReport.

This method allow to use a single copy of usage reporter for an application. Real initialization will be done on first call to this method. Newly created reporter inherit current CUsageReportAPI setting, like reporting URL and default parameters. You should change it if necessary before any call to Instance().

Returns
Global instance of the usage reporter.
See also
CUsageReportAPI

Definition at line 337 of file ncbi_usage_report.cpp.

References CUsageReport::CUsageReport(), and gs_DefaultParams().

Referenced by CUsageReportSampleApp::Pattern_3_StatusControl().

◆ IsEnabled() [1/2]

bool CUsageReportAPI::IsEnabled ( void  )
static

Indicates whether global application usage statistics collection is enabled.

See also
SetEnabled()

Definition at line 106 of file ncbi_usage_report.cpp.

References gs_IsEnabled, and NStr::StringToBool().

Referenced by CUsageReport::IsEnabled().

◆ IsEnabled() [2/2]

bool CUsageReport::IsEnabled ( void  )

Indicates whether application usage statistics collection is enabled for a current reporter instance.

Takes into account local status and global API setting as well.

See also
CUsageReportAPI::SetEnabled, SetEnabled

Definition at line 394 of file ncbi_usage_report.cpp.

References CUsageReportAPI::IsEnabled(), CUsageReport::m_IsEnabled, and CUsageReport::m_IsFinishing.

Referenced by CBlastUsageReport::AddParam(), BlastdbCopyApplication::BlastdbCopyApplication(), CBlastDBAliasApp::CBlastDBAliasApp(), CBlastDbCheckApplication::CBlastDbCheckApplication(), CBlastDBCmdApp::CBlastDBCmdApp(), CBlastdbConvertApp::CBlastdbConvertApp(), CBlastFormatterApp::CBlastFormatterApp(), CBlastFormatterVdbApp::CBlastFormatterVdbApp(), CBlastnApp::CBlastnApp(), CBlastpApp::CBlastpApp(), CBlastVdbCmdApp::CBlastVdbCmdApp(), CBlastxApp::CBlastxApp(), CConvert2BlastMaskApplication::CConvert2BlastMaskApplication(), CDeltaBlastApp::CDeltaBlastApp(), CMagicBlastApp::CMagicBlastApp(), CMakeBlastDBApp::CMakeBlastDBApp(), CMakeClusterDBApp::CMakeClusterDBApp(), CMakeProfileDBApp::CMakeProfileDBApp(), CPsiBlastApp::CPsiBlastApp(), CRPSBlastApp::CRPSBlastApp(), CRPSTBlastnApp::CRPSTBlastnApp(), CTblastnApp::CTblastnApp(), CTblastxApp::CTblastxApp(), CVDBBlastnApp::CVDBBlastnApp(), CVDBTblastnApp::CVDBTblastnApp(), CIgBlastnApp::Init(), CIgBlastpApp::Init(), CBlastFormat::LogBlastSearchInfo(), CIgBlastnApp::Run(), CIgBlastpApp::Run(), CUsageReport::Send(), CMagicBlastApp::x_LogBlastSearchInfo(), CUsageReport::x_ThreadHandler(), and CBlastUsageReport::~CBlastUsageReport().

◆ OnStateChange()

virtual void CUsageReportJob::OnStateChange ( EState  )
inlinevirtual

Callback for async reporting.

Calls on each state change.

CUsageReport::Send() change job state during asynchronous reporting and call this method on each change. This method can be overloaded to allow checking reporting progress or failures, see EState for a list of states.

See also
EState, CUsageReport::Send()

Definition at line 345 of file ncbi_usage_report.hpp.

Referenced by CUsageReportJob::x_SetState().

◆ operator=() [1/3]

CUsageReport& CUsageReport::operator= ( const CUsageReport )
privatedelete

◆ operator=() [2/3]

CUsageReportJob& CUsageReportJob::operator= ( const CUsageReportJob other)
inline

Copy assignment operator.

Definition at line 350 of file ncbi_usage_report.hpp.

References CUsageReportJob::x_CopyFrom().

◆ operator=() [3/3]

CUsageReportParameters& CUsageReportParameters::operator= ( const CUsageReportParameters other)
inline

Copy assignment operator.

Definition at line 281 of file ncbi_usage_report.hpp.

References CUsageReportParameters::x_CopyFrom().

◆ Send() [1/3]

void CUsageReport::Send ( CUsageReportParameters params)

Report usage statistics (asynchronously).

Send usage statistics with specified parameters in background, without blocking current thread execution.

Parameters
paramsSpecifies extra parameters to report, in addition to default parameters specified in the CUsageReport constructor. The reporter copy parameters before asynchronously reporting them in background, so parameters object can be freely changed or destroyed after this call.
Note
This version do nothing on errors. If you want to control reporting progress and results you can use Send(CUsageReportJob&) version with your own class derived from CUsageReportJob.
See also
CUsageReportParameters, CUsageReportJob, TWhat, SetEnabled(), Wait()

Definition at line 468 of file ncbi_usage_report.cpp.

References CUsageReport::IsEnabled(), and CUsageReport::x_SendAsync().

◆ Send() [2/3]

template<typename TJob >
void CUsageReport::Send ( TJob &  job)
inline

Report usage statistics (asynchronously) (advanced version).

Send usage statistics in background without blocking current thread execution. You can use this version if you want to control reporting progress and get status of submitted reports.

Parameters
jobJob to report, some object of type CUsageReportJob or derived from it. CUsageReportJob do nothing if something bad happens on reporting. All errors are ignored and silenced. You need to derive your own class from CUsageReportJob if you want to control reporting status or store additional information. See CUsageReportJob description for details.
See also
CUsageReportJob, CUsageReportJob::OnStateChange(), SetEnabled(), Wait()
// Usage example
CUsageReportJob_or_derived_class job;
job.Add(...);
void Send(void)
Report usage statistics (asynchronously), default parameters.

Definition at line 514 of file ncbi_usage_report.hpp.

References CUsageReport::IsEnabled(), and CUsageReport::x_SendAsync().

◆ Send() [3/3]

void CUsageReport::Send ( void  )

Report usage statistics (asynchronously), default parameters.

Send usage statistics with default parameters in background, without blocking current thread execution.

See also
CUsageReportParameters, SetEnabled(), Wait()

Definition at line 457 of file ncbi_usage_report.cpp.

References CUsageReport::IsEnabled(), and CUsageReport::x_SendAsync().

Referenced by CUsageReportSampleApp::Pattern_2_MultipleReporters(), CUsageReportSampleApp::Pattern_3_StatusControl(), and CBlastUsageReport::~CBlastUsageReport().

◆ SERV_Close()

void SERV_Close ( SERV_ITER  iter)

Deallocate the iterator.

Must be called to finish the lookup process.

Warning
Invalidates all previosuly issued server descriptors (SSERV_Info*).
Parameters
iterAn iterator handle obtained via a "SERV_Open*" call.
Note
NULL is accepted, and causes no actions.
See also
SERV_OpenEx, SERV_Reset

Definition at line 993 of file ncbi_service.c.

References SSERV_VTable::Close, free(), i, SSERV_IterTag::n_skip, SSERV_IterTag::name, SSERV_IterTag::op, SERV_Reset(), and SSERV_IterTag::skip.

Referenced by DBLB_GetServer(), SServIterDeleter::Delete(), CServiceDiscovery::DiscoverImpl(), CDBLB_ServiceMapper::GetServerOptions(), CDBLB_ServiceMapper::GetServersList(), s_CloseDispatcher(), s_Open(), SERV_GetInfoP(), SERV_GetServers(), CConnTest::ServiceOkay(), CConnTest::StatefulOkay(), and x_Open().

◆ SERV_CopyInfo()

SSERV_Info* SERV_CopyInfo ( const SSERV_Info info)

Definition at line 614 of file ncbi_server_info.c.

References orig, and SERV_CopyInfoEx().

Referenced by CReaderServiceConnector::RememberIfBad().

◆ SERV_CreateDnsInfo()

SSERV_Info* SERV_CreateDnsInfo ( unsigned int  host)

Definition at line 1120 of file ncbi_server_info.c.

References SERV_CreateDnsInfoEx().

Referenced by DBLB_GetServer(), s_FakeDnsReturn(), and s_GetNextInfo().

◆ SERV_CreateFirewallInfo()

SSERV_Info* SERV_CreateFirewallInfo ( unsigned int  host,
unsigned short  port,
ESERV_Type  type 
)

Definition at line 1057 of file ncbi_server_info.c.

References SERV_CreateFirewallInfoEx().

◆ SERV_CreateHttpInfo()

SSERV_Info* SERV_CreateHttpInfo ( ESERV_Type  type,
unsigned int  host,
unsigned short  port,
const char *  path,
const char *  args 
)

Definition at line 978 of file ncbi_server_info.c.

References SERV_CreateHttpInfoEx().

◆ SERV_CreateNcbidInfo()

SSERV_Info* SERV_CreateNcbidInfo ( unsigned int  host,
unsigned short  port,
const char *  args 
)

Definition at line 774 of file ncbi_server_info.c.

References SERV_CreateNcbidInfoEx().

◆ SERV_CreateStandaloneInfo()

SSERV_Info* SERV_CreateStandaloneInfo ( unsigned int  host,
unsigned short  port 
)

Definition at line 838 of file ncbi_server_info.c.

References SERV_CreateStandaloneInfoEx().

Referenced by DBLB_GetServer().

◆ SERV_EqualInfo()

int SERV_EqualInfo ( const SSERV_Info info1,
const SSERV_Info info2 
)

◆ SERV_GetImplicitServerType()

ESERV_Type SERV_GetImplicitServerType ( const char *  service)

Get a server type that would be assigned to typeless entries for the given service name.

See also
ConnNetInfo_GetValue, SERV_SetImplicitServerType, SERV_GetImplicitServerTypeDefault

Definition at line 1300 of file ncbi_service.c.

◆ SERV_GetInfo()

SSERV_Info* SERV_GetInfo ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
const SConnNetInfo net_info 
)

Same as "SERV_GetInfoEx(., ., ., ., 0, 0, 0)" – i.e.

w/o the "skip" array, and w/o "host_info".

See also
SERV_GetInfoEx, SERV_Open

Definition at line 872 of file ncbi_service.c.

References SERV_GetInfoP(), and types.

Referenced by CEUtils_Request::GetBaseURL(), and CEutilsClient::x_GetHostName().

◆ SERV_GetInfoEx()

SSERV_Info* SERV_GetInfoEx ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip,
HOST_INFO host_info 
)

A "fast track" routine equivalent to creating of an iterator as with SERV_OpenEx(), and then taking an info as with SERV_GetNextInfoEx().

However, this call is optimized for an application, which only needs a single entry (the first one), and which is not interested in iterating over all available instances. Both the returned server-info and host information (if any) have to be explicitly free()'d by the application when no longer needed.

Parameters
serviceA service name (may not be NULL or empty).
typesA bitset of type(s) of servers requested.
preferred_hostPreferred host to use the service at, nbo.
net_infoConnection information (NULL disables network-based dispatching via LINKERD, NAMERD, and DISPD)
skip[]An array of servers NOT to select, see SERV_OpenEx() for notes.
n_skipNumber of entries in the "skip" array.
host_infoAn optional pointer to store host info at (may be NULL).
Note
The host information is provided only (if at all) if this call returns a non-NULL result, see SERV_OpenEx() for notes.
Returns
First matching server-info (non-NULL), or NULL if no instances found.
See also
SERV_GetInfo, SERV_OpenEx

Definition at line 886 of file ncbi_service.c.

References SERV_GetInfoP(), and types.

◆ SERV_GetInfoSimple()

SSERV_Info* SERV_GetInfoSimple ( const char *  service)

Equivalent to "SERV_GetInfo(., fSERV_Any, SERV_ANYHOST, ConnNetInfo_Create(service))", but it takes care not to leak its last "net_info" parameter, which it builds on the fly.

See also
SERV_GetInfo, SERV_OpenSimple

Definition at line 858 of file ncbi_service.c.

References ConnNetInfo_Create(), ConnNetInfo_Destroy(), fSERV_Any, info, SERV_ANYHOST, and SERV_GetInfoP().

◆ SERV_GetNextInfo()

SSERV_InfoCPtr SERV_GetNextInfo ( SERV_ITER  iter)

◆ SERV_GetNextInfoEx()

SSERV_InfoCPtr SERV_GetNextInfoEx ( SERV_ITER  iter,
HOST_INFO host_info 
)

Get the next server meta-address, optionally accompanied by the host parameters made available by the LB daemon (LBSMD).

Parameters
iterAn iterator handle obtained via a "SERV_Open*" call.
Note
NULL is accepted, and results in NULL returned.
Parameters
host_infoAn optional pointer to store host info at (may be NULL).
Returns
NULL if no more servers have been found for the service requested (the pointer to "host_info" remains untouched in this case); otherwise, a non-NULL pointer to the server meta address.
Note
The returned server-info is valid only until either of the two events: 1. SERV_GetNextInfo[Ex]() is called with this iterator again; or 2. The iterator reset / closed (SERV_Reset() / SERV_Close() called).
Application program should NOT destroy the returned server-info as it is managed automatically by the iterator.
Resulting DNS-type server-info (only if coming out for the first time) may contain 0 in the host field to denote that the name exists but the service is currently not serving (down / unavailable).
Only when completing successfully, i.e. returning a non-NULL info, this call can also provide host information as the following: if "host_info" parameter is passed as a non-NULL pointer, then a copy of host information may be allocated, and the handle is then stored at "*host_info" when the host information is available for the host. Otherwise, the pointer is updated with a NULL value stored. Using the non-NULL handle returned, various parameters like load, environment, number of CPUs, etc can be retrieved (see ncbi_host_info.h). The returned host information handle has to be explicitly free()'d when no longer needed.
See also
SERV_Reset, SERV_Close, SERV_GetInfoEx, ncbi_host_info.h

Definition at line 928 of file ncbi_service.c.

References assert, SSERV_IterTag::op, and s_GetNextInfo().

Referenced by CServiceDiscovery::DiscoverImpl(), and CDBLB_ServiceMapper::GetServerOptions().

◆ SERV_Open()

SERV_ITER SERV_Open ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
const SConnNetInfo net_info 
)

◆ SERV_OpenEx()

SERV_ITER SERV_OpenEx ( const char *  service,
TSERV_Type  types,
unsigned int  preferred_host,
const SConnNetInfo net_info,
SSERV_InfoCPtr  skip[],
size_t  n_skip 
)

Create an iterator for sequential server lookup.

Note
'nbo' in comments denotes parameters coming in network byte order; 'hbo' stands for 'host byte order'.
Parameters
serviceA service name, may not be NULL or empty.
typesA bitset of type(s) of servers requested.
preferred_hostPreferred host to use the service at, nbo.
net_infoConnection information (NULL prevents the use of the network-based dispatching via LINKERD, NAMERD, and DISPD)
Note
If "net_info" is NULL, only the following mappers will be consulted: LOCAL(if enabled, see below), LBSMD, and LBDNS. If "net_info" is not NULL, the above mappers are consulted first, followed by LINKERD, NAMERD, and DISPD (using the connection information provided) but only if mapping with the preceding mapper(s), if any occurred, has failed.
The registry section [CONN], keys: LOCAL_ENABLE, LBSMD_DISABLE, LBDNS_ENABLE, LINKERD_ENABLE, NAMERD_ENABLE, DISPD_DISABLE which can be overridden by the environment variables: CONN_LOCAL_ENABLE, CONN_LBSMD_DISABLE, CONN_LBDNS_ENABLE, CONN_LINKERD_ENABLE, CONN_NAMERD_ENABLE, and CONN_DISPD_DISABLE can be used to add(for LOCAL, LBDNS, LINKERD, NAMERD) or to skip (for LBSMD and DISPD) the corresponding service mapper(s). This scheme permits to use any combination of the service mappers (local/lbsmd/ lbdns/linkerd/namerd/dispd, network-aware or not). These keys can also be used for even more granular, per-service basis, as described in <connect/ncbi_connutil.h> – when used in the registry section '[service]' or prefixed with the service name in the process environment.
If "net_info" is not NULL then a non-zero value of "net_info->stateless" forces "types" to get the "fSERV_Stateless" bit set implicitly.
Parameters
skipAn array of servers NOT to select: contains server-info elements that are not to return from the search (whose server-infos match the would-be result).
Note
However, special additional rules apply to the "skip" elements when the fSERV_ReverseDns bit is set in the "types" parameter: the result-to-be is not considered if either 1. There is an entry of the fSERV_Dns type found in "skip" array that matches the host[:port] (any port if the skip entry's port is 0); or 2. The reverse lookup of the host:port turns up an fSERV_Dns-type server whose name matches an fSERV_Dns-type server in "skip".
Parameters
n_skipNumber of entries in the "skip" array.
Returns
Non-NULL iterator, or NULL if the service does not exist.
Note
Non-NULL iterator does not guarantee the service operational, it merely acknowledges the service existence.
See also
SERV_GetNextInfoEx, SERV_Reset, SERV_Close, ConnNetInfo_Create

Definition at line 822 of file ncbi_service.c.

References s_Open(), and types.

◆ SERV_OpenSimple()

SERV_ITER SERV_OpenSimple ( const char *  service)

Allocate an iterator and consult either local databases (if any present), or network database, using all default communication parameters found both in the registry and the environment variables (as if having an implicit parameter "net_info" created with "ConnNetInfo_Create(service)").

Note
No preferred host is set in the target iterator.
Parameters
serviceA service name (may not be NULL or empty).
Returns
Non-NULL iterator, or NULL if the service does not exist.
Note
Non-NULL iterator does not guarantee the service operational, it merely acknowledges the service existence.
See also
SERV_GetNextInfoEx, SERV_OpenEx, SERV_Reset, SERV_Close, ConnNetInfo_Create

Definition at line 795 of file ncbi_service.c.

References ConnNetInfo_Create(), ConnNetInfo_Destroy(), fSERV_Any, s_Open(), and SERV_ANYHOST.

Referenced by CConnTest::ServiceOkay(), and CConnTest::StatefulOkay().

◆ SERV_Penalize()

int SERV_Penalize ( SERV_ITER  iter,
double  fine 
)

Penalize the server returned last from SERV_GetNextInfo[Ex]().

Parameters
iterAn iterator handle obtained via a "SERV_Open*" call.
fineA fine value in the range [0=min..100=max] (%%), inclusive.
Returns
Return 0 if failed, non-zero if successful.
See also
SERV_OpenEx, SERV_GetNextInfoEx

Definition at line 966 of file ncbi_service.c.

References SERV_PenalizeEx().

◆ SERV_ReadInfo()

SSERV_Info* SERV_ReadInfo ( const char *  info_str)

Definition at line 587 of file ncbi_server_info.c.

References SERV_ReadInfoEx(), and str().

◆ SERV_ReadType()

const char* SERV_ReadType ( const char *  str,
ESERV_Type type 
)

◆ SERV_Rerate()

int SERV_Rerate ( SERV_ITER  iter,
double  rate 
)

Rerate the server returned last from SERV_GetNextInfo[Ex]().

Note
This is an experimental API.
Parameters
iterAn iterator handle obtained via a "SERV_Open*" call.
rateA new rate value, or 0.0 to turn the server off, or fabs(rate) >= LBSM_RERATE_DEFAULT to revert to the default.
Returns
Return 0 if failed, non-zero if successful.
See also
SERV_OpenEx, SERV_GetNextInfoEx

Definition at line 972 of file ncbi_service.c.

References assert, SSERV_VTable::Feedback, SSERV_IterTag::last, and SSERV_IterTag::op.

◆ SERV_Reset()

void SERV_Reset ( SERV_ITER  iter)

Reset the iterator to the state as if it has just been opened.

Warning
Invalidates all previosuly issued server descriptors (SSERV_Info*).
Parameters
iterAn iterator handle obtained via a "SERV_Open*" call.
Note
NULL is accepted, and causes no actions.
See also
SERV_OpenEx, SERV_GetNextInfoEx, SERV_Close

Definition at line 981 of file ncbi_service.c.

References SSERV_IterTag::last, SSERV_IterTag::op, SSERV_VTable::Reset, s_SkipSkip(), and SSERV_IterTag::time.

Referenced by s_GetNextInfo(), and SERV_Close().

◆ SERV_ServerPort()

unsigned short SERV_ServerPort ( const char *  name,
unsigned int  host 
)

Obtain a port number that corresponds to the named (standalone) service declared at the specified host (per the LB configuration information).

Parameters
nameService name (of type fSERV_Standalone) to look up.
hostHost address (or SERV_LOCALHOST, or 0, same) to look the service up at.
Returns
The port number or 0 on error (no suitable service found).
Note
The call returns the first match, and does not check whether an application is already running at the returned port (i.e. regardless of whether or not the service is currently up).
See also
ESERV_Type, SERV_OpenEx, LSOCK_CreateEx

Definition at line 1200 of file ncbi_service.c.

References assert, eDefault, free(), fSERV_Promiscuous, fSERV_Standalone, info, SERV_GetInfoP(), SERV_LOCALHOST, and SOCK_GetLocalHostAddress().

◆ SERV_SetImplicitServerType()

int SERV_SetImplicitServerType ( const char *  service,
ESERV_Type  type 
)

Set a server type to use when a service mapper returns typeless entries for the given service name (typed entries retain their types as received).

Note
Current implementation of this call tries to store the association in the application's registry as a transient setting. Only if that has failed, then it proceeds to store the association in the application environment.
Implicit server type designation is managed the same way as any other service-related parameters from <connect/ncbi_connutil.h>: this one is using the REG_CONN_IMPLICIT_SERVER_TYPE key.
Returns
0 if failed; non-zero if succeeded
See also
ConnNetInfo_GetValue, SERV_GetImplicitServerType

Definition at line 1227 of file ncbi_service.c.

References buf, CONN_IMPLICIT_SERVER_TYPE, CORE_LOCK_WRITE, CORE_REG_SET, CORE_UNLOCK, eREG_Transient, free(), len, putenv, SERV_ServiceName(), SERV_TypeStr(), setenv, strupr, and x_tr().

◆ SERV_SizeOfInfo()

size_t SERV_SizeOfInfo ( const SSERV_Info info)

◆ SERV_TypeStr()

const char* SERV_TypeStr ( ESERV_Type  type)

◆ SERV_WriteInfo()

char* SERV_WriteInfo ( const SSERV_Info info)

◆ SetAppName()

void CUsageReportAPI::SetAppName ( const string name)
static

Set application name for the usage reporters.

If CNcbiApplication is used, all usage reporters automatically use program name specified there, if it is not empty, and this call doesn't have any effect. Otherwise, specified application name will be used by all reporters, created afterwards.

Note
Can be specified thought the global parameter: Registry file: USAGE_REPORT] AppName = ... Environment variable: NCBI_USAGE_REPORT_APPNAME=...
See also
CNcbiApplication::GetProgramDisplayName(), GetAppName

Definition at line 139 of file ncbi_usage_report.cpp.

References NCBI_PARAM_TYPE.

Referenced by CUsageReportSampleApp::ConfigureAPI().

◆ SetAppVersion() [1/2]

void CUsageReportAPI::SetAppVersion ( const CVersionInfo version)
static

Definition at line 149 of file ncbi_usage_report.cpp.

References CUsageReportAPI::SetAppVersion(), and version.

◆ SetAppVersion() [2/2]

void CUsageReportAPI::SetAppVersion ( const string version)
static

Set application version for the usage reporter(s).

If CNcbiApplication is used, all usage reporters automatically use application's version specified there, if it is not empty, and this call doesn't have any effect. Otherwise, specified value will be used by all reporters, created afterwards.

Note
Can be specified thought the global parameter: Registry file: [USAGE_REPORT] AppVersion = ... Environment variable: NCBI_USAGE_REPORT_APPVERSION=...
See also
CNcbiApplicationAPI::GetVersion(), GetAppVersion

Definition at line 144 of file ncbi_usage_report.cpp.

References NCBI_PARAM_TYPE, and version.

Referenced by CUsageReportSampleApp::ConfigureAPI(), and CUsageReportAPI::SetAppVersion().

◆ SetDefaultParameters()

void CUsageReportAPI::SetDefaultParameters ( TWhat  what = fDefault)
static

Set default reporting parameters.

Allow to change default reporting parameters, that will be automatically added to each usage report. Should be used before creating CUsageReport object or any CUsageReport::Instance() usage. Doesn't affect already created reporters.

Parameters
whatNew set of parameters, that should be reported by default by all newly created reporters.
See also
TWhat, CUsageReport, CUsageReportParameters

Definition at line 87 of file ncbi_usage_report.cpp.

References gs_DefaultParams().

Referenced by CUsageReportSampleApp::ConfigureAPI().

◆ SetEnabled() [1/2]

void CUsageReportAPI::SetEnabled ( bool  enable = true)
static

Enable or disable usage statistics reporting globally for all reporters.

This is an only an API method that affects all reporters, even already created. Also, you can enable/disable reporting for each reporter separately, but only if global API is enabled. Global settings have a priority over local status of any reporter.

Note
The usage reporting is disabled by default.
Enabling/disabling reporting can be done using the global parameter: Registry file: [USAGE_REPORT] Enabled = true/false Environment variable: NCBI_USAGE_REPORT_ENABLED=1/0 DO_NOT_TRACK If DO_NOT_TRACK environment variable is set to any value other than 0, FALSE, NO, or OFF (case-insensitive), it disables reporting as well. DO_NOT_TRACK=1 It have priority over NCBI_USAGE_REPORT_ENABLED. See Console Do Not Track standard: https://consoledonottrack.com/.
See also
SetEnabled(), CUsageReport

Definition at line 127 of file ncbi_usage_report.cpp.

References gs_IsEnabled.

Referenced by CUsageReportSampleApp::ConfigureAPI(), and CBlastUsageReport::x_CheckBlastUsageEnv().

◆ SetEnabled() [2/2]

void CUsageReport::SetEnabled ( bool  enable = true)
inline

Enable or disable usage reporter (current instance only).

Note, global API settings have a priority, and if disabled, overrides enable status for the current instance.

See also
CUsageReportAPI::SetEnabled(), IsEnabled()

Definition at line 458 of file ncbi_usage_report.hpp.

References CUsageReport::m_IsEnabled.

Referenced by CBlastUsageReport::x_CheckBlastUsageEnv(), and CUsageReport::x_SendAsync().

◆ SetMaxQueueSize()

void CUsageReportAPI::SetMaxQueueSize ( unsigned  n)
static

Declare the maximum reporting jobs queue size per reporter.

Minimum value is 1. Value 0 sets queue to predefined size. Maximum value is unspecified, but be aware that too big queue size takes more memory and affects reporting accuracy. All requests processes on first-in-first-out base, and if queue is almost full, some newly added reports can become obsolete before the reporter can send it to server.

Affects all reporters created afterwards only. Used by CUsageReport::Send() method.

Note
Can be specified thought the global parameter: Registry file: [USAGE_REPORT] MaxQueueSize = ... Environment variable: NCBI_USAGE_REPORT_MAXQUEUESIZE=...
Parameters
Maximumnumber of reporting jobs in the queue per reporter. 0 - (re)set to default value.
See also
GetMaxQueueSize, CUsageReport::Send()

Definition at line 154 of file ncbi_usage_report.cpp.

References kDefault_MaxQueueSize, n, and NCBI_PARAM_TYPE.

Referenced by CUsageReportSampleApp::ConfigureAPI().

◆ SetURL()

void CUsageReportAPI::SetURL ( const string url)
static

Change CGI URL for reporting usage statistics.

Doesn't affect already created reporters.

Note
Can be specified thought the global parameter: Registry file: [USAGE_REPORT] URL = https://... Environment variable: NCBI_USAGE_REPORT_URL=https://...

Definition at line 134 of file ncbi_usage_report.cpp.

References NCBI_PARAM_TYPE.

Referenced by CUsageReportSampleApp::ConfigureAPI().

◆ ToString()

string CUsageReportParameters::ToString ( void  ) const

Convert parameters to string. URL-encode all values.

Definition at line 230 of file ncbi_usage_report.cpp.

References first(), CUsageReportParameters::m_Params, and result.

Referenced by CUsageReport::CUsageReport(), and CUsageReport::x_ThreadHandler().

◆ Wait()

void CUsageReport::Wait ( void  )

Wait until all queued jobs starts to process and queue is empty.

Can be called before Finish() to be sure that all queued requests are processed and nothing is discarded.

Note
It doesn't wait for already started job that is sending at the current moment. You still need to call Finish().
See also
Finish(), ClearQueue()

Definition at line 511 of file ncbi_usage_report.cpp.

References CUsageReport::m_IsFinishing, CUsageReport::m_Queue, CUsageReport::m_ThreadSignal, CUsageReport::m_ThreadSignal_Mutex, and MT_GUARD.

Referenced by CUsageReportSampleApp::Pattern_2_MultipleReporters(), and CBlastUsageReport::~CBlastUsageReport().

◆ x_ClearQueue()

void CUsageReport::x_ClearQueue ( void  )
private

Remove all unprocessed reporting jobs from queue - internal version.

Definition at line 500 of file ncbi_usage_report.cpp.

References CUsageReportJob::eCanceled, and CUsageReport::m_Queue.

Referenced by CUsageReport::ClearQueue(), CUsageReport::Finish(), and CUsageReport::x_ThreadHandler().

◆ x_CopyFrom() [1/2]

void CUsageReportJob::x_CopyFrom ( const CUsageReportJob other)
protected

Copy data from 'other' job.

Definition at line 266 of file ncbi_usage_report.cpp.

References CUsageReportJob::m_State, and CUsageReportParameters::x_CopyFrom().

Referenced by CUsageReportJob::operator=().

◆ x_CopyFrom() [2/2]

void CUsageReportParameters::x_CopyFrom ( const CUsageReportParameters other)
protected

◆ x_Send()

bool CUsageReport::x_Send ( const string extra_params)
private

Send parameters string synchronously.

Definition at line 404 of file ncbi_usage_report.cpp.

References CHttpSession_Base::Get(), CHttpResponse::GetStatusCode(), CUsageReport::m_DefaultParams, and CUsageReport::m_URL.

Referenced by CUsageReport::x_ThreadHandler().

◆ x_SendAsync()

void CUsageReport::x_SendAsync ( TJobPtr  job_ptr)
private

◆ x_SetState()

void CUsageReportJob::x_SetState ( EState  state)
protected

Set new job state.

CUsageReportJob::

Used by CUsageReport::Send() only. User cannot change state directly.

See also
EState, CUsageReport::Send()

Definition at line 260 of file ncbi_usage_report.cpp.

References CUsageReportJob::m_State, and CUsageReportJob::OnStateChange().

Referenced by CUsageReport::x_SendAsync(), and CUsageReport::x_ThreadHandler().

◆ x_ThreadHandler()

void CUsageReport::x_ThreadHandler ( void  )
private

◆ ~CUsageReport()

CUsageReport::~CUsageReport ( void  )
virtual

Destructor.

Clean up the reporter, call Finish(), all queued and non-sent reporting jobs will be destroyed.

See also
Wait(), Finish()

Definition at line 387 of file ncbi_usage_report.cpp.

References CUsageReport::Finish().

◆ ~CUsageReportJob()

virtual CUsageReportJob::~CUsageReportJob ( void  )
inlinevirtual

Destructor.

Definition at line 332 of file ncbi_usage_report.hpp.

Variable Documentation

◆ _pad

char SSERV_StandaloneInfo::_pad

Definition at line 131 of file ncbi_server_info.h.

◆ addr

TNCBI_IPv6Addr SSERV_Info::addr

Definition at line 173 of file ncbi_server_info.h.

Referenced by SERV_EqualInfo(), and x_UpdateHost().

◆ algo

TSERV_Algo SSERV_Info::algo

Definition at line 172 of file ncbi_server_info.h.

Referenced by CDBLB_ServiceMapper::GetServerOptions(), and s_GetNextInfo().

◆ arch

TNcbiArch SHINFO_Params::arch

Architecture ID, see enum, 0=unknown.

Definition at line 179 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ args [1/2]

TNCBI_Size SSERV_NcbidInfo::args

Definition at line 126 of file ncbi_server_info.h.

◆ args [2/2]

TNCBI_Size SSERV_HttpInfo::args

Definition at line 136 of file ncbi_server_info.h.

◆ bits

TNcbiCapacity SHINFO_Params::bits

Platform bitness, 32/64/32+64/0=unknown.

Definition at line 180 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ bootup

TNCBI_Time SHINFO_Params::bootup

System boot time, time_t-compatible.

Definition at line 188 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ coef

double SSERV_Info::coef

Definition at line 167 of file ncbi_server_info.h.

◆ 

struct { ... } SHINFO_Params::daemon

LBSMD daemon version.

Referenced by LBSM_HINFO_MachineParams().

◆ dns

SSERV_DnsInfo USERV_Info::dns

Definition at line 157 of file ncbi_server_info.h.

Referenced by s_Dns_SizeOf().

◆ extra

unsigned short SSERV_Info::extra

Definition at line 175 of file ncbi_server_info.h.

◆ firewall

SSERV_FirewallInfo USERV_Info::firewall

◆ flag

unsigned int SHEAP_Block::flag

Definition at line 59 of file ncbi_heapmgr.h.

Referenced by LBSMD_GetLocalHostAddress(), and s_HEAP_Free().

◆ host

unsigned int SSERV_Info::host

◆ http

SSERV_HttpInfo USERV_Info::http

Definition at line 155 of file ncbi_server_info.h.

Referenced by s_Http_Equal(), s_Http_SizeOf(), and s_Http_Write().

◆ 

struct { ... } SHINFO_Params::kernel

Kernel/OS version #, if available.

Referenced by LBSM_HINFO_MachineParams().

◆ m_DefaultParams

string CUsageReport::m_DefaultParams
private

Default parameters to report, concatenated and URL-encoded.

Definition at line 578 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::CUsageReport(), and CUsageReport::x_Send().

◆ m_IsEnabled

bool CUsageReport::m_IsEnabled
mutableprivate

Enable/disable status.

Definition at line 574 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::CUsageReport(), CUsageReport::IsEnabled(), and CUsageReport::SetEnabled().

◆ m_IsFinishing

bool CUsageReport::m_IsFinishing
mutableprivate

TRUE if Finish() has called and reporting thread should terminate.

Definition at line 577 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::CUsageReport(), CUsageReport::Finish(), CUsageReport::IsEnabled(), CUsageReport::Wait(), and CUsageReport::x_ThreadHandler().

◆ m_MaxQueueSize

unsigned CUsageReport::m_MaxQueueSize
private

Maximum allowed queue size.

Definition at line 582 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::CUsageReport(), and CUsageReport::x_SendAsync().

◆ m_Params

std::map<string, string> CUsageReportParameters::m_Params
private

◆ m_Queue

list<TJobPtr> CUsageReport::m_Queue
private

◆ m_State

EState CUsageReportJob::m_State
private

◆ m_Thread

std::thread CUsageReport::m_Thread
private

Reporting thread.

Definition at line 580 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::Finish(), and CUsageReport::x_SendAsync().

◆ m_ThreadSignal

std::condition_variable CUsageReport::m_ThreadSignal
private

Signal conditional variable for reporting thread synchronization.

Definition at line 586 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::Finish(), CUsageReport::Wait(), CUsageReport::x_SendAsync(), and CUsageReport::x_ThreadHandler().

◆ m_ThreadSignal_Mutex

std::mutex CUsageReport::m_ThreadSignal_Mutex
private

Definition at line 587 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::Wait(), and CUsageReport::x_ThreadHandler().

◆ m_URL

string CUsageReport::m_URL
private

Reporting URL.

Definition at line 579 of file ncbi_usage_report.hpp.

Referenced by CUsageReport::CUsageReport(), and CUsageReport::x_Send().

◆ m_Usage_Mutex

std::mutex CUsageReport::m_Usage_Mutex
private

MT-protection to access members.

Definition at line 583 of file ncbi_usage_report.hpp.

◆ major [1/3]

unsigned short SHINFO_Params::major

Definition at line 183 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆  [2/3]

unsigned { ... } ::major

Definition at line 183 of file ncbi_host_info.h.

◆  [3/3]

unsigned { ... } ::major

Definition at line 191 of file ncbi_host_info.h.

◆ mime_e

EMIME_Encoding SSERV_Info::mime_e

Definition at line 171 of file ncbi_server_info.h.

◆ mime_s

EMIME_SubType SSERV_Info::mime_s

Definition at line 170 of file ncbi_server_info.h.

◆ mime_t

EMIME_Type SSERV_Info::mime_t

Definition at line 169 of file ncbi_server_info.h.

◆ minor [1/3]

unsigned short SHINFO_Params::minor

Definition at line 184 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆  [2/3]

unsigned { ... } ::minor

Definition at line 184 of file ncbi_host_info.h.

◆  [3/3]

unsigned { ... } ::minor

Definition at line 192 of file ncbi_host_info.h.

◆ mode

TSERV_Mode SSERV_Info::mode

Definition at line 164 of file ncbi_server_info.h.

Referenced by s_GetNextInfo().

◆ name

unsigned char SSERV_DnsInfo::name

Definition at line 146 of file ncbi_server_info.h.

◆ ncbid

SSERV_NcbidInfo USERV_Info::ncbid

Definition at line 153 of file ncbi_server_info.h.

Referenced by s_Ncbid_Equal(), s_Ncbid_SizeOf(), and s_Ncbid_Write().

◆ ostype

TNcbiOSType SHINFO_Params::ostype

OS type ID, see enum, 0=unknown.

Definition at line 181 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ patch [1/3]

unsigned short SHINFO_Params::patch

Definition at line 185 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆  [2/3]

unsigned { ... } ::patch

Definition at line 185 of file ncbi_host_info.h.

◆  [3/3]

unsigned { ... } ::patch

Definition at line 193 of file ncbi_host_info.h.

◆ path

TNCBI_Size SSERV_HttpInfo::path

Definition at line 135 of file ncbi_server_info.h.

◆ pgsize

size_t SHINFO_Params::pgsize

Hardware page size in bytes, if known.

Definition at line 187 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ port [1/2]

unsigned short SHINFO_PortUsage::port

Port number, host byte order.

Definition at line 215 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_PortUsage().

◆ port [2/2]

unsigned short SSERV_Info::port

◆ rate

double SSERV_Info::rate

◆ site

TSERV_Site SSERV_Info::site

Definition at line 165 of file ncbi_server_info.h.

Referenced by s_GetNextInfo().

◆ size

TNCBI_Size SHEAP_Block::size

◆ standalone

SSERV_StandaloneInfo USERV_Info::standalone

Definition at line 154 of file ncbi_server_info.h.

Referenced by s_Standalone_SizeOf().

◆ startup

TNCBI_Time SHINFO_Params::startup

LBSMD start time, time_t-compatible.

Definition at line 189 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ svcpack

unsigned short SHINFO_Params::svcpack

Kernel service pack (Hi=major, Lo=minor)

Definition at line 195 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_MachineParams().

◆ time

TNCBI_Time SSERV_Info::time

◆ type [1/2]

ESERV_Type SSERV_FirewallInfo::type

◆ type [2/2]

ESERV_Type SSERV_Info::type

◆ u

USERV_Info SSERV_Info::u

Definition at line 176 of file ncbi_server_info.h.

Referenced by s_AddSkipInfo(), s_GetNextInfo(), and SERV_EqualInfo().

◆ used

double SHINFO_PortUsage::used

Port usage as percentage, [0..100].

Definition at line 216 of file ncbi_host_info.h.

Referenced by LBSM_HINFO_PortUsage().

◆ vhost

unsigned char SSERV_Info::vhost

Definition at line 174 of file ncbi_server_info.h.

Friends

◆ CUsageReport [1/2]

friend class CUsageReport
friend

Definition at line 290 of file ncbi_usage_report.hpp.

◆ CUsageReport [2/2]

friend class CUsageReport
friend

Definition at line 364 of file ncbi_usage_report.hpp.

◆ CUsageReportAPI

friend class CUsageReportAPI
friend

Definition at line 559 of file ncbi_usage_report.hpp.

Modified on Sun Apr 21 03:40:18 2024 by modify_doxy.py rev. 669887