コード例 #1
0
DirectoryEntryPtr
MetaDataStore::rename(const ObjectId& from_parent,
                      const std::string& from,
                      const ObjectId& to_parent,
                      const std::string& to)
{
    LOG_TRACE(from << " -> " << to);

    FrontendPath from_path(find_path(from_parent));
    from_path /= from;

    FrontendPath to_path(find_path(to_parent));
    to_path /= to;

    boost::optional<DirectoryEntryPtr>
        maybe_overwritten(harakoon_.rename<DirectoryEntry>(yt::UUID(from_parent.str()),
                                                           from,
                                                           yt::UUID(to_parent.str()),
                                                           to));
    drop_from_cache(from_path);

    DirectoryEntryPtr dentry;

    if (maybe_overwritten)
    {
        drop_from_cache(to_path);
        dentry = *maybe_overwritten;
    }

    return dentry;
}
コード例 #2
0
ファイル: OutputFileHandler.cpp プロジェクト: Chaste/Chaste
FileFinder OutputFileHandler::CopyFileTo(const FileFinder& rSourceFile) const
{
    if (!rSourceFile.IsFile())
    {
        EXCEPTION("Can only copy single files:\n" << rSourceFile.GetAbsolutePath() << " is not a file.");
    }
    fs::path from_path(rSourceFile.GetAbsolutePath());
    fs::path to_path(GetOutputDirectoryFullPath());
    to_path /= from_path.leaf();
    if (PetscTools::AmMaster())
    {
        try
        {
            fs::copy_file(from_path, to_path);
        }
        // LCOV_EXCL_START
        catch (const fs::filesystem_error& e)
        {
            TERMINATE("Error copying file '" << rSourceFile.GetAbsolutePath() << "': " << e.what());
        }
        // LCOV_EXCL_STOP
    }
    PetscTools::Barrier("OutputFileHandler::CopyFileTo");
    return FileFinder(to_path.string(), RelativeTo::Absolute);
}
コード例 #3
0
ファイル: router.cpp プロジェクト: mondieu/rest-cpp
  Router::Node* Router::Node::unify(Router::Node* const& root, std::string const& path, std::unordered_map<std::string, std::string>& params) {
    Node* node = from_path(path);
    Node* match = unify(root, node, params);

    delete node;

    // if (match != nullptr) {
    //   std::cout << "Matched '"<< path <<"' to '"<<match->uri()<<"'\n";
    // }

    return match;
  }
コード例 #4
0
void icarus::routes::compiler::compile(std::string from, std::string to)
{
	boost::filesystem::path from_path(from);
	boost::filesystem::path to_path(to);

	if (
		(!boost::filesystem::exists(to_path))
		|| (boost::filesystem::last_write_time(from_path) > boost::filesystem::last_write_time(to_path))
	)
	{
		parser parser(from_path.parent_path().string());
		document document(from_path.stem().string());
		parser.parse(from, document);

		routes_writer writer;
		std::stringstream memoryStream;
		writer.write(memoryStream, document);

		boost::filesystem::create_directories(to_path.parent_path());
		std::ofstream of(to_path.string());
		of << memoryStream.rdbuf();
	}
}
コード例 #5
0
int main( int argc, char* argv[])
{
  try {

    po::options_description generic("Generic options");
    generic.add_options()
      ("help,h", "display this help and exit")
      (
        "conf-file,c",
        po::value<std::string>(),
        "configuration file"
      )
      (
        "log-file,l",
        po::value<std::string>(),
        "logs any information into the specified file"
      );

    po::options_description triggering("Triggering options");
    triggering.add_options()
      (
        "threshold,t",
        po::value<int>(),
        "sets the purging threshold to the specified number of seconds"
      )
      (
        "allocated-limit,a",
        po::value<int>(),
        "defines the percentange of allocated blocks which triggers the"
        " purging"
      );

    po::options_description source("Job source options");
    source.add_options()
      (
        "staging-path,p",
        po::value<std::string>(),
        "absolute path to sandbox staging directory"
        " (useless in conjuctions with query-lbproxy)"
      )
      ( 
        "query-lbproxy,q", "query lbproxy for jobs in terminal state"
        " ( Available only if Common.LBProxy == true )"
      );
     po::options_description status("Job selection options");
     status.add_options()
      (
        "skip-status-checking,s",
        "does not perform any status checking before purging"
        " (does not work in conjuction with query-lbproxy)"
      )
      (
        "force-orphan-node-removal,o",
        "force removal of orphan dag nodes"
        " (does not work in coniuction with query-lbproxy)"
      )
     ;
    po::options_description desc;
    desc.add(generic).add(triggering).add(source).add(status);

    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(desc).run(), vm);
    po::notify(vm);

    if (vm.count("help")) {
      std::cout << desc << '\n';
      return EXIT_SUCCESS;
    }
    configuration::Configuration config(
      vm.count("conf-file")
      ? vm["conf-file"].as<std::string>()
      : "glite_wms.conf",
      configuration::ModuleType::workload_manager
    );

    bool have_lbproxy = lb_proxy();


    std::string const staging_path(
      vm.count("staging-path")
      ?  vm["staging-path"].as<std::string>()
      : get_staging_path()
    );
    
    int const allocated_limit(
      vm.count("allocated-limit") ? vm["allocated-limit"].as<int>(): 0
    );
    if (allocated_limit) {
      struct statfs fs_stat;
      if (!statfs(staging_path.c_str(), &fs_stat)) {
        int const allocated(
          static_cast<int>(
            (1.0 - (static_cast<double>(fs_stat.f_bfree) / fs_stat.f_blocks))
            * 100
          )
        );
        if (allocated < allocated_limit) {
          return EXIT_SUCCESS;
	}
      }
    }

    wl::purger::Purger thePurger(have_lbproxy);

    boost::function<int(edg_wll_Context)> log_clear;

    if (have_lbproxy) {
      log_clear = edg_wll_LogClearTIMEOUTProxy;
    } else {
      log_clear = edg_wll_LogClearTIMEOUT;
    }

    thePurger.threshold(
      vm.count("threshold") ? vm["threshold"].as<int>() : 0
    ).
    skip_status_checking(
      vm.count("skip-status-checking")
    ).
    force_orphan_node_removal(
      vm.count("force-orphan-node-removal")
    ).
    log_using(log_clear);
   
   if (vm.count("log-file")) {
     logger::threadsafe::edglog.open( vm["log-file"].as<std::string>(), logger::info);
   }
   else {
     logger::threadsafe::edglog.open( std::cout, logger::info);
   }
   std::vector<fs::path> found_path;
   fs::path from_path( staging_path, fs::native);
   
   purge_directories(
     from_path, 
     thePurger
   );

  }
  catch (boost::program_options::unknown_option const& e) {
    std::cerr<< e.what() << '\n';
  } catch (std::exception const& e) {
    std::cerr << e.what() << '\n';
  } catch (...) {
    std::cerr << "unknown exception\n";
  }
  return EXIT_FAILURE;
}