29 void ClientCatalogManager::ActivateCatalog(
Catalog *catalog) {
30 const Counters &counters =
const_cast<const Catalog*
>(catalog)->GetCounters();
38 ClientCatalogManager::ClientCatalogManager(
MountPoint *mountpoint)
40 , repo_name_(mountpoint->fqrn())
41 , fetcher_(mountpoint->fetcher())
43 , workspace_(mountpoint->file_system()->workspace())
44 , offline_mode_(false)
47 , fixed_root_catalog_()
48 , fixed_alt_root_catalog_(false)
53 "cache.n_certificate_hits",
"Number of certificate hits");
55 "cache.n_certificate_misses",
"Number of certificate misses");
77 return new Catalog(mountpoint, catalog_hash, parent_catalog);
97 bool alternative_path)
156 uint64_t local_newest_timestamp = 0;
163 local_newest_timestamp = breadcrumb.
timestamp;
164 local_newest_revision = breadcrumb.
revision;
166 "Cached copy publish date %s (hash %s, revision %" PRIu64
")",
167 StringifyTime(static_cast<int64_t>(local_newest_timestamp),
true).c_str(),
180 const std::map<PathString, shash::Any>::iterator curr_hash_itr =
182 mounted_hash = curr_hash_itr->second;
190 local_newest_hash = mounted_hash;
204 local_newest_hash = mounted_hash;
223 if (ensemble->manifest->revision() > local_newest_revision
227 || (ensemble->manifest->revision() == 0 &&
228 local_newest_revision == 0)) {
229 result->
SetHash(ensemble->manifest->catalog_hash());
235 static_cast<manifest::ManifestEnsemble*>(
243 "Failed fetch manifest from server: "
244 "manifest too old or server unreachable (%d - %s)",
254 && ensemble->manifest->revision() == local_newest_revision) {
259 result->
SetHash(local_newest_hash);
273 return "file catalog at " +
repo_name_ +
":" +
295 ctlg_context->
hash());
296 string alt_root_catalog_path =
"";
304 catalog_descr, alt_root_catalog_path,
350 const std::string &alt_root_catalog_path,
351 std::string *sqlite_path)
358 alt_root_catalog_path);
365 "FetchCatalogByHash filedescriptor %d", fd);
394 map<PathString, shash::Any>::iterator iter =
416 " is blacklisted",
repo_name_.c_str(), revision);
419 for (
unsigned i = 0; i < blacklist.size(); ++i) {
420 std::string line = blacklist[i];
424 if (line.length() <= idx)
426 if ((line[idx] !=
' ') && (line[idx] !=
'\t'))
431 while ((line[idx] ==
' ') || (line[idx] ==
'\t'))
433 if (idx >= line.length())
Counter * Register(const std::string &name, const std::string &desc)
shash::Any fixed_root_catalog_
const Counters & GetCounters() const
cvmfs::Fetcher * fetcher_
friend class CachedManifestEnsemble
download::DownloadManager * download_mgr()
std::string MakeAlternativePath() const
perf::Statistics * statistics()
static const int kLabelCatalog
virtual void Unpin(const shash::Any &hash)=0
perf::Counter * n_certificate_misses_
std::string ToString(const bool with_suffix=false) const
bool fixed_alt_root_catalog_
CacheManager * cache_mgr()
static const uint64_t kInvalidRevision
RootCatalogLocation root_ctlg_location() const
virtual manifest::Breadcrumb LoadBreadcrumb(const std::string &)
virtual void StageNestedCatalogByHash(const shash::Any &hash, const PathString &mountpoint)
Counters_t GetSelfEntries() const
assert((mem||(size==0))&&"Out Of Memory")
perf::Counter * n_certificate_hits_
virtual bool StoreBreadcrumb(const manifest::Manifest &)
string StringifyTime(const time_t seconds, const bool utc)
std::map< PathString, shash::Any > loaded_catalogs_
bool String2Uint64Parse(const std::string &value, uint64_t *result)
manifest::ManifestEnsemble * manifest_ensemble() const
void SetMountpoint(const PathString &mountpoint)
std::string repo_name() const
void TakeManifestEnsemble(manifest::ManifestEnsemble *manifest_ensemble)
static const int kLabelCertificate
LoadReturn FetchCatalogByHash(const shash::Any &hash, const std::string &name, const std::string &alt_catalog_path, std::string *catalog_path)
int Fetch(const CacheManager::LabeledObject &object, const std::string &alt_url="")
signature::SignatureManager * signature_mgr_
bool CommitFromMem(const LabeledObject &object, const unsigned char *buffer, const uint64_t size)
bool IsRevisionBlacklisted()
const char kSuffixCatalog
std::map< PathString, shash::Any > mounted_catalogs_
Failures Fetch(const std::string &base_url, const std::string &repository_name, const uint64_t minimum_timestamp, const shash::Any *base_catalog, signature::SignatureManager *signature_manager, download::DownloadManager *download_manager, ManifestEnsemble *ensemble)
const signature::SignatureManager * signature_mgr() const
uint64_t GetTimestampNoLock() const
shash::Any certificate() const
void FetchCertificate(const shash::Any &hash)
PathString mountpoint() const
virtual LoadReturn LoadCatalogByHash(CatalogContext *ctlg_context)
string StringifyInt(const int64_t value)
void Inc(class Counter *counter)
ClientCatalogManager * catalog_mgr_
virtual int Close(int fd)=0
void SetRootCtlgLocation(RootCatalogLocation root_ctlg_location)
bool InitFixed(const shash::Any &root_hash, bool alternative_path)
std::string GetCatalogDescription(const PathString &mountpoint, const shash::Any &hash)
CacheManager * cache_mgr_
signature::SignatureManager * signature_mgr_
QuotaManager * quota_mgr()
catalog::Catalog * CreateCatalog(const PathString &mountpoint, const shash::Any &catalog_hash, catalog::Catalog *parent_catalog)
std::string * GetSqlitePathPtr()
uint64_t GetRevision() const
uint64_t GetRevisionNoLock() const
std::string ToString() const
virtual ~ClientCatalogManager()
ShortString< kDefaultMaxPath, 0 > PathString
PathString mountpoint() const
Catalog * MountCatalog(const PathString &mountpoint, const shash::Any &hash, Catalog *parent_catalog)
virtual LoadReturn GetNewRootCatalogContext(CatalogContext *result)
bool Open2Mem(const LabeledObject &object, unsigned char **buffer, uint64_t *size)
void SetHash(shash::Any hash)
manifest::Manifest * manifest() const
unsigned GetLength() const
Counters_t GetAllEntries() const
const char * c_str() const
const char * GetChars() const
std::vector< std::string > GetBlacklist()
void UnloadCatalog(const catalog::Catalog *catalog)
void SetRootCtlgRevision(uint64_t root_ctlg_revision)
const char * Code2Ascii(const Failures error)
CVMFS_EXPORT void LogCvmfs(const LogSource source, const int mask, const char *format,...)