& blob_id,
61 size_t* blob_size_ptr,
64m_Connection(exec_result.
conn)
79string::size_type pos = exec_result.
response.find(
"SIZE=");
81 if(pos == string::npos) {
85 "No SIZE field in reply to the blob reading command");
89exec_result.
response.c_str() + pos +
sizeof(
"SIZE=") - 1,
92 if(blob_size_ptr !=
NULL) {
102 while(bytes_to_read > 0) {
103 size_tbytes_read = 0;
105 sizeof(
buf) : (
size_t) bytes_to_read, &bytes_read);
107bytes_to_read -= bytes_read;
114 "Blob size is greater than the amount of data cached for it");
131 size_t* bytes_read_ptr)
134 if(bytes_read_ptr !=
NULL)
142 size_tbytes_read = 0;
151 "Unexpected EOF while reading file cache for "<<
m_BlobID<<
155 ", unread bytes: "<< remaining_bytes <<
")");
161 if(bytes_read_ptr !=
NULL)
162*bytes_read_ptr = bytes_read;
190setsockopt(fd, IPPROTO_TCP, TCP_QUICKACK, &
val,
sizeof(
val));
201 "Timeout while reading blob contents");
204 if(
count> *bytes_read) {
209 "Unexpected EOF while reading "<<
m_BlobID<<
211 ", unread bytes: "<< remaining_bytes <<
")");
229m_ResponseType(response_type),
230m_NetCacheAPI(
impl),
233m_Parameters(parameters)
266 size_t* bytes_written_ptr)
270 if(bytes_written_ptr !=
NULL)
271*bytes_written_ptr = bytes_written;
293 boolblob_written =
false;
298blob_written =
true;
321 "Timeout while sending EOF packet");
325 "IO error while sending EOF packet");
355 size_tbytes_written;
357 while(buf_size > 0) {
362buf_ptr += bytes_written;
363buf_size -= bytes_written;
397vector<CSocketAPI::SPoll>
poll(1,
423 if(!
msg.empty()) {
424 if(
msg.find(
"ERR:") == 0) {
475 size_t count,
size_t* bytes_written)
483 "Server closed communication channel (timeout?)");
488 "Timeout while writing blob contents");
501 if(bytes_written) *bytes_written =
count;
532 size_tbytes_written;
CNanoTimeout â Timeout interval, using nanoseconds.
NetCache internal exception.
const STimeout & GetCommunicationTimeout() const
IWriter with transmission control.
@ eDontSendEofPacket
Writer will not send EOF packet in the destructor.
@ eSendEofPacket
Writer will send EOF packet in the destructor.
std::ofstream out("events_result.xml")
main entry point for tests
static CS_CONNECTION * conn
#define poll(fds, nfds, timeout)
@ eNoOwnership
No ownership is assumed.
#define NCBI_CATCH_ALL_X(err_subcode, message)
#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.
void Close(void)
Close file.
size_t Write(const void *buf, size_t count) const
Write file.
void Flush(void) const
Flush file buffers.
void CreateTemporary(const string &dir, const string &prefix, EAutoRemove auto_remove=eRemoveInClose)
Create temporary file in the specified directory.
Uint8 GetFilePos(void) const
Get file position.
void SetFilePos(Uint8 position) const
Set file position from beginning of the file.
size_t Read(void *buf, size_t count) const
Read file.
CNetCacheAPI m_NetCacheAPI
ENetCacheResponseType m_ResponseType
virtual ERW_Result Write(const void *buf, size_t count, size_t *bytes_written=0)
Write up to "count" bytes from the buffer pointed to by the "buf" argument onto the output device.
void EstablishConnection()
CNetServerConnection m_Connection
virtual ~CNetCacheReader()
unique_ptr< CSocketReaderWriter > m_SocketReaderWriter
CNetCacheWriter(SNetCacheAPIImpl *impl, string *blob_id, const string &key, ENetCacheResponseType response_type, const CNetCacheAPIParameters *parameters)
CNetCacheAPI::ECachingMode GetCachingMode() const
virtual ERW_Result PendingCount(size_t *count)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
CNetCacheReader(SNetCacheAPIImpl *impl, const string &blob_id, CNetServer::SExecResult &exec_result, size_t *blob_size_ptr, const CNetCacheAPIParameters *parameters)
virtual ~CNetCacheWriter()
CNetServerConnection m_Connection
void SocketRead(void *buf, size_t count, size_t *bytes_read)
virtual ERW_Result Read(void *buf, size_t count, size_t *bytes_read_ptr=0)
Read as many as "count" bytes into a buffer pointed to by the "buf" argument.
size_t CheckBlobSize(Uint8 blob_size)
void WriteBufferAndClose(const char *buf_ptr, size_t buf_size)
virtual ERW_Result Flush(void)
Flush pending data (if any) down to the output device.
EIO_Status TransmitImpl(const char *buf, size_t count)
unique_ptr< CTransmissionWriter > m_TransmissionWriter
const CNetCacheAPIParameters * m_Parameters
void Transmit(const void *buf, size_t count, size_t *bytes_written)
uint64_t Uint8
8-byte (64-bit) unsigned integer
virtual ERW_Result PendingCount(size_t *count)
Via parameter "count" (which is guaranteed to be supplied non-NULL) return the number of bytes that a...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
virtual EIO_Status GetOSHandle(void *handle_buf, size_t handle_size, EOwnership ownership=eNoOwnership) const
Access to the system-specific socket handle.
EIO_Status ReadLine(string &str)
Read a line from socket (up to CR-LF, LF, or null character, discarding any of the EOLs).
static EIO_Status Poll(vector< SPoll > &polls, const STimeout *timeout, size_t *n_ready=0)
Poll a vector of CPollable objects for I/O readiness.
EIO_Status GetStatus(EIO_Event direction) const
Return status of *last* I/O operation without making any actual I/O.
void SetCork(bool on_off=true)
EIO_Status Read(void *buf, size_t size, size_t *n_read=0, EIO_ReadMethod how=eIO_ReadPlain)
Read from socket.
ERW_Result
Result codes for I/O operations.
const char * g_RW_ResultToString(ERW_Result res)
@ eRW_Eof
End of data, should be considered permanent.
@ eRW_Error
Unrecoverable error, no retry possible.
@ eRW_Timeout
Timeout expired, try again later.
@ eRW_Success
Everything is okay, I/O completed.
static string ParseEscapes(const CTempString str, EEscSeqRange mode=eEscSeqRange_Standard, char user_char='?')
Parse C-style escape sequences in the specified string.
static Uint8 StringToUInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Uint8.
@ fAllowTrailingSymbols
Ignore trailing non-numerics characters.
CNanoTimeout GetRemainingTime(void) const
Get time left to the expiration.
const STimeout * g_CTimeoutToSTimeout(const CTimeout &cto, STimeout &sto)
CTimeout/STimeout adapters.
const char * IO_StatusStr(EIO_Status status)
Get the text form of an enum status value.
CTimeout g_STimeoutToCTimeout(const STimeout *sto)
Convert STimeout to CTimeout.
EIO_Event
I/O event (or direction).
@ eIO_Timeout
timeout expired before any I/O succeeded
@ eIO_Interrupt
signal arrival prevented any I/O to succeed
@ eIO_NotSupported
operation is not supported or is not available
@ eIO_Success
everything is fine, no error occurred
@ eIO_Unknown
unknown I/O error (likely fatal but can retry)
@ eIO_InvalidArg
bad argument / parameter value(s) supplied
@ eIO_WritePlain
write as much as possible, report back how much
@ eIO_ReadWrite
eIO_Read | eIO_Write (also, eCONN_OnFlush)
@ eIO_Open
also serves as no-event indicator in SOCK_Poll
@ eIO_Close
also serves as an error indicator in SOCK_Poll
Definition of all error codes used in connect services library (xconnserv.lib and others).
const struct ncbi::grid::netcache::search::fields::KEY key
NetCache API exception declarations.
#define CACHE_XFER_BUFFER_SIZE
static const char s_OutputBlobCachePrefix[]
#define MAX_PENDING_COUNT
static const char s_InputBlobCachePrefix[]
#define CONNSERV_THROW_FMT(exception_class, err_code, server, message)
std::istream & in(std::istream &in_, double &x_)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
CNetServerConnection conn
The polling structure m_Event can be either of eIO_Open, eIO_Read, eIO_Write, eIO_ReadWrite.
virtual CNetServerConnection InitiateWriteCmd(CNetCacheWriter *nc_writer, const CNetCacheAPIParameters *parameters)
void ReadCmdOutputLine(string &result, bool multiline_output)
CRef< SNetServerInPool > m_ServerInPool
CNetServerPool m_ServerPool
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