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

Go to the SVN repository for this file.

1 #ifndef NETSCHEDULE_SERVER_PARAMS__HPP
2 #define NETSCHEDULE_SERVER_PARAMS__HPP
3 
4 /* $Id: ns_server_params.hpp 84290 2018-10-31 14:21:21Z satskyse $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Anatoliy Kuznetsov, Victor Joukov
30  *
31  * File Description: [server] section of the configuration
32  *
33  */
34 
35 #include <corelib/ncbireg.hpp>
36 #include <connect/server.hpp>
37 
38 #include <string>
39 #include <limits>
40 
42 
43 
44 
45 #if defined(_DEBUG) && !defined(NDEBUG)
46 // error emulator parameters use the following format:
47 // F:Ff Fb-Fe
48 // F is a value (int, bool, double, etc)
49 // Ff is a frequency (int)
50 // Fb-Fe is a range of request number when it fails (integers or infinitum)
52 {
53  string value; // Could be int, bool or double, so here it is a
54  // generic string as read from the config file
55  int as_int; // 'value' as int
56  double as_double; // 'value' as double
57  bool as_bool; // 'value' as bool
58 
59  unsigned int frequency; // frequency with which the corresponding event
60  // is emulated
63 
64  void ReadInt(const IRegistry & reg,
65  const string & section,
66  const string & param_name);
67  void ReadDouble(const IRegistry & reg,
68  const string & section,
69  const string & param_name);
70  void ReadBool(const IRegistry & reg,
71  const string & section,
72  const string & param_name);
73 
75  value(""), as_int(-1), as_double(0.0), as_bool(false), frequency(1),
77  {}
78 
79  bool IsActive(void) const;
80 
81  private:
82  void x_ReadCommon(const IRegistry & reg,
83  const string & section,
84  const string & param_name);
85 };
86 #endif
87 
88 
89 // A set of parameters for a registry. Used for affinities, groups and scopes
91 {
92  // Max number of records in a registry
93  unsigned int max_records;
94 
95  // GC settings for a registry
96  unsigned int high_mark_percentage;
97  unsigned int low_mark_percentage;
98  unsigned int high_removal;
99  unsigned int low_removal;
100  unsigned int dirt_percentage;
101 
102  void Read(const IRegistry & reg,
103  const string & sname,
104  const string & name,
105  unsigned int default_max,
106  unsigned int default_high_mark_percentage,
107  unsigned int default_low_mark_percentage,
108  unsigned int default_high_removal,
109  unsigned int default_low_removal,
110  unsigned int default_dirt_percentage);
111  string Serialize(const string & name,
112  const string & prefix,
113  const string & suffix) const;
114 
115  private:
117  unsigned int default_high_mark_percentage,
118  unsigned int default_low_mark_percentage,
119  unsigned int default_high_removal,
120  unsigned int default_low_removal,
121  unsigned int default_dirt_percentage);
122 };
123 
124 
125 
126 // Parameters for server
128 {
129  unsigned short port;
130 
132  unsigned network_timeout;
133 
134  bool is_log;
140 
141  unsigned int del_batch_size; // Max number of jobs to be deleted
142  // from memory during one Purge() call
143  unsigned int markdel_batch_size; // Max number of jobs marked for deletion
144  unsigned int scan_batch_size; // Max number of jobs expiration checks
145  // during one Purge() call
146  double purge_timeout; // Timeout in seconds between
147  // Purge() calls
148  unsigned int stat_interval; // Interval between statistics output
149  unsigned int job_counters_interval;
150  unsigned int max_client_data; // Max (transient) client data size
151 
152  string admin_hosts;
156 
160 
161  unsigned int reserve_dump_space;
162 
163  string path;
164  unsigned int max_queues;
165  bool diskless;
166 
167  void Read(const IRegistry & reg);
168 
169  #if defined(_DEBUG) && !defined(NDEBUG)
171  // instead the real FDs
172  SErrorEmulatorParameter debug_mem_count; // # of used memory bytes
173  // instead the real value
175  // into socket
176 
177  // connection drops before writing into the client socket
179 
180  // connection drops before writing into the client socket
182 
183  // to send a specified garbage instead of the real response
186 
187  void ReadErrorEmulatorSection(const IRegistry & reg);
188  #endif
189 
190 
191  private:
193 };
194 
196 
197 #endif
198 
IRegistry –.
Definition: ncbireg.hpp:73
#define false
Definition: bool.h:36
#define numeric_limits
Pre-declaration of the "numeric_limits<>" template Forcibly overrides (using preprocessor) the origin...
Definition: ncbi_limits.hpp:92
uint32_t Uint4
4-byte (32-bit) unsigned integer
Definition: ncbitype.h:103
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Process information in the NCBI Registry, including working with configuration files.
T max(T x_, T y_)
Framework to create multithreaded network servers with thread-per-request scheduling.
void x_ReadCommon(const IRegistry &reg, const string &section, const string &param_name)
void ReadInt(const IRegistry &reg, const string &section, const string &param_name)
void ReadDouble(const IRegistry &reg, const string &section, const string &param_name)
void ReadBool(const IRegistry &reg, const string &section, const string &param_name)
string Serialize(const string &name, const string &prefix, const string &suffix) const
void x_CheckGarbageCollectorSettings(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)
unsigned int low_mark_percentage
unsigned int high_mark_percentage
void Read(const IRegistry &reg, const string &sname, 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)
SNSRegistryParameters group_reg
void x_CheckJobGarbageCollectorSettings(void)
string state_transition_perf_log_classes
unsigned int del_batch_size
SErrorEmulatorParameter debug_mem_count
unsigned int max_queues
string state_transition_perf_log_queues
SErrorEmulatorParameter debug_fd_count
unsigned int stat_interval
unsigned int markdel_batch_size
SErrorEmulatorParameter debug_write_delay
unsigned int reserve_dump_space
SNSRegistryParameters affinity_reg
unsigned short port
void ReadErrorEmulatorSection(const IRegistry &reg)
SErrorEmulatorParameter debug_conn_drop_after_write
SErrorEmulatorParameter debug_conn_drop_before_write
unsigned int scan_batch_size
SErrorEmulatorParameter debug_reply_with_garbage
unsigned int job_counters_interval
SNSRegistryParameters scope_reg
unsigned int max_client_data
void Read(const IRegistry &reg)
SServer_Parameters::
Definition: server.hpp:434
Modified on Wed Sep 04 15:02:39 2024 by modify_doxy.py rev. 669887