24 return "Internal in-memory cache manager (size " +
38 , regular_entries_(max_entries,
41 perf::StatisticsTemplate(
"kv.regular", statistics))
42 , volatile_entries_(max_entries,
45 perf::StatisticsTemplate(
"kv.volatile", statistics))
46 , counters_(statistics)
48 int retval = pthread_rwlock_init(&
rwlock_, NULL);
51 max_size, max_entries);
53 "DEPRECATION WARNING: The RAM cache manager is depcreated and "
54 "will be removed from future releases.");
59 pthread_rwlock_destroy(&
rwlock_);
65 if (result == -ENFILE) {
98 id.ToString().c_str());
103 int fd =
AddFd(generic_handle);
106 id.ToString().c_str(), strerror(-fd));
111 id.ToString().c_str());
115 id.ToString().c_str());
170 generic_handle.
handle, buf, size, offset);
183 rc =
AddFd(generic_handle);
184 if (rc < 0)
return rc;
211 id.ToString().c_str());
214 transaction->
pos = 0;
220 "failed to allocate %lu B for %s",
221 size,
id.ToString().c_str());
247 size_t new_size = max(2*transaction->
buffer.
size,
248 static_cast<size_t>(size + transaction->
pos));
252 void *new_ptr = realloc(transaction->
buffer.
address, new_size);
255 "failed to allocate %lu B for %s",
263 "attempted to write more than requested (%lu>%zu)",
283 transaction->
pos = 0;
297 "error while committing transaction on %s: %s",
323 if (rc < 0)
return rc;
348 int64_t overrun = regular_size + volatile_size +
353 overrun = max(overrun, (int64_t)
max_size_>>2);
364 "transaction for %s would overrun the cache limit by %ld",
373 "commit on %s failed",
perf::Counter * n_aborttxn
perf::Counter * n_openmiss
virtual CacheManagerIds id()
RamCacheManager(uint64_t max_size, unsigned max_entries, MemoryKvStore::MemoryAllocator alloc, perf::StatisticsTemplate statistics)
perf::Counter * n_getsize
virtual int OpenFromTxn(void *txn)
std::string GetDescription() const
virtual int Open(const LabeledObject &object)
static const shash::Any kInvalidHandle
static const int kLabelCatalog
bool Contains(const shash::Any &id)
std::string ToString(const bool with_suffix=false) const
int64_t Read(const shash::Any &id, void *buf, size_t size, size_t offset)
virtual int Close(int fd)
perf::Counter * n_committxn
virtual int CommitTxn(void *txn)
assert((mem||(size==0))&&"Out Of Memory")
MemoryKvStore * GetStore(const ReadOnlyHandle &fd)
virtual int AbortTxn(void *txn)
perf::Counter * n_starttxn
virtual void CtrlTxn(const Label &label, const int flags, void *txn)
virtual int StartTxn(const shash::Any &id, uint64_t size, void *txn)
int Commit(const MemoryBuffer &buf)
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)
virtual int Readahead(int fd)
FdTable< ReadOnlyHandle > fd_table_
perf::Counter * n_readahead
perf::Counter * n_overrun
bool IncRef(const shash::Any &id)
perf::Counter * n_realloc
int AddFd(const ReadOnlyHandle &handle)
int64_t CommitToKvStore(Transaction *transaction)
perf::Counter * n_openregular
bool Unref(const shash::Any &id)
static const int kLabelPinned
string StringifyInt(const int64_t value)
bool ShrinkTo(size_t size)
void Inc(class Counter *counter)
virtual int DoOpen(const shash::Any &id)
static const int kLabelVolatile
perf::Counter * n_openvolatile
virtual std::string Describe()
int64_t GetSize(const shash::Any &id)
QuotaManager * quota_mgr()
QuotaManager * quota_mgr_
virtual int64_t GetSize(int fd)
virtual int Reset(void *txn)
virtual ~RamCacheManager()
MemoryKvStore regular_entries_
MemoryKvStore volatile_entries_
virtual int64_t Write(const void *buf, uint64_t size, void *txn)
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)
static const uint64_t kSizeUnknown
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)