40 #include <corelib/ncbi_base64.h>
48 #define NCBI_USE_ERRCODE_X NetStorage_Common
50 #define FILETRACK_STORAGE_CODE "FT"
51 #define NETCACHE_STORAGE_CODE "NC"
53 #define STORAGE_INFO_CUE 0
59 const string& app_domain,
62 m_CompoundIDPool(cid_pool),
63 m_LocatorFlags(x_StorageFlagsToLocatorFlags(
flags, ft_site)),
64 m_AppDomain(app_domain),
65 m_Timestamp(time(
NULL)),
66 m_Random(random_number),
67 m_ShortUniqueKey(MakeShortUniqueKey()),
68 m_UniqueKey(MakeUniqueKey()),
76 const string& app_domain,
77 const string& unique_key,
79 m_CompoundIDPool(cid_pool),
80 m_LocatorFlags(x_StorageFlagsToLocatorFlags(
flags, ft_site) | fLF_HasUserKey),
81 m_AppDomain(app_domain),
82 m_ShortUniqueKey(unique_key),
83 m_UniqueKey(MakeUniqueKey()),
88 #define INVALID_LOC_ERROR_MSG "Invalid NetStorage object locator"
90 #define THROW_INVALID_LOC_ERROR(cid, msg) \
91 NCBI_THROW_FMT(CNetStorageException, eInvalidArg, \
92 msg " '" << cid.ToString() << '\'')
94 #define VERIFY_FIELD_EXISTS(field) \
96 THROW_INVALID_LOC_ERROR(cid, INVALID_LOC_ERROR_MSG); \
113 const string& object_loc) :
114 m_CompoundIDPool(cid_pool),
116 m_Locator(object_loc)
124 if (service_name.empty() ||
125 strchr(service_name.c_str(),
':') !=
NULL)
137 loc.
Parse(cid,
true);
147 "Unsupported NetStorage object locator version");
165 if (service_name_only)
return;
242 if (!nc_service_name.empty()) {
393 return locator_flags;
438 root.
SetByKey(
"StorageFlags", storage_flags);
448 root.
SetByKey(
"NetCache", storage_info);
468 auto i = p.find(ft_site_name);
Compound ID field – an element of the compound ID that has a type and a value.
string GetString() const
Return the string value that this field contains.
CCompoundIDField GetNextHomogeneous()
Return the next field of the same type.
CCompoundIDField GetNextNeighbor()
Return the next immediately adjacent field.
Uint4 GetRandom() const
Return the random number value that this field contains.
Uint8 GetCue() const
Return the application-specific numeric tag value that this field contains.
string GetServiceName() const
Return the LBSM service name that this field contains.
Int8 GetTimestamp() const
Return the UNIX timestamp that this field contains.
Int8 GetInteger() const
Return the integer value that this field contains.
string GetDatabaseName() const
Return the database name that this field contains.
Uint8 GetID() const
Return the ID value that this field contains.
Uint8 GetFlags() const
Return the combination of binary flags stored in this field.
Pool of recycled CCompoundID objects.
CCompoundID NewID(ECompoundIDClass new_id_class)
Create and return a new CCompoundID objects.
CCompoundID FromString(const string &cid)
Unpack the base64-encoded ID and return a CCompoundID object for field extraction.
Base64-encoded ID string that contains extractable typed fields.
void AppendDatabaseName(const string &db_name)
Append an eCIT_DatabaseName field at the end of this compound ID.
void AppendRandom(Uint4 random_number)
Append an eCIT_Random field at the end of this compound ID.
void AppendCue(Uint8 tag)
Append an eCIT_Cue field at the end of this compound ID.
void AppendString(const string &string_value)
Append an eCIT_String field at the end of this compound ID.
CCompoundIDField GetFirst(ECompoundIDFieldType field_type)
Return the first field of the specified type or NULL if this compound ID contains no fields of such t...
string ToString()
Pack the ID and return its string representation.
void AppendTimestamp(Int8 timestamp)
Append an eCIT_Timestamp field at the end of this compound ID.
void AppendID(Uint8 id)
Append an eCIT_ID field at the end of this compound ID.
void AppendFlags(Uint8 flags)
Append an eCIT_Flags field at the end of this compound ID.
ECompoundIDClass GetClass() const
One of the registered ID classes.
void AppendServiceName(const string &service_name)
Append an eCIT_ServiceName field at the end of this compound ID.
void AppendInteger(Int8 number)
Append an eCIT_Integer field at the end of this compound ID.
void SetString(const string &key, const string &value)
Set a JSON object element to the specified string value.
void SetNull(const string &key)
Set a JSON object element to the specified null value.
void SetBoolean(const string &key, bool value)
Set a JSON object element to the specified boolean value.
void SetInteger(const string &key, Int8 value)
Set a JSON object element to the specified integer value.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
static CJsonNode NewObjectNode()
Create a new JSON object node.
void SetStorageAttrFlags(TNetStorageAttrFlags flags)
void Parse(CCompoundID cid, bool service_name_only)
static string Create(const string &service_name, const string &cache_name, const string &key, const string &subkey, const TVersion &version=null)
static TLocatorFlags x_StorageFlagsToLocatorFlags(TNetStorageAttrFlags storage_flags, EFileTrackSite ft_site=eFileTrack_ProdSite)
TNetStorageAttrFlags GetStorageAttrFlags() const
void SetLocatorFlags(TLocatorFlags flags)
string GetLocator() const
CCompoundIDPool m_CompoundIDPool
ENetStorageObjectLocation m_Location
TLocatorFlags m_LocatorFlags
string MakeShortUniqueKey() const
void SetLocation(const string &nc_service_name)
CNullable< int > TVersion
string MakeUniqueKey() const
void ClearLocatorFlags(TLocatorFlags flags)
string GetServiceName() const
static EFileTrackSite ParseFileTrackSite(const string &ft_site_name)
void SetServiceName(const string &service_name)
EFileTrackSite GetFileTrackSite() const
#define MAKE_CONST_MAP(name, type1, type2,...)
@ eCIC_NetStorageObjectLocV1
Old version of NetStorageObjectLoc.
@ eCIC_NetStorageObjectLoc
static const char location[]
bool IsNull(void) const
Check if the object is unassigned.
const TValue & GetValue(void) const
Get a const reference to the current value.
static const string & GetHostRole(void)
Get host role (DEV/QA/TRY/PROD) from /etc/ncbi/role.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
ENetStorageObjectLocation
Enumeration that indicates the current location of the object.
@ fNST_NoMetaData
Do not use NetStorage relational database to track ownership & changes.
@ fNST_Cacheable
Has no effect at the moment.
@ fNST_Movable
Allow the object to move between storages.
uint32_t Uint4
4-byte (32-bit) unsigned integer
uint64_t Uint8
8-byte (64-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
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 of all error codes used in connect services library (xconnserv.lib and others).
std::false_type tagStrNocase
const string version
version string
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
Defines command line argument related classes.
#define FILETRACK_STORAGE_CODE
#define VERIFY_FIELD_EXISTS(field)
#define NETCACHE_STORAGE_CODE
ENetStorageObjectLocation s_LocationCodeToLocation(const string &location)
#define THROW_INVALID_LOC_ERROR(cid, msg)
#define INVALID_LOC_ERROR_MSG