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

Go to the SVN repository for this file.

1 /* $Id: nst_server_parameters.cpp 71779 2016-03-29 16:10:07Z 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: Denis Vakatov
27  *
28  * File Description: [server] section of the configuration
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 
36 #include "nst_exception.hpp"
37 #include "nst_config.hpp"
38 #include "nst_constants.hpp"
39 
40 
42 
43 #define GetIntNoErr(name, dflt) \
44  reg.GetInt(sname, name, dflt, 0, IRegistry::eReturn)
45 #define GetBoolNoErr(name, dflt) \
46  reg.GetBool(sname, name, dflt, 0, IRegistry::eReturn)
47 
48 
49 
51  const string & sname,
52  string & decrypt_warning)
53 {
56 
58  if (init_threads > max_threads) {
59  ERR_POST(Warning <<
60  "INI file sets init_threads > max_threads. "
61  "Assume init_threads = max_threads(" << max_threads <<
62  ") instead of given " << init_threads);
64  }
65 
66  port = (unsigned short) GetIntNoErr("port", 0);
67  if (port <= 0 || port >= 65535)
68  NCBI_THROW(CNetStorageServerException, eInvalidArgument,
69  "Server listening port number is not specified "
70  "or invalid ([server]/port)");
71 
73  if (network_timeout == 0) {
74  ERR_POST(Warning <<
75  "INI file sets 0 sec. network timeout. Assume " <<
76  default_network_timeout << " seconds.");
78  }
79 
80  log = GetBoolNoErr("log", default_log);
81  log_timing_nst_api = GetBoolNoErr("log_timing_nst_api",
83  log_timing_client_socket = GetBoolNoErr("log_timing_client_socket",
85 
86 
87  // Deal with potentially encrypted admin client names
88  try {
90  sname, "admin_client_name",
92  } catch (const CRegistryException & ex) {
93  decrypt_warning = "[server]/admin_client_name "
94  "decrypting error detected. " + string(ex.what());
95  } catch (...) {
96  decrypt_warning = "[server]/admin_client_name "
97  "unknown decrypting error";
98  }
99 
100  string default_data_path = "./data." + NStr::NumericToString(port);
101  data_path = reg.GetString(sname, "data_path", default_data_path);
102 }
103 
CRegistryException –.
Definition: ncbireg.hpp:1005
IRegistry –.
Definition: ncbireg.hpp:73
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
void Warning(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1191
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 enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
unsigned int max_threads
Maximum simultaneous threads.
Definition: server.hpp:447
unsigned int max_connections
Maximum # of open connections.
Definition: server.hpp:436
unsigned int init_threads
Number of initial threads.
Definition: server.hpp:446
const unsigned int default_max_threads
const unsigned int default_init_threads
const unsigned int default_max_connections
const unsigned int default_network_timeout
const bool default_log_timing_nst_api
const bool default_log_timing_client_socket
const bool default_log
#define GetBoolNoErr(name, dflt)
#define GetIntNoErr(name, dflt)
Defines NCBI C++ secure resources API.
void Read(const IRegistry &reg, const string &sname, string &decrypt_warning)
Modified on Fri May 24 14:57:48 2024 by modify_doxy.py rev. 669887