46 bool require_version,
bool require_service)
53 "options are required in icache mode.");
60 if (require_service) {
62 "option is required when ID is not provided.");
68 if (
key.GetVersion() != 3) {
80 if (
key.GetVersion() != 3) {
86 "must be a host:port server address.");
105 "option is required in icache mode.");
123 "must be explicitly specified.");
131 CTime generation_time;
133 generation_time.
SetTimeT((time_t)
key.GetCreationTime());
135 if (
key.GetVersion() != 3)
136 printf(
"server_address: %s:%hu\n",
139 printf(
"server_address_crc32: 0x%08X\n",
key.GetHostPortCRC32());
141 printf(
"id: %u\nkey_generation_time: %s\nrandom: %u\n",
144 (
unsigned)
key.GetRandomPart());
146 string service(
key.GetServiceName());
148 if (!service.empty())
149 printf(
"service_name: %s\n", service.c_str());
177 bool icache_mode,
bool require_version)
182 "Too many positional parameters.");
189 vector<string> key_parts;
192 if (key_parts.size() != 3) {
194 "Invalid ICache key specification \"" <<
key <<
"\" ("
195 "expected a comma-separated key,version,subkey triplet).");
197 key = key_parts.front();
199 subkey = key_parts.back();
204 }
else if (require_version) {
206 "blob version parameter is missing");
242 if (
output.ReadLine(line)) {
244 printf(
"%s\n", line.c_str());
245 while (
output.ReadLine(line))
246 printf(
"%s\n", line.c_str());
254 printf(
"Size: %lu\n", (
unsigned long)
267 printf(
"Size: %lu\n", (
unsigned long) blob_size);
281 unique_ptr<IReader> reader;
284 size_t blob_size = 0;
285 switch (reader_select) {
322 switch (reader_select) {
379 "Cannot find the requested blob");
386 while ((read_result = reader->Read(
buffer,
391 ERR_POST(
"Error while sending data to the output stream");
402 unique_ptr<IEmbeddedStreamWriter> writer;
458 size_t bytes_written;
474 if (writer->Write(
buffer, bytes_read, &bytes_written) !=
Pool of recycled CCompoundID objects.
CCompoundIDPool m_CompoundIDPool
bool IsOptionSet(int option) const
struct CGridCommandLineInterfaceApp::SOptions m_Opts
CNetICacheClient m_NetICacheClient
CNetScheduleAPIExt m_NetScheduleAPI
@ eAdminCmdWithSideEffects
void PrintServerAddress(CNetServer server)
enum CGridCommandLineInterfaceApp::EAPIClass m_APIClass
bool IsOptionExplicitlySet(int option) const
void SetUp_NetCacheAdminCmd(EAdminCmdSeverity cmd_severity)
CNetCacheAdmin m_NetCacheAdmin
CNetCacheAPI m_NetCacheAPI
static void PrintBlobMeta(const CNetCacheKey &key)
Client API for NetCache server.
NetCache internal exception.
Client to NetCache server (implements ICache interface)
void StickToServer(SSocketAddress address)
string GetServerAddress() const
bool IsLoadBalanced() const
CNetServerPool GetServerPool()
EBlobVersionValidity
BLOB version existence and validity – from the point of view of the underlying cache implementation.
@ eCurrent
The returned BLOB's version is considered valid.
@ eValid
Synonym for eCurrent.
@ fBestReliability
Usually, it's not a problem if something fails to get cached sometimes.
Declarations of command line interface arguments and handlers.
CNcbiRegistry & GetRWConfig(void)
Get the application's cached configuration parameters, accessible for read-write for an application's...
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
#define NCBI_USER_THROW(message)
Throw a quick-and-dirty runtime exception of type 'CException' with the given error message and error...
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 NCBI_THROW_FMT(exception_class, err_code, message)
The same as NCBI_THROW but with message processed as output to ostream.
#define nc_blob_password
Blob password.
#define nc_server_last_used
Pointer to a variable for saving the CNetServer that was last used.
#define nc_try_all_servers
Whether to run a request through all NetCache servers in the ICache service in an attempt to find the...
#define nc_server_check
For blob readers: whether to check if the primary server that stores the blob is still in service.
#define nc_caching_mode
Caching mode.
#define nc_use_compound_id
Whether to return NetCache keys in CompoundID format.
#define nc_blob_ttl
Blob life span in seconds.
IReader * GetPartReader(const string &key, size_t offset, size_t part_size, size_t *blob_size=NULL, const CNamedParameterList *optional=NULL)
Get a pointer to the IReader interface to read a portion of the blob contents.
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 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 &blob_id, const CNamedParameterList *optional=NULL)
Returns the size of the BLOB identified by the "key" parameter.
void Remove(const string &blob_id, const CNamedParameterList *optional=NULL)
Remove BLOB by key.
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.
CNetServerMultilineCmdOutput GetBlobInfo(const string &blob_id, const CNamedParameterList *optional=NULL)
Return a CNetServerMultilineCmdOutput object for reading meta information about the specified blob.
string PutData(const void *buf, size_t size, const CNamedParameterList *optional=NULL)
Put BLOB to server.
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.
void SetDefaultParameters(const CNamedParameterList *parameters)
Override defaults used by this object.
IReader * GetReader(const string &key, size_t *blob_size=NULL, const CNamedParameterList *optional=NULL)
Get a pointer to the IReader interface to read blob contents.
virtual void SetFlags(TFlags flags)
Pass flags to the underlying storage.
void Purge(const string &cache_name)
Remove all blobs from an ICache database.
CNetCacheAdmin GetAdmin()
@ eServerError
Blob is not found.
bool Set(const string §ion, const string &name, const string &value, TFlags flags=0, const string &comment=kEmptyStr)
Set the configuration parameter value.
ERW_Result
Result codes for I/O operations.
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Success
Everything is okay, I/O completed.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static bool MatchesMask(CTempString str, CTempString mask, ECase use_case=eCase)
Match "str" against the "mask".
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
CTime & SetTimeT(const time_t t)
Set time using time_t time value.
string g_NetService_TryResolveHost(const string &ip_or_hostname)
const struct ncbi::grid::netcache::search::fields::KEY key
const struct ncbi::grid::netcache::search::fields::SUBKEY subkey
static pcre_uint8 * buffer
static SQLCHAR output[256]
bool AddPart(const string &part)
void Parse(bool icache_mode, bool require_version)
struct CGridCommandLineInterfaceApp::SOptions::SNCID ncid
Meaningful information encoded in the NetCache key.
static SSocketAddress Parse(const string &address, SHost::EName name=SHost::EName::eResolved)