bool HBaseConfigurationLoader::LoadProperties()

in src/hbase/client/hbase-configuration-loader.cc [158:187]


bool HBaseConfigurationLoader::LoadProperties(const std::string &file, ConfigMap &property_map) {
  // Create empty property tree object
  using boost::property_tree::ptree;
  ptree pt;
  try {
    // Load XML file and put contents in a property tree.
    // If read fails, throw exception.
    read_xml(file, pt);

    // If configuration key is not found exception is thrown
    std::string configuration = pt.get<std::string>("configuration");

    // Iterate over configuration section.
    // Store all found properties in ConfigMap
    BOOST_FOREACH (ptree::value_type &v, pt.get_child("configuration")) {
      if ("property" == v.first) {
        std::string name_node = v.second.get<std::string>("name");
        std::string value_node = v.second.get<std::string>("value");
        if ((name_node.size() > 0) && (value_node.size() > 0)) {
          boost::optional<std::string> final_node = v.second.get_optional<std::string>("final");
          UpdateMapWithValue(property_map, name_node, value_node, final_node);
        }
      }
    }
  } catch (std::exception &ex) {
    DLOG(WARNING) << "Exception in parsing file [" << file << "]:[" << ex.what() << "]";
    return false;
  }
  return true;
}