4 #include "cvmfs_config.h"
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,
83 const string &description)
86 int fd = this->
StartTxn(
id, size, txn);
90 int64_t retval = this->
Write(buffer, size, txn);
91 if ((retval < 0) || (static_cast<uint64_t>(retval) != size)) {
101 State *state =
reinterpret_cast<State *
>(data);
102 if (fd_progress >= 0)
103 SendMsg2Socket(fd_progress,
"Releasing saved open files table\n");
108 if (fd_progress >= 0) {
110 " *** Releasing open files table failed!\n");
129 const std::string &description,
130 unsigned char **buffer,
142 *size =
static_cast<uint64_t
>(s);
146 *buffer =
static_cast<unsigned char *
>(smalloc(*size));
147 retval = this->
Pread(fd, *buffer, *size, 0);
153 if ((retval < 0) || (static_cast<uint64_t>(retval) != *size)) {
172 const string &description,
176 int fd = this->
Open(
Bless(
id, object_info));
184 quota_mgr_->
Pin(
id, static_cast<uint64_t>(size), description, is_catalog);
195 State *state =
reinterpret_cast<State *
>(data);
196 if (fd_progress >= 0)
199 if (fd_progress >= 0)
204 if (fd_progress >= 0)
205 SendMsg2Socket(fd_progress,
"switching cache manager unsupported!\n");
209 if (new_root_fd < -1) {
222 if (fd_progress >= 0)
228 if (fd_progress >= 0) {
230 " *** This cache manager does not support saving state!\n");
int ChecksumFd(int fd, shash::Any *id)
virtual int64_t GetSize(int fd)=0
int OpenPinned(const shash::Any &id, const std::string &description, bool is_catalog)
int RestoreState(const int fd_progress, void *state)
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 int Open(const BlessedObject &object)=0
virtual void * DoSaveState()
virtual bool DoFreeState(void *data)
virtual CacheManagerIds id()=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)
virtual bool Pin(const shash::Any &hash, const uint64_t size, const std::string &description, const bool is_catalog)=0
bool CommitFromMem(const shash::Any &id, const unsigned char *buffer, const uint64_t size, const std::string &description)
void Final(ContextPtr context, Any *any_digest)
bool Open2Mem(const shash::Any &id, const std::string &description, unsigned char **buffer, uint64_t *size)
virtual int Close(int fd)=0
void CompressInit(z_stream *strm)
static const unsigned kStateVersion
void FreeState(const int fd_progress, void *state)
static BlessedObject Bless(const shash::Any &id)
QuotaManager * quota_mgr_
virtual uint32_t SizeOfTxn()=0
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
virtual void CtrlTxn(const ObjectInfo &object_info, const int flags, void *txn)=0