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

Go to the SVN repository for this file.

1 #ifndef CONNECT_SERVICES_IMPL__NETSTORAGE_INT__HPP
2 #define CONNECT_SERVICES_IMPL__NETSTORAGE_INT__HPP
3 
4 /* $Id: netstorage_int.hpp 91249 2020-09-30 19:12:51Z 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  * NetStorage implementation declarations.
33  *
34  */
35 
38 
39 #include <corelib/ncbimisc.hpp>
40 
42 
43 /// @internal
44 template <TNetStorageFlags MASK>
46 {
48 public:
50  TSelf& operator &=(TSelf flag) { m_Flags &= flag; return *this; }
51  TSelf& operator |=(TSelf flag) { m_Flags |= flag; return *this; }
52  TSelf& operator ^=(TSelf flag) { m_Flags ^= flag; return *this; }
53  operator TNetStorageFlags() const { return m_Flags; }
54 
55 private:
57 };
58 
61 
62 /// @internal
64 {
65 public:
67 
69  eFileTrack_ProdSite = 0,
72  eNumberOfFileTrackSites
73  };
74 
77  const string& app_domain,
78  Uint8 random_number,
79  EFileTrackSite ft_site);
82  const string& app_domain,
83  const string& unique_key,
84  EFileTrackSite ft_site);
86  const string& object_loc);
87 
88  void SetServiceName(const string& service_name);
89 
90  bool HasServiceName() const {return m_LocatorFlags & fLF_NetStorageService;}
91 
92  string GetServiceName() const {return m_ServiceName;}
93  static string GetServiceName(CCompoundID cid);
94 
95  ENetStorageObjectLocation GetLocation() const {return m_Location;}
96 
97  bool IsMetaDataDisabled() const
98  {
99  return (m_LocatorFlags & fLF_NoMetaData) != 0;
100  }
101 
102  CTime GetCreationTime() const {return CTime(m_Timestamp);}
103 
104  bool HasUserKey() const {return (m_LocatorFlags & fLF_HasUserKey) != 0;}
105  bool HasSubKey() const { return m_LocatorFlags & fLF_HasSubKey; }
106 
107  // These are intended to be used together
108  string GetAppDomain() const {return m_AppDomain;}
109  string GetShortUniqueKey() const {return m_ShortUniqueKey;}
110 
111  // This contains both of the above
112  string GetUniqueKey() const {return m_UniqueKey;}
113 
114  const string& GetSubKey() const { return m_SubKey; }
115  const TVersion& GetVersion() const { return m_Version; }
116 
117  void SetLocation(const string& nc_service_name);
118 
119  string GetNCServiceName() const {return m_NCServiceName;}
120 
121  EFileTrackSite GetFileTrackSite() const;
122 
123  string GetLocator() const
124  {
125  if (m_Dirty)
126  x_Pack();
127  return m_Locator;
128  }
129 
130  TNetStorageAttrFlags GetStorageAttrFlags() const;
131  void SetStorageAttrFlags(TNetStorageAttrFlags flags);
132 
133  // Serialize to a JSON object.
134  void ToJSON(CJsonNode& root) const;
135  CJsonNode ToJSON() const;
136 
137  static EFileTrackSite ParseFileTrackSite(const string& ft_site_name);
138 
139  // Create an object locator for an ICache blob
140  static string Create(const string& service_name, const string& cache_name,
141  const string& key, const string& subkey, const TVersion& version = null);
142 
143 private:
145  fLF_NetStorageService = (1 << 0),
146  fLF_NoMetaData = (1 << 1),
147  fLF_HasObjectID = (1 << 2),
148  fLF_HasUserKey = (1 << 3),
149  fLF_Movable = (1 << 4),
150  fLF_Cacheable = (1 << 5),
151  fLF_DevEnv = (1 << 6),
152  fLF_QAEnv = (1 << 7),
153  fLF_HasSubKey = (1 << 8),
154  fLF_HasVersion = (1 << 9),
155 
156  eLF_AttrFlags = (
157  fLF_NoMetaData |
158  fLF_Movable |
159  fLF_Cacheable),
160  eLF_FieldFlags = (
161  fLF_NetStorageService |
162  fLF_HasObjectID |
163  fLF_HasUserKey |
164  fLF_DevEnv |
165  fLF_QAEnv)
166  };
167  typedef unsigned TLocatorFlags;
168 
169  CNetStorageObjectLoc() : m_CompoundIDPool(eVoid) {}
170  void Parse(CCompoundID cid, bool service_name_only);
171  string MakeShortUniqueKey() const;
172  string MakeUniqueKey() const { return m_AppDomain + '-' + m_ShortUniqueKey; }
173 
174  void x_Pack() const;
175  void SetLocatorFlags(TLocatorFlags flags) {m_LocatorFlags |= flags;}
176  void ClearLocatorFlags(TLocatorFlags flags) {m_LocatorFlags &= ~flags;}
177 
178  static TLocatorFlags x_StorageFlagsToLocatorFlags(
179  TNetStorageAttrFlags storage_flags,
180  EFileTrackSite ft_site = eFileTrack_ProdSite);
181 
183 
185 
186  // Not used, but still supported (for backward compatibility)
187  Uint8 m_ObjectID = 0;
188 
192 
193  string m_AppDomain;
194 
197 
198  // Either user key or key composed of timestamp, random value and object ID.
200  // The same as above plus app domain
201  string m_UniqueKey;
202 
203  string m_SubKey;
204  TVersion m_Version = 0;
205 
207 
208  mutable bool m_Dirty;
209 
210  mutable string m_Locator;
211 };
212 
213 /// @internal
215 {
216 public:
217  enum EErrCode {
223  ePrivileges = 1006,
228  eWriteError = 1011,
229  eReadError = 1012,
239 
240  // Meta info involving operation requested while the service
241  // is not configured for meta or HELLO metadata option conflict
243  eUnknownError = 1023
244  };
245 };
246 
247 /// @internal
248 struct SNetStorageAdminImpl;
249 
250 /// @internal
252 {
253  NCBI_NET_COMPONENT(NetStorageAdmin);
254 
255  CNetStorageAdmin(CNetStorage::TInstance netstorage_impl);
256 
257  CNetService GetService();
258 
259  CJsonNode MkNetStorageRequest(const string& request_type);
260 
261  CJsonNode ExchangeJson(const CJsonNode& request,
262  CNetServer::TInstance server_to_use = NULL,
264 
265  CNetStorageAdmin GetServer(CNetServer::TInstance server);
266 
267  CNetStorageObject Open(const string& object_loc);
268 };
269 
271 
272 #endif /* CONNECT_SERVICES_IMPL__NETSTORAGE_INT__HPP */
Pool of recycled CCompoundID objects.
Base64-encoded ID string that contains extractable typed fields.
JSON node abstraction.
NCBI_NET_COMPONENT(NetStorageAdmin)
TSelf & operator&=(TSelf flag)
TSelf & operator^=(TSelf flag)
TSelf & operator|=(TSelf flag)
CNetStorageFlagsSubset(TNetStorageFlags flags)
TNetStorageFlags m_Flags
CNetStorageFlagsSubset TSelf
string GetShortUniqueKey() const
CTime GetCreationTime() const
string GetAppDomain() const
string GetNCServiceName() const
const TVersion & GetVersion() const
void SetLocatorFlags(TLocatorFlags flags)
string GetLocator() const
const string & GetSubKey() const
CCompoundIDPool m_CompoundIDPool
ENetStorageObjectLocation GetLocation() const
bool HasServiceName() const
TLocatorFlags m_LocatorFlags
bool IsMetaDataDisabled() const
string MakeUniqueKey() const
void ClearLocatorFlags(TLocatorFlags flags)
string GetServiceName() const
string GetUniqueKey() const
Basic network-based data object I/O.
Definition: netstorage.hpp:167
CTime –.
Definition: ncbitime.hpp:296
Declarations of CCompoundIDPool, CCompoundID, and CCompoundIDField.
CNetStorageFlagsSubset< fNST_AnyAttr > TNetStorageAttrFlags
CNetStorageFlagsSubset< fNST_AnyLoc > TNetStorageLocFlags
static uch flags
static CS_CONNECTION * conn
Definition: ct_dynamic.c:25
#define MASK(n)
#define NULL
Definition: ncbistd.hpp:225
unsigned TNetStorageFlags
Bitwise OR of ENetStorageFlags.
Definition: netstorage.hpp:147
ENetStorageObjectLocation
Enumeration that indicates the current location of the object.
Definition: netstorage.hpp:86
@ eNFL_Unknown
Definition: netstorage.hpp:87
int64_t Int8
8-byte (64-bit) signed integer
Definition: ncbitype.h:104
uint64_t Uint8
8-byte (64-bit) unsigned integer
Definition: ncbitype.h:105
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_XCONNECT_EXPORT
const string version
version string
Definition: variables.hpp:66
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
Miscellaneous common-use basic types and functionality.
@ eVoid
To create a void (uninitialized) instance of a component.
Modified on Fri Sep 20 14:57:40 2024 by modify_doxy.py rev. 669887