& blob_key) :
48m_NetCacheObject(nc_object),
62{
"write", ExecMethod<TSelf, &TSelf::ExecWrite>, {
65{
"read", ExecMethod<TSelf, &TSelf::ExecRead>, {
68{
"close", ExecMethod<TSelf, &TSelf::ExecClose>, },
69{
"get_key", ExecMethod<TSelf, &TSelf::ExecGetKey>, },
79 auto& reply = io.
reply;
80 const auto value= args[
"value"].AsString();
84 "Cannot write blob while it's being read");
87 const boolreturn_blob_key =
m_BlobKey.empty();
89 if(return_blob_key) reply.AppendString(
m_BlobKey);
98 auto& reply = io.
reply;
99 autobuf_size = args[
"buf_size"].AsInteger<
size_t>();
103 "Cannot read blob while it's being written");
108 string buffer(buf_size, 0);
109 char* buf_ptr = &
buffer[0];
111 size_ttotal_bytes_read = 0;
113 while(buf_size > 0) {
116total_bytes_read += bytes_read;
117buf_ptr += bytes_read;
118buf_size -= bytes_read;
119}
else if(rw_res ==
eRW_Eof) {
123 "I/O error while reading "<<
m_BlobKey);
126 buffer.resize(total_bytes_read);
129reply.AppendString(
buffer);
154 auto& reply = io.
reply;
159 const string& blob_key,
intblob_version,
const string& blob_subkey) :
161m_BlobVersion(blob_version),
162m_BlobSubKey(blob_subkey)
178 auto& reply = io.
reply;
187m_NetICacheClient(ic_api),
188m_NetCacheAPI(ic_api.GetNetCacheAPI())
190 autowarning_handler = [&](
const string& m,
CNetServers) {
205 "NetCacheServer constructor: " 206 "'server_address' must be a host:port combination");
213{
"service_name",
"", },
214{
"client_name",
"", },
215{
"cache_name",
"", },
223 const autoservice_name = args[
"service_name"].AsString();
224 const autoclient_name = args[
"client_name"].AsString();
225 const autocache_name = args[
"cache_name"].AsString();
234{
"service_name",
"", },
235{
"client_name",
"", },
236{
"cache_name",
"", },
244 const autoservice_name = args[
"service_name"].AsString();
245 const autoclient_name = args[
"client_name"].AsString();
246 const autocache_name = args[
"cache_name"].AsString();
276{
"get_blob", ExecMethod<TSelf, &TSelf::ExecGetBlob>, {
277{
"blob_key",
"", },
278{
"blob_version", 0, },
279{
"blob_subkey",
"", },
281{
"get_servers", ExecMethod<TSelf, &TSelf::ExecGetServers>, },
285cmds.insert(cmds.end(), base_cmds.begin(), base_cmds.end());
294 auto& reply = io.
reply;
295 const autoblob_key = args[
"blob_key"].AsString();
296 const autoblob_version = args[
"blob_version"].AsInteger<
int>();
297 const autoblob_subkey = args[
"blob_subkey"].AsString();
312 auto& reply = io.
reply;
319reply.Append(object_ids);
static CJsonNode NewArrayNode()
Create a new JSON array node.
void AppendInteger(Int8 value)
For an array node, add a integer node at the end of the array.
void AppendString(const string &value)
For an array node, add a string node at the end of the array.
NetCache internal exception.
Client to NetCache server (implements ICache interface)
void SetWarningHandler(TEventHandler warning_handler)
CNetServiceIterator Iterate(EIterationMode mode=eSortByLoad)
A very basic data-read interface.
CAutomationProc * m_AutomationProc
TObjectID AddObject(TAutomationObjectRef new_object)
void SendWarning(const string &warn_msg, TAutomationObjectRef source)
TAutomationObjectRef ReturnNetCacheServerObject(CNetICacheClient::TInstance ic_api, CNetServer::TInstance server)
#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.
static bool IsValidKey(const char *key_str, size_t key_len, CCompoundIDPool::TInstance id_pool=NULL)
string PutData(const void *buf, size_t size, const CNamedParameterList *optional=NULL)
Put BLOB to server.
IEmbeddedStreamWriter * GetNetCacheWriter(const string &key, int version, const string &subkey, const CNamedParameterList *optional=NULL)
Create or update the specified blob.
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.
void Reset(void)
Reset reference object.
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.
pair< TCommands, TCommandChecker > TCommandGroup
vector< CCommand > TCommands
const GenericPointer< typename T::ValueType > T2 value
IReader * GetReadStream(const string &key, const string &subkey, int *version, size_t *blob_size_ptr, const CNamedParameterList *optional=NULL)
SNetCacheBlob(SNetCacheService *nc_object, const string &blob_key)
void ExecWrite(const TArguments &args, SInputOutput &io)
static CCommand CallCommand()
CRef< SNetCacheService > m_NetCacheObject
void ExecRead(const TArguments &args, SInputOutput &io)
static TCommands CallCommands()
virtual void ExecGetKey(const TArguments &args, SInputOutput &io)
static const string kName
void ExecClose(const TArguments &args, SInputOutput &io)
unique_ptr< IReader > m_Reader
unique_ptr< IEmbeddedStreamWriter > m_Writer
static CCommand NewCommand()
SNetCacheServer(CAutomationProc *automation_proc, CNetICacheClientExt ic_api, CNetServer::TInstance server)
static CAutomationObject * Create(const TArguments &args, CAutomationProc *automation_proc)
static const string kName
static CCommand CallCommand()
IReader * GetReader(const string &blob_key, size_t &blob_size)
CNetCacheAPI m_NetCacheAPI
IEmbeddedStreamWriter * GetWriter(string &blob_key)
static CAutomationObject * Create(const TArguments &args, CAutomationProc *automation_proc)
static const string kName
void ExecGetBlob(const TArguments &args, SInputOutput &io)
static CCommand CallCommand()
CNetICacheClientExt m_NetICacheClient
SNetCacheService(CAutomationProc *automation_proc, CNetICacheClientExt ic_api)
static CCommand NewCommand()
void ExecGetServers(const TArguments &args, SInputOutput &io)
static TCommands CallCommands()
void ExecGetKey(const TArguments &args, SInputOutput &io) override
void SetWriter() override
SNetICacheBlob(SNetCacheService *nc_object, const string &blob_key, int blob_version, const string &blob_subkey)
void SetReader() override
static TCommands CallCommands()
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