MCPcopy Create free account
hub / github.com/apache/mesos / reserveCacheSpace

Method reserveCacheSpace

src/slave/containerizer/fetcher.cpp:701–741  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

699
700
701Future<shared_ptr<FetcherProcess::Cache::Entry>>
702FetcherProcess::reserveCacheSpace(
703 const Try<Bytes>& requestedSpace,
704 const shared_ptr<FetcherProcess::Cache::Entry>& entry)
705{
706 if (requestedSpace.isError()) {
707 // Let anyone waiting on this future know that we've
708 // failed to download and they should bypass the cache
709 // (any new requests will try again).
710 entry->fail();
711 cache.remove(entry);
712
713 return Failure("Could not determine size of cache file for '" +
714 entry->key + "' with error: " +
715 requestedSpace.error());
716 }
717
718 Try<Nothing> reservation = cache.reserve(requestedSpace.get());
719
720 if (reservation.isError()) {
721 // Let anyone waiting on this future know that we've
722 // failed to download and they should bypass the cache
723 // (any new requests will try again).
724 entry->fail();
725 cache.remove(entry);
726
727 return Failure("Failed to reserve space in the cache: " +
728 reservation.error());
729 }
730
731 VLOG(1) << "Claiming fetcher cache space for: " << entry->key;
732
733 cache.claimSpace(requestedSpace.get());
734
735 // NOTE: We must set the entry size only when we are also claiming
736 // the space! Other functions rely on this dependency (see
737 // Cache::remove()).
738 entry->size = requestedSpace.get();
739
740 return entry;
741}
742
743
744Future<Nothing> FetcherProcess::run(

Callers

nothing calls this directly

Calls 8

FailureClass · 0.85
claimSpaceMethod · 0.80
errorMethod · 0.65
isErrorMethod · 0.45
failMethod · 0.45
removeMethod · 0.45
reserveMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected