41 hash_context.
buffer = alloca(hash_context.
size);
48 unsigned char buf[4096];
53 int64_t nbytes =
Pread(fd, buf, 4096, pos);
81 const unsigned char *buffer,
85 int fd = this->
StartTxn(
object.
id, size, txn);
88 this->
CtrlTxn(
object.label, 0, txn);
89 int64_t retval = this->
Write(buffer, size, txn);
90 if ((retval < 0) || (static_cast<uint64_t>(retval) != size)) {
100 State *state =
reinterpret_cast<State *
>(data);
101 if (fd_progress >= 0)
102 SendMsg2Socket(fd_progress,
"Releasing saved open files table\n");
107 if (fd_progress >= 0) {
109 " *** Releasing open files table failed!\n");
128 unsigned char **buffer,
134 int fd = this->
Open(
object);
140 *size =
static_cast<uint64_t
>(s);
144 *buffer =
static_cast<unsigned char *
>(smalloc(*size));
145 retval = this->
Pread(fd, *buffer, *size, 0);
151 if ((retval < 0) || (static_cast<uint64_t>(retval) != *size)) {
169 int fd = this->
Open(
object);
177 object.
id, static_cast<uint64_t>(size),
178 object.label.GetDescription(),
object.label.IsCatalog());
189 State *state =
reinterpret_cast<State *
>(data);
190 if (fd_progress >= 0)
193 if (fd_progress >= 0)
198 if (fd_progress >= 0)
199 SendMsg2Socket(fd_progress,
"switching cache manager unsupported!\n");
203 if (new_root_fd < -1) {
216 if (fd_progress >= 0)
222 if (fd_progress >= 0) {
224 " *** This cache manager does not support saving state!\n");
int ChecksumFd(int fd, shash::Any *id)
virtual int64_t GetSize(int fd)=0
int RestoreState(const int fd_progress, void *state)
int OpenPinned(const LabeledObject &object)
CacheManagerIds manager_type
void * SaveState(const int fd_progress)
void SendMsg2Socket(const int fd, const std::string &msg)
assert((mem||(size==0))&&"Out Of Memory")
virtual int AbortTxn(void *txn)=0
virtual void * DoSaveState()
virtual bool DoFreeState(void *data)
virtual CacheManagerIds id()=0
virtual int Open(const LabeledObject &object)=0
void Init(ContextPtr context)
StreamStates CompressZStream2Null(const void *buf, const int64_t size, const bool eof, z_stream *strm, shash::ContextPtr *hash_context)
virtual int DoRestoreState(void *data)
virtual int CommitTxn(void *txn)=0
void CompressFini(z_stream *strm)
bool CommitFromMem(const LabeledObject &object, const unsigned char *buffer, const uint64_t size)
virtual bool Pin(const shash::Any &hash, const uint64_t size, const std::string &description, const bool is_catalog)=0
void Final(ContextPtr context, Any *any_digest)
virtual int Close(int fd)=0
void CompressInit(z_stream *strm)
static const unsigned kStateVersion
void FreeState(const int fd_progress, void *state)
virtual void CtrlTxn(const Label &label, const int flags, void *txn)=0
QuotaManager * quota_mgr_
virtual uint32_t SizeOfTxn()=0
bool Open2Mem(const LabeledObject &object, unsigned char **buffer, uint64_t *size)
virtual int StartTxn(const shash::Any &id, uint64_t size, void *txn)=0
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)=0
virtual int64_t Write(const void *buf, uint64_t sz, void *txn)=0
static const uint64_t kSizeUnknown