コード例 #1
0
ファイル: fetcher.cpp プロジェクト: fin09pcap/mesos
// Returns the resulting file or in case of extraction the destination
// directory (for logging).
static Try<string> fetchBypassingCache(
    const CommandInfo::URI& uri,
    const string& sandboxDirectory,
    const Option<string>& frameworksHome)
{
  LOG(INFO) << "Fetching directly into the sandbox directory";

  Try<string> basename = Fetcher::basename(uri.value());
  if (basename.isError()) {
    return Error("Failed to determine the basename of the URI '" +
                 uri.value() + "' with error: " + basename.error());
  }

  string path = path::join(sandboxDirectory, basename.get());

  Try<string> downloaded = download(uri.value(), path, frameworksHome);
  if (downloaded.isError()) {
    return Error(downloaded.error());
  }

  if (uri.executable()) {
    return chmodExecutable(downloaded.get());
  } else if (uri.extract()) {
    Try<bool> extracted = extract(path, sandboxDirectory);
    if (extracted.isError()) {
      return Error(extracted.error());
    } else if (!extracted.get()) {
      LOG(WARNING) << "Copying instead of extracting resource from URI with "
                   << "'extract' flag, because it does not seem to be an "
                   << "archive: " << uri.value();
    }
  }

  return downloaded;
}
コード例 #2
0
ファイル: type_utils.hpp プロジェクト: WuErPing/mesos
inline bool operator == (
    const CommandInfo::URI& left,
    const CommandInfo::URI& right)
{
  return left.has_executable() == right.has_executable() &&
    (!left.has_executable() || (left.executable() == right.executable())) &&
    left.value() == right.value();
}
コード例 #3
0
ファイル: fetcher.cpp プロジェクト: BonnieTang/mesos
// Returns the resulting file or in case of extraction the destination
// directory (for logging).
static Try<string> fetchBypassingCache(
    const CommandInfo::URI& uri,
    const string& sandboxDirectory,
    const Option<string>& frameworksHome)
{
  LOG(INFO) << "Fetching directly into the sandbox directory";

  // TODO(mrbrowning): Factor out duplicated processing of "output_file" field
  // here and in fetchFromCache into a separate helper function.
  if (uri.has_output_file()) {
    string dirname = Path(uri.output_file()).dirname();
    if (dirname != ".") {
      Try<Nothing> result =
        os::mkdir(path::join(sandboxDirectory, dirname), true);

      if (result.isError()) {
        return Error(
            "Unable to create subdirectory " + dirname + " in sandbox");
      }
    }
  }

  Try<string> outputFile = uri.has_output_file()
    ? uri.output_file()
    : Fetcher::basename(uri.value());

  if (outputFile.isError()) {
    return Error(outputFile.error());
  }

  string path = path::join(sandboxDirectory, outputFile.get());

  Try<string> downloaded = download(uri.value(), path, frameworksHome);
  if (downloaded.isError()) {
    return Error(downloaded.error());
  }

  if (uri.executable()) {
    return chmodExecutable(downloaded.get());
  } else if (uri.extract()) {
    Try<bool> extracted = extract(path, sandboxDirectory);
    if (extracted.isError()) {
      return Error(extracted.error());
    } else if (!extracted.get()) {
      LOG(WARNING) << "Copying instead of extracting resource from URI with "
                   << "'extract' flag, because it does not seem to be an "
                   << "archive: " << uri.value();
    }
  }

  return downloaded;
}
コード例 #4
0
ファイル: type_utils.hpp プロジェクト: GSidRam/mesos
inline std::size_t hash_value(const CommandInfo::URI& uri)
{
  size_t seed = 0;

  if (uri.extract()) {
    seed += 11;
  }

  if (uri.executable()) {
    seed += 2003;
  }

  boost::hash_combine(seed, uri.value());
  return seed;
}
コード例 #5
0
ファイル: type_utils.cpp プロジェクト: lukeleslie/mesos
bool operator == (const CommandInfo::URI& left, const CommandInfo::URI& right)
{
    return left.value() == right.value() &&
           left.executable() == right.executable() &&
           left.extract() == right.extract();
}