5 #define _FILE_OFFSET_BITS 64
6 #define __STDC_FORMAT_MACROS
8 #include "cvmfs_config.h"
45 case cvmfs::OBJECT_REGULAR:
47 case cvmfs::OBJECT_CATALOG:
49 case cvmfs::OBJECT_VOLATILE:
59 , callbacks_(*callbacks)
94 int result = callbacks_.cvmcache_chrefcnt(&c_hash, change_by);
95 return static_cast<cvmfs::EnumStatus
>(result);
104 memset(&c_info, 0,
sizeof(c_info));
106 int result = callbacks_.cvmcache_obj_info(&c_hash, &c_info);
114 return static_cast<cvmfs::EnumStatus
>(result);
121 unsigned char *buffer)
124 int result = callbacks_.cvmcache_pread(&c_hash, offset, size, buffer);
125 return static_cast<cvmfs::EnumStatus
>(result);
130 const uint64_t txn_id,
134 return cvmfs::STATUS_NOSUPPORT;
138 memset(&c_info, 0,
sizeof(c_info));
146 int result = callbacks_.cvmcache_start_txn(&c_hash, txn_id, &c_info);
148 return static_cast<cvmfs::EnumStatus
>(result);
152 const uint64_t txn_id,
153 unsigned char *buffer,
157 return cvmfs::STATUS_NOSUPPORT;
159 int result = callbacks_.cvmcache_write_txn(txn_id, buffer, size);
160 return static_cast<cvmfs::EnumStatus
>(result);
163 virtual cvmfs::EnumStatus
CommitTxn(
const uint64_t txn_id) {
165 return cvmfs::STATUS_NOSUPPORT;
167 int result = callbacks_.cvmcache_commit_txn(txn_id);
168 return static_cast<cvmfs::EnumStatus
>(result);
171 virtual cvmfs::EnumStatus
AbortTxn(
const uint64_t txn_id) {
173 return cvmfs::STATUS_NOSUPPORT;
175 int result = callbacks_.cvmcache_abort_txn(txn_id);
176 return static_cast<cvmfs::EnumStatus
>(result);
181 return cvmfs::STATUS_NOSUPPORT;
188 int result = callbacks_.cvmcache_info(&c_info);
195 return static_cast<cvmfs::EnumStatus
>(result);
198 virtual cvmfs::EnumStatus
Shrink(uint64_t shrink_to, uint64_t *used) {
200 return cvmfs::STATUS_NOSUPPORT;
202 int result = callbacks_.cvmcache_shrink(shrink_to, used);
203 return static_cast<cvmfs::EnumStatus
>(result);
208 cvmfs::EnumObjectType
type)
211 return cvmfs::STATUS_NOSUPPORT;
215 return static_cast<cvmfs::EnumStatus
>(result);
223 return cvmfs::STATUS_NOSUPPORT;
226 memset(&c_item, 0,
sizeof(c_item));
227 int result = callbacks_.cvmcache_listing_next(lst_id, &c_item);
238 return static_cast<cvmfs::EnumStatus
>(result);
243 return cvmfs::STATUS_NOSUPPORT;
245 int result = callbacks_.cvmcache_listing_end(lst_id);
246 return static_cast<cvmfs::EnumStatus
>(result);
253 return cvmfs::STATUS_NOSUPPORT;
257 callbacks_.cvmcache_breadcrumb_load(fqrn.c_str(), &c_breadcrumb);
263 return static_cast<cvmfs::EnumStatus
>(result);
270 return cvmfs::STATUS_NOSUPPORT;
277 callbacks_.cvmcache_breadcrumb_store(fqrn.c_str(), &c_breadcrumb);
278 return static_cast<cvmfs::EnumStatus
>(result);
301 else if (hash_a == hash_b)
309 return strdup(hash.
ToString().c_str());
327 return ctx->
plugin->Listen(locator);
332 ctx->
plugin->ProcessRequests(nworkers);
336 ctx->
plugin->AskToDetach();
349 return ctx->
plugin->max_object_size();
356 session_ctx->
Get(&(session->
id),
366 g_watchdog->
Spawn((crash_dump_file != NULL) ?
string(crash_dump_file) :
"");
struct cvmcache_hash catalog_hash
void Get(uint64_t *id, char **reponame, char **client_instance)
int(* cvmcache_chrefcnt)(struct cvmcache_hash *id, int32_t change_by)
struct cvmcache_hash Cpphash2Chash(const shash::Any &hash)
struct cvmcache_context * ctx
Session * session() const
static const uint64_t kSizeUnknown
int(* cvmcache_info)(struct cvmcache_info *info)
void cvmcache_terminate(struct cvmcache_context *ctx)
virtual ~ForwardCachePlugin()
int cvmcache_listen(struct cvmcache_context *ctx, char *locator)
std::string ToString(const bool with_suffix=false) const
int(* cvmcache_listing_next)(int64_t lst_id, struct cvmcache_object_info *item)
void cvmcache_cleanup_global()
void cvmcache_terminate_watchdog()
virtual cvmfs::EnumStatus LoadBreadcrumb(const std::string &fqrn, manifest::Breadcrumb *breadcrumb)
cvmfs::EnumObjectType object_type
assert((mem||(size==0))&&"Out Of Memory")
int cvmcache_is_supervised()
int(* cvmcache_pread)(struct cvmcache_hash *id, uint64_t offset, uint32_t *size, unsigned char *buffer)
int(* cvmcache_breadcrumb_load)(const char *fqrn, cvmcache_breadcrumb *breadcrumb)
unsigned char digest[digest_size_]
virtual cvmfs::EnumStatus GetInfo(Info *info)
void cvmcache_wait_for(struct cvmcache_context *ctx)
virtual cvmfs::EnumStatus AbortTxn(const uint64_t txn_id)
static Watchdog * Create(FnOnCrash on_crash)
void cvmcache_ask_detach(struct cvmcache_context *ctx)
int(* cvmcache_write_txn)(uint64_t txn_id, unsigned char *buffer, uint32_t size)
virtual cvmfs::EnumStatus StartTxn(const shash::Any &id, const uint64_t txn_id, const ObjectInfo &info)
virtual cvmfs::EnumStatus CommitTxn(const uint64_t txn_id)
int cvmcache_hash_cmp(struct cvmcache_hash *a, struct cvmcache_hash *b)
virtual cvmfs::EnumStatus StoreBreadcrumb(const std::string &fqrn, const manifest::Breadcrumb &breadcrumb)
void cvmcache_get_session(cvmcache_session *session)
cvmcache_context(ForwardCachePlugin *p)
UniquePtr< ForwardCachePlugin > plugin
virtual cvmfs::EnumStatus WriteTxn(const uint64_t txn_id, unsigned char *buffer, uint32_t size)
void cvmcache_spawn_watchdog(const char *crash_dump_file)
char * cvmcache_hash_print(const struct cvmcache_hash *h)
enum cvmcache_object_type type
virtual cvmfs::EnumStatus Shrink(uint64_t shrink_to, uint64_t *used)
struct cvmcache_context * cvmcache_init(struct cvmcache_callbacks *callbacks)
virtual cvmfs::EnumStatus ListingBegin(uint64_t lst_id, cvmfs::EnumObjectType type)
void cvmcache_init_global()
int(* cvmcache_shrink)(uint64_t shrink_to, uint64_t *used)
int(* cvmcache_listing_begin)(uint64_t lst_id, enum cvmcache_object_type type)
virtual cvmfs::EnumStatus ListingEnd(int64_t lst_id)
void cvmcache_process_requests(struct cvmcache_context *ctx, unsigned nworkers)
int(* cvmcache_breadcrumb_store)(const char *fqrn, const cvmcache_breadcrumb *breadcrumb)
static enum cvmcache_object_type ObjectType2CType(cvmfs::EnumObjectType type)
int(* cvmcache_commit_txn)(uint64_t txn_id)
int(* cvmcache_start_txn)(struct cvmcache_hash *id, uint64_t txn_id, struct cvmcache_object_info *info)
int(* cvmcache_listing_end)(int64_t lst_id)
int(* cvmcache_abort_txn)(uint64_t txn_id)
void Spawn(const std::string &crash_dump_path)
ForwardCachePlugin(struct cvmcache_callbacks *callbacks)
virtual cvmfs::EnumStatus GetObjectInfo(const shash::Any &id, ObjectInfo *info)
virtual cvmfs::EnumStatus ChangeRefcount(const shash::Any &id, int32_t change_by)
int(* cvmcache_obj_info)(struct cvmcache_hash *id, struct cvmcache_object_info *info)
shash::Any Chash2Cpphash(const struct cvmcache_hash *h)
virtual cvmfs::EnumStatus Pread(const shash::Any &id, uint64_t offset, uint32_t *size, unsigned char *buffer)
virtual cvmfs::EnumStatus ListingNext(int64_t lst_id, ObjectInfo *item)
static const char * kEnvReadyNotifyFd
static SessionCtx * GetInstance()
uint32_t cvmcache_max_object_size(struct cvmcache_context *ctx)