mirror of https://gitee.com/bigwinds/arangodb
added loadPlannedDatabases method
This commit is contained in:
parent
e02b0b52e1
commit
b5a448ffdb
|
@ -434,6 +434,48 @@ vector<DatabaseID> ClusterInfo::listDatabases () {
|
||||||
return res;
|
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<std::string, std::string> databases;
|
||||||
|
|
||||||
|
if (result.flattenJson(databases, prefix + "/", false)) {
|
||||||
|
LOG_TRACE("%s loaded successfully", prefix.c_str());
|
||||||
|
|
||||||
|
WRITE_LOCKER(_lock);
|
||||||
|
_plannedDatabases.clear();
|
||||||
|
|
||||||
|
std::map<std::string, std::string>::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<DatabaseID, TRI_json_t*>(name, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG_TRACE("Error while loading %s", prefix.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief (re-)load the information about collections from the agency
|
/// @brief (re-)load the information about collections from the agency
|
||||||
/// Usually one does not have to call this directly.
|
/// Usually one does not have to call this directly.
|
||||||
|
@ -456,7 +498,7 @@ void ClusterInfo::loadCurrentCollections () {
|
||||||
std::map<std::string, std::string> collections;
|
std::map<std::string, std::string> collections;
|
||||||
|
|
||||||
if (result.flattenJson(collections, prefix + "/", false)) {
|
if (result.flattenJson(collections, prefix + "/", false)) {
|
||||||
LOG_TRACE("Current/Collections loaded successfully");
|
LOG_TRACE("%s loaded successfully", prefix.c_str());
|
||||||
|
|
||||||
WRITE_LOCKER(_lock);
|
WRITE_LOCKER(_lock);
|
||||||
_collections.clear();
|
_collections.clear();
|
||||||
|
|
|
@ -300,6 +300,13 @@ namespace triagens {
|
||||||
|
|
||||||
void loadCurrentCollections ();
|
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
|
/// @brief ask about a collection
|
||||||
/// If it is not found in the cache, the cache is reloaded once.
|
/// If it is not found in the cache, the cache is reloaded once.
|
||||||
|
@ -391,6 +398,7 @@ namespace triagens {
|
||||||
_uniqid;
|
_uniqid;
|
||||||
|
|
||||||
// Cached data from the agency, we reload whenever necessary:
|
// Cached data from the agency, we reload whenever necessary:
|
||||||
|
std::map<DatabaseID, struct TRI_json_s*> _plannedDatabases; // from Plan/Databases
|
||||||
AllCollections _collections; // from Current/Collections/
|
AllCollections _collections; // from Current/Collections/
|
||||||
bool _collectionsValid;
|
bool _collectionsValid;
|
||||||
std::map<ServerID, std::string> _servers; // from Current/ServersRegistered
|
std::map<ServerID, std::string> _servers; // from Current/ServersRegistered
|
||||||
|
|
Loading…
Reference in New Issue