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

Function fetchThroughCache

src/launcher/fetcher.cpp:406–447  ·  view source on GitHub ↗

Returns the resulting file or in case of extraction the destination directory (for logging).

Source from the content-addressed store, hash-verified

404// Returns the resulting file or in case of extraction the destination
405// directory (for logging).
406static Try<string> fetchThroughCache(
407 const FetcherInfo::Item& item,
408 const Option<string>& cacheDirectory,
409 const string& sandboxDirectory,
410 const Option<string>& frameworksHome,
411 const Option<Duration>& stallTimeout)
412{
413 if (cacheDirectory.isNone() || cacheDirectory->empty()) {
414 return Error("Cache directory not specified");
415 }
416
417 if (!item.has_cache_filename() || item.cache_filename().empty()) {
418 // This should never happen if this program is used by the Mesos
419 // slave and could then be a CHECK. But other uses are possible.
420 return Error("No cache file name for: " + item.uri().value());
421 }
422
423 CHECK_NE(FetcherInfo::Item::BYPASS_CACHE, item.action())
424 << "Unexpected fetcher action selector";
425
426 CHECK(os::exists(cacheDirectory.get()))
427 << "Fetcher cache directory was expected to exist but was not found";
428
429 if (item.action() == FetcherInfo::Item::DOWNLOAD_AND_CACHE) {
430 const string cachePath =
431 path::join(cacheDirectory.get(), item.cache_filename());
432
433 if (!os::exists(cachePath)) {
434 Try<string> downloaded = download(
435 item.uri().value(),
436 cachePath,
437 frameworksHome,
438 stallTimeout);
439
440 if (downloaded.isError()) {
441 return Error(downloaded.error());
442 }
443 }
444 }
445
446 return fetchFromCache(item, cacheDirectory.get(), sandboxDirectory);
447}
448
449
450// Returns the resulting file or in case of extraction the destination

Callers 1

fetchFunction · 0.85

Calls 12

fetchFromCacheFunction · 0.85
actionMethod · 0.80
downloadFunction · 0.70
errorMethod · 0.65
ErrorFunction · 0.50
existsFunction · 0.50
joinFunction · 0.50
isNoneMethod · 0.45
emptyMethod · 0.45
valueMethod · 0.45
getMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected