diff --git a/arangod/Cluster/ClusterInfo.cpp b/arangod/Cluster/ClusterInfo.cpp index 357d9c3565..25f98bca96 100644 --- a/arangod/Cluster/ClusterInfo.cpp +++ b/arangod/Cluster/ClusterInfo.cpp @@ -434,6 +434,48 @@ vector ClusterInfo::listDatabases () { return res; } +//////////////////////////////////////////////////////////////////////////////// +/// @brief (re-)load the information about planned databases +/// Usually one does not have to call this directly. +//////////////////////////////////////////////////////////////////////////////// + +void ClusterInfo::loadPlannedDatabases () { + static const std::string prefix = "Plan/Databases"; + + AgencyCommResult result; + + { + AgencyCommLocker locker("Plan", "READ"); + + if (locker.successful()) { + result = _agency.getValues(prefix, true); + } + } + + if (result.successful()) { + std::map databases; + + if (result.flattenJson(databases, prefix + "/", false)) { + LOG_TRACE("%s loaded successfully", prefix.c_str()); + + WRITE_LOCKER(_lock); + _plannedDatabases.clear(); + + std::map::const_iterator it; + for (it = databases.begin(); it != databases.end(); ++it) { + const std::string& name = (*it).first; + TRI_json_t* options = JsonHelper::fromString((*it).second); + + _plannedDatabases.insert(std::make_pair(name, options)); + } + + return; + } + } + + LOG_TRACE("Error while loading %s", prefix.c_str()); +} + //////////////////////////////////////////////////////////////////////////////// /// @brief (re-)load the information about collections from the agency /// Usually one does not have to call this directly. @@ -456,7 +498,7 @@ void ClusterInfo::loadCurrentCollections () { std::map collections; if (result.flattenJson(collections, prefix + "/", false)) { - LOG_TRACE("Current/Collections loaded successfully"); + LOG_TRACE("%s loaded successfully", prefix.c_str()); WRITE_LOCKER(_lock); _collections.clear(); diff --git a/arangod/Cluster/ClusterInfo.h b/arangod/Cluster/ClusterInfo.h index 20b60c0c29..2fa93c5a28 100644 --- a/arangod/Cluster/ClusterInfo.h +++ b/arangod/Cluster/ClusterInfo.h @@ -300,6 +300,13 @@ namespace triagens { void loadCurrentCollections (); +//////////////////////////////////////////////////////////////////////////////// +/// @brief (re-)load the information about planned databases +/// Usually one does not have to call this directly. +//////////////////////////////////////////////////////////////////////////////// + + void loadPlannedDatabases (); + //////////////////////////////////////////////////////////////////////////////// /// @brief ask about a collection /// If it is not found in the cache, the cache is reloaded once. @@ -391,6 +398,7 @@ namespace triagens { _uniqid; // Cached data from the agency, we reload whenever necessary: + std::map _plannedDatabases; // from Plan/Databases AllCollections _collections; // from Current/Collections/ bool _collectionsValid; std::map _servers; // from Current/ServersRegistered