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

Go to the SVN repository for this file.

1 /* $Id: ns_util.cpp 89004 2020-02-11 19:47:28Z 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: Victor Joukov
27  *
28  * File Description: Utility functions for NetSchedule
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
33 
34 #include "ns_util.hpp"
35 #include "ns_queue.hpp"
36 #include "ns_ini_params.hpp"
37 #include "ns_queue_parameters.hpp"
38 #include "queue_database.hpp"
39 #include <util/bitset/bmalgo.h>
40 #include <util/checksum.hpp>
41 #include <connect/ncbi_socket.hpp>
42 
43 #include <unistd.h>
44 
45 
47 
48 
49 static void NS_ValidateServerSection(const IRegistry & reg,
50  vector<string> & warnings,
51  bool throw_port_exception,
52  bool & decrypting_error);
53 static void NS_ValidateQueuesAndClasses(const IRegistry & reg,
54  list<string> & queues,
55  vector<string> & warnings);
56 static TQueueParams NS_ValidateClasses(const IRegistry & reg,
57  vector<string> & warnings);
58 static void NS_ValidateQueues(const IRegistry & reg,
59  const TQueueParams & qclasses,
60  list<string> & queues,
61  vector<string> & warnings);
62 static void NS_ValidateServiceToQueueSection(const IRegistry & reg,
63  const list<string> & queues,
64  vector<string> & warnings);
65 static string NS_OutOfLimitMessage(const string & section,
66  const string & entry,
67  unsigned int low_limit,
68  unsigned int high_limit);
69 static void
71  const string & section,
72  const string & name,
73  unsigned int default_max,
74  unsigned int default_high_mark_percentage,
75  unsigned int default_low_mark_percentage,
76  unsigned int default_high_removal,
77  unsigned int default_low_removal,
78  unsigned int default_dirt_percentage,
79  vector<string> & warnings);
80 
81 
82 // Forms the ini file value name for warnings
83 string NS_RegValName(const string & section, const string & entry)
84 {
85  return "[" + section + "]/" + entry;
86 }
87 
88 bool NS_ValidateDouble(const IRegistry & reg,
89  const string & section, const string & entry,
90  vector<string> & warnings)
91 {
92  try {
93  reg.GetDouble(section, entry, 0.0);
94  } catch (...) {
95  warnings.push_back(g_WarnPrefix + NS_RegValName(section, entry) +
96  ". Expected a floating point value.");
97  return false;
98  }
99  return true;
100 }
101 
102 bool NS_ValidateBool(const IRegistry & reg,
103  const string & section, const string & entry,
104  vector<string> & warnings)
105 {
106  try {
107  reg.GetBool(section, entry, false);
108  } catch (...) {
109  warnings.push_back(g_WarnPrefix + NS_RegValName(section, entry) +
110  ". Expected boolean value.");
111  return false;
112  }
113  return true;
114 }
115 
116 bool NS_ValidateInt(const IRegistry & reg,
117  const string & section, const string & entry,
118  vector<string> & warnings)
119 {
120  try {
121  reg.GetInt(section, entry, 0);
122  } catch (...) {
123  warnings.push_back(g_WarnPrefix + NS_RegValName(section, entry) +
124  ". Expected integer value.");
125  return false;
126  }
127  return true;
128 }
129 
130 bool NS_ValidateString(const IRegistry & reg,
131  const string & section, const string & entry,
132  vector<string> & warnings)
133 {
134  try {
135  reg.GetString(section, entry, "");
136  } catch (...) {
137  warnings.push_back(g_WarnPrefix + NS_RegValName(section, entry) +
138  ". Expected string value.");
139  return false;
140  }
141  return true;
142 }
143 
144 
146  const string & section, const string & entry,
147  vector<string> & warnings)
148 {
149  if (!reg.HasEntry(section, entry))
150  return true;
151 
152  try {
153  CConfig conf(reg);
154  const CConfig::TParamTree * param_tree = conf.GetTree();
155  const TPluginManagerParamTree * section_tree =
156  param_tree->FindSubNode(section);
157 
158  if (!section_tree)
159  return true; // Section not found
160 
161  CConfig c((CConfig::TParamTree*)section_tree, eNoOwnership);
162  c.GetDataSize("netschedule", entry, CConfig::eErr_Throw, 0);
163  } catch (...) {
164  warnings.push_back(g_WarnPrefix + NS_RegValName(section, entry) +
165  ". Expected data size value.");
166  return false;
167  }
168  return true;
169 }
170 
171 
172 unsigned int NS_GetDataSize(const IRegistry & reg,
173  const string & section, const string & entry,
174  unsigned int default_val)
175 {
176  CConfig conf(reg);
177  const CConfig::TParamTree * param_tree = conf.GetTree();
178  const TPluginManagerParamTree * section_tree =
179  param_tree->FindSubNode(section);
180 
181  if (!section_tree)
182  return default_val;
183 
184  CConfig c((CConfig::TParamTree*)section_tree, eNoOwnership);
185  return c.GetDataSize("netschedule", entry, CConfig::eErr_NoThrow,
186  default_val);
187 }
188 
189 
190 void NS_ValidateConfigFile(const IRegistry & reg, vector<string> & warnings,
191  bool throw_port_exception,
192  bool & decrypting_error)
193 {
194  list<string> queues;
195 
196  NS_ValidateServerSection(reg, warnings, throw_port_exception,
197  decrypting_error);
198  NS_ValidateQueuesAndClasses(reg, queues, warnings);
199  NS_ValidateServiceToQueueSection(reg, queues, warnings);
200 }
201 
202 
203 // Populates the warnings list if there are problems
205  vector<string> & warnings,
206  bool throw_port_exception,
207  bool & decrypting_error)
208 {
209  const string section = "server";
210 
211  // port is a unique value in this section. NS must not start
212  // if there is a problem with port.
213  bool ok = NS_ValidateInt(reg, section, "port", warnings);
214  if (ok) {
215  int port_val = reg.GetInt(section, "port", 0);
216  if (port_val < port_low_limit || port_val > port_high_limit) {
217  string msg = "Invalid " + NS_RegValName(section, "port") +
218  " value. Allowed range: " +
219  to_string(port_low_limit) +
220  " to " + to_string(port_high_limit);
221  if (throw_port_exception)
222  NCBI_THROW(CNetScheduleException, eInvalidParameter, msg);
223  warnings.push_back(msg);
224  }
225  } else {
226  if (throw_port_exception)
227  NCBI_THROW(CNetScheduleException, eInvalidParameter,
228  "Invalid " + NS_RegValName(section, "port") +
229  " parameter.");
230  }
231 
232  ok = NS_ValidateInt(reg, section, "max_connections", warnings);
233  if (ok) {
234  int val = reg.GetInt(section, "max_connections",
236  if (val < int(max_connections_low_limit) ||
238  string message = NS_OutOfLimitMessage(section, "max_connections",
241  // See the logic in SNS_Parameters::Read()::ns_server_params.cpp
242  if (val < int(max_connections_low_limit))
243  message += " Value " + to_string(
246  else
247  message += " Value " + to_string(max_connections_high_limit);
248  warnings.push_back(message + " will be used when restarted");
249  }
250  }
251 
252  ok = NS_ValidateInt(reg, section, "max_threads", warnings);
253  unsigned int max_threads_val = default_max_threads;
254  if (ok) {
255  int val = reg.GetInt(section, "max_threads", default_max_threads);
256  if (val < int(max_threads_low_limit) ||
258  warnings.push_back(NS_OutOfLimitMessage(section, "max_threads",
261  else
262  max_threads_val = val;
263  }
264 
265  ok = NS_ValidateInt(reg, section, "init_threads", warnings);
266  unsigned int init_threads_val = default_init_threads;
267  if (ok) {
268  int val = reg.GetInt(section, "init_threads", default_init_threads);
269  if (val < int(init_threads_low_limit) ||
271  warnings.push_back(NS_OutOfLimitMessage(section, "init_threads",
274  else
275  init_threads_val = val;
276  }
277 
278  if (init_threads_val > max_threads_val)
279  warnings.push_back(g_ValidPrefix + "values " +
280  NS_RegValName(section, "max_threads") + " and " +
281  NS_RegValName(section, "init_threads") +
282  " break the mandatory condition "
283  "init_threads <= max_threads");
284 
285 
286  NS_ValidateBool(reg, section, "use_hostname", warnings);
287 
288  ok = NS_ValidateInt(reg, section, "network_timeout", warnings);
289  if (ok) {
290  int val = reg.GetInt(section, "network_timeout",
292  if (val <= 0)
293  warnings.push_back(g_ValidPrefix + "value " +
294  NS_RegValName(section, "network_timeout") +
295  " must be > 0");
296  }
297 
298  ok = NS_ValidateInt(reg, section, "max_queues", warnings);
299  if (ok) {
300  int val = reg.GetInt(section, "max_queues",
302  if (val <= 0)
303  warnings.push_back(g_ValidPrefix + "value " +
304  NS_RegValName(section, "max_queues") +
305  " must be > 0");
306  }
307 
308  NS_ValidateBool(reg, section, "log", warnings);
309  NS_ValidateBool(reg, section, "log_batch_each_job", warnings);
310  NS_ValidateBool(reg, section, "log_notification_thread", warnings);
311  NS_ValidateBool(reg, section, "log_cleaning_thread", warnings);
312  NS_ValidateBool(reg, section, "log_execution_watcher_thread", warnings);
313  NS_ValidateBool(reg, section, "log_statistics_thread", warnings);
314  NS_ValidateBool(reg, section, "diskless", warnings);
315 
316 
317  ok = NS_ValidateInt(reg, section, "del_batch_size", warnings);
318  unsigned int del_batch_size_val = default_del_batch_size;
319  if (ok) {
320  int val = reg.GetInt(section, "del_batch_size",
322  if (val <= 0)
323  warnings.push_back(g_ValidPrefix + "value " +
324  NS_RegValName(section, "del_batch_size") +
325  " must be > 0");
326  else
327  del_batch_size_val = val;
328  }
329 
330  ok = NS_ValidateInt(reg, section, "markdel_batch_size", warnings);
331  unsigned int markdel_batch_size_val = default_markdel_batch_size;
332  if (ok) {
333  int val = reg.GetInt(section, "markdel_batch_size",
335  if (val <= 0)
336  warnings.push_back(g_ValidPrefix + "value " +
337  NS_RegValName(section, "markdel_batch_size") +
338  " must be > 0");
339  else
340  markdel_batch_size_val = val;
341  }
342 
343  ok = NS_ValidateInt(reg, section, "scan_batch_size", warnings);
344  unsigned int scan_batch_size_val = default_scan_batch_size;
345  if (ok) {
346  int val = reg.GetInt(section, "scan_batch_size",
348  if (val <= 0)
349  warnings.push_back(g_ValidPrefix + "value " +
350  NS_RegValName(section, "scan_batch_size") +
351  " must be > 0");
352  else
353  scan_batch_size_val = val;
354  }
355 
356  ok = NS_ValidateDouble(reg, section, "purge_timeout", warnings);
357  if (ok) {
358  double val = reg.GetDouble(section, "purge_timeout",
360  if (val <= 0.0)
361  warnings.push_back(g_ValidPrefix + "value " +
362  NS_RegValName(section, "purge_timeout") +
363  " must be > 0");
364  }
365 
366  if (scan_batch_size_val < markdel_batch_size_val)
367  warnings.push_back(g_ValidPrefix + "values " +
368  NS_RegValName(section, "scan_batch_size") + " and " +
369  NS_RegValName(section, "markdel_batch_size") +
370  " break the mandatory condition "
371  "markdel_batch_size <= scan_batch_size");
372 
373  if (markdel_batch_size_val < del_batch_size_val)
374  warnings.push_back(g_ValidPrefix + "values " +
375  NS_RegValName(section, "markdel_batch_size") + " and " +
376  NS_RegValName(section, "del_batch_size") +
377  " break the mandatory condition "
378  "del_batch_size <= markdel_batch_size");
379 
380 
381  ok = NS_ValidateInt(reg, section, "stat_interval", warnings);
382  if (ok) {
383  int val = reg.GetInt(section, "stat_interval",
385  if (val <= 0)
386  warnings.push_back(g_ValidPrefix + "value " +
387  NS_RegValName(section, "stat_interval") +
388  " must be > 0");
389  }
390 
391  ok = NS_ValidateInt(reg, section, "job_counters_interval", warnings);
392  if (ok) {
393  int val = reg.GetInt(section, "job_counters_interval",
395  if (val < 0)
396  warnings.push_back(g_ValidPrefix + "value " +
397  NS_RegValName(section, "job_counters_interval") +
398  " must be >= 0");
399  }
400 
401  ok = NS_ValidateInt(reg, section, "max_client_data", warnings);
402  if (ok) {
403  int val = reg.GetInt(section, "max_client_data",
405  if (val <= 0)
406  warnings.push_back(g_ValidPrefix + "value " +
407  NS_RegValName(section, "max_client_data") +
408  " must be > 0");
409  }
410 
411 
412  NS_ValidateRegistrySettings(reg, section, "affinity",
419  warnings);
420  NS_ValidateRegistrySettings(reg, section, "group",
427  warnings);
428  NS_ValidateRegistrySettings(reg, section, "scope",
435  warnings);
436 
437  NS_ValidateString(reg, section, "admin_host", warnings);
438  NS_ValidateString(reg, section,
439  "state_transition_perf_log_queues", warnings);
440  NS_ValidateString(reg, section,
441  "state_transition_perf_log_classes", warnings);
442 
443  // Instead of just validating the administrator names we try to read them
444  decrypting_error = false;
445  try {
446  reg.GetEncryptedString(section, "admin_client_name",
448  } catch (const CRegistryException & ex) {
449  warnings.push_back(g_ValidPrefix +
450  NS_RegValName(section, "admin_client_name") +
451  " decrypting error detected. " +
452  string(ex.what()));
453  decrypting_error = true;
454  } catch (...) {
455  warnings.push_back(g_ValidPrefix +
456  NS_RegValName(section, "admin_client_name") +
457  " unknown decrypting error");
458  decrypting_error = true;
459  }
460 
461  NS_ValidateDataSize(reg, section, "reserve_dump_space", warnings);
462 }
463 
464 
465 // Populates the warnings list if there are problems in the config file
466 // the queues parameter is filled with what queues will be accepted
468  list<string> & queues,
469  vector<string> & warnings)
470 {
471  TQueueParams qclasses;
472 
473  qclasses = NS_ValidateClasses(reg, warnings);
474  NS_ValidateQueues(reg, qclasses, queues, warnings);
475 }
476 
477 
479  vector<string> & warnings)
480 {
481  TQueueParams queue_classes;
482  list<string> sections;
483 
484  reg.EnumerateSections(&sections);
485 
486  ITERATE(list<string>, it, sections) {
487  string queue_class;
488  string prefix;
489  const string & section_name = *it;
490 
491  NStr::SplitInTwo(section_name, "_", prefix, queue_class);
492  if (NStr::CompareNocase(prefix, "qclass") != 0)
493  continue;
494  if (queue_class.empty()) {
495  warnings.push_back(g_ValidPrefix + "section " + section_name +
496  " does not have a queue class name");
497  continue;
498  }
499  if (queue_class.size() > kMaxQueueNameSize - 1) {
500  warnings.push_back(g_ValidPrefix + "section " + section_name +
501  " introduces a queue class which name length"
502  " exceeds the max allowed lenght of " +
503  to_string(kMaxQueueNameSize - 1) + " bytes");
504  continue;
505  }
506 
507  SQueueParameters params;
508  if (params.ReadQueueClass(reg, section_name, warnings)) {
509  // false => problems with linked sections; see CXX-2617
510  // The same sections cannot appear twice
511  queue_classes[queue_class] = params;
512  }
513  }
514 
515  return queue_classes;
516 }
517 
518 
519 // Returns true if the config file is well formed
520 void NS_ValidateQueues(const IRegistry & reg,
521  const TQueueParams & qclasses,
522  list<string> & queues,
523  vector<string> & warnings)
524 {
525  list<string> sections;
526 
527  reg.EnumerateSections(&sections);
528  for (list<string>::const_iterator k = sections.begin();
529  k != sections.end(); ++k) {
530  string queue_name;
531  string prefix;
532  string section_name = *k;
533 
534  NStr::SplitInTwo(section_name, "_", prefix, queue_name);
535  if (NStr::CompareNocase(prefix, "queue") != 0)
536  continue;
537 
538  if (queue_name.empty()) {
539  warnings.push_back(g_ValidPrefix + "section " + section_name +
540  " does not have a queue name");
541  continue;
542  }
543  if (queue_name.size() > kMaxQueueNameSize - 1) {
544  warnings.push_back(g_ValidPrefix + "section " + section_name +
545  " introduces a queue which name length"
546  " exceeds the max allowed lenght of " +
547  to_string(kMaxQueueNameSize - 1) + " bytes");
548  continue;
549  }
550 
551  SQueueParameters params;
552  if (params.ReadQueue(reg, section_name, qclasses, warnings)) {
553  // false => problems with linked sections; see CXX-2617
554  queues.push_back(queue_name);
555  }
556  }
557 }
558 
559 
560 // Returns true if the config file is well formed
562  const list<string> & queues,
563  vector<string> & warnings)
564 {
565  const string section = "service_to_queue";
566  list<string> entries;
567  reg.EnumerateEntries(section, &entries);
568 
569  for (list<string>::const_iterator k = entries.begin();
570  k != entries.end(); ++k) {
571  string service_name = *k;
572  string qname = reg.Get(section, service_name);
573  if (qname.empty()) {
574  warnings.push_back(g_ValidPrefix +
575  NS_RegValName(section, service_name) +
576  " does not specify a queue name");
577  continue;
578  }
579 
580  // Check that the queue name has been provided
581  if (find(queues.begin(), queues.end(), qname) == queues.end())
582  warnings.push_back(g_ValidPrefix +
583  NS_RegValName(section, service_name) +
584  " does not point to an existing static queue");
585  }
586 }
587 
588 
589 // Forms an out of limits message
590 string NS_OutOfLimitMessage(const string & section,
591  const string & entry,
592  unsigned int low_limit,
593  unsigned int high_limit)
594 {
595  return g_ValidPrefix + NS_RegValName(section, entry) +
596  " is out of limits (" + to_string(low_limit) + "..." +
597  to_string(high_limit) + ")";
598 
599 }
600 
601 
602 static const string s_ErrorGettingChecksum = "error detected";
603 
604 
605 string NS_GetConfigFileChecksum(const string & file_name,
606  vector<string> & warnings)
607 {
608  // Note: at the time of writing the ComputeFileCRC32() function does not
609  // generate exceptions at least in some error cases e.g. if there
610  // is no file. Therefore some manual checks are introduced here:
611  // - the file exists
612  // - there are read permissions for it
613  // Technically speaking it is not 100% guarantee because the file could be
614  // replaced between the checks and the sum culculation but it is better
615  // than nothing.
616 
617  if (access(file_name.c_str(), F_OK) != 0) {
618  warnings.push_back("Error computing config file checksum, "
619  "the file does not exist: " + file_name);
620  return s_ErrorGettingChecksum;
621  }
622 
623  if (access(file_name.c_str(), R_OK) != 0) {
624  warnings.push_back("Error computing config file checksum, "
625  "there are no read permissions: " + file_name);
626  return s_ErrorGettingChecksum;
627  }
628 
629  try {
630  string checksum_as_string;
631  CChecksum checksum(CChecksum::eMD5);
632 
633  checksum.AddFile(file_name);
634  checksum.GetMD5Digest(checksum_as_string);
635  return checksum_as_string;
636  } catch (const exception & ex) {
637  warnings.push_back("Error computing config file checksum. " +
638  string(ex.what()));
639  return s_ErrorGettingChecksum;
640  } catch (...) {
641  warnings.push_back("Unknown error of computing config file checksum");
642  return s_ErrorGettingChecksum;
643  }
644  return s_ErrorGettingChecksum;
645 }
646 
647 
649  const string & section,
650  const string & name,
651  unsigned int default_max,
652  unsigned int default_high_mark_percentage,
653  unsigned int default_low_mark_percentage,
654  unsigned int default_high_removal,
655  unsigned int default_low_removal,
656  unsigned int default_dirt_percentage,
657  vector<string> & warnings)
658 {
659  bool ok = true;
660  string plural;
661 
662  if (name == "affinity")
663  plural = "affinities";
664  else
665  plural = name + "s";
666 
667 
668  ok = NS_ValidateInt(reg, section, "max_" + plural, warnings);
669  if (ok) {
670  int val = reg.GetInt(section, "max_" + plural, default_max);
671  if (val <= 0)
672  warnings.push_back(g_ValidPrefix + "value " +
673  NS_RegValName(section, "max_" + plural) +
674  " must be > 0");
675  }
676 
677  ok = NS_ValidateInt(reg, section, name + "_high_mark_percentage",
678  warnings);
679  unsigned int high_mark_percentage_val =
680  default_high_mark_percentage;
681  if (ok) {
682  int val = reg.GetInt(section, name + "_high_mark_percentage",
683  default_high_mark_percentage);
684  if (val <= 0 || val >= 100)
685  warnings.push_back(g_ValidPrefix + "value " +
686  NS_RegValName(section, name + "_high_mark_percentage") +
687  " must be between 0 and 100");
688  else
689  high_mark_percentage_val = val;
690  }
691 
692  ok = NS_ValidateInt(reg, section, name + "_low_mark_percentage",
693  warnings);
694  unsigned int low_mark_percentage_val =
695  default_low_mark_percentage;
696  if (ok) {
697  int val = reg.GetInt(section, name + "_low_mark_percentage",
698  default_low_mark_percentage);
699  if (val <= 0 || val >= 100)
700  warnings.push_back(g_ValidPrefix + "value " +
701  NS_RegValName(section, name + "_low_mark_percentage") +
702  " must be between 0 and 100");
703  else
704  low_mark_percentage_val = val;
705  }
706 
707  ok = NS_ValidateInt(reg, section, name + "_high_removal", warnings);
708  unsigned int high_removal_val = default_high_removal;
709  if (ok) {
710  int val = reg.GetInt(section, name + "_high_removal",
711  default_high_removal);
712  if (val <= 0)
713  warnings.push_back(g_ValidPrefix + "value " +
714  NS_RegValName(section, name + "_high_removal") +
715  " must be > 0");
716  else
717  high_removal_val = val;
718  }
719 
720  ok = NS_ValidateInt(reg, section, name + "_low_removal", warnings);
721  unsigned int low_removal_val = default_low_removal;
722  if (ok) {
723  int val = reg.GetInt(section, name + "_low_removal",
724  default_low_removal);
725  if (val <= 0)
726  warnings.push_back(g_ValidPrefix + "value " +
727  NS_RegValName(section, name + "_low_removal") +
728  " must be > 0");
729  else
730  low_removal_val = val;
731  }
732 
733  ok = NS_ValidateInt(reg, section, name + "_dirt_percentage", warnings);
734  unsigned int dirt_percentage_val = default_dirt_percentage;
735  if (ok) {
736  int val = reg.GetInt(section, name + "_dirt_percentage",
737  default_dirt_percentage);
738  if (val <= 0 || val >= 100)
739  warnings.push_back(g_ValidPrefix + "value " +
740  NS_RegValName(section, name + "_dirt_percentage") +
741  " must be between 0 and 100");
742  else
743  dirt_percentage_val = val;
744  }
745 
746  if (low_mark_percentage_val >= high_mark_percentage_val)
747  warnings.push_back(g_ValidPrefix + "values " +
748  NS_RegValName(section, name + "_low_mark_percentage") +
749  " and " +
750  NS_RegValName(section, name + "_high_mark_percentage") +
751  " break the mandatory condition " +
752  name + "_low_mark_percentage < " +
753  name + "_high_mark_percentage");
754 
755  if (dirt_percentage_val >= low_mark_percentage_val)
756  warnings.push_back(g_ValidPrefix + "values " +
757  NS_RegValName(section, name + "_low_mark_percentage") +
758  " and " +
759  NS_RegValName(section, name + "_dirt_percentage") +
760  " break the mandatory condition " +
761  name + "_dirt_percentage < " +
762  name + "_low_mark_percentage");
763 
764  if (high_removal_val < low_removal_val)
765  warnings.push_back(g_ValidPrefix + "values " +
766  NS_RegValName(section, name + "_high_removal") +
767  " and " +
768  NS_RegValName(section, name + "_low_removal") +
769  " break the mandatory condition " +
770  name + "_low_removal <= " +
771  name + "_high_removal");
772 }
773 
774 
776 
Algorithms for bvector<> (main include)
Checksum and hash calculation classes.
CChecksum – Checksum calculator.
Definition: checksum.hpp:302
NetSchedule internal exception.
CRegistryException –.
Definition: ncbireg.hpp:1005
definition of a Culling tree
Definition: ncbi_tree.hpp:100
IRegistry –.
Definition: ncbireg.hpp:73
const char * file_name[]
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
@ eNoOwnership
No ownership is assumed.
Definition: ncbi_types.h:135
void AddFile(const string &file_path)
Update checksum with the file data.
Definition: checksum.cpp:373
void GetMD5Digest(unsigned char digest[16]) const
Return calculated MD5 digest.
Definition: checksum.hpp:637
#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.
@ eErr_Throw
Throw an exception 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 void EnumerateSections(list< string > *sections, TFlags flags=fAllLayers) const
Enumerate section names.
Definition: ncbireg.cpp:497
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
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
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:3554
const TTreeType * FindSubNode(const TKeyType &key) const
Non recursive linear scan of all subnodes, with key comparison.
Definition: ncbi_tree.hpp:940
const unsigned short port_high_limit
const unsigned int default_group_low_removal
const unsigned int default_affinity_low_mark_percentage
const unsigned int default_group_dirt_percentage
const unsigned int default_max_threads
const unsigned int default_scope_high_removal
const unsigned int default_scope_high_mark_percentage
const double default_purge_timeout
const unsigned int default_group_high_mark_percentage
const unsigned int default_init_threads
const unsigned int default_stat_interval
const unsigned int default_max_scopes
const unsigned int default_max_client_data
const unsigned int default_max_groups
const unsigned int default_group_high_removal
const unsigned short port_low_limit
const unsigned int default_group_low_mark_percentage
const unsigned int default_scope_low_removal
const unsigned int default_markdel_batch_size
const unsigned int default_max_queues
const unsigned int max_threads_high_limit
const unsigned int default_affinity_low_removal
const unsigned int default_affinity_high_mark_percentage
const unsigned int default_del_batch_size
const unsigned int default_job_counters_interval
const unsigned int default_scope_low_mark_percentage
const unsigned int max_connections_low_limit
const unsigned int default_max_connections
const unsigned int default_affinity_high_removal
const unsigned int default_max_affinities
const unsigned int default_scope_dirt_percentage
const unsigned int max_threads_low_limit
const unsigned int init_threads_high_limit
const unsigned int init_threads_low_limit
const unsigned int max_connections_high_limit
const unsigned int default_affinity_dirt_percentage
const unsigned int default_scan_batch_size
const unsigned int default_network_timeout
const unsigned kMaxQueueNameSize
Definition: ns_types.hpp:108
bool NS_ValidateDouble(const IRegistry &reg, const string &section, const string &entry, vector< string > &warnings)
Definition: ns_util.cpp:88
void NS_ValidateConfigFile(const IRegistry &reg, vector< string > &warnings, bool throw_port_exception, bool &decrypting_error)
Definition: ns_util.cpp:190
bool NS_ValidateBool(const IRegistry &reg, const string &section, const string &entry, vector< string > &warnings)
Definition: ns_util.cpp:102
static void NS_ValidateRegistrySettings(const IRegistry &reg, const string &section, const string &name, unsigned int default_max, unsigned int default_high_mark_percentage, unsigned int default_low_mark_percentage, unsigned int default_high_removal, unsigned int default_low_removal, unsigned int default_dirt_percentage, vector< string > &warnings)
Definition: ns_util.cpp:648
static void NS_ValidateQueuesAndClasses(const IRegistry &reg, list< string > &queues, vector< string > &warnings)
Definition: ns_util.cpp:467
string NS_RegValName(const string &section, const string &entry)
Definition: ns_util.cpp:83
static string NS_OutOfLimitMessage(const string &section, const string &entry, unsigned int low_limit, unsigned int high_limit)
Definition: ns_util.cpp:590
string NS_GetConfigFileChecksum(const string &file_name, vector< string > &warnings)
Definition: ns_util.cpp:605
unsigned int NS_GetDataSize(const IRegistry &reg, const string &section, const string &entry, unsigned int default_val)
Definition: ns_util.cpp:172
static const string s_ErrorGettingChecksum
Definition: ns_util.cpp:602
static TQueueParams NS_ValidateClasses(const IRegistry &reg, vector< string > &warnings)
Definition: ns_util.cpp:478
static void NS_ValidateServiceToQueueSection(const IRegistry &reg, const list< string > &queues, vector< string > &warnings)
Definition: ns_util.cpp:561
static void NS_ValidateServerSection(const IRegistry &reg, vector< string > &warnings, bool throw_port_exception, bool &decrypting_error)
Definition: ns_util.cpp:204
static void NS_ValidateQueues(const IRegistry &reg, const TQueueParams &qclasses, list< string > &queues, vector< string > &warnings)
Definition: ns_util.cpp:520
bool NS_ValidateInt(const IRegistry &reg, const string &section, const string &entry, vector< string > &warnings)
Definition: ns_util.cpp:116
bool NS_ValidateDataSize(const IRegistry &reg, const string &section, const string &entry, vector< string > &warnings)
Definition: ns_util.cpp:145
bool NS_ValidateString(const IRegistry &reg, const string &section, const string &entry, vector< string > &warnings)
Definition: ns_util.cpp:130
const string g_WarnPrefix
Definition: ns_util.hpp:47
const string g_ValidPrefix
Definition: ns_util.hpp:46
static const char * prefix[]
Definition: pcregrep.c:405
bool ReadQueueClass(const IRegistry &reg, const string &sname, vector< string > &warnings)
bool ReadQueue(const IRegistry &reg, const string &sname, const map< string, SQueueParameters, PNocase > &queue_classes, vector< string > &warnings)
static wxAcceleratorEntry entries[3]
Modified on Sun Apr 14 05:25:43 2024 by modify_doxy.py rev. 669887