NCBI C++ ToolKit
pubseq_gateway_stat.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef PUBSEQ_GATEWAY_STAT__HPP
2 #define PUBSEQ_GATEWAY_STAT__HPP
3 
4 /* $Id: pubseq_gateway_stat.hpp 101645 2024-01-18 20:19:14Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Sergey Satskiy
30  *
31  * File Description:
32  *
33  */
34 
35 
38 
39 class IPSGS_Processor;
40 
42 {
43  public:
44  CPSGSCounters(const map<string, size_t> & proc_group_to_index);
46 
47  public:
110 
111  // Request stop statuses
155  ePSGS_xxx, // unknown request stop status
156 
157  // Not pure monotonic counters;
158  // They participate in the output though so the name and identifier will be
159  // required for them too
169 
170  // Used to reserve an array for individual counters
172 
173  // Counters which are per processor
181 
182  // Used to calculate the number of counters per processor
184 
185  };
186 
187  static EPSGS_CounterType StatusToCounterType(int status);
189  {
190  return counter > ePSGS_MaxIndividualCounter;
191  }
192 
193  void Increment(IPSGS_Processor * processor,
194  EPSGS_CounterType counter);
195  void IncrementRequestStopCounter(int status);
197  const map<string, tuple<string, string>> & conf);
198  void Reset(void);
199 
200  public:
201  void PopulateDictionary(CJsonNode & dict);
202  void AppendValueNode(CJsonNode & dict, const string & id,
203  const string & name, const string & description,
204  uint64_t value);
205  void AppendValueNode(CJsonNode & dict, const string & id,
206  const string & name, const string & description,
207  bool value);
208  void AppendValueNode(CJsonNode & dict, const string & id,
209  const string & name, const string & description,
210  const string & value);
211  void AppendValueNode(CJsonNode & dict, EPSGS_CounterType counter_type,
212  uint64_t value);
213  void AppendValueNode(CJsonNode & dict, EPSGS_CounterType counter_type,
214  bool value);
215  void AppendValueNode(CJsonNode & dict, EPSGS_CounterType counter_type,
216  const string & value);
217 
219  {
221  ePSGS_Monotonic, // Monotonically growing counter,
222  // needs to be generically sent to the
223  // client
224  ePSGS_Arbitrary // The value is set from outside at the moment
225  // of sending a reply. Can float arbitrary.
226  // Basically a storage for the identifier,
227  // name, and description
228  };
229 
230  string m_Identifier;
231  string m_Name;
234 
235  atomic_uint_fast64_t m_Value;
236 
237  SCounterInfo(const string & identifier,
238  const string & name,
239  const string & description,
240  EPSGS_CounterType counter_type = ePSGS_Monotonic) :
241  m_Identifier(identifier), m_Name(name),
242  m_Description(description), m_Type(counter_type),
243  m_Value(0)
244  {}
245  };
246 
247  private:
250  vector<vector<SCounterInfo *>> m_PerProcessorCounters;
251 };
252 
253 
254 
255 /*
256 void AppendValueNode(CJsonNode & dict,
257  const string & id,
258  bool value);
259 */
261  const string & id,
262  const string & value);
263 
264 #endif
JSON node abstraction.
void IncrementRequestStopCounter(int status)
static bool IsPerProcessorCounter(EPSGS_CounterType counter)
@ ePSGS_TSEChunkSplitVersionCacheNotMatched
CPSGSCounters(const map< string, size_t > &proc_group_to_index)
void Increment(IPSGS_Processor *processor, EPSGS_CounterType counter)
void AppendValueNode(CJsonNode &dict, const string &id, const string &name, const string &description, uint64_t value)
map< string, size_t > m_ProcGroupToIndex
void UpdateConfiguredNameDescription(const map< string, tuple< string, string >> &conf)
SCounterInfo * m_Counters[ePSGS_MaxIndividualCounter]
vector< vector< SCounterInfo * > > m_PerProcessorCounters
void PopulateDictionary(CJsonNode &dict)
static EPSGS_CounterType StatusToCounterType(int status)
Interface class (and self-factory) for request processor objects that can retrieve data from a given ...
Uint8 uint64_t
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
void AppendValueNode(CJsonNode &dict, const string &id, const string &value)
USING_NCBI_SCOPE
SCounterInfo(const string &identifier, const string &name, const string &description, EPSGS_CounterType counter_type=ePSGS_Monotonic)
Modified on Wed Apr 17 13:10:44 2024 by modify_doxy.py rev. 669887