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

Go to the SVN repository for this file.

1 /* $Id: settings.cpp 101029 2023-10-18 12:33:48Z 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 const bool kDefaultSSLEnable = false;
90 const string kDefaultSSLCertFile = "";
91 const string kDefaultSSLKeyFile = "";
92 const string kDefaultSSLCiphers = "EECDH+aRSA+AESGCM EDH+aRSA+AESGCM EECDH+aRSA EDH+aRSA !SHA !SHA256 !SHA384";
95 const string kDefaultTestSeqId = "gi|2";
96 const bool kDefaultTestSeqIdIgnoreError = true;
98 const bool kDefaultOSGProcessorsEnabled = false;
99 const bool kDefaultCDDProcessorsEnabled = true;
102 const size_t kDefaultMyNCBIOKCacheSize = 10000;
103 const size_t kDefaultMyNCBINotFoundCacheSize = 10000;
105 const size_t kDefaultMyNCBIErrorCacheSize = 10000;
107 const string kDefaultMyNCBIURL = "http://txproxy.linkerd.ncbi.nlm.nih.gov/v1/service/MyNCBIAccount?txsvc=MyNCBIAccount";
108 const string kDefaultMyNCBIHttpProxy = "linkerd:4140";
110 
111 
112 
114  m_HttpPort(0),
115  m_HttpWorkers(kWorkersDefault),
116  m_ListenerBacklog(kListenerBacklogDefault),
117  m_TcpMaxConn(kTcpMaxConnDefault),
118  m_TimeoutMs(kTimeoutDefault),
119  m_MaxRetries(kMaxRetriesDefault),
120  m_SendBlobIfSmall(kDefaultSendBlobIfSmall),
121  m_Log(kDefaultLog),
122  m_MaxHops(kDefaultMaxHops),
123  m_ResendTimeoutSec(kDefaultResendTimeoutSec),
124  m_RequestTimeoutSec(kDefaultRequestTimeoutSec),
125  m_ProcessorMaxConcurrency(kDefaultProcessorMaxConcurrency),
126  m_SplitInfoBlobCacheSize(kDefaultSplitInfoBlobCacheSize),
127  m_ShutdownIfTooManyOpenFD(0),
128  m_RootKeyspace(kDefaultRootKeyspace),
129  m_ConfigurationDomain(kDefaultConfigurationDomain),
130  m_HttpMaxBacklog(kDefaultHttpMaxBacklog),
131  m_HttpMaxRunning(kDefaultHttpMaxRunning),
132  m_LogSamplingRatio(kDefaultLogSamplingRatio),
133  m_LogTimingThreshold(kDefaultLogTimingThreshold),
134  m_SmallBlobSize(kDefaultSmallBlobSize),
135  m_MinStatValue(kMinStatValue),
136  m_MaxStatValue(kMaxStatValue),
137  m_NStatBins(kNStatBins),
138  m_StatScaleType(kStatScaleType),
139  m_TickSpan(kTickSpan),
140  m_OnlyForProcessor(kDefaultOnlyForProcessor),
141  m_ExcludeCacheMaxSize(kDefaultExcludeCacheMaxSize),
142  m_ExcludeCachePurgePercentage(kDefaultExcludeCachePurgePercentage),
143  m_ExcludeCacheInactivityPurge(kDefaultExcludeCacheInactivityPurge),
144  m_AllowIOTest(kDefaultAllowIOTest),
145  m_AllowProcessorTiming(kDefaultAllowProcessorTiming),
146  m_SSLEnable(kDefaultSSLEnable),
147  m_SSLCiphers(kDefaultSSLCiphers),
148  m_TestSeqId(kDefaultTestSeqId),
149  m_TestSeqIdIgnoreError(kDefaultTestSeqIdIgnoreError),
150  m_CassandraProcessorsEnabled(kDefaultCassandraProcessorsEnabled),
151  m_OSGProcessorsEnabled(kDefaultOSGProcessorsEnabled),
152  m_CDDProcessorsEnabled(kDefaultCDDProcessorsEnabled),
153  m_WGSProcessorsEnabled(kDefaultWGSProcessorsEnabled),
154  m_SNPProcessorsEnabled(kDefaultSNPProcessorsEnabled),
155  m_MyNCBIOKCacheSize(kDefaultMyNCBIOKCacheSize),
156  m_MyNCBINotFoundCacheSize(kDefaultMyNCBINotFoundCacheSize),
157  m_MyNCBINotFoundCacheExpirationSec(kDefaultMyNCBINotFoundCacheExpirationSec),
158  m_MyNCBIErrorCacheSize(kDefaultMyNCBIErrorCacheSize),
159  m_MyNCBIErrorCacheBackOffMs(kDefaultMyNCBIErrorCacheBackOffMs),
160  m_MyNCBIURL(kDefaultMyNCBIURL),
161  m_MyNCBIHttpProxy(kDefaultMyNCBIHttpProxy),
162  m_MyNCBITimeoutMs(kDefaultMyNCBITimeoutMs)
163 {}
164 
165 
167 {}
168 
169 
171  CPSGAlerts & alerts)
172 {
173  // Note: reading of some values in the [SERVER] depends if SSL is on/off
174  // So, reading of the SSL settings is done first
176 
184  x_ReadAdminSection(registry, alerts);
192 }
193 
194 
196 {
197 
198  if (!registry.HasEntry(kServerSection, "port"))
199  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
200  "[" + kServerSection +
201  "]/port value is not found in the configuration "
202  "file. The port must be provided to run the server. "
203  "Exiting.");
204 
212  m_TimeoutMs = registry.GetInt(kServerSection, "optimeout",
214  m_MaxRetries = registry.GetInt(kServerSection, "maxretries",
216  m_RootKeyspace = registry.GetString(kServerSection, "root_keyspace",
218  m_ConfigurationDomain = registry.GetString(kServerSection, "configuration_domain",
220  m_HttpMaxBacklog = registry.GetInt(kServerSection, "http_max_backlog",
222  m_HttpMaxRunning = registry.GetInt(kServerSection, "http_max_running",
224  m_LogSamplingRatio = registry.GetInt(kServerSection, "log_sampling_ratio",
226  m_LogTimingThreshold = registry.GetInt(kServerSection, "log_timing_threshold",
229  "send_blob_if_small",
238  "ProcessorMaxConcurrency",
241  "split_info_blob_cache_size",
243 
244  if (m_SSLEnable) {
246  registry.GetInt(kServerSection, "ShutdownIfTooManyOpenFD",
248  } else {
250  registry.GetInt(kServerSection, "ShutdownIfTooManyOpenFD",
252  }
253 }
254 
255 
257 {
259  "small_blob_size", kDefaultSmallBlobSize);
261  "min", kMinStatValue);
263  "max", kMaxStatValue);
265  "n_bins", kNStatBins);
267  "type", kStatScaleType);
269  "tick_span", kTickSpan);
271  "only_for_processor",
273 }
274 
275 
277 {
279  "dbfile_si2csi", "");
281  "dbfile_bioseq_info", "");
283  "dbfile_blob_prop", "");
284 }
285 
286 
288 {
290  kAutoExcludeSection, "max_cache_size",
293  kAutoExcludeSection, "purge_percentage",
296  kAutoExcludeSection, "inactivity_purge_timeout",
298 }
299 
300 
302 {
303  m_AllowIOTest = registry.GetBool(kDebugSection, "psg_allow_io_test",
305  m_AllowProcessorTiming = registry.GetBool(kDebugSection, "allow_processor_timing",
307 }
308 
309 
311 {
312  m_IPGPageSize = registry.GetInt(kIPGSection, "page_size",
314  m_EnableHugeIPG = registry.GetBool(kIPGSection, "enable_huge_ipg",
316 }
317 
318 
320 {
322  "ssl_enable", kDefaultSSLEnable);
324  "ssl_cert_file", kDefaultSSLCertFile);
326  "ssl_key_file", kDefaultSSLKeyFile);
328  "ssl_ciphers", kDefaultSSLCiphers);
329 }
330 
331 
333 {
335  "test_seq_id", kDefaultTestSeqId);
337  "test_seq_id_ignore_error",
339 }
340 
341 
343 {
347 }
348 
349 
351 {
353  "enabled",
355 }
356 
357 
359 {
361  "enabled",
363 }
364 
365 
367 {
369  "enabled",
371 }
372 
373 
375 {
377  "enabled",
379 }
380 
381 
383 {
385  "ok_cache_size",
388  "not_found_cache_size",
391  kMyNCBISection, "not_found_cache_expiration_sec",
394  "error_cache_size",
397  "error_cache_back_off_ms",
400  "url",
403  "http_proxy",
406  "timeout_ms",
408 }
409 
410 
412 {
413  list<string> entries;
415 
416  for(const auto & value_id : entries) {
417  string name_and_description = registry.Get(kCountersSection,
418  value_id);
419  string name;
420  string description;
421  if (NStr::SplitInTwo(name_and_description, ":::", name, description,
423  m_IdToNameAndDescription[value_id] = {name, description};
424  } else {
425  PSG_WARNING("Malformed counter [" << kCountersSection << "]/" <<
426  name << " information. Expected <name>:::<description");
427  }
428  }
429 }
430 
431 
433  CPSGAlerts & alerts)
434 {
435  try {
438  } catch (const CRegistryException & ex) {
439  string msg = "Decrypting error detected while reading "
440  "[" + kAdminSection + "]/auth_token value: " +
441  string(ex.what());
442  ERR_POST(msg);
443  alerts.Register(ePSGS_ConfigAuthDecrypt, msg);
444 
445  // Treat the value as a clear text
446  m_AuthToken = registry.GetString("ADMIN", "auth_token",
448  } catch (...) {
449  string msg = "Unknown decrypting error detected while reading "
450  "[" + kAdminSection + "]/auth_token value";
451  ERR_POST(msg);
452  alerts.Register(ePSGS_ConfigAuthDecrypt, msg);
453 
454  // Treat the value as a clear text
455  m_AuthToken = registry.GetString("ADMIN", "auth_token",
457  }
458 }
459 
460 
462 {
463  const unsigned short kHttpPortMin = 1;
464  const unsigned short kHttpPortMax = 65534;
465  const unsigned short kWorkersMin = 1;
466  const unsigned short kWorkersMax = 100;
467  const unsigned int kListenerBacklogMin = 5;
468  const unsigned int kListenerBacklogMax = 2048;
469  const unsigned short kTcpMaxConnMax = 65000;
470  const unsigned short kTcpMaxConnMin = 5;
471  const unsigned int kTimeoutMsMin = 0;
472  const unsigned int kTimeoutMsMax = UINT_MAX;
473  const unsigned int kMaxRetriesMin = 0;
474  const unsigned int kMaxRetriesMax = UINT_MAX;
475 
476 
477  if (m_HttpPort < kHttpPortMin || m_HttpPort > kHttpPortMax) {
478  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
479  "[" + kServerSection +
480  "]/port value is out of range. Allowed range: " +
481  to_string(kHttpPortMin) + "..." +
482  to_string(kHttpPortMax) + ". Received: " +
483  to_string(m_HttpPort));
484  }
485 
486  if (m_Si2csiDbFile.empty()) {
487  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_si2csi is not found "
488  "in the ini file. No si2csi cache will be used.");
489  }
490 
491  if (m_BioseqInfoDbFile.empty()) {
492  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_bioseq_info is not found "
493  "in the ini file. No bioseq_info cache will be used.");
494  }
495 
496  if (m_BlobPropDbFile.empty()) {
497  PSG_WARNING("[" + kLmdbCacheSection + "]/dbfile_blob_prop is not found "
498  "in the ini file. No blob_prop cache will be used.");
499  }
500 
501  if (m_HttpWorkers < kWorkersMin || m_HttpWorkers > kWorkersMax) {
502  string err_msg =
503  "The number of HTTP workers is out of range. Allowed "
504  "range: " + to_string(kWorkersMin) + "..." +
505  to_string(kWorkersMax) + ". Received: " +
506  to_string(m_HttpWorkers) + ". Reset to "
507  "default: " + to_string(kWorkersDefault);
508  alerts.Register(ePSGS_ConfigHttpWorkers, err_msg);
509  PSG_ERROR(err_msg);
511  }
512 
513  if (m_ListenerBacklog < kListenerBacklogMin ||
514  m_ListenerBacklog > kListenerBacklogMax) {
515  string err_msg =
516  "The listener backlog is out of range. Allowed "
517  "range: " + to_string(kListenerBacklogMin) + "..." +
518  to_string(kListenerBacklogMax) + ". Received: " +
519  to_string(m_ListenerBacklog) + ". Reset to "
520  "default: " + to_string(kListenerBacklogDefault);
521  alerts.Register(ePSGS_ConfigListenerBacklog, err_msg);
522  PSG_ERROR(err_msg);
524  }
525 
526  if (m_TcpMaxConn < kTcpMaxConnMin || m_TcpMaxConn > kTcpMaxConnMax) {
527  string err_msg =
528  "The max number of connections is out of range. Allowed "
529  "range: " + to_string(kTcpMaxConnMin) + "..." +
530  to_string(kTcpMaxConnMax) + ". Received: " +
531  to_string(m_TcpMaxConn) + ". Reset to "
532  "default: " + to_string(kTcpMaxConnDefault);
533  alerts.Register(ePSGS_ConfigMaxConnections, err_msg);
534  PSG_ERROR(err_msg);
536  }
537 
538  if (m_TimeoutMs < kTimeoutMsMin || m_TimeoutMs > kTimeoutMsMax) {
539  string err_msg =
540  "The operation timeout is out of range. Allowed "
541  "range: " + to_string(kTimeoutMsMin) + "..." +
542  to_string(kTimeoutMsMax) + ". Received: " +
543  to_string(m_TimeoutMs) + ". Reset to "
544  "default: " + to_string(kTimeoutDefault);
545  alerts.Register(ePSGS_ConfigTimeout, err_msg);
546  PSG_ERROR(err_msg);
548  }
549 
550  if (m_MaxRetries < kMaxRetriesMin || m_MaxRetries > kMaxRetriesMax) {
551  string err_msg =
552  "The max retries is out of range. Allowed "
553  "range: " + to_string(kMaxRetriesMin) + "..." +
554  to_string(kMaxRetriesMax) + ". Received: " +
555  to_string(m_MaxRetries) + ". Reset to "
556  "default: " + to_string(kMaxRetriesDefault);
557  alerts.Register(ePSGS_ConfigRetries, err_msg);
558  PSG_ERROR(err_msg);
560  }
561 
562  if (m_ExcludeCacheMaxSize < 0) {
563  string err_msg =
564  "The max exclude cache size must be a positive integer. "
565  "Received: " + to_string(m_ExcludeCacheMaxSize) + ". "
566  "Reset to 0 (exclude blobs cache is disabled)";
567  alerts.Register(ePSGS_ConfigExcludeCacheSize, err_msg);
568  PSG_ERROR(err_msg);
570  }
571 
572  if (m_ExcludeCachePurgePercentage < 0 || m_ExcludeCachePurgePercentage > 100) {
573  string err_msg = "The exclude cache purge percentage is out of range. "
574  "Allowed: 0...100. Received: " +
575  to_string(m_ExcludeCachePurgePercentage) + ". ";
576  if (m_ExcludeCacheMaxSize > 0) {
577  err_msg += "Reset to " +
579  PSG_ERROR(err_msg);
580  } else {
581  err_msg += "The provided value has no effect "
582  "because the exclude cache is disabled.";
583  PSG_WARNING(err_msg);
584  }
587  }
588 
590  string err_msg = "The exclude cache inactivity purge timeout must be "
591  "a positive integer greater than zero. Received: " +
592  to_string(m_ExcludeCacheInactivityPurge) + ". ";
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 
606  if (m_HttpMaxBacklog <= 0) {
607  PSG_WARNING("Invalid " + kServerSection + "]/http_max_backlog value (" +
608  to_string(m_HttpMaxBacklog) + "). "
609  "The http max backlog must be greater than 0. The http max backlog is "
610  "reset to the default value (" +
611  to_string(kDefaultHttpMaxBacklog) + ").");
613  }
614 
615  if (m_HttpMaxRunning <= 0) {
616  PSG_WARNING("Invalid " + kServerSection + "]/http_max_running value (" +
617  to_string(m_HttpMaxRunning) + "). "
618  "The http max running must be greater than 0. The http max running is "
619  "reset to the default value (" +
620  to_string(kDefaultHttpMaxRunning) + ").");
622  }
623 
624  if (m_LogSamplingRatio < 0) {
625  PSG_WARNING("Invalid " + kServerSection + "]/log_sampling_ratio value (" +
626  to_string(m_LogSamplingRatio) + "). "
627  "The log sampling ratio must be greater or equal 0. The log sampling ratio is "
628  "reset to the default value (" +
629  to_string(kDefaultLogSamplingRatio) + ").");
631  }
632 
633  if (m_LogTimingThreshold < 0) {
634  PSG_WARNING("Invalid " + kServerSection + "]/log_timing_threshold value (" +
635  to_string(m_LogTimingThreshold) + "). "
636  "The log timing threshold must be greater or equal 0. The log timing threshold is "
637  "reset to the default value (" +
638  to_string(kDefaultLogTimingThreshold) + ").");
640  }
641 
642  if (m_MaxHops <= 0) {
643  PSG_WARNING("Invalid " + kServerSection + "]/max_hops value (" +
644  to_string(m_MaxHops) + "). "
645  "The max hops must be greater than 0. The max hops is "
646  "reset to the default value (" +
647  to_string(kDefaultMaxHops) + ").");
649  }
650 
651  bool stat_settings_good = true;
652  if (NStr::CompareNocase(m_StatScaleType, "log") != 0 &&
653  NStr::CompareNocase(m_StatScaleType, "linear") != 0) {
654  string err_msg = "Invalid [" + kStatisticsSection +
655  "]/type value '" + m_StatScaleType +
656  "'. Allowed values are: log, linear. "
657  "The statistics parameters are reset to default.";
658  alerts.Register(ePSGS_ConfigStatScaleType, err_msg);
659  PSG_ERROR(err_msg);
660  stat_settings_good = false;
661 
666  }
667 
668  if (stat_settings_good) {
670  string err_msg = "Invalid [" + kStatisticsSection +
671  "]/min and max values. The "
672  "max cannot be less than min. "
673  "The statistics parameters are reset to default.";
674  alerts.Register(ePSGS_ConfigStatMinMaxVal, err_msg);
675  PSG_ERROR(err_msg);
676  stat_settings_good = false;
677 
682  }
683  }
684 
685  if (stat_settings_good) {
686  if (m_NStatBins <= 0) {
687  string err_msg = "Invalid [" + kStatisticsSection +
688  "]/n_bins value. The "
689  "number of bins must be greater than 0. "
690  "The statistics parameters are reset to default.";
691  alerts.Register(ePSGS_ConfigStatNBins, err_msg);
692  PSG_ERROR(err_msg);
693 
694  // Uncomment if there will be more [STATISTICS] section parameters
695  // stat_settings_good = false;
696 
701  }
702  }
703 
704  if (m_TickSpan <= 0) {
705  PSG_WARNING("Invalid [" + kStatisticsSection + "]/tick_span value (" +
706  to_string(m_TickSpan) + "). "
707  "The tick span must be greater than 0. The tick span is "
708  "reset to the default value (" +
709  to_string(kTickSpan) + ").");
711  }
712 
713  if (m_ResendTimeoutSec < 0.0) {
714  PSG_WARNING("Invalid [" + kServerSection + "]/resend_timeout value (" +
715  to_string(m_ResendTimeoutSec) + "). "
716  "The resend timeout must be greater or equal to 0. The resend "
717  "timeout is reset to the default value (" +
718  to_string(kDefaultResendTimeoutSec) + ").");
720  }
721 
722  if (m_RequestTimeoutSec <= 0.0) {
723  PSG_WARNING("Invalid [" + kServerSection + "]/request_timeout value (" +
724  to_string(m_RequestTimeoutSec) + "). "
725  "The request timeout must be greater than 0. The request "
726  "timeout is reset to the default value (" +
727  to_string(kDefaultRequestTimeoutSec) + ").");
729  }
730 
731  if (m_ProcessorMaxConcurrency == 0) {
732  PSG_WARNING("Invalid [" + kServerSection +
733  "]/ProcessorMaxConcurrency value (" +
734  to_string(m_ProcessorMaxConcurrency) + "). "
735  "The processor max concurrency must be greater than 0. "
736  "The processor max concurrency is reset to the default value (" +
737  to_string(kDefaultProcessorMaxConcurrency) + ").");
739  }
740 
741  if (m_IPGPageSize <= 0) {
742  PSG_WARNING("The [" + kIPGSection + "]/page_size value must be > 0. "
743  "The [" + kIPGSection + "]/page_size is switched to the "
744  "default value: " + to_string(kDefaultIPGPageSize));
746  }
747 
748  if (m_SSLEnable) {
749  if (m_SSLCertFile.empty()) {
750  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
751  "[" + kSSLSection + "]/ssl_cert_file value must be provided "
752  "if [" + kSSLSection + "]/ssl_enable is set to true");
753  }
754  if (m_SSLKeyFile.empty()) {
755  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
756  "[" + kSSLSection + "]/ssl_key_file value must be provided "
757  "if [" + kSSLSection + "]/ssl_enable is set to true");
758  }
759 
760  if (!CFile(m_SSLCertFile).Exists()) {
761  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
762  "[" + kSSLSection + "]/ssl_cert_file is not found");
763  }
764  if (!CFile(m_SSLKeyFile).Exists()) {
765  NCBI_THROW(CPubseqGatewayException, eConfigurationError,
766  "[" + kSSLSection + "]/ssl_key_file is not found");
767  }
768 
769  if (m_SSLCiphers.empty()) {
771  }
772  }
773 
774  if (m_MyNCBIURL.empty()) {
775  PSG_WARNING("The [" + kMyNCBISection + "]/url value must be not empty. "
776  "The [" + kMyNCBISection + "]/url is switched to the "
777  "default value: " + kDefaultMyNCBIURL);
779  }
780 
781  if (m_MyNCBITimeoutMs <= 0) {
782  PSG_WARNING("The [" + kMyNCBISection + "]/timeout_ms value must be > 0. "
783  "The [" + kMyNCBISection + "]/timeout_ms is switched to the "
784  "default value: " + to_string(kDefaultMyNCBITimeoutMs));
786  }
787 }
788 
789 
790 unsigned long
792  const string & section,
793  const string & entry,
794  unsigned long default_val)
795 {
796  CConfig conf(registry);
797  const CConfig::TParamTree * param_tree = conf.GetTree();
798  const TPluginManagerParamTree * section_tree =
799  param_tree->FindSubNode(section);
800 
801  if (!section_tree)
802  return default_val;
803 
804  CConfig c((CConfig::TParamTree*)section_tree, eNoOwnership);
805  return c.GetDataSize("psg", entry, CConfig::eErr_NoThrow,
806  default_val);
807 }
808 
809 
811  const CNcbiRegistry & registry,
812  const string & processor_id)
813 {
814  string section = processor_id + "_PROCESSOR";
815 
816  if (registry.HasEntry(section, "ProcessorMaxConcurrency")) {
817  size_t limit = registry.GetInt(section,
818  "ProcessorMaxConcurrency",
820  if (limit == 0) {
821  PSG_WARNING("Invalid [" + section + "]/ProcessorMaxConcurrency value (" +
822  to_string(limit) + "). "
823  "The processor max concurrency must be greater than 0. "
824  "The processor max concurrency is reset to the "
825  "non-processor specific default value (" +
826  to_string(m_ProcessorMaxConcurrency) + ").");
828  }
829 
830  return limit;
831  }
832 
833  // No processor specific value => server wide (or default)
835 }
836 
@ 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
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
@ 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 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:3550
@ 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.
Plugin manager (using class factory paradigm).
#define PSG_ERROR(message)
#define PSG_WARNING(message)
const bool kDefaultTestSeqIdIgnoreError
Definition: settings.cpp:96
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:94
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:89
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:91
const string kDefaultOnlyForProcessor
Definition: settings.cpp:81
const bool kDefaultLog
Definition: settings.cpp:74
const string kDefaultSSLCertFile
Definition: settings.cpp:90
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:97
const unsigned short kWorkersDefault
Definition: settings.cpp:61
const bool kDefaultSNPProcessorsEnabled
Definition: settings.cpp:101
const string kDefaultConfigurationDomain
Definition: settings.cpp:67
const size_t kDefaultMyNCBINotFoundCacheExpirationSec
Definition: settings.cpp:104
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:105
const size_t kDefaultMyNCBIOKCacheSize
Definition: settings.cpp:102
const string kDefaultRootKeyspace
Definition: settings.cpp:66
const size_t kDefaultLogSamplingRatio
Definition: settings.cpp:70
const size_t kDefaultProcessorMaxConcurrency
Definition: settings.cpp:84
const unsigned long kDefaultSmallBlobSize
Definition: settings.cpp:73
const size_t kDefaultShutdownIfTooManyOpenFDforHTTP
Definition: settings.cpp:93
const unsigned int kDefaultExcludeCachePurgePercentage
Definition: settings.cpp:76
const string kDefaultTestSeqId
Definition: settings.cpp:95
size_t kDefaultMyNCBITimeoutMs
Definition: settings.cpp:109
const string kMyNCBISection
Definition: settings.cpp:57
const unsigned int kDefaultExcludeCacheMaxSize
Definition: settings.cpp:75
const size_t kDefaultMyNCBIErrorCacheBackOffMs
Definition: settings.cpp:106
const string kLmdbCacheSection
Definition: settings.cpp:44
const string kSNPProcessorSection
Definition: settings.cpp:54
const bool kDefaultCDDProcessorsEnabled
Definition: settings.cpp:99
const bool kDefaultAllowIOTest
Definition: settings.cpp:79
const bool kDefaultOSGProcessorsEnabled
Definition: settings.cpp:98
const string kDefaultSSLCiphers
Definition: settings.cpp:92
const size_t kDefaultMyNCBINotFoundCacheSize
Definition: settings.cpp:103
const double kDefaultResendTimeoutSec
Definition: settings.cpp:82
const unsigned int kMaxRetriesDefault
Definition: settings.cpp:65
const string kDefaultMyNCBIURL
Definition: settings.cpp:107
const bool kDefaultWGSProcessorsEnabled
Definition: settings.cpp:100
const string kDefaultMyNCBIHttpProxy
Definition: settings.cpp:108
const string kAdminSection
Definition: settings.cpp:56
const bool kDefaultEnableHugeIPG
Definition: settings.cpp:87
const unsigned int kTimeoutDefault
Definition: settings.cpp:64
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:350
void Read(const CNcbiRegistry &registry, CPSGAlerts &alerts)
Definition: settings.cpp:170
unsigned long m_MinStatValue
Definition: settings.hpp:77
unsigned int m_TimeoutMs
Definition: settings.hpp:58
void x_ReadCountersSection(const CNcbiRegistry &registry)
Definition: settings.cpp:411
size_t m_SplitInfoBlobCacheSize
Definition: settings.hpp:66
unsigned long x_GetDataSize(const CNcbiRegistry &registry, const string &section, const string &entry, unsigned long default_val)
Definition: settings.cpp:791
void x_ReadCDDProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:358
map< string, tuple< string, string > > m_IdToNameAndDescription
Definition: settings.hpp:133
unsigned int m_ExcludeCachePurgePercentage
Definition: settings.hpp:92
void x_ReadIPGSection(const CNcbiRegistry &registry)
Definition: settings.cpp:310
size_t m_MyNCBINotFoundCacheSize
Definition: settings.hpp:137
unsigned short m_HttpPort
Definition: settings.hpp:54
void x_ReadSNPProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:374
unsigned long m_MaxStatValue
Definition: settings.hpp:78
void x_ReadStatisticsSection(const CNcbiRegistry &registry)
Definition: settings.cpp:256
void x_ReadWGSProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:366
void x_ReadServerSection(const CNcbiRegistry &registry)
Definition: settings.cpp:195
unsigned short m_HttpWorkers
Definition: settings.hpp:55
string m_ConfigurationDomain
Definition: settings.hpp:69
void x_ReadAutoExcludeSection(const CNcbiRegistry &registry)
Definition: settings.cpp:287
size_t m_MyNCBIErrorCacheBackOffMs
Definition: settings.hpp:140
void x_ReadMyNCBISection(const CNcbiRegistry &registry)
Definition: settings.cpp:382
unsigned int m_ExcludeCacheMaxSize
Definition: settings.hpp:91
void Validate(CPSGAlerts &alerts)
Definition: settings.cpp:461
unsigned short m_TcpMaxConn
Definition: settings.hpp:57
void x_ReadAdminSection(const CNcbiRegistry &registry, CPSGAlerts &alerts)
Definition: settings.cpp:432
unsigned long m_TickSpan
Definition: settings.hpp:81
unsigned long m_SmallBlobSize
Definition: settings.hpp:76
size_t GetProcessorMaxConcurrency(const CNcbiRegistry &registry, const string &processor_id)
Definition: settings.cpp:810
void x_ReadSSLSection(const CNcbiRegistry &registry)
Definition: settings.cpp:319
size_t m_ProcessorMaxConcurrency
Definition: settings.hpp:65
unsigned int m_MaxRetries
Definition: settings.hpp:59
void x_ReadHealthSection(const CNcbiRegistry &registry)
Definition: settings.cpp:332
size_t m_ShutdownIfTooManyOpenFD
Definition: settings.hpp:67
unsigned int m_ListenerBacklog
Definition: settings.hpp:56
unsigned int m_ExcludeCacheInactivityPurge
Definition: settings.hpp:93
size_t m_MyNCBINotFoundCacheExpirationSec
Definition: settings.hpp:138
unsigned long m_SendBlobIfSmall
Definition: settings.hpp:60
void x_ReadLmdbCacheSection(const CNcbiRegistry &registry)
Definition: settings.cpp:276
void x_ReadCassandraProcessorSection(const CNcbiRegistry &registry)
Definition: settings.cpp:342
void x_ReadDebugSection(const CNcbiRegistry &registry)
Definition: settings.cpp:301
unsigned long m_NStatBins
Definition: settings.hpp:79
const unsigned long kNStatBins
Definition: timing.hpp:51
const unsigned long kMinStatValue
Definition: timing.hpp:49
const string kStatScaleType
Definition: timing.hpp:52
const unsigned long kMaxStatValue
Definition: timing.hpp:50
const unsigned long kTickSpan
Definition: timing.hpp:53
static wxAcceleratorEntry entries[3]
Modified on Tue Dec 05 02:09:59 2023 by modify_doxy.py rev. 669887