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

Go to the SVN repository for this file.

1 /* $Id: settings.cpp 101614 2024-01-12 16:31:21Z 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 #include <ncbi_pch.hpp>
32 
33 #include <corelib/ncbi_config.hpp>
35 
36 #include "settings.hpp"
39 #include "alerts.hpp"
40 #include "timing.hpp"
41 
42 
43 const string kServerSection = "SERVER";
44 const string kLmdbCacheSection = "LMDB_CACHE";
45 const string kStatisticsSection = "STATISTICS";
46 const string kAutoExcludeSection = "AUTO_EXCLUDE";
47 const string kDebugSection = "DEBUG";
48 const string kIPGSection = "IPG";
49 const string kSSLSection = "SSL";
50 const string kHealthSection = "HEALTH";
51 const string kOSGProcessorSection = "OSG_PROCESSOR";
52 const string kCDDProcessorSection = "CDD_PROCESSOR";
53 const string kWGSProcessorSection = "WGS_PROCESSOR";
54 const string kSNPProcessorSection = "SNP_PROCESSOR";
55 const string kCassandraProcessorSection = "CASSANDRA_PROCESSOR";
56 const string kAdminSection = "ADMIN";
57 const string kMyNCBISection = "MY_NCBI";
58 const string kCountersSection = "COUNTERS";
59 
60 
61 const unsigned short kWorkersDefault = 64;
62 const unsigned int kListenerBacklogDefault = 256;
63 const unsigned short kTcpMaxConnDefault = 4096;
64 const unsigned int kTimeoutDefault = 30000;
65 const unsigned int kMaxRetriesDefault = 2;
66 const string kDefaultRootKeyspace = "sat_info3";
67 const string kDefaultConfigurationDomain = "PSG";
68 const size_t kDefaultHttpMaxBacklog = 1024;
69 const size_t kDefaultHttpMaxRunning = 64;
70 const size_t kDefaultLogSamplingRatio = 0;
71 const size_t kDefaultLogTimingThreshold = 1000;
72 const unsigned long kDefaultSendBlobIfSmall = 10 * 1024;
73 const unsigned long kDefaultSmallBlobSize = 16;
74 const bool kDefaultLog = true;
75 const unsigned int kDefaultExcludeCacheMaxSize = 1000;
76 const unsigned int kDefaultExcludeCachePurgePercentage = 20;
77 const unsigned int kDefaultExcludeCacheInactivityPurge = 60;
78 const unsigned int kDefaultMaxHops = 2;
79 const bool kDefaultAllowIOTest = false;
80 const bool kDefaultAllowProcessorTiming = false;
81 const string kDefaultOnlyForProcessor = "";
82 const double kDefaultResendTimeoutSec = 0.2;
83 const double kDefaultRequestTimeoutSec = 30.0;
84 const size_t kDefaultProcessorMaxConcurrency = 1200;
85 const size_t kDefaultSplitInfoBlobCacheSize = 1000;
86 const size_t kDefaultIPGPageSize = 1024;
87 const bool kDefaultEnableHugeIPG = true;
88 const string kDefaultAuthToken = "";
89 // All ADMIN/ urls except of 'info'
90 const string kDefaultAuthCommands = "config status shutdown get_alerts ack_alert statistics";
91 const bool kDefaultSSLEnable = false;
92 const string kDefaultSSLCertFile = "";
93 const string kDefaultSSLKeyFile = "";
94 const string kDefaultSSLCiphers = "EECDH+aRSA+AESGCM EDH+aRSA+AESGCM EECDH+aRSA EDH+aRSA !SHA !SHA256 !SHA384";
97 const string kDefaultTestSeqId = "gi|2";
98 const bool kDefaultTestSeqIdIgnoreError = true;
100 const bool kDefaultOSGProcessorsEnabled = false;
104 const size_t kDefaultMyNCBIOKCacheSize = 10000;
105 const size_t kDefaultMyNCBINotFoundCacheSize = 10000;
107 const size_t kDefaultMyNCBIErrorCacheSize = 10000;
109 const string kDefaultMyNCBIURL = "http://txproxy.linkerd.ncbi.nlm.nih.gov/v1/service/MyNCBIAccount?txsvc=MyNCBIAccount";
110 const string kDefaultMyNCBIHttpProxy = "linkerd:4140";
111 const size_t kDefaultMyNCBITimeoutMs = 100;
113 
114 
115 
117  m_HttpPort(0),
118  m_HttpWorkers(kWorkersDefault),
119  m_ListenerBacklog(kListenerBacklogDefault),
120  m_TcpMaxConn(kTcpMaxConnDefault),
121  m_TimeoutMs(kTimeoutDefault),
122  m_MaxRetries(kMaxRetriesDefault),
123  m_SendBlobIfSmall(kDefaultSendBlobIfSmall),
124  m_Log(kDefaultLog),
125  m_MaxHops(kDefaultMaxHops),
126  m_ResendTimeoutSec(kDefaultResendTimeoutSec),
127  m_RequestTimeoutSec(kDefaultRequestTimeoutSec),
128  m_ProcessorMaxConcurrency(kDefaultProcessorMaxConcurrency),
129  m_SplitInfoBlobCacheSize(kDefaultSplitInfoBlobCacheSize),
130  m_ShutdownIfTooManyOpenFD(0),
131  m_RootKeyspace(kDefaultRootKeyspace),
132  m_ConfigurationDomain(kDefaultConfigurationDomain),
133  m_HttpMaxBacklog(kDefaultHttpMaxBacklog),
134  m_HttpMaxRunning(kDefaultHttpMaxRunning),
135  m_LogSamplingRatio(kDefaultLogSamplingRatio),
136  m_LogTimingThreshold(kDefaultLogTimingThreshold),
137  m_SmallBlobSize(kDefaultSmallBlobSize),
138  m_MinStatValue(kMinStatValue),
139  m_MaxStatValue(kMaxStatValue),
140  m_NStatBins(kNStatBins),
141  m_StatScaleType(kStatScaleType),
142  m_TickSpan(kTickSpan),
143  m_OnlyForProcessor(kDefaultOnlyForProcessor),
144  m_ExcludeCacheMaxSize(kDefaultExcludeCacheMaxSize),
145  m_ExcludeCachePurgePercentage(kDefaultExcludeCachePurgePercentage),
146  m_ExcludeCacheInactivityPurge(kDefaultExcludeCacheInactivityPurge),
147  m_AllowIOTest(kDefaultAllowIOTest),
148  m_AllowProcessorTiming(kDefaultAllowProcessorTiming),
149  m_SSLEnable(kDefaultSSLEnable),
150  m_SSLCiphers(kDefaultSSLCiphers),
151  m_TestSeqId(kDefaultTestSeqId),
152  m_TestSeqIdIgnoreError(kDefaultTestSeqIdIgnoreError),
153  m_CassandraProcessorsEnabled(kDefaultCassandraProcessorsEnabled),
154  m_OSGProcessorsEnabled(kDefaultOSGProcessorsEnabled),
155  m_CDDProcessorsEnabled(kDefaultCDDProcessorsEnabled),
156  m_WGSProcessorsEnabled(kDefaultWGSProcessorsEnabled),
157  m_SNPProcessorsEnabled(kDefaultSNPProcessorsEnabled),
158  m_MyNCBIOKCacheSize(kDefaultMyNCBIOKCacheSize),
159  m_MyNCBINotFoundCacheSize(kDefaultMyNCBINotFoundCacheSize),
160  m_MyNCBINotFoundCacheExpirationSec(kDefaultMyNCBINotFoundCacheExpirationSec),
161  m_MyNCBIErrorCacheSize(kDefaultMyNCBIErrorCacheSize),
162  m_MyNCBIErrorCacheBackOffMs(kDefaultMyNCBIErrorCacheBackOffMs),
163  m_MyNCBIURL(kDefaultMyNCBIURL),
164  m_MyNCBIHttpProxy(kDefaultMyNCBIHttpProxy),
165  m_MyNCBITimeoutMs(kDefaultMyNCBITimeoutMs),
166  m_MyNCBIResolveTimeoutMs(kDefaultMyNCBIResolveTimeoutMs)
167 {}
168 
169 
171 {}
172 
173 
175  CPSGAlerts & alerts)
176 {
177  // Note: reading of some values in the [SERVER] depends if SSL is on/off
178  // So, reading of the SSL settings is done first
180 
188  x_ReadAdminSection(registry, alerts);
196 }
197 
198 
200 {
201 
202  if (!registry.HasEntry(kServerSection, "port"))
203  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
204  "[" + kServerSection +
205  "]/port value is not found in the configuration "
206  "file. The port must be provided to run the server. "
207  "Exiting.");
208 
216  m_TimeoutMs = registry.GetInt(kServerSection, "optimeout",
218  m_MaxRetries = registry.GetInt(kServerSection, "maxretries",
220  m_RootKeyspace = registry.GetString(kServerSection, "root_keyspace",
222  m_ConfigurationDomain = registry.GetString(kServerSection, "configuration_domain",
224  m_HttpMaxBacklog = registry.GetInt(kServerSection, "http_max_backlog",
226  m_HttpMaxRunning = registry.GetInt(kServerSection, "http_max_running",
228  m_LogSamplingRatio = registry.GetInt(kServerSection, "log_sampling_ratio",
230  m_LogTimingThreshold = registry.GetInt(kServerSection, "log_timing_threshold",
233  "send_blob_if_small",
242  "ProcessorMaxConcurrency",
245  "split_info_blob_cache_size",
247 
248  if (m_SSLEnable) {
250  registry.GetInt(kServerSection, "ShutdownIfTooManyOpenFD",
252  } else {
254  registry.GetInt(kServerSection, "ShutdownIfTooManyOpenFD",
256  }
257 }
258 
259 
261 {
263  "small_blob_size", kDefaultSmallBlobSize);
265  "min", kMinStatValue);
267  "max", kMaxStatValue);
269  "n_bins", kNStatBins);
271  "type", kStatScaleType);
273  "tick_span", kTickSpan);
275  "only_for_processor",
277 }
278 
279 
281 {
283  "dbfile_si2csi", "");
285  "dbfile_bioseq_info", "");
287  "dbfile_blob_prop", "");
288 }
289 
290 
292 {
294  kAutoExcludeSection, "max_cache_size",
297  kAutoExcludeSection, "purge_percentage",
300  kAutoExcludeSection, "inactivity_purge_timeout",
302 }
303 
304 
306 {
307  m_AllowIOTest = registry.GetBool(kDebugSection, "psg_allow_io_test",
309  m_AllowProcessorTiming = registry.GetBool(kDebugSection, "allow_processor_timing",
311 }
312 
313 
315 {
316  m_IPGPageSize = registry.GetInt(kIPGSection, "page_size",
318  m_EnableHugeIPG = registry.GetBool(kIPGSection, "enable_huge_ipg",
320 }
321 
322 
324 {
326  "ssl_enable", kDefaultSSLEnable);
328  "ssl_cert_file", kDefaultSSLCertFile);
330  "ssl_key_file", kDefaultSSLKeyFile);
332  "ssl_ciphers", kDefaultSSLCiphers);
333 }
334 
335 
337 {
339  "test_seq_id", kDefaultTestSeqId);
341  "test_seq_id_ignore_error",
343 }
344 
345 
347 {
351 }
352 
353 
355 {
357  "enabled",
359 }
360 
361 
363 {
365  "enabled",
367 }
368 
369 
371 {
373  "enabled",
375 }
376 
377 
379 {
381  "enabled",
383 }
384 
385 
387 {
389  "ok_cache_size",
392  "not_found_cache_size",
395  kMyNCBISection, "not_found_cache_expiration_sec",
398  "error_cache_size",
401  "error_cache_back_off_ms",
404  "url",
407  "http_proxy",
410  "timeout_ms",
413  "resolve_timeout_ms",
415 }
416 
417 
419 {
420  list<string> entries;
422 
423  for(const auto & value_id : entries) {
424  string name_and_description = registry.Get(kCountersSection,
425  value_id);
426  string name;
427  string description;
428  if (NStr::SplitInTwo(name_and_description, ":::", name, description,
430  m_IdToNameAndDescription[value_id] = {name, description};
431  } else {
432  PSG_WARNING("Malformed counter [" << kCountersSection << "]/" <<
433  name << " information. Expected <name>:::<description");
434  }
435  }
436 }
437 
438 
440  CPSGAlerts & alerts)
441 {
442  try {
445  } catch (const CRegistryException & ex) {
446  string msg = "Decrypting error detected while reading "
447  "[" + kAdminSection + "]/auth_token value: " +
448  string(ex.what());
449  ERR_POST(msg);
450  alerts.Register(ePSGS_ConfigAuthDecrypt, msg);
451 
452  // Treat the value as a clear text
453  m_AuthToken = registry.GetString("ADMIN", "auth_token",
455  } catch (...) {
456  string msg = "Unknown decrypting error detected while reading "
457  "[" + kAdminSection + "]/auth_token value";
458  ERR_POST(msg);
459  alerts.Register(ePSGS_ConfigAuthDecrypt, msg);
460 
461  // Treat the value as a clear text
462  m_AuthToken = registry.GetString("ADMIN", "auth_token",
464  }
465 
466  string auth_commands = registry.GetString(kAdminSection, "auth_commands",
468  NStr::Split(auth_commands, " ", m_AuthCommands);
469  if (!m_AuthCommands.empty()) {
470  for (size_t k = 0; k < m_AuthCommands.size(); ++k) {
472  m_AuthCommands[k].begin(), ::tolower);
473  }
474  }
475 }
476 
477 
479 {
480  const unsigned short kHttpPortMin = 1;
481  const unsigned short kHttpPortMax = 65534;
482  const unsigned short kWorkersMin = 1;
483  const unsigned short kWorkersMax = 100;
484  const unsigned int kListenerBacklogMin = 5;
485  const unsigned int kListenerBacklogMax = 2048;
486  const unsigned short kTcpMaxConnMax = 65000;
487  const unsigned short kTcpMaxConnMin = 5;
488  const unsigned int kTimeoutMsMin = 0;
489  const unsigned int kTimeoutMsMax = UINT_MAX;
490  const unsigned int kMaxRetriesMin = 0;
491  const unsigned int kMaxRetriesMax = UINT_MAX;
492 
493 
494  if (m_HttpPort < kHttpPortMin || m_HttpPort > kHttpPortMax) {
495  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
496  "[" + kServerSection +
497  "]/port value is out of range. Allowed range: " +
498  to_string(kHttpPortMin) + "..." +
499  to_string(kHttpPortMax) + ". Received: " +
500  to_string(m_HttpPort));
501  }
502 
503  if (m_Si2csiDbFile.empty()) {
504  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_si2csi is not found "
505  "in the ini file. No si2csi cache will be used.");
506  }
507 
508  if (m_BioseqInfoDbFile.empty()) {
509  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_bioseq_info is not found "
510  "in the ini file. No bioseq_info cache will be used.");
511  }
512 
513  if (m_BlobPropDbFile.empty()) {
514  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_blob_prop is not found "
515  "in the ini file. No blob_prop cache will be used.");
516  }
517 
518  if (m_HttpWorkers < kWorkersMin || m_HttpWorkers > kWorkersMax) {
519  string err_msg =
520  "The number of HTTP workers is out of range. Allowed "
521  "range: " + to_string(kWorkersMin) + "..." +
522  to_string(kWorkersMax) + ". Received: " +
523  to_string(m_HttpWorkers) + ". Reset to "
524  "default: " + to_string(kWorkersDefault);
525  alerts.Register(ePSGS_ConfigHttpWorkers, err_msg);
526  PSG_ERROR(err_msg);
528  }
529 
530  if (m_ListenerBacklog < kListenerBacklogMin ||
531  m_ListenerBacklog > kListenerBacklogMax) {
532  string err_msg =
533  "The listener backlog is out of range. Allowed "
534  "range: " + to_string(kListenerBacklogMin) + "..." +
535  to_string(kListenerBacklogMax) + ". Received: " +
536  to_string(m_ListenerBacklog) + ". Reset to "
537  "default: " + to_string(kListenerBacklogDefault);
538  alerts.Register(ePSGS_ConfigListenerBacklog, err_msg);
539  PSG_ERROR(err_msg);
541  }
542 
543  if (m_TcpMaxConn < kTcpMaxConnMin || m_TcpMaxConn > kTcpMaxConnMax) {
544  string err_msg =
545  "The max number of connections is out of range. Allowed "
546  "range: " + to_string(kTcpMaxConnMin) + "..." +
547  to_string(kTcpMaxConnMax) + ". Received: " +
548  to_string(m_TcpMaxConn) + ". Reset to "
549  "default: " + to_string(kTcpMaxConnDefault);
550  alerts.Register(ePSGS_ConfigMaxConnections, err_msg);
551  PSG_ERROR(err_msg);
553  }
554 
555  if (m_TimeoutMs < kTimeoutMsMin || m_TimeoutMs > kTimeoutMsMax) {
556  string err_msg =
557  "The operation timeout is out of range. Allowed "
558  "range: " + to_string(kTimeoutMsMin) + "..." +
559  to_string(kTimeoutMsMax) + ". Received: " +
560  to_string(m_TimeoutMs) + ". Reset to "
561  "default: " + to_string(kTimeoutDefault);
562  alerts.Register(ePSGS_ConfigTimeout, err_msg);
563  PSG_ERROR(err_msg);
565  }
566 
567  if (m_MaxRetries < kMaxRetriesMin || m_MaxRetries > kMaxRetriesMax) {
568  string err_msg =
569  "The max retries is out of range. Allowed "
570  "range: " + to_string(kMaxRetriesMin) + "..." +
571  to_string(kMaxRetriesMax) + ". Received: " +
572  to_string(m_MaxRetries) + ". Reset to "
573  "default: " + to_string(kMaxRetriesDefault);
574  alerts.Register(ePSGS_ConfigRetries, err_msg);
575  PSG_ERROR(err_msg);
577  }
578 
579  if (m_ExcludeCacheMaxSize < 0) {
580  string err_msg =
581  "The max exclude cache size must be a positive integer. "
582  "Received: " + to_string(m_ExcludeCacheMaxSize) + ". "
583  "Reset to 0 (exclude blobs cache is disabled)";
584  alerts.Register(ePSGS_ConfigExcludeCacheSize, err_msg);
585  PSG_ERROR(err_msg);
587  }
588 
589  if (m_ExcludeCachePurgePercentage < 0 || m_ExcludeCachePurgePercentage > 100) {
590  string err_msg = "The exclude cache purge percentage is out of range. "
591  "Allowed: 0...100. Received: " +
592  to_string(m_ExcludeCachePurgePercentage) + ". ";
593  if (m_ExcludeCacheMaxSize > 0) {
594  err_msg += "Reset to " +
596  PSG_ERROR(err_msg);
597  } else {
598  err_msg += "The provided value has no effect "
599  "because the exclude cache is disabled.";
600  PSG_WARNING(err_msg);
601  }
604  }
605 
607  string err_msg = "The exclude cache inactivity purge timeout must be "
608  "a positive integer greater than zero. Received: " +
609  to_string(m_ExcludeCacheInactivityPurge) + ". ";
610  if (m_ExcludeCacheMaxSize > 0) {
611  err_msg += "Reset to " +
613  PSG_ERROR(err_msg);
614  } else {
615  err_msg += "The provided value has no effect "
616  "because the exclude cache is disabled.";
617  PSG_WARNING(err_msg);
618  }
621  }
622 
623  if (m_HttpMaxBacklog <= 0) {
624  PSG_WARNING("Invalid " + kServerSection + "]/http_max_backlog value (" +
625  to_string(m_HttpMaxBacklog) + "). "
626  "The http max backlog must be greater than 0. The http max backlog is "
627  "reset to the default value (" +
628  to_string(kDefaultHttpMaxBacklog) + ").");
630  }
631 
632  if (m_HttpMaxRunning <= 0) {
633  PSG_WARNING("Invalid " + kServerSection + "]/http_max_running value (" +
634  to_string(m_HttpMaxRunning) + "). "
635  "The http max running must be greater than 0. The http max running is "
636  "reset to the default value (" +
637  to_string(kDefaultHttpMaxRunning) + ").");
639  }
640 
641  if (m_LogSamplingRatio < 0) {
642  PSG_WARNING("Invalid " + kServerSection + "]/log_sampling_ratio value (" +
643  to_string(m_LogSamplingRatio) + "). "
644  "The log sampling ratio must be greater or equal 0. The log sampling ratio is "
645  "reset to the default value (" +
646  to_string(kDefaultLogSamplingRatio) + ").");
648  }
649 
650  if (m_LogTimingThreshold < 0) {
651  PSG_WARNING("Invalid " + kServerSection + "]/log_timing_threshold value (" +
652  to_string(m_LogTimingThreshold) + "). "
653  "The log timing threshold must be greater or equal 0. The log timing threshold is "
654  "reset to the default value (" +
655  to_string(kDefaultLogTimingThreshold) + ").");
657  }
658 
659  if (m_MaxHops <= 0) {
660  PSG_WARNING("Invalid " + kServerSection + "]/max_hops value (" +
661  to_string(m_MaxHops) + "). "
662  "The max hops must be greater than 0. The max hops is "
663  "reset to the default value (" +
664  to_string(kDefaultMaxHops) + ").");
666  }
667 
668  bool stat_settings_good = true;
669  if (NStr::CompareNocase(m_StatScaleType, "log") != 0 &&
670  NStr::CompareNocase(m_StatScaleType, "linear") != 0) {
671  string err_msg = "Invalid [" + kStatisticsSection +
672  "]/type value '" + m_StatScaleType +
673  "'. Allowed values are: log, linear. "
674  "The statistics parameters are reset to default.";
675  alerts.Register(ePSGS_ConfigStatScaleType, err_msg);
676  PSG_ERROR(err_msg);
677  stat_settings_good = false;
678 
683  }
684 
685  if (stat_settings_good) {
687  string err_msg = "Invalid [" + kStatisticsSection +
688  "]/min and max values. The "
689  "max cannot be less than min. "
690  "The statistics parameters are reset to default.";
691  alerts.Register(ePSGS_ConfigStatMinMaxVal, err_msg);
692  PSG_ERROR(err_msg);
693  stat_settings_good = false;
694 
699  }
700  }
701 
702  if (stat_settings_good) {
703  if (m_NStatBins <= 0) {
704  string err_msg = "Invalid [" + kStatisticsSection +
705  "]/n_bins value. The "
706  "number of bins must be greater than 0. "
707  "The statistics parameters are reset to default.";
708  alerts.Register(ePSGS_ConfigStatNBins, err_msg);
709  PSG_ERROR(err_msg);
710 
711  // Uncomment if there will be more [STATISTICS] section parameters
712  // stat_settings_good = false;
713 
718  }
719  }
720 
721  if (m_TickSpan <= 0) {
722  PSG_WARNING("Invalid [" + kStatisticsSection + "]/tick_span value (" +
723  to_string(m_TickSpan) + "). "
724  "The tick span must be greater than 0. The tick span is "
725  "reset to the default value (" +
726  to_string(kTickSpan) + ").");
728  }
729 
730  if (m_ResendTimeoutSec < 0.0) {
731  PSG_WARNING("Invalid [" + kServerSection + "]/resend_timeout value (" +
732  to_string(m_ResendTimeoutSec) + "). "
733  "The resend timeout must be greater or equal to 0. The resend "
734  "timeout is reset to the default value (" +
735  to_string(kDefaultResendTimeoutSec) + ").");
737  }
738 
739  if (m_RequestTimeoutSec <= 0.0) {
740  PSG_WARNING("Invalid [" + kServerSection + "]/request_timeout value (" +
741  to_string(m_RequestTimeoutSec) + "). "
742  "The request timeout must be greater than 0. The request "
743  "timeout is reset to the default value (" +
744  to_string(kDefaultRequestTimeoutSec) + ").");
746  }
747 
748  if (m_ProcessorMaxConcurrency == 0) {
749  PSG_WARNING("Invalid [" + kServerSection +
750  "]/ProcessorMaxConcurrency value (" +
751  to_string(m_ProcessorMaxConcurrency) + "). "
752  "The processor max concurrency must be greater than 0. "
753  "The processor max concurrency is reset to the default value (" +
754  to_string(kDefaultProcessorMaxConcurrency) + ").");
756  }
757 
758  if (m_IPGPageSize <= 0) {
759  PSG_WARNING("The [" + kIPGSection + "]/page_size value must be > 0. "
760  "The [" + kIPGSection + "]/page_size is switched to the "
761  "default value: " + to_string(kDefaultIPGPageSize));
763  }
764 
765  if (m_SSLEnable) {
766  if (m_SSLCertFile.empty()) {
767  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
768  "[" + kSSLSection + "]/ssl_cert_file value must be provided "
769  "if [" + kSSLSection + "]/ssl_enable is set to true");
770  }
771  if (m_SSLKeyFile.empty()) {
772  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
773  "[" + kSSLSection + "]/ssl_key_file value must be provided "
774  "if [" + kSSLSection + "]/ssl_enable is set to true");
775  }
776 
777  if (!CFile(m_SSLCertFile).Exists()) {
778  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
779  "[" + kSSLSection + "]/ssl_cert_file is not found");
780  }
781  if (!CFile(m_SSLKeyFile).Exists()) {
782  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
783  "[" + kSSLSection + "]/ssl_key_file is not found");
784  }
785 
786  if (m_SSLCiphers.empty()) {
788  }
789  }
790 
791  if (m_MyNCBIURL.empty()) {
792  PSG_WARNING("The [" + kMyNCBISection + "]/url value must be not empty. "
793  "The [" + kMyNCBISection + "]/url is switched to the "
794  "default value: " + kDefaultMyNCBIURL);
796  }
797 
798  if (m_MyNCBITimeoutMs <= 0) {
799  PSG_WARNING("The [" + kMyNCBISection + "]/timeout_ms value must be > 0. "
800  "The [" + kMyNCBISection + "]/timeout_ms is switched to the "
801  "default value: " + to_string(kDefaultMyNCBITimeoutMs));
803  }
804 
805  if (m_MyNCBIResolveTimeoutMs <= 0) {
806  PSG_WARNING("The [" + kMyNCBISection + "]/resolve_timeout_ms value must be > 0. "
807  "The [" + kMyNCBISection + "]/resolve_timeout_ms is switched to the "
808  "default value: " + to_string(kDefaultMyNCBIResolveTimeoutMs));
810  }
811 }
812 
813 
814 unsigned long
816  const string & section,
817  const string & entry,
818  unsigned long default_val)
819 {
820  CConfig conf(registry);
821  const CConfig::TParamTree * param_tree = conf.GetTree();
822  const TPluginManagerParamTree * section_tree =
823  param_tree->FindSubNode(section);
824 
825  if (!section_tree)
826  return default_val;
827 
828  CConfig c((CConfig::TParamTree*)section_tree, eNoOwnership);
829  return c.GetDataSize("psg", entry, CConfig::eErr_NoThrow,
830  default_val);
831 }
832 
833 
835  const CNcbiRegistry & registry,
836  const string & processor_id)
837 {
838  string section = processor_id + "_PROCESSOR";
839 
840  if (registry.HasEntry(section, "ProcessorMaxConcurrency")) {
841  size_t limit = registry.GetInt(section,
842  "ProcessorMaxConcurrency",
844  if (limit == 0) {
845  PSG_WARNING("Invalid [" + section + "]/ProcessorMaxConcurrency value (" +
846  to_string(limit) + "). "
847  "The processor max concurrency must be greater than 0. "
848  "The processor max concurrency is reset to the "
849  "non-processor specific default value (" +
850  to_string(m_ProcessorMaxConcurrency) + ").");
852  }
853 
854  return limit;
855  }
856 
857  // No processor specific value => server wide (or default)
859 }
860 
861 
863 {
864  for (const auto & item: m_AuthCommands) {
865  if (item == cmd) {
866  return true;
867  }
868  }
869  return false;
870 }
871 
@ ePSGS_ConfigListenerBacklog
Definition: alerts.hpp:50
@ ePSGS_ConfigRetries
Definition: alerts.hpp:53
@ ePSGS_ConfigAuthDecrypt
Definition: alerts.hpp:48
@ ePSGS_ConfigExcludeCachePurgeSize
Definition: alerts.hpp:55
@ ePSGS_ConfigHttpWorkers
Definition: alerts.hpp:49
@ ePSGS_ConfigStatScaleType
Definition: alerts.hpp:57
@ ePSGS_ConfigMaxConnections
Definition: alerts.hpp:51
@ ePSGS_ConfigStatNBins
Definition: alerts.hpp:59
@ ePSGS_ConfigExcludeCacheInactivity
Definition: alerts.hpp:56
@ ePSGS_ConfigTimeout
Definition: alerts.hpp:52
@ ePSGS_ConfigStatMinMaxVal
Definition: alerts.hpp:58
@ ePSGS_ConfigExcludeCacheSize
Definition: alerts.hpp:54
void transform(Container &c, UnaryFunction *op)
Definition: chainer.hpp:86
CFile –.
Definition: ncbifile.hpp:1604
CNcbiRegistry –.
Definition: ncbireg.hpp:913
void Register(EPSGS_AlertType alert_type, const string &message)
Definition: alerts.cpp:93
CRegistryException –.
Definition: ncbireg.hpp:1005
definition of a Culling tree
Definition: ncbi_tree.hpp:100
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
constexpr auto begin(const ct_const_array< T, N > &in) noexcept
constexpr auto end(const ct_const_array< T, N > &in) noexcept
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
string
Definition: cgiapp.hpp:687
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
Definition: ncbidiag.hpp:186
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const TParamTree * GetTree() const
Uint8 GetDataSize(const string &driver_name, const string &param_name, EErrAction on_error, unsigned int default_value, const list< string > *synonyms=NULL)
Utility function to get an integer element of parameter tree Throws an exception when mandatory param...
@ eErr_NoThrow
Return default value on error.
virtual bool GetBool(const string &section, const string &name, bool default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get boolean value of specified parameter name.
Definition: ncbireg.cpp:391
virtual const string & Get(const string &section, const string &name, TFlags flags=0) const
Get the parameter value.
Definition: ncbireg.cpp:262
virtual int GetInt(const string &section, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
Definition: ncbireg.cpp:362
virtual double GetDouble(const string &section, const string &name, double default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get double value of specified parameter name.
Definition: ncbireg.cpp:420
virtual bool HasEntry(const string &section, const string &name=kEmptyStr, TFlags flags=0) const
Definition: ncbireg.cpp:290
virtual void EnumerateEntries(const string &section, list< string > *entries, TFlags flags=fAllLayers) const
Enumerate parameter names for a specified section.
Definition: ncbireg.cpp:514
string GetEncryptedString(const string &section, const string &name, TFlags flags=0, const string &password=kEmptyStr) const
Get a value that was (potentially) stored encrypted.
Definition: ncbireg.cpp:329
virtual string GetString(const string &section, const string &name, const string &default_value, TFlags flags=0) const
Get the parameter string value.
Definition: ncbireg.cpp:321
@ fPlaintextAllowed
Definition: ncbireg.hpp:99
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
Definition: ncbistr.cpp:219
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
Definition: ncbistr.cpp:3461
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
Definition: ncbistr.cpp:3554
@ fSplit_ByPattern
Require full delimiter strings.
Definition: ncbistr.hpp:2502
const TTreeType * FindSubNode(const TKeyType &key) const
Non recursive linear scan of all subnodes, with key comparison.
Definition: ncbi_tree.hpp:940
Parameters initialization model.
int tolower(Uchar c)
Definition: ncbictype.hpp:72
Plugin manager (using class factory paradigm).
#define PSG_ERROR(message)
#define PSG_WARNING(message)
const bool kDefaultTestSeqIdIgnoreError
Definition: settings.cpp:98
const string kAutoExcludeSection
Definition: settings.cpp:46
const size_t kDefaultLogTimingThreshold
Definition: settings.cpp:71
const string kDefaultAuthToken
Definition: settings.cpp:88
const size_t kDefaultShutdownIfTooManyOpenFDforHTTPS
Definition: settings.cpp:96
const size_t kDefaultHttpMaxBacklog
Definition: settings.cpp:68
const string kHealthSection
Definition: settings.cpp:50
const size_t kDefaultIPGPageSize
Definition: settings.cpp:86
const unsigned int kDefaultMaxHops
Definition: settings.cpp:78
const unsigned long kDefaultSendBlobIfSmall
Definition: settings.cpp:72
const bool kDefaultSSLEnable
Definition: settings.cpp:91
const string kOSGProcessorSection
Definition: settings.cpp:51
const bool kDefaultAllowProcessorTiming
Definition: settings.cpp:80
const string kWGSProcessorSection
Definition: settings.cpp:53
const unsigned short kTcpMaxConnDefault
Definition: settings.cpp:63
const string kDefaultSSLKeyFile
Definition: settings.cpp:93
const string kDefaultOnlyForProcessor
Definition: settings.cpp:81
const bool kDefaultLog
Definition: settings.cpp:74
const string kDefaultSSLCertFile
Definition: settings.cpp:92
const string kServerSection
Definition: settings.cpp:43
const size_t kDefaultHttpMaxRunning
Definition: settings.cpp:69
const string kCassandraProcessorSection
Definition: settings.cpp:55
const string kCDDProcessorSection
Definition: settings.cpp:52
const bool kDefaultCassandraProcessorsEnabled
Definition: settings.cpp:99
const unsigned short kWorkersDefault
Definition: settings.cpp:61
const bool kDefaultSNPProcessorsEnabled
Definition: settings.cpp:103
const string kDefaultConfigurationDomain
Definition: settings.cpp:67
const size_t kDefaultMyNCBINotFoundCacheExpirationSec
Definition: settings.cpp:106
const string kDebugSection
Definition: settings.cpp:47
const unsigned int kListenerBacklogDefault
Definition: settings.cpp:62
const string kSSLSection
Definition: settings.cpp:49
const double kDefaultRequestTimeoutSec
Definition: settings.cpp:83
const string kCountersSection
Definition: settings.cpp:58
const size_t kDefaultSplitInfoBlobCacheSize
Definition: settings.cpp:85
const size_t kDefaultMyNCBIErrorCacheSize
Definition: settings.cpp:107
const size_t kDefaultMyNCBIOKCacheSize
Definition: settings.cpp:104
const string kDefaultRootKeyspace
Definition: settings.cpp:66
const size_t kDefaultLogSamplingRatio
Definition: settings.cpp:70
const size_t kDefaultProcessorMaxConcurrency
Definition: settings.cpp:84
const size_t kDefaultMyNCBIResolveTimeoutMs
Definition: settings.cpp:112
const unsigned long kDefaultSmallBlobSize
Definition: settings.cpp:73
const size_t kDefaultShutdownIfTooManyOpenFDforHTTP
Definition: settings.cpp:95
const unsigned int kDefaultExcludeCachePurgePercentage
Definition: settings.cpp:76
const string kDefaultTestSeqId
Definition: settings.cpp:97
const string kMyNCBISection
Definition: settings.cpp:57
const unsigned int kDefaultExcludeCacheMaxSize
Definition: settings.cpp:75
const size_t kDefaultMyNCBIErrorCacheBackOffMs
Definition: settings.cpp:108
const string kLmdbCacheSection
Definition: settings.cpp:44
const string kSNPProcessorSection
Definition: settings.cpp:54
const bool kDefaultCDDProcessorsEnabled
Definition: settings.cpp:101
const bool kDefaultAllowIOTest
Definition: settings.cpp:79
const bool kDefaultOSGProcessorsEnabled
Definition: settings.cpp:100
const string kDefaultSSLCiphers
Definition: settings.cpp:94
const string kDefaultAuthCommands
Definition: settings.cpp:90
const size_t kDefaultMyNCBINotFoundCacheSize
Definition: settings.cpp:105
const double kDefaultResendTimeoutSec
Definition: settings.cpp:82
const unsigned int kMaxRetriesDefault
Definition: settings.cpp:65
const string kDefaultMyNCBIURL
Definition: settings.cpp:109
const bool kDefaultWGSProcessorsEnabled
Definition: settings.cpp:102
const string kDefaultMyNCBIHttpProxy
Definition: settings.cpp:110
const string kAdminSection
Definition: settings.cpp:56
const bool kDefaultEnableHugeIPG
Definition: settings.cpp:87
const unsigned int kTimeoutDefault
Definition: settings.cpp:64
const size_t kDefaultMyNCBITimeoutMs
Definition: settings.cpp:111
const string kIPGSection
Definition: settings.cpp:48
const unsigned int kDefaultExcludeCacheInactivityPurge
Definition: settings.cpp:77
const string kStatisticsSection
Definition: settings.cpp:45
void x_ReadOSGProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:354
void Read(const CNcbiRegistry &registry, CPSGAlerts &alerts)
Definition: settings.cpp:174
unsigned long m_MinStatValue
Definition: settings.hpp:78
unsigned int m_TimeoutMs
Definition: settings.hpp:59
void x_ReadCountersSection(const CNcbiRegistry &registry)
Definition: settings.cpp:418
size_t m_SplitInfoBlobCacheSize
Definition: settings.hpp:67
unsigned long x_GetDataSize(const CNcbiRegistry &registry, const string &section, const string &entry, unsigned long default_val)
Definition: settings.cpp:815
void x_ReadCDDProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:362
map< string, tuple< string, string > > m_IdToNameAndDescription
Definition: settings.hpp:135
unsigned int m_ExcludeCachePurgePercentage
Definition: settings.hpp:93
void x_ReadIPGSection(const CNcbiRegistry &registry)
Definition: settings.cpp:314
size_t m_MyNCBINotFoundCacheSize
Definition: settings.hpp:139
unsigned short m_HttpPort
Definition: settings.hpp:55
void x_ReadSNPProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:378
unsigned long m_MaxStatValue
Definition: settings.hpp:79
void x_ReadStatisticsSection(const CNcbiRegistry &registry)
Definition: settings.cpp:260
void x_ReadWGSProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:370
void x_ReadServerSection(const CNcbiRegistry &registry)
Definition: settings.cpp:199
unsigned short m_HttpWorkers
Definition: settings.hpp:56
string m_ConfigurationDomain
Definition: settings.hpp:70
void x_ReadAutoExcludeSection(const CNcbiRegistry &registry)
Definition: settings.cpp:291
bool IsAuthProtectedCommand(const string &cmd) const
Definition: settings.cpp:862
size_t m_MyNCBIErrorCacheBackOffMs
Definition: settings.hpp:142
void x_ReadMyNCBISection(const CNcbiRegistry &registry)
Definition: settings.cpp:386
unsigned int m_ExcludeCacheMaxSize
Definition: settings.hpp:92
void Validate(CPSGAlerts &alerts)
Definition: settings.cpp:478
unsigned short m_TcpMaxConn
Definition: settings.hpp:58
void x_ReadAdminSection(const CNcbiRegistry &registry, CPSGAlerts &alerts)
Definition: settings.cpp:439
unsigned long m_TickSpan
Definition: settings.hpp:82
unsigned long m_SmallBlobSize
Definition: settings.hpp:77
size_t GetProcessorMaxConcurrency(const CNcbiRegistry &registry, const string &processor_id)
Definition: settings.cpp:834
void x_ReadSSLSection(const CNcbiRegistry &registry)
Definition: settings.cpp:323
size_t m_ProcessorMaxConcurrency
Definition: settings.hpp:66
unsigned int m_MaxRetries
Definition: settings.hpp:60
void x_ReadHealthSection(const CNcbiRegistry &registry)
Definition: settings.cpp:336
size_t m_ShutdownIfTooManyOpenFD
Definition: settings.hpp:68
unsigned int m_ListenerBacklog
Definition: settings.hpp:57
unsigned int m_ExcludeCacheInactivityPurge
Definition: settings.hpp:94
size_t m_MyNCBINotFoundCacheExpirationSec
Definition: settings.hpp:140
unsigned long m_SendBlobIfSmall
Definition: settings.hpp:61
void x_ReadLmdbCacheSection(const CNcbiRegistry &registry)
Definition: settings.cpp:280
vector< string > m_AuthCommands
Definition: settings.hpp:106
void x_ReadCassandraProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:346
void x_ReadDebugSection(const CNcbiRegistry &registry)
Definition: settings.cpp:305
unsigned long m_NStatBins
Definition: settings.hpp:80
size_t m_MyNCBIResolveTimeoutMs
Definition: settings.hpp:146
const unsigned long kNStatBins
Definition: timing.hpp:52
const unsigned long kMinStatValue
Definition: timing.hpp:50
const string kStatScaleType
Definition: timing.hpp:53
const unsigned long kMaxStatValue
Definition: timing.hpp:51
const unsigned long kTickSpan
Definition: timing.hpp:54
static wxAcceleratorEntry entries[3]
Modified on Fri Apr 12 17:16:43 2024 by modify_doxy.py rev. 669887