78 size_t bytes_read_local = 0;
81 if (bytes_read !=
NULL)
82 *bytes_read = bytes_read_local;
226 "Cannot open \"" <<
GetLoc() <<
"\" for writing.");
242 "Object creation is disabled (no backend storages were provided)");
250 "NetStorageObject \"" <<
GetLoc() <<
251 "\" could not be found in any of the designated locations.");
279 "NetStorageObject \"" <<
GetLoc() <<
280 "\" could not be found in any of the designated locations.");
287 "NetStorageObject \"" <<
GetLoc() <<
288 "\" could not be found in any of the designated locations.");
296 "NetStorageObject \"" <<
GetLoc() <<
297 "\" could not be found in any of the designated locations.");
356 m_Read.Set(std::move(reader), blob_size);
367 #define NC_CHECK_VERSION(object_loc) \
368 if (object_loc.GetVersion().IsNull()) { \
369 NCBI_THROW_FMT(CNetStorageException, eInvalidArg, \
370 "Null version is not supported"); \
373 #define NC_GET_ARGS(object_loc) \
374 object_loc.GetShortUniqueKey(), object_loc.GetVersion(), object_loc.GetSubKey(), \
375 nc_cache_name = object_loc.GetAppDomain()
391 m_Write.Set(std::move(writer));
425 while (
output.ReadLine(line))
437 &object_loc, blob_size, blob_info);
443 #define NC_EXISTS_IMPL(object_loc) \
444 if (!m_Client.HasBlob(object_loc.GetShortUniqueKey(), \
445 object_loc.GetSubKey(), nc_cache_name = object_loc.GetAppDomain())) { \
447 NCBI_THROW_FMT(CNetStorageException, eNotExists, \
448 "NetStorageObject \"" << object_loc.GetLocator() << \
449 "\" does not exist in NetCache."); \
507 "NetStorageObject \"" <<
GetLoc() <<
508 "\" is not a FileTrack object");
581 m_Context->filetrack_api.GetFileInfo(object_loc);
597 #define FT_EXISTS_IMPL(object_loc) \
598 if (!m_Context->filetrack_api.GetFileInfo(object_loc)) { \
600 NCBI_THROW_FMT(CNetStorageException, eNotExists, \
601 "NetStorageObject \"" << object_loc.GetLocator() << \
602 "\" does not exist in FileTrack."); \
617 m_Context->filetrack_api.Remove(object_loc);
629 "SetExpiration() is not supported for FileTrack");
644 if (my_ncbi_id)
return make_pair(
string(
"my_ncbi_id"), my_ncbi_id.
Repr());
663 if (!service.empty()) {
664 const string section =
"service_" + service;
671 return "netstorage_api";
677 const string param_name =
"filetrack";
679 const string ft_section =
registry.
Get(service_section, param_name);
686 const string param_name =
"netcache";
688 const string nc_section =
registry.
Get(service_section, param_name);
700 if (!app_domain.empty())
return app_domain;
705 if (!cache_name.empty())
return cache_name;
713 size_t default_value)
715 const string param_name =
"relocate_chunk";
717 return registry.
GetInt(service_section, param_name,
static_cast<int>(default_value));
727 default_flags(
flags),
Pool of recycled CCompoundID objects.
Int8 AsInteger() const
Provided that this is a numeric node (that is, either an integer or a floating point node),...
static CJsonNode GuessType(const CTempString &value)
Guess the type of a JSON scalar from the string representation of its value and initialize a new node...
string Repr(TReprFlags flags=0) const
Return a string representation of this node.
void SetByKey(const string &key, CJsonNode::TInstance value)
For a JSON object node, insert a new element or update an existing element.
bool IsInteger() const
Return true for an integer node. Return false otherwise.
static CJsonNode NewObjectNode()
Create a new JSON object node.
CJsonNode GetByKeyOrNull(const string &key) const
For a JSON object node, return the value associated with the specified key.
Client to NetCache server (implements ICache interface)
const string & GetServiceName() const
Exception class for use by CNetStorage, CNetStorageByKey, and CNetStorageObject.
Detailed information about a CNetStorage object.
string GetShortUniqueKey() const
string GetAppDomain() const
string GetNCServiceName() const
const TVersion & GetVersion() const
string GetLocator() const
const string & GetSubKey() const
ENetStorageObjectLocation GetLocation() const
void SetLocation(const string &nc_service_name)
CTimeout – Timeout interval.
CRef< SContext > m_Context
TState< CROFileTrack > m_Read
ENetStorageRemoveResult Remove() override
void SetLocator() override
INetStorageObjectState * StartWrite(const void *, size_t, size_t *, ERW_Result *) override
CNetStorageObjectInfo GetInfo() override
TState< CWOFileTrack > m_Write
void SetExpiration(const CTimeout &) override
string FileTrack_Path() override
pair< string, string > GetUserInfo() override
INetStorageObjectState * StartRead(void *, size_t, size_t *, ERW_Result *) override
TState< CRONetCache > m_Read
pair< string, string > GetUserInfo() override
void SetLocator() override
void SetExpiration(const CTimeout &) override
ENetStorageRemoveResult Remove() override
CNetICacheClientExt m_Client
TState< CWONetCache > m_Write
string FileTrack_Path() override
INetStorageObjectState * StartWrite(const void *, size_t, size_t *, ERW_Result *) override
CRef< SContext > m_Context
CNetStorageObjectInfo GetInfo() override
INetStorageObjectState * StartRead(void *, size_t, size_t *, ERW_Result *) override
void SetExpiration(const CTimeout &) override
TState< CRWNotFound > m_RW
string FileTrack_Path() override
void SetLocator() override
pair< string, string > GetUserInfo() override
CNetStorageObjectInfo GetInfo() override
ENetStorageRemoveResult Remove() override
INetStorageObjectState * StartRead(void *, size_t, size_t *, ERW_Result *) override
INetStorageObjectState * StartWrite(const void *, size_t, size_t *, ERW_Result *) override
ERW_Result PendingCount(size_t *count) override
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Read(void *buf, size_t count, size_t *read) override
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
ERW_Result Read(void *buf, size_t count, size_t *read) override
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
unique_ptr< IReader > TReaderPtr
ERW_Result PendingCount(size_t *count) override
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Read(void *buf, size_t count, size_t *read) override
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
ERW_Result Write(const void *buf, size_t count, size_t *written) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
ERW_Result PendingCount(size_t *count) override
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
ERW_Result Flush() override
Flush pending data (if any) down to the output device.
ERW_Result Write(const void *buf, size_t count, size_t *written) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
unique_ptr< IEmbeddedStreamWriter > TWriterPtr
ERW_Result Write(const void *buf, size_t count, size_t *written) override
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
ERW_Result Flush() override
Flush pending data (if any) down to the output device.
CNetStorageFlagsSubset< fNST_AnyLoc > TNetStorageLocFlags
static SQLCHAR output[256]
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
#define nc_caching_mode
Caching mode.
#define nc_cache_name
In ICache mode, override the name of the cache specified in the CNetICacheClient constructor.
virtual string GetCacheName(void) const
void RemoveBlob(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
CNetServerMultilineCmdOutput GetBlobInfo(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
Return a CNetServerMultilineCmdOutput object for reading meta information about the specified blob.
size_t GetBlobSize(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
Returns the size of the BLOB identified by the "key", "version", and "subkey" parameters.
IEmbeddedStreamWriter * GetNetCacheWriter(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
Create or update the specified blob.
unsigned TNetStorageFlags
Bitwise OR of ENetStorageFlags.
ENetStorageRemoveResult
Result returned by Remove() methods.
@ fNST_NetCache
Use NetCache as the primary storage.
@ fNST_FileTrack
Use FileTrack as the primary storage.
@ eNotExists
Illegal op applied to non-existent object.
@ eNSTRR_Removed
Object has been removed successfully.
@ eNSTRR_NotFound
Removing failed due to object not found.
void Reset(void)
Reset reference object.
uint64_t Uint8
8-byte (64-bit) unsigned integer
void Randomize(void)
Re-initialize (re-seed) the generator using platform-specific randomization.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
virtual int GetInt(const string §ion, const string &name, int default_value, TFlags flags=0, EErrAction err_action=eThrow) const
Get integer value of specified parameter name.
virtual bool HasEntry(const string §ion, const string &name=kEmptyStr, TFlags flags=0) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
ERW_Result
Result codes for I/O operations.
@ eRW_Error
Unrecoverable error, no retry possible.
@ eRW_Success
Everything is okay, I/O completed.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static bool SplitInTwo(const CTempString str, const CTempString delim, string &str1, string &str2, TSplitFlags flags=0)
Split a string into two pieces using the specified delimiters.
@ fSplit_ByPattern
Require full delimiter strings.
void Set(EType type)
Set special value.
bool IsFinite() const
Check if timeout holds a numeric value.
string s_GetSection(const IRegistry ®istry, const string &service, const string &name)
string s_GetAppDomain(const string &app_domain, CNetICacheClient &nc_client)
const size_t kRelocateChunk
SFileTrackConfig s_GetFTConfig(const IRegistry ®istry, const string &service)
CNetICacheClient s_GetICClient(const SCombinedNetStorageConfig &c)
size_t s_GetRelocateChunk(const IRegistry ®istry, const string &service, size_t default_value)
const string version
version string
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
const GenericPointer< typename T::ValueType > T2 value
@ eVoid
To create a void (uninitialized) instance of a component.
#define NETSTORAGE_CONVERT_NETCACHEEXCEPTION(message)
CNetStorageObjectInfo g_CreateNetStorageObjectInfo(const string &object_loc, ENetStorageObjectLocation location, const CNetStorageObjectLoc *object_loc_struct, Uint8 file_size, CJsonNode::TInstance storage_specific_info)
#define NC_CHECK_VERSION(object_loc)
#define NC_GET_ARGS(object_loc)
#define FT_EXISTS_IMPL(object_loc)
#define NC_EXISTS_IMPL(object_loc)
IReader * GetReadStream(const string &key, const string &subkey, int *version, size_t *blob_size_ptr, const CNamedParameterList *optional=NULL)
void ProlongBlobLifetime(const string &key, const string &subkey, const CTimeout &ttl, const CNamedParameterList *optional=NULL)
virtual string GetLoc() const =0
SContext(const SCombinedNetStorageConfig &, TNetStorageFlags)
TNetStorageFlags default_flags
CNetICacheClientExt icache_client
SFileTrackAPI filetrack_api
void ParseArg(const string &, const string &)
static EMode GetMode(const string &)
bool ParseArg(const string &, const string &)
ERW_Result Read(void *buf, size_t count, size_t *bytes_read)
void Write(const void *buf, size_t count, size_t *bytes_written)
CNetStorageObjectLoc & Locator() override
string GetLoc() const override
void ParseArg(const string &, const string &)