5 #define _FILE_OFFSET_BITS 64
6 #define __STDC_FORMAT_MACROS
45 case cvmfs::OBJECT_REGULAR:
47 case cvmfs::OBJECT_CATALOG:
49 case cvmfs::OBJECT_VOLATILE:
58 :
CachePlugin(callbacks->capabilities), callbacks_(*callbacks) {
90 int result = callbacks_.cvmcache_chrefcnt(&c_hash, change_by);
91 return static_cast<cvmfs::EnumStatus
>(result);
98 memset(&c_info, 0,
sizeof(c_info));
100 int result = callbacks_.cvmcache_obj_info(&c_hash, &c_info);
108 return static_cast<cvmfs::EnumStatus
>(result);
114 unsigned char *buffer) {
116 int result = callbacks_.cvmcache_pread(&c_hash, offset, size, buffer);
117 return static_cast<cvmfs::EnumStatus
>(result);
121 const uint64_t txn_id,
124 return cvmfs::STATUS_NOSUPPORT;
128 memset(&c_info, 0,
sizeof(c_info));
136 int result = callbacks_.cvmcache_start_txn(&c_hash, txn_id, &c_info);
138 return static_cast<cvmfs::EnumStatus
>(result);
141 virtual cvmfs::EnumStatus
WriteTxn(
const uint64_t txn_id,
142 unsigned char *buffer,
145 return cvmfs::STATUS_NOSUPPORT;
147 int result = callbacks_.cvmcache_write_txn(txn_id, buffer, size);
148 return static_cast<cvmfs::EnumStatus
>(result);
151 virtual cvmfs::EnumStatus
CommitTxn(
const uint64_t txn_id) {
153 return cvmfs::STATUS_NOSUPPORT;
155 int result = callbacks_.cvmcache_commit_txn(txn_id);
156 return static_cast<cvmfs::EnumStatus
>(result);
159 virtual cvmfs::EnumStatus
AbortTxn(
const uint64_t txn_id) {
161 return cvmfs::STATUS_NOSUPPORT;
163 int result = callbacks_.cvmcache_abort_txn(txn_id);
164 return static_cast<cvmfs::EnumStatus
>(result);
169 return cvmfs::STATUS_NOSUPPORT;
176 int result = callbacks_.cvmcache_info(&c_info);
183 return static_cast<cvmfs::EnumStatus
>(result);
186 virtual cvmfs::EnumStatus
Shrink(uint64_t shrink_to, uint64_t *used) {
188 return cvmfs::STATUS_NOSUPPORT;
190 int result = callbacks_.cvmcache_shrink(shrink_to, used);
191 return static_cast<cvmfs::EnumStatus
>(result);
195 cvmfs::EnumObjectType
type) {
197 return cvmfs::STATUS_NOSUPPORT;
199 int result = callbacks_.cvmcache_listing_begin(lst_id,
201 return static_cast<cvmfs::EnumStatus
>(result);
206 return cvmfs::STATUS_NOSUPPORT;
209 memset(&c_item, 0,
sizeof(c_item));
210 int result = callbacks_.cvmcache_listing_next(lst_id, &c_item);
221 return static_cast<cvmfs::EnumStatus
>(result);
226 return cvmfs::STATUS_NOSUPPORT;
228 int result = callbacks_.cvmcache_listing_end(lst_id);
229 return static_cast<cvmfs::EnumStatus
>(result);
235 return cvmfs::STATUS_NOSUPPORT;
238 int result = callbacks_.cvmcache_breadcrumb_load(fqrn.c_str(),
245 return static_cast<cvmfs::EnumStatus
>(result);
251 return cvmfs::STATUS_NOSUPPORT;
257 int result = callbacks_.cvmcache_breadcrumb_store(fqrn.c_str(),
259 return static_cast<cvmfs::EnumStatus
>(result);
282 else if (hash_a == hash_b)
290 return strdup(hash.
ToString().c_str());
308 return ctx->
plugin->Listen(locator);
313 ctx->
plugin->ProcessRequests(nworkers);
317 ctx->
plugin->AskToDetach();
330 return ctx->
plugin->max_object_size();
346 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)