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

Go to the SVN repository for this file.

1 #ifndef CONNECT_SERVICES___NETCACHE_API_IMPL__HPP
2 #define CONNECT_SERVICES___NETCACHE_API_IMPL__HPP
3 
4 /* $Id: netcache_api_impl.hpp 87146 2019-07-30 15:47:21Z sadyrovr $
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  * Author: Dmitry Kazimirov
30  *
31  * File Description:
32  */
33 
34 #include "netcache_rw.hpp"
35 #include "netservice_api_impl.hpp"
37 
39 
41 {
45  {
46  }
47 
49 
51  bool mirrored;
52 };
53 
55 {
56 public:
57  void SetAuthString(const string& auth) { m_Auth = auth; }
58 
59  TPropCreator GetPropCreator() const override;
61 
62  void OnConnected(CNetServerConnection& connection) override;
63 
64 private:
65  void OnErrorImpl(const string& err_msg, CNetServer& server) override;
66  void OnWarningImpl(const string& warn_msg, CNetServer& server) override;
67 
68  string m_Auth;
69 };
70 
72 {
73  SNetCacheAPIImpl(CSynRegistryBuilder registry_builder, const string& section,
74  const string& service, const string& client_name,
76 
77  // For use by SNetICacheClientImpl
79 
80  // Special constructor for CNetCacheAPI::GetServer().
82 
84  {
85  return static_cast<CNetCacheServerListener*>(m_Service->m_Listener.GetPointer());
86  }
87 
88  CNetCacheReader* GetPartReader(
89  const string& blob_id,
90  size_t offset,
91  size_t part_size,
92  size_t* blob_size,
93  const CNamedParameterList* optional);
94 
95  static CNetCacheAPI::EReadResult ReadBuffer(
96  IReader& reader,
97  char* buf_ptr,
98  size_t buf_size,
99  size_t* n_read,
100  size_t blob_size);
101 
102  virtual CNetServerConnection InitiateWriteCmd(CNetCacheWriter* nc_writer,
103  const CNetCacheAPIParameters* parameters);
104 
105  void AppendClientIPSessionID(string* cmd, CRequestContext& req);
106  void AppendHitID(string* cmd, CRequestContext& req);
107  void AppendClientIPSessionIDHitID(string* cmd);
108  void AppendClientIPSessionIDPasswordAgeHitID(string* cmd,
109  const CNetCacheAPIParameters* parameters);
110  string MakeCmd(const char* cmd_base, const CNetCacheKey& key,
111  const CNetCacheAPIParameters* parameters);
112 
113  unsigned x_ExtractBlobAge(const CNetServer::SExecResult& exec_result,
114  const char* cmd_name);
115 
116  CNetServer::SExecResult ExecMirrorAware(
117  const CNetCacheKey& key, const string& cmd,
118  bool multiline_output,
119  const CNetCacheAPIParameters* parameters,
122 
123  void Init(CSynRegistry& registry, const SRegSynonyms& sections);
124 
126 
128 
129  string m_TempDir;
132 
134 
136 
138 
139  size_t m_FlagsOnWrite = 0;
140 };
141 
143 {
144  SNetCacheAdminImpl(SNetCacheAPIImpl* nc_api_impl) : m_API(nc_api_impl) {}
145 
146  void ExecOnAllServers(string cmd);
147  void PrintCmdOutput(string cmd, CNcbiOstream& output_stream, bool multiline_output = true);
148 
150 };
151 
153 {
154 public:
156  CNetServer::TInstance primary_server, ESwitch server_check) :
157  m_Service(service),
158  m_PrimaryServer(primary_server),
159  m_PrimaryServerCheck(server_check != eOff)
160  {
161  }
162 
163  virtual CNetServer BeginIteration();
164  virtual CNetServer NextServer();
165 
170 };
171 
172 namespace grid {
173 namespace netcache {
174 namespace search {
175 
176 NCBI_XCONNECT_EXPORT CExpression operator+(CExpression l, CFields r);
177 NCBI_XCONNECT_EXPORT ostream& operator<<(ostream& os, CExpression expression);
178 NCBI_XCONNECT_EXPORT void operator<<(CBlobInfo& blob_info, string data);
179 
180 }
181 }
182 }
183 
185 
186 #endif /* CONNECT_SERVICES___NETCACHE_API_IMPL__HPP */
Pool of recycled CCompoundID objects.
CFastMutex –.
Definition: ncbimtx.hpp:667
Client API for NetCache server.
void SetAuthString(const string &auth)
Client API for NCBI NetSchedule server.
CObject –.
Definition: ncbiobj.hpp:180
A very basic data-read interface.
CNetServer::TInstance m_PrimaryServer
CNetServiceIterator m_Iterator
SNetCacheMirrorTraversal(CNetService::TInstance service, CNetServer::TInstance primary_server, ESwitch server_check)
static CMemoryRegistry registry
Definition: cn3d_tools.cpp:81
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define false
Definition: bool.h:36
static void Init(void)
Definition: cursor6.c:76
int offset
Definition: replacements.h:160
char data[12]
Definition: iconv.c:80
EReadResult
Status of GetData() call.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
enum ENcbiSwitch ESwitch
Aux.
#define NCBI_XCONNECT_EXPORT
CExpression operator+(CExpression l, CFields r)
ostream & operator<<(ostream &os, CExpression expression)
const struct ncbi::grid::netcache::search::fields::KEY key
NetCache client specs.
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
Meaningful information encoded in the NetCache key.
virtual TPropCreator GetPropCreator() const
virtual void OnErrorImpl(const string &err_msg, CNetServer &server)=0
virtual INetServerConnectionListener * Clone()=0
virtual void OnConnected(CNetServerConnection &connection)=0
virtual void OnWarningImpl(const string &warn_msg, CNetServer &server)=0
CNetCacheServerListener * GetListener()
CNetCacheAPIParameters m_DefaultParameters
SNetServiceMap m_ServiceMap
CNetScheduleAPI m_NetScheduleAPI
CCompoundIDPool m_CompoundIDPool
SNetCacheAdminImpl(SNetCacheAPIImpl *nc_api_impl)
void ExecOnAllServers(string cmd)
void PrintCmdOutput(string cmd, CNcbiOstream &output_stream, bool multiline_output=true)
Modified on Wed Jul 17 13:19:09 2024 by modify_doxy.py rev. 669887