Ejemplo n.º 1
0
bool server_base::load(const std::string& id) {
  const std::string path = build_local_path(argv_, "jubatus", id);
  std::ifstream ifs(path.c_str(), std::ios::binary);
  if (!ifs) {
    throw JUBATUS_EXCEPTION(jubatus::exception::runtime_error("cannot open input file")
        << jubatus::exception::error_file_name(path)
        << jubatus::exception::error_errno(errno));
  }
  try {
    LOG(INFO) << "starting load from " << path;
    std::vector<mixable0*> mixables = get_mixable_holder()->get_mixables();
    for (size_t i = 0; i < mixables.size(); ++i) {
      mixables[i]->clear();
      mixables[i]->load(ifs);
    }
    ifs.close();
    LOG(INFO) << "loaded from " << path;
  } catch (const std::runtime_error& e) {
    ifs.close();
    LOG(ERROR) << "failed to load: " << path;
    LOG(ERROR) << e.what();
    throw;
  }
  return true;
}
Ejemplo n.º 2
0
 jubatus::util::concurrent::rw_mutex& rw_mutex() {
   return get_mixable_holder()->rw_mutex();
 }