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

Go to the SVN repository for this file.

1 /* $Id: pubseq_gateway_stat.cpp 101645 2024-01-18 20:19:14Z satskyse $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Sergey Satskiy
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include "pubseq_gateway_stat.hpp"
36 #include "ipsgs_processor.hpp"
37 
39 
40 static const string kValue("value");
41 static const string kName("name");
42 static const string kDescription("description");
43 
44 
45 CPSGSCounters::CPSGSCounters(const map<string, size_t> & proc_group_to_index) :
46  m_ProcGroupToIndex(proc_group_to_index)
47 {
48  // Monotonic counters
50  new SCounterInfo(
51  "BadUrlPathCount", "Unknown URL counter",
52  "Number of times clients requested a path "
53  "which is not served by the server");
55  new SCounterInfo(
56  "NonProtocolRequests", "Bad requests counter",
57  "The number of requests which do not conform to the PSG protocol");
59  new SCounterInfo(
60  "NoProcessorInstantiated", "No processor instantiated counter",
61  "The number of requests when no processors were instantiated");
63  new SCounterInfo(
64  "AcceptFailure", "TCP socket accept failure",
65  "The number of times a TCP accept failed");
67  new SCounterInfo(
68  "FrameworkUnknownError", "Framework unknown error counter",
69  "Number of times a framework unknown error has been detected");
71  new SCounterInfo(
72  "NoRequestStop", "Missed request stop error counter",
73  "Number of times a processor group was erased when there was no request stop for that request");
75  new SCounterInfo(
76  "InsufficientArgumentsCount", "Insufficient arguments counter",
77  "Number of times clients did not supply all the requiried arguments");
79  new SCounterInfo(
80  "MalformedArgumentsCount", "Malformed arguments counter",
81  "Number of times clients supplied malformed arguments");
83  new SCounterInfo(
84  "ClientSatToSatNameErrorCount",
85  "Client provided sat to sat name mapping error counter",
86  "Number of times a client provided sat could not be mapped to a sat name");
88  new SCounterInfo(
89  "ServerSatToSatNameErrorCount",
90  "Server data sat to sat name mapping error counter",
91  "Number of times a server data sat could not be mapped to a sat name");
93  new SCounterInfo(
94  "BlobPropsNotFoundCount", "Blob properties not found counter",
95  "Number of times blob properties were not found");
97  new SCounterInfo(
98  "LMDBErrorCount", "LMDB cache error count",
99  "Number of times an error was detected while searching in the LMDB cache");
101  new SCounterInfo(
102  "CassQueryTimeoutErrorCount", "Cassandra query timeout error counter",
103  "Number of times a timeout error was detected while executing a Cassandra query");
105  new SCounterInfo(
106  "InvalidId2InfoErrorCount", "Invalid bioseq info ID2 field error counter",
107  "Number of times a malformed bioseq info ID2 field was detected");
109  new SCounterInfo(
110  "SplitHistoryNotFoundCount", "Split history not found counter",
111  "Number of times a split history was not found");
113  new SCounterInfo(
114  "PublicCommentNotFoundCount", "Public comment not found counter",
115  "Number of times a public comment was not found");
117  new SCounterInfo(
118  "AccessionVersionHistoryNotFoundCount", "Accession version history not found counter",
119  "Number of times an accession version history was not found");
121  new SCounterInfo(
122  "IPGResolveNotFoundCount", "IPG resolution not found counter",
123  "Number of times an IPG resolution was not found");
125  new SCounterInfo(
126  "MaxHopsExceededErrorCount", "Max hops exceeded error count",
127  "Number of times the max number of hops was exceeded");
129  new SCounterInfo(
130  "TSEChunkSplitVersionCacheMatched",
131  "Requested TSE chunk split version matched the cached one counter",
132  "Number of times a client requested TSE chunk split version "
133  "matched the cached version");
135  new SCounterInfo(
136  "TSEChunkSplitVersionCacheNotMatched",
137  "Requested TSE chunk split version did not match the cached one counter",
138  "Number of times a client requested TSE chunk split version "
139  "did not match the cached version");
141  new SCounterInfo(
142  "AdminRequestCount", "Administrative requests counter",
143  "Number of time a client requested administrative functionality");
145  new SCounterInfo(
146  "ResolveRequestCount", "Resolve requests counter",
147  "Number of times a client requested resolve functionality");
149  new SCounterInfo(
150  "GetBlobBySeqIdRequestCount", "Blob requests (by seq id) counter",
151  "Number of times a client requested a blob by seq id");
153  new SCounterInfo(
154  "GetBlobBySatSatKeyRequestCount", "Blob requests (by sat and sat key) counter",
155  "Number of times a client requested a blob by sat and sat key");
157  new SCounterInfo(
158  "GetNamedAnnotationsCount", "Named annotations requests counter",
159  "Number of times a client requested named annotations");
161  new SCounterInfo(
162  "AccessionVersionHistoryCount", "Accession version history requests counter",
163  "Number of times a client requested accession version history");
165  new SCounterInfo(
166  "IPGResolve", "IPG resolve request counter",
167  "Number of times a client requested IPG resolution");
169  new SCounterInfo(
170  "TestIORequestCount", "Test input/output requests counter",
171  "Number of times a client requested an input/output test");
173  new SCounterInfo(
174  "GetTSEChunkCount", "TSE chunk requests counter",
175  "Number of times a client requested a TSE chunk");
177  new SCounterInfo(
178  "HealthRequestCount", "Health requests counter",
179  "Number of times a client requested health or deep-health status");
181  new SCounterInfo(
182  "Si2csiCacheHit", "si2csi cache hit counter",
183  "Number of times a si2csi LMDB cache lookup found a record");
185  new SCounterInfo(
186  "Si2csiCacheMiss", "si2csi cache miss counter",
187  "Number of times a si2csi LMDB cache lookup did not find a record");
189  new SCounterInfo(
190  "BioseqInfoCacheHit", "bioseq info cache hit counter",
191  "Number of times a bioseq info LMDB cache lookup found a record");
193  new SCounterInfo(
194  "BioseqInfoCacheMiss", "bioseq info cache miss counter",
195  "Number of times a bioseq info LMDB cache lookup did not find a record");
197  new SCounterInfo(
198  "BlobPropCacheHit", "Blob properties cache hit counter",
199  "Number of times a blob properties LMDB cache lookup found a record");
201  new SCounterInfo(
202  "BlobPropCacheMiss", "Blob properties cache miss counter",
203  "Number of times a blob properties LMDB cache lookup did not find a record");
205  new SCounterInfo(
206  "Si2csiNotFound", "si2csi not found in Cassandra counter",
207  "Number of times a Cassandra si2csi query resulted in no records");
209  new SCounterInfo(
210  "Si2csiFoundOne", "si2csi found one record in Cassandra counter",
211  "Number of times a Cassandra si2csi query resulted in exactly one record");
213  new SCounterInfo(
214  "Si2csiFoundMany", "si2csi found more than one record in Cassandra counter",
215  "Number of times a Cassandra si2csi query resulted in more than one record");
217  new SCounterInfo(
218  "BioseqInfoNotFound", "bioseq info not found in Cassandra counter",
219  "Number of times a Cassandra bioseq info query resulted in no records");
221  new SCounterInfo(
222  "BioseqInfoFoundOne", "bioseq info found one record in Cassandra counter",
223  "Number of times a Cassandra bioseq info query resulted in exactly one record");
225  new SCounterInfo(
226  "BioseqInfoFoundMany", "bioseq info found more than one record in Cassandra counter",
227  "Number of times a Cassandra bioseq info query resulted in more than one record");
229  new SCounterInfo(
230  "Si2csiError", "si2csi Cassandra query execution error counter",
231  "Number of time a Cassandra si2csi query resulted in an error");
233  new SCounterInfo(
234  "BioseqInfoError", "bioseq info Cassandra query execution error counter",
235  "Number of times a Cassandra bioseq info query resulted in an error");
237  new SCounterInfo(
238  "BackloggedRequests", "Backlogged requests counter",
239  "Number of times a request has been put into a backlog list");
241  new SCounterInfo(
242  "TooManyRequests", "Too many requests counter",
243  "Number of times a request has been rejected because currently there are too many in serving");
245  new SCounterInfo(
246  "DestroyedProcessorCallbacks", "Destroyed processor callback counter",
247  "Number of times a postponed callback was going to be invoked when a processor has already been destroyed");
249  new SCounterInfo(
250  "NoWebCubbyUserCookieCount", "No web cubby user cookie found counter",
251  "Number of times a web cubby user cookie was not found for a secure keyspace");
253  new SCounterInfo(
254  "FailureToGetCassConnectionCount", "Getting Cassandra connection failure counter",
255  "Number of times there was a failure to get a Cassandra connection (secure or unsecure)");
257  new SCounterInfo(
258  "MyNCBIErrorCount", "My NCBI error counter",
259  "Number of times my NCBI service replied with an error");
261  new SCounterInfo(
262  "MyNCBINotFoundCount", "My NCBI not found counter",
263  "Number of times my NCBI service replied with 'not found'");
265  new SCounterInfo(
266  "SecureSatUnauthorizedCount", "Secure satellite unauthorized counter",
267  "Number of times a secure satellite refused authorization");
269  new SCounterInfo(
270  "MyNCBIOKCacheMissCount", "My NCBI user info OK cache miss counter",
271  "Number of times a lookup in the my NCBI user info OK cache found no record");
273  new SCounterInfo(
274  "MyNCBIOKCacheHitCount", "My NCBI user info OK cache hit counter",
275  "Number of times a lookup in the my NCBI user info OK cache found a record");
277  new SCounterInfo(
278  "MyNCBINotFoundCacheMissCount", "My NCBI not found cache miss counter",
279  "Number of times a lookup in the my NCBI not found cache found no record");
281  new SCounterInfo(
282  "MyNCBINotFoundCacheHitCount", "My NCBI not found cache hit counter",
283  "Number of times a lookup in the my NCBI not found cache found a record");
285  new SCounterInfo(
286  "MyNCBIErrorCacheMissCount", "My NCBI error cache miss counter",
287  "Number of times a lookup in the my NCBI error cache found no record");
289  new SCounterInfo(
290  "MyNCBIErrorCacheHitCount", "My NCBI error cache hit counter",
291  "Number of times a lookup in the my NCBI error cache found a record");
293  new SCounterInfo(
294  "MyNCBIOKCacheWaitHitCount", "My NCBI OK cache hit counter when resolution is in progress",
295  "Number of times a lookup in the my NCBI user info OK cache found a record in an in progress state");
297  new SCounterInfo(
298  "IncludeHUPSetToNo", "Include HUP set to 'no' when a blob in a secure keyspace counter",
299  "Number of times a secure blob was going to be retrieved when include HUP option is explicitly set to 'no'");
301  new SCounterInfo(
302  "RequestStop100", "Request stop counter with status 100",
303  "Number of times a request finished with status 100");
305  new SCounterInfo(
306  "RequestStop101", "Request stop counter with status 101",
307  "Number of times a request finished with status 101");
309  new SCounterInfo(
310  "RequestStop200", "Request stop counter with status 200",
311  "Number of times a request finished with status 200");
313  new SCounterInfo(
314  "RequestStop201", "Request stop counter with status 201",
315  "Number of times a request finished with status 201");
317  new SCounterInfo(
318  "RequestStop202", "Request stop counter with status 202",
319  "Number of times a request finished with status 202");
321  new SCounterInfo(
322  "RequestStop203", "Request stop counter with status 203",
323  "Number of times a request finished with status 203");
325  new SCounterInfo(
326  "RequestStop204", "Request stop counter with status 204",
327  "Number of times a request finished with status 204");
329  new SCounterInfo(
330  "RequestStop205", "Request stop counter with status 205",
331  "Number of times a request finished with status 205");
333  new SCounterInfo(
334  "RequestStop206", "Request stop counter with status 206",
335  "Number of times a request finished with status 206");
337  new SCounterInfo(
338  "RequestStop299", "Request stop counter with status 299",
339  "Number of times a request finished with status 299");
341  new SCounterInfo(
342  "RequestStop300", "Request stop counter with status 300",
343  "Number of times a request finished with status 300");
345  new SCounterInfo(
346  "RequestStop301", "Request stop counter with status 301",
347  "Number of times a request finished with status 301");
349  new SCounterInfo(
350  "RequestStop302", "Request stop counter with status 302",
351  "Number of times a request finished with status 302");
353  new SCounterInfo(
354  "RequestStop303", "Request stop counter with status 303",
355  "Number of times a request finished with status 303");
357  new SCounterInfo(
358  "RequestStop304", "Request stop counter with status 304",
359  "Number of times a request finished with status 304");
361  new SCounterInfo(
362  "RequestStop305", "Request stop counter with status 305",
363  "Number of times a request finished with status 305");
365  new SCounterInfo(
366  "RequestStop307", "Request stop counter with status 307",
367  "Number of times a request finished with status 307");
369  new SCounterInfo(
370  "RequestStop400", "Request stop counter with status 400",
371  "Number of times a request finished with status 400");
373  new SCounterInfo(
374  "RequestStop401", "Request stop counter with status 401",
375  "Number of times a request finished with status 401");
377  new SCounterInfo(
378  "RequestStop402", "Request stop counter with status 402",
379  "Number of times a request finished with status 402");
381  new SCounterInfo(
382  "RequestStop403", "Request stop counter with status 403",
383  "Number of times a request finished with status 403");
385  new SCounterInfo(
386  "RequestStop404", "Request stop counter with status 404",
387  "Number of times a request finished with status 404");
389  new SCounterInfo(
390  "RequestStop405", "Request stop counter with status 405",
391  "Number of times a request finished with status 405");
393  new SCounterInfo(
394  "RequestStop406", "Request stop counter with status 406",
395  "Number of times a request finished with status 406");
397  new SCounterInfo(
398  "RequestStop407", "Request stop counter with status 407",
399  "Number of times a request finished with status 407");
401  new SCounterInfo(
402  "RequestStop408", "Request stop counter with status 408",
403  "Number of times a request finished with status 408");
405  new SCounterInfo(
406  "RequestStop409", "Request stop counter with status 409",
407  "Number of times a request finished with status 409");
409  new SCounterInfo(
410  "RequestStop410", "Request stop counter with status 410",
411  "Number of times a request finished with status 410");
413  new SCounterInfo(
414  "RequestStop411", "Request stop counter with status 411",
415  "Number of times a request finished with status 411");
417  new SCounterInfo(
418  "RequestStop412", "Request stop counter with status 412",
419  "Number of times a request finished with status 412");
421  new SCounterInfo(
422  "RequestStop413", "Request stop counter with status 413",
423  "Number of times a request finished with status 413");
425  new SCounterInfo(
426  "RequestStop414", "Request stop counter with status 414",
427  "Number of times a request finished with status 414");
429  new SCounterInfo(
430  "RequestStop415", "Request stop counter with status 415",
431  "Number of times a request finished with status 415");
433  new SCounterInfo(
434  "RequestStop416", "Request stop counter with status 416",
435  "Number of times a request finished with status 416");
437  new SCounterInfo(
438  "RequestStop417", "Request stop counter with status 417",
439  "Number of times a request finished with status 417");
441  new SCounterInfo(
442  "RequestStop422", "Request stop counter with status 422",
443  "Number of times a request finished with status 422");
445  new SCounterInfo(
446  "RequestStop499", "Request stop counter with status 499",
447  "Number of times a request finished with status 499");
449  new SCounterInfo(
450  "RequestStop500", "Request stop counter with status 500",
451  "Number of times a request finished with status 500");
453  new SCounterInfo(
454  "RequestStop501", "Request stop counter with status 501",
455  "Number of times a request finished with status 501");
457  new SCounterInfo(
458  "RequestStop502", "Request stop counter with status 502",
459  "Number of times a request finished with status 502");
461  new SCounterInfo(
462  "RequestStop503", "Request stop counter with status 503",
463  "Number of times a request finished with status 503");
465  new SCounterInfo(
466  "RequestStop504", "Request stop counter with status 504",
467  "Number of times a request finished with status 504");
469  new SCounterInfo(
470  "RequestStop505", "Request stop counter with status 505",
471  "Number of times a request finished with status 505");
473  new SCounterInfo(
474  "RequestStopXXX", "Request stop counter with unknown status",
475  "Number of times a request finished with unknown status");
476 
477  // The counters below are for the sake of an identifier, name and
478  // description. The name and description can be overwritten by the
479  // configuration values
480 
482  new SCounterInfo(
483  "CassandraActiveStatementsCount", "Cassandra active statements counter",
484  "Number of the currently active Cassandra queries",
487  new SCounterInfo(
488  "NumberOfTCPConnections", "Client TCP connections counter",
489  "Number of the client TCP connections",
492  new SCounterInfo(
493  "ActiveProcessorGroupCount", "Active processor groups counter",
494  "Number of processor groups currently active in the dispatcher",
497  new SCounterInfo(
498  "SplitInfoCacheSize", "Split info cache size",
499  "Number of records in the split info cache",
502  new SCounterInfo(
503  "MyNCBIOKCacheSize", "My NCBI user info OK cache size",
504  "Number of records in the my NCBI user info OK cache",
507  new SCounterInfo(
508  "MyNCBINotFoundCacheSize", "My NCBI not found cache size",
509  "Number of records in the my NCBI not found cache",
512  new SCounterInfo(
513  "MyNCBIErrorCacheSize", "My NCBI error cache size",
514  "Number of records in the my NCBI error cache",
517  new SCounterInfo(
518  "ShutdownRequested", "Shutdown requested flag",
519  "Shutdown requested flag",
522  new SCounterInfo(
523  "GracefulShutdownExpiredInSec", "Graceful shutdown expiration",
524  "Graceful shutdown expiration in seconds from now",
526 
527 
528  // Counters below must be per processor
529  size_t counter = static_cast<size_t>(ePSGS_LastCounter) - 1;
530  while (counter > static_cast<size_t>(ePSGS_MaxIndividualCounter)) {
531  m_PerProcessorCounters.push_back(vector<SCounterInfo *>());
532  --counter;
533  }
534 
535  string proc_group_names[m_ProcGroupToIndex.size()];
536  for (const auto & item : m_ProcGroupToIndex) {
537  proc_group_names[item.second] = item.first;
538  }
539 
540  size_t index;
541  for (const auto & proc_group : proc_group_names) {
542  index = static_cast<size_t>(ePSGS_InputSeqIdNotResolved) -
543  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
544 
545  m_PerProcessorCounters[index].push_back(
546  new SCounterInfo(
547  proc_group + "_InputSeqIdNotResolved",
548  "Seq id not resolved counter (" + proc_group + ")",
549  "Number of times a client provided seq id could not be resolved by " + proc_group));
550 
551 
552  index = static_cast<size_t>(ePSGS_AnnotationBlobNotFound) -
553  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
554 
555  m_PerProcessorCounters[index].push_back(
556  new SCounterInfo(
557  proc_group + "_AnnotationBlobNotFoundCount",
558  "Annotation blob not found counter (" + proc_group + ")",
559  "Number of times an annotation blob was not found by " + proc_group));
560 
561 
562  index = static_cast<size_t>(ePSGS_AnnotationNotFound) -
563  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
564 
565  m_PerProcessorCounters[index].push_back(
566  new SCounterInfo(
567  proc_group + "_AnnotationNotFoundCount",
568  "Annotation not found counter (" + proc_group + ")",
569  "Number of times an annotation was not found by " + proc_group));
570 
571 
572  index = static_cast<size_t>(ePSGS_GetBlobNotFound) -
573  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
574 
575  m_PerProcessorCounters[index].push_back(
576  new SCounterInfo(
577  proc_group + "_GetBlobNotFoundCount",
578  "Blob not found counter (" + proc_group + ")",
579  "Number of times clients requested a blob which was not found by " + proc_group));
580 
581 
582  index = static_cast<size_t>(ePSGS_TSEChunkNotFound) -
583  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
584 
585  m_PerProcessorCounters[index].push_back(
586  new SCounterInfo(
587  proc_group + "_TSEChunkNotFoundCount",
588  "TSE chunk not found counter (" + proc_group + ")",
589  "Number of times a TSE chunk was not found by " + proc_group));
590 
591 
592  index = static_cast<size_t>(ePSGS_ProcUnknownError) -
593  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
594 
595  m_PerProcessorCounters[index].push_back(
596  new SCounterInfo(
597  proc_group + "_ProcUnknownErrorCount",
598  "Processor unknown error counter (" + proc_group + ")",
599  "Number of times an unknown error has been detected by " + proc_group));
600 
601 
602  index = static_cast<size_t>(ePSGS_OpTooLong) -
603  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
604 
605  m_PerProcessorCounters[index].push_back(
606  new SCounterInfo(
607  proc_group + "_OperationTooLong",
608  "Operation took too long (" + proc_group + ")",
609  "The number of times an operation (like a backend retrieval) "
610  "took longer than a configurable time by " + proc_group));
611  }
612 }
613 
614 
616 {
617  for (size_t k=0; k < ePSGS_MaxIndividualCounter; ++k) {
618  delete m_Counters[k];
619  }
620 
621  for (size_t k=0; k < m_PerProcessorCounters.size(); ++k) {
622  for (size_t m=0; m < m_PerProcessorCounters[k].size(); ++m) {
623  delete m_PerProcessorCounters[k][m];
624  }
625  }
626 }
627 
628 
630  EPSGS_CounterType counter)
631 {
632  if (counter >= ePSGS_LastCounter) {
633  PSG_ERROR("Invalid counter id " + to_string(counter) +
634  ". Ignore and continue.");
635  return;
636  }
637 
638  if (IsPerProcessorCounter(counter)) {
639  if (processor == nullptr) {
640  PSG_ERROR("Invalid nullptr processor for the per processor counter id " +
641  to_string(counter) + ". Ignore and continue.");
642  return;
643  }
644 
645  size_t cnt_index = static_cast<size_t>(counter) -
646  static_cast<size_t>(ePSGS_MaxIndividualCounter) - 1;
647  size_t proc_index = m_ProcGroupToIndex[processor->GetGroupName()];
648 
649  ++(m_PerProcessorCounters[cnt_index][proc_index]->m_Value);
650  return;
651  }
652 
653  if (counter >= ePSGS_MaxIndividualCounter) {
654  PSG_ERROR("Invalid counter id " + to_string(counter) +
655  " (non per-processor). Ignore and continue.");
656  return;
657  }
658 
659  ++(m_Counters[counter]->m_Value);
660 }
661 
662 
665 {
666  switch (status) {
667  case 100: return ePSGS_100;
668  case 101: return ePSGS_101;
669  case 200: return ePSGS_200;
670  case 201: return ePSGS_201;
671  case 202: return ePSGS_202;
672  case 203: return ePSGS_203;
673  case 204: return ePSGS_204;
674  case 205: return ePSGS_205;
675  case 206: return ePSGS_206;
676  case 299: return ePSGS_299;
677  case 300: return ePSGS_300;
678  case 301: return ePSGS_301;
679  case 302: return ePSGS_302;
680  case 303: return ePSGS_303;
681  case 304: return ePSGS_304;
682  case 305: return ePSGS_305;
683  case 307: return ePSGS_307;
684  case 400: return ePSGS_400;
685  case 401: return ePSGS_401;
686  case 402: return ePSGS_402;
687  case 403: return ePSGS_403;
688  case 404: return ePSGS_404;
689  case 405: return ePSGS_405;
690  case 406: return ePSGS_406;
691  case 407: return ePSGS_407;
692  case 408: return ePSGS_408;
693  case 409: return ePSGS_409;
694  case 410: return ePSGS_410;
695  case 411: return ePSGS_411;
696  case 412: return ePSGS_412;
697  case 413: return ePSGS_413;
698  case 414: return ePSGS_414;
699  case 415: return ePSGS_415;
700  case 416: return ePSGS_416;
701  case 417: return ePSGS_417;
702  case 422: return ePSGS_422;
703  case 499: return ePSGS_499;
704  case 500: return ePSGS_500;
705  case 501: return ePSGS_501;
706  case 502: return ePSGS_502;
707  case 503: return ePSGS_503;
708  case 504: return ePSGS_504;
709  case 505: return ePSGS_505;
710  }
711  return ePSGS_xxx;
712 }
713 
714 
716 {
717  Increment(nullptr, StatusToCounterType(status));
718 }
719 
720 
722  const map<string, tuple<string, string>> & conf)
723 {
724  for (auto const & conf_item : conf) {
725  for (size_t k=0; k < ePSGS_MaxIndividualCounter; ++k) {
726  if (m_Counters[k]->m_Identifier == conf_item.first) {
727  m_Counters[k]->m_Name = get<0>(conf_item.second);
728  m_Counters[k]->m_Description = get<1>(conf_item.second);
729  break;
730  }
731  }
732 
733  for (size_t k=0; k < m_PerProcessorCounters.size(); ++k) {
734  for (size_t m=0; m < m_PerProcessorCounters[k].size(); ++m) {
735  if (m_PerProcessorCounters[k][m]->m_Identifier == conf_item.first) {
736  m_PerProcessorCounters[k][m]->m_Name = get<0>(conf_item.second);
737  m_PerProcessorCounters[k][m]->m_Description = get<1>(conf_item.second);
738  break;
739  }
740  }
741  }
742  }
743 }
744 
745 
747 {
748  uint64_t value(0);
749 
750  for (size_t k=0; k < ePSGS_MaxIndividualCounter; ++k) {
751  if (m_Counters[k]->m_Type == SCounterInfo::ePSGS_Monotonic) {
752  value = m_Counters[k]->m_Value;
753  AppendValueNode(dict, m_Counters[k]->m_Identifier,
754  m_Counters[k]->m_Name, m_Counters[k]->m_Description,
755  value);
756  }
757  }
758 
759  for (size_t k=0; k < m_PerProcessorCounters.size(); ++k) {
760  for (size_t m=0; m < m_PerProcessorCounters[k].size(); ++m) {
761  value = m_PerProcessorCounters[k][m]->m_Value;
762  AppendValueNode(dict, m_PerProcessorCounters[k][m]->m_Identifier,
763  m_PerProcessorCounters[k][m]->m_Name,
764  m_PerProcessorCounters[k][m]->m_Description,
765  value);
766  }
767  }
768 }
769 
770 
772 {
773  for (size_t k=0; k < ePSGS_MaxIndividualCounter; ++k) {
774  if (m_Counters[k]->m_Type == SCounterInfo::ePSGS_Monotonic) {
775  m_Counters[k]->m_Value = 0;
776  }
777  }
778 
779  for (size_t k=0; k < m_PerProcessorCounters.size(); ++k) {
780  for (size_t m=0; m < m_PerProcessorCounters[k].size(); ++m) {
781  m_PerProcessorCounters[k][m]->m_Value = 0;
782  }
783  }
784 }
785 
786 
787 void CPSGSCounters::AppendValueNode(CJsonNode & dict, const string & id,
788  const string & name, const string & description,
789  uint64_t value)
790 {
791  CJsonNode value_dict(CJsonNode::NewObjectNode());
792 
793  value_dict.SetInteger(kValue, value);
794  value_dict.SetString(kName, name);
795  value_dict.SetString(kDescription, description);
796  dict.SetByKey(id, value_dict);
797 }
798 
799 
800 void CPSGSCounters::AppendValueNode(CJsonNode & dict, const string & id,
801  const string & name, const string & description,
802  bool value)
803 {
804  CJsonNode value_dict(CJsonNode::NewObjectNode());
805 
806  value_dict.SetBoolean(kValue, value);
807  value_dict.SetString(kName, name);
808  value_dict.SetString(kDescription, description);
809  dict.SetByKey(id, value_dict);
810 
811 }
812 
813 
814 void CPSGSCounters::AppendValueNode(CJsonNode & dict, const string & id,
815  const string & name, const string & description,
816  const string & value)
817 {
818  CJsonNode value_dict(CJsonNode::NewObjectNode());
819 
820  value_dict.SetString(kValue, value);
821  value_dict.SetString(kName, name);
822  value_dict.SetString(kDescription, description);
823  dict.SetByKey(id, value_dict);
824 
825 }
826 
827 
829  EPSGS_CounterType counter_type,
830  uint64_t value)
831 {
832  AppendValueNode(dict,
833  m_Counters[counter_type]->m_Identifier,
834  m_Counters[counter_type]->m_Name,
835  m_Counters[counter_type]->m_Description,
836  value);
837 }
838 
839 
841  EPSGS_CounterType counter_type,
842  bool value)
843 {
844  AppendValueNode(dict,
845  m_Counters[counter_type]->m_Identifier,
846  m_Counters[counter_type]->m_Name,
847  m_Counters[counter_type]->m_Description,
848  value);
849 }
850 
851 
853  EPSGS_CounterType counter_type,
854  const string & value)
855 {
856  AppendValueNode(dict,
857  m_Counters[counter_type]->m_Identifier,
858  m_Counters[counter_type]->m_Name,
859  m_Counters[counter_type]->m_Description,
860  value);
861 }
862 
JSON node abstraction.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
void SetBoolean(const string &key, bool value)
Set a JSON object element to the specified boolean value.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
static CJsonNode NewObjectNode()
Create a new JSON object node.
void 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 ...
virtual string GetGroupName(void) const =0
Tells the processor group name.
size_type size() const
Definition: map.hpp:148
Uint8 uint64_t
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1227
#define PSG_ERROR(message)
static const string kName("name")
static const string kDescription("description")
USING_NCBI_SCOPE
static const string kValue("value")
Modified on Wed May 15 15:09:29 2024 by modify_doxy.py rev. 669887