1 #ifndef NETCACHE__SRV_STAT__HPP
2 #define NETCACHE__SRV_STAT__HPP
57 #if !NCBI_INT8_IS_LONG
65 operator const string& (void)
const;
172 template <
class Map,
class Key>
176 typename Map::iterator it_time =
map.
find(
key);
178 return it_time->second;
261 return total == 0? 0:
val * 100 / total;
293 template<
typename T>
inline string
326 if (
value > 0xFFFFFFFF) {
330 if (
value > 0xFFFF) {
412 #if !NCBI_INT8_IS_LONG
445 CSrvStrStream::operator
const string& (void)
const
468 : m_PrintMode(ePrintSocket),
469 m_LineStarted(
false),
475 : m_PrintMode(ePrintLog),
476 m_LineStarted(
false),
541 m_ValuesSum +=
value;
543 m_ValuesMax =
max(m_ValuesMax,
value);
559 return m_ValuesCount;
580 return m_ValuesCount == 0? 0:
T(m_ValuesSum / m_ValuesCount);
587 return m_ValuesCount == 0? 0: double(m_ValuesSum) / m_ValuesCount;
Mutex created to have minimum possible size (its size is 4 bytes) and to sleep using kernel capabilit...
Class used in all diagnostic logging.
const CSrvDiagMsg & StartInfo(void) const
Starts informational message which doesn't need to have filename, line number or function name.
void Flush(void)
Finishes current message and prepare to start new one.
Stream-like class to help unify printing some text messages to diagnostics and to any socket.
CSrvPrintProxy(const CSrvPrintProxy &)
CSrvSocketTask * m_Socket
CSrvPrintProxy & operator<<(T x)
Universal streaming operator.
EPrintOutput m_PrintMode
Type of media to print to.
CSrvPrintProxy & operator=(const CSrvPrintProxy &)
CNcbiOstream &(* TEndlType)(CNcbiOstream &)
CSrvPrintProxy(CSrvSocketTask *sock)
CRequestContext * m_DiagCtx
EPrintOutput
Type of media to print to.
@ ePrintSocket
Print to socket.
@ ePrintLog
Print to diagnostics.
CSrvStrStream m_StrStream
Task controlling a socket.
CSrvSocketTask & WriteText(CTempString message)
Write text into socket.
Class representing one statistical value.
T GetAverage(void) const
Get average of all values in the set.
Uint8 GetCount(void) const
Get number of values in the set.
Uint8 m_ValuesCount
Number of all values collected.
void Initialize(void)
Initialize all data members.
Uint8 GetSum(void) const
Get sum of all values in the set.
T m_ValuesMax
Maximum value among collected.
void AddValue(T value)
Add next value into the set.
Uint8 m_ValuesSum
Sum of all values collected.
void AddValues(const CSrvStatTerm< T > &other)
Add all values from another set.
T GetMaximum(void) const
Get maximum value in the set.
CSrvStatTerm(void)
Empty constructor, all initialization should be made in Initialize() because in memory manager static...
double GetDoubleAvg(void) const
TStatusOpenTimes m_SocksByStatus
CSrvStat & operator=(const CSrvStat &)
SSrvStateStat m_StartState
void CopyStartState(CSrvStat *src_stat)
void PrintState(CSrvSocketTask &sock)
void TransferEndState(CSrvStat *src_stat)
void SetMMStat(SMMStat *stat)
CSrvStat(const CSrvStat &)
void PrintToLogs(CRequestContext *ctx, CSrvPrintProxy &proxy)
void AddAllStats(CSrvStat *src_stat)
CSrvStatTerm< Uint4 > m_CntSockets
CSrvStatTerm< Uint4 > m_CntThreads
void SockOpenActive(void)
void SockClose(int status, Uint8 open_time)
void InitStartState(void)
CSrvStatTerm< Uint8 > m_DoneTasks
TSrvTimeTerm m_SockOpenTime
void SockOpenPassive(void)
void x_PrintUnstructured(CSrvPrintProxy &proxy)
void x_AddStats(CSrvStat *src_stat)
map< int, TSrvTimeTerm > TStatusOpenTimes
void SchedJiffyStat(Uint8 jiffy_len, Uint8 max_slice, Uint8 exec_time, Uint8 done_tasks, Uint8 wait_time)
void CopyEndState(CSrvStat *src_stat)
void PrintToSocket(CSrvPrintProxy &proxy)
unique_ptr< SMMStat > m_MMStat
void CollectThreads(bool need_clear)
void SaveEndStateStat(void)
Stream-like class to accumulate all in one string without actual streams-related overhead.
CSrvStrStream & operator<<(const string &str)
Streaming operator for all supported data types.
string m_Data
Accumulated data.
void Clear(void)
Clear the accumulated value and start from the beginning.
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
const_iterator end() const
const_iterator find(const key_type &key) const
static const char * str(char *buf, int n)
CRange< Position > Map(const CRange< Position > &target, const CRange< Position > &range)
uint32_t Uint4
4-byte (32-bit) unsigned integer
int64_t Int8
8-byte (64-bit) signed integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static string UInt8ToString_DataSize(Uint8 value, TNumToStringFlags flags=0, unsigned int max_digits=3)
Convert UInt8 to string using "software" qualifiers.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
@ fDS_PutBSuffixToo
UInt8ToString_DataSize(): Use "B" suffix for small bytes values.
@ fWithCommas
Use commas as thousands separator.
@ fDS_PutSpaceBeforeSuffix
UInt8ToString_DataSize(): Add space between value and qualifiers, like "10.0 KB".
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
const GenericPointer< typename T::ValueType > T2 value
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
CSrvStatTerm< Uint8 > TSrvTimeTerm
Uint8 g_CalcStatPct(Uint8 val, Uint8 total)
std::enable_if< std::is_unsigned< T >::value, string >::type g_ToSizeStr(T size)
string g_ToSmartStr(T num)
double g_AsMSecStat(Uint8 time_usec)
CNcbiOstream & operator<<(CNcbiOstream &stream, const CSrvStrStream &str)
unsigned int g_GetLogBase2(Uint8 value)
Get integer part of the logarithm with base 2.
TSrvTimeTerm & g_SrvTimeTerm(Map &map, Key key)