&
key,
const string&
subkey,
string* encoded_key)
70encoded_key->push_back(
'"');
78 "ICache key or subkey is too long");
81 returnencoded_subkey;
87blob_id.reserve(1 +
key.length() + 3 +
subkey.length() + 1);
91blob_id.append(
"\" \"", 3);
93blob_id.append(encoded_subkey);
95blob_id.push_back(
'"');
104blob_id.reserve(1 +
key.length() + 2 +
105 int((
double)
sizeof(
version) * 1.5) + 2 +
subkey.length() + 1);
109blob_id.append(
"\" ", 2);
111blob_id.append(
" \"", 2);
113blob_id.append(encoded_subkey);
115blob_id.push_back(
'"');
125 const string& section,
126 const string& service_name,
127 const string& client_name,
128 const string& cache_name) :
135registry_builder, sections);
136 Init(registry_builder, sections);
147 boolmultiline_output,
150 string MakeStdCmd(
const char* cmd_base,
const string& blob_id,
154 string ExecStdCmd(
const char* cmd_base,
const string&
key,
162 const string&
key,
const string&
subkey,
163 size_t* blob_size_ptr,
166 unsignedmax_age,
unsigned* actual_age,
171 size_t offset,
size_tpart_size,
172 size_t* blob_size_ptr,
186 if(cache_name.empty()) cache_name =
registry.
Get(sections, {
"name",
"cache_name"},
"default_cache");
200 cmd.append(
") STOR ");
203 cmd.push_back(
' ');
206 cmd.append(
" confirm=1");
211 false, parameters).
conn;
215 const string& conf_section) :
224 const string& cache_name,
225 const string& client_name) :
227host +
':'+
NStr::UIntToString(port),
228client_name, cache_name))
233 const string& service_name,
234 const string& cache_name,
235 const string& client_name) :
237service_name, client_name, cache_name))
255 m_Impl->m_Service->m_ServerPool.SetCommunicationTimeout(to);
261 return m_Impl->m_Service->m_ServerPool.GetCommunicationTimeout();
268 const string&
key) :
296 boolmultiline_output,
305 if(!try_all_servers && selected_server) {
308}
else if(selected_server) {
313selected_server, server_check);
321&service_traversal, try_all_servers ?
325 if(server_last_used_ptr !=
NULL)
345 return m_Impl->m_CacheFlags;
396 unsigned inttime_to_live,
403parameters.
SetTTL(time_to_live);
437 ERR_POST(
"NetCache command 'GBLW' has been phased out");
443 size_t offset,
size_tpart_size,
453 const char* cmd_name;
456 if(
offset== 0 && part_size == 0) {
460cmd_name =
"READPART";
474exec_result, blob_size_ptr, ¶meters);
505unique_ptr<IReader> rdr(
m_Impl->GetReadStreamPart(
509 if(rdr.get() ==
NULL)
524blob_descr->
reader.reset(
m_Impl->ReadCurrentBlobNotOlderThan(
569 unsigned inttime_to_live,
628 stringresponse(
m_Impl->ExecStdCmd(
"HASB",
key, 0,
subkey, ¶meters));
640time_t access_timeout)
642 if(access_timeout) {
654 const auto cmd=
m_Impl->MakeStdCmd(
"PURGE2",
"'"+
key+
"'", &
m_Impl->m_DefaultParameters);
662 size_t* blob_size_ptr,
6660, 0, blob_size_ptr, optional);
675 size_t* blob_size_ptr,
679 offset, part_size, blob_size_ptr, optional);
695 return m_Impl->ReadCurrentBlobNotOlderThan(
key,
subkey, blob_size_ptr,
709 size_t* blob_size_ptr,
712 unsignedmax_age,
unsigned* actual_age,
725 string cmd=
MakeStdCmd(
"READLAST", blob_id, ¶meters);
730string::size_type pos = exec_result.
response.find(
"VER=");
732 if(pos == string::npos) {
734 "No VER field in READLAST output");
738exec_result.
response.c_str() + pos +
sizeof(
"VER=") - 1,
741pos = exec_result.
response.find(
"VALID=");
743 if(pos == string::npos) {
745 "No VALID field in READLAST output");
748 switch(exec_result.
response[pos +
sizeof(
"VALID=") - 1]) {
749 case 't':
case 'T':
case 'y':
case 'Y':
752 case 'f':
case 'F':
case 'n':
case 'N':
757 "Invalid format of the VALID field in READLAST output");
766 if(actual_age !=
NULL)
767*actual_age = e.
GetAge();
794 autowarning_handler = [&](
const string& m,
CNetServers) {
820 if(ver_pos ==
NPOS)
823 int version= atoi(warn_msg.c_str() + ver_pos +
sizeof(
"VER=") - 1);
827 "\"): the cached blob version downgraded from "<<
841 m_Impl->ChooseServerAndExec(
842 m_Impl->MakeStdCmd(
"SETVALID",
844&
m_Impl->m_DefaultParameters),
847&
m_Impl->m_DefaultParameters));
849 if(!exec_result.
response.empty()) {
850 ERR_POST(
"SetBlobVersionAsCurrent(\""<<
key<<
"\", "<<
864 m_Impl->ChooseServerAndExec(
865 m_Impl->MakeStdCmd(
"GETMETA",
872 output->SetNetCacheCompatMode();
884 if(
output.ReadLine(line)) {
887 while(
output.ReadLine(line))
894 return m_Impl->m_Service;
899 const string& injection)
904 cmd.append(cmd_base);
906 cmd.push_back(
' ');
908 cmd.append(blob_id);
910 if(!injection.empty())
911 cmd.append(injection);
933 return m_Impl->m_DefaultParameters.GetCacheName();
951 const autoparameters = &
m_Impl->m_DefaultParameters;
954 m_Impl->AppendClientIPSessionIDPasswordAgeHitID(&ids, parameters);
956oss <<
"IC("<< cache_name <<
") BLIST2"<< expression + filter << ids;
959 m_Impl->ChooseServerAndExec(
963&
m_Impl->m_DefaultParameters));
965 output->SetNetCacheCompatMode();
967vector<CNetICacheClient::CBlobInfo>
result;
969 while(
output.ReadLine(line) && !line.empty()) {
972 result.push_back(blob_info);
984 string cmd(
"PROLONG \"");
993 m_Impl->AppendClientIPSessionIDHitID(&
cmd);
1030 const string& driver,
Utility class for ICache class factories.
Exception thrown when the requested blob is older than the requested age.
NetCache internal exception.
Class factory for NetCache implementation of ICache.
virtual ICache * x_CreateInstance(const string &driver=kEmptyStr, CVersionInfo version=NCBI_INTERFACE_VERSION(ICache), const TPluginManagerParamTree *params=0) const
CICacheCF< CNetICacheClient > TParent
Client to NetCache server (implements ICache interface)
SExecResult ExecWithRetry(const string &cmd, bool multiline_output=false)
Execute remote command 'cmd', wait for the reply, check if it starts with 'OK:', and return the remai...
CNetServiceIterator IterateByWeight(const string &key)
CSetValidWarningSuppressor(INetServerConnectionListener *listener, const string &key, const string &subkey, int version)
~CSetValidWarningSuppressor()
CRef< INetServerConnectionListener > m_Listener
bool OnWarning(const string &warn_msg, CNetServer server)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
CTimeout â Timeout interval.
definition of a Culling tree
BLOB cache read/write/maintenance interface.
EKeepVersions
If to keep already cached versions of the BLOB when storing another version of it (not necessarily a ...
int TFlags
Bitwise OR of "EFlags" flags.
EBlobVersionValidity
BLOB version existence and validity â from the point of view of the underlying cache implementation.
@ eExpired
Validity of the BLOB version cannot be confirmed.
@ eCurrent
The returned BLOB's version is considered valid.
@ fBestReliability
Usually, it's not a problem if something fails to get cached sometimes.
int TTimeStampFlags
Holds a bitwise OR of "ETimeStampFlags".
A very basic data-read interface.
A very basic data-write interface.
CNetServiceIterator m_Iterator
SWeightedServiceTraversal(CNetService::TInstance service, const string &key)
virtual CNetServer BeginIteration()
virtual CNetServer NextServer()
static SQLCHAR output[256]
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
TErrCode GetErrCode(void) const
Get error code.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
#define nc_caching_mode
Caching mode.
#define nc_actual_age
A pointer to an unsigned variable where the actual age of the blob must be stored.
#define nc_blob_ttl
Blob life span in seconds.
#define nc_max_age
Do not read the blob if its age is greater than the specified value.
virtual time_t GetAccessTime(const string &key, int version, const string &subkey)
Return last access time for the specified cache entry.
IReader * GetReadStream(const string &key, int version, const string &subkey, size_t *blob_size_ptr, const CNamedParameterList *optional=NULL)
Read a lengthy blob via the IReader interface.
ENetCacheResponseType GetResponseType() const
unsigned * GetActualBlobAgePtr() const
void SetCacheName(const string &cache_name)
const string & GetBlobID() const
virtual string GetCacheName(void) const
void RemoveBlob(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
virtual void Store(const string &key, int version, const string &subkey, const void *data, size_t size, unsigned int time_to_live=0, const string &owner=kEmptyStr)
Add or replace BLOB.
virtual EKeepVersions GetVersionRetention() const
Get version retention.
virtual void SetBlobVersionAsCurrent(const string &key, const string &subkey, int version)
Set current valid version for a BLOB.
bool GetTryAllServers() const
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.
virtual void Remove(const string &key, int version, const string &subkey)
Remove specific cache entry.
virtual void SetVersionRetention(EKeepVersions policy)
Set version retention policy.
virtual TTimeStampFlags GetTimeStampPolicy() const
Get timestamp policy.
virtual TFlags GetFlags()
Retrieve the effective combination of flags from the underlying storage.
bool GetServerCheck(ESwitch *server_check) const
grid::netcache::search::CBlobInfo CBlobInfo
void Cache_RegisterDriver_NetCache(void)
grid::netcache::search::CExpression CExpression
void RegisterSession(unsigned pid)
Send session registration command.
IReader * GetReadStreamPart(const string &key, int version, const string &subkey, size_t offset, size_t part_size, size_t *blob_size_ptr, const CNamedParameterList *optional=NULL)
Read data from the specified blob.
CNetServer * GetServerLastUsedPtr() const
STimeout GetCommunicationTimeout() const
bool ReadPart(const string &key, int version, const string &subkey, size_t offset, size_t part_size, void *buf, size_t buf_size)
void SetMaxBlobAge(unsigned max_age)
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.
void SetTTL(unsigned blob_ttl)
void UnRegisterSession(unsigned pid)
Send session unregistration command.
virtual bool Read(const string &key, int version, const string &subkey, void *buf, size_t buf_size)
void LoadNamedParameters(const CNamedParameterList *optional)
size_t CheckBlobSize(Uint8 blob_size)
CNetRef< SNetICacheClientImpl > m_Impl
const char *const kNetICacheDriverName
vector< CBlobInfo > Search(CExpression expression, CFields fields=CFields())
Returns information for all blobs matching provided search expression.
void WriteBufferAndClose(const char *buf_ptr, size_t buf_size)
virtual int GetTimeout() const
Get expiration timeout.
EAppRegistry
Defines how this object must be initialized.
bool HasBlob(const string &key, const string &subkey, const CNamedParameterList *optional=NULL)
CNetServer GetServerToUse() const
void NCBI_EntryPoint_xcache_netcache(CPluginManager< ICache >::TDriverInfoList &info_list, CPluginManager< ICache >::EEntryPointRequest method)
virtual bool HasBlobs(const string &key, const string &subkey)
Check if any BLOB exists (any version)
IEmbeddedStreamWriter * GetNetCacheWriter(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
Create or update the specified blob.
grid::netcache::search::CFields CFields
virtual IWriter * GetWriteStream(const string &key, int version, const string &subkey, unsigned int time_to_live=0, const string &owner=kEmptyStr)
Return sequential stream interface to write BLOB data.
unsigned GetMaxBlobAge() const
void PrintBlobInfo(const string &key, int version, const string &subkey)
Print meta information about the specified blob.
virtual void GetBlobOwner(const string &key, int version, const string &subkey, string *owner)
Retrieve BLOB owner.
virtual void SetFlags(TFlags flags)
Pass flags to the underlying storage.
void SetTryAllServers(bool try_all_servers)
virtual void GetBlobAccess(const string &key, int version, const string &subkey, SBlobAccessDescr *blob_descr)
Get BLOB access using BlobAccessDescr.
virtual bool SameCacheParams(const TCacheParams *params) const
virtual size_t GetSize(const string &key, int version, const string &subkey)
Check if BLOB exists, return BLOB size.
string GetCacheName() const
virtual void Purge(time_t access_timeout)
Delete all BLOBs older than specified.
virtual bool IsOpen() const
void SetCommunicationTimeout(const STimeout &to)
Set communication timeout.
virtual void SetTimeStampPolicy(TTimeStampFlags policy, unsigned int timeout, unsigned int max_timeout=0)
Set timestamp update policy.
const string & GetKey() const
void SetCachingMode(CNetCacheAPI::ECachingMode caching_mode)
@ eReadComplete
The whole BLOB has been read.
@ eBlobNotFound
Access denied.
static void NCBI_EntryPointImpl(TDriverInfoList &info_list, EEntryPointRequest method)
Entry point implementation.
#define NCBI_INTERFACE_VERSION(iface)
Macro to construct CVersionInfo class using interface name (relies on CInterfaceVersion class)
list< SDriverInfo > TDriverInfoList
List of driver information.
EEntryPointRequest
Actions performed by the entry point.
uint64_t Uint8
8-byte (64-bit) unsigned integer
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
NCBI_NS_STD::string::size_type SIZE_TYPE
static string PrintableString(const CTempString str, TPrintableMode mode=fNewLine_Quote|fNonAscii_Passthru)
Get a printable version of the specified string.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
static SIZE_TYPE FindCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case sensitive search.
static string UIntToString(unsigned int value, TNumToStringFlags flags=0, int base=10)
Convert UInt to string.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static Uint8 StringToUInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Uint8.
static unsigned int StringToUInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned int.
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.
static string UInt8ToString(Uint8 value, TNumToStringFlags flags=0, int base=10)
Convert UInt8 to string.
@ fAllowTrailingSymbols
Ignore trailing non-numerics characters.
double GetAsDouble(void) const
Get as number of seconds (fractional value).
enum ENcbiSwitch ESwitch
Aux.
@ eNonCompatible
major, minor does not match
unsigned int
A callback function used to compare two keys in a database.
Definition of all error codes used in connect services library (xconnserv.lib and others).
const string version
version string
const struct ncbi::grid::netcache::search::fields::SIZE size
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
Static variables safety - create on demand, destroy on application termination.
Defines: CTimeFormat - storage class for time format.
NetCache API exception declarations.
#define MAX_ICACHE_CACHE_NAME_LENGTH
#define MAX_ICACHE_SUBKEY_LENGTH
static string s_KeyVersionSubkeyToBlobID(const string &key, int version, const string &subkey)
static string s_KeySubkeyToBlobID(const string &key, const string &subkey)
#define MAX_ICACHE_KEY_LENGTH
static const char s_NetICacheAPIName[]
static string s_CheckKeySubkey(const string &key, const string &subkey, string *encoded_key)
NetCache ICache client specs.
Helper classes and templates to implement plugins.
Defines CRequestContext class for NCBI C++ diagnostic API.
IReader * GetReadStream(const string &key, int version, const string &subkey, size_t *blob_size_ptr, const CNamedParameterList *optional=NULL)
Read a lengthy blob via the IReader interface.
void ProlongBlobLifetime(const string &key, const string &subkey, const CTimeout &ttl, const CNamedParameterList *optional=NULL)
SNetCacheAPIImpl * GetNetCacheAPI()
CNetICacheClientExt GetServer(CNetServer::TInstance server)
CNetServerConnection conn
unsigned maximum_age
Set to a non-zero value to return a version not older than the specified value.
unsigned actual_age
If `maximum_age` is not zero, GetBlobAccess() will set this field to the actual blob version age upon...
unique_ptr< IReader > reader
EBlobVersionValidity current_version_validity
If `return_current_version` is set, the `current_version_validity` field will contain the validity of...
bool return_current_version_supported
If TRUE, the ICache instance supports return_current_version.
TBlobVersion current_version
If `return_current_version` is set, the current version number of the blob is stored in the `current_...
bool return_current_version
If TRUE, the `version` argument of GetBlobAccess() will be ignored and the `current_version` and `cur...
void SetWarningHandler(TEventHandler warning_handler)
void AppendClientIPSessionIDPasswordAgeHitID(string *cmd, const CNetCacheAPIParameters *parameters)
CNetCacheAPIParameters m_DefaultParameters
unsigned x_ExtractBlobAge(const CNetServer::SExecResult &exec_result, const char *cmd_name)
static CNetCacheAPI::EReadResult ReadBuffer(IReader &reader, char *buf_ptr, size_t buf_size, size_t *n_read, size_t blob_size)
void Init(CSynRegistry ®istry, const SRegSynonyms §ions)
CNetServer::SExecResult ChooseServerAndExec(const string &cmd, const string &key, bool multiline_output, const CNetCacheAPIParameters *parameters)
void Init(CSynRegistry ®istry, const SRegSynonyms §ions)
IReader * ReadCurrentBlobNotOlderThan(const string &key, const string &subkey, size_t *blob_size_ptr, int *version, ICache::EBlobVersionValidity *validity, unsigned max_age, unsigned *actual_age, const CNamedParameterList *optional=NULL)
ICache::TFlags m_CacheFlags
string MakeStdCmd(const char *cmd_base, const string &blob_id, const CNetCacheAPIParameters *parameters, const string &injection=kEmptyStr)
SNetICacheClientImpl(CSynRegistryBuilder registry_builder, const string §ion, const string &service_name, const string &client_name, const string &cache_name)
IReader * GetReadStreamPart(const string &key, int version, const string &subkey, size_t offset, size_t part_size, size_t *blob_size_ptr, const CNamedParameterList *optional)
string ExecStdCmd(const char *cmd_base, const string &key, int version, const string &subkey, const CNetCacheAPIParameters *parameters)
SNetICacheClientImpl(SNetServerInPool *server, SNetICacheClientImpl *parent)
virtual CNetServerConnection InitiateWriteCmd(CNetCacheWriter *nc_writer, const CNetCacheAPIParameters *parameters)
CRef< SNetServerInPool > m_ServerInPool
@ eRethrowAllServerErrors
static SNetServiceImpl * Create(const string &api_name, const string &service_name, const string &client_name, INetServerConnectionListener *listener, CSynRegistry ®istry, SRegSynonyms §ions, const string &ns_client_name=kEmptyStr)
void IterateUntilExecOK(const string &cmd, bool multiline_output, CNetServer::SExecResult &exec_result, IServiceTraversal *service_traversal, EServerErrorHandling error_handling)
Reader writer with transmission checking.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4