mirror of https://gitee.com/bigwinds/arangodb
fixed arangom script
This commit is contained in:
parent
85c75926e3
commit
f66c4400b4
|
@ -353,6 +353,8 @@ ClusterInfo::ClusterInfo ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ClusterInfo::~ClusterInfo () {
|
||||
clearPlannedDatabases();
|
||||
clearCurrentDatabases();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -400,6 +402,9 @@ void ClusterInfo::flush () {
|
|||
_collections.clear();
|
||||
_servers.clear();
|
||||
_shardIds.clear();
|
||||
|
||||
clearPlannedDatabases();
|
||||
clearCurrentDatabases();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -450,6 +455,50 @@ vector<DatabaseID> ClusterInfo::listDatabases () {
|
|||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief flushes the list of planned databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ClusterInfo::clearPlannedDatabases () {
|
||||
std::map<DatabaseID, TRI_json_t*>::iterator it = _plannedDatabases.begin();
|
||||
|
||||
while (it != _plannedDatabases.end()) {
|
||||
TRI_json_t* json = (*it).second;
|
||||
|
||||
if (json != 0) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
_plannedDatabases.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief flushes the list of current databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ClusterInfo::clearCurrentDatabases () {
|
||||
std::map<DatabaseID, std::map<ServerID, TRI_json_t*> >::iterator it = _currentDatabases.begin();
|
||||
|
||||
while (it != _currentDatabases.end()) {
|
||||
std::map<ServerID, TRI_json_t*>::iterator it2 = (*it).second.begin();
|
||||
|
||||
while (it2 != (*it).second.end()) {
|
||||
TRI_json_t* json = (*it2).second;
|
||||
|
||||
if (json != 0) {
|
||||
TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, json);
|
||||
}
|
||||
|
||||
++it2;
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
_currentDatabases.clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief (re-)load the information about planned databases
|
||||
/// Usually one does not have to call this directly.
|
||||
|
@ -472,7 +521,7 @@ void ClusterInfo::loadPlannedDatabases () {
|
|||
result.parse(prefix + "/", false);
|
||||
|
||||
WRITE_LOCKER(_lock);
|
||||
_plannedDatabases.clear();
|
||||
clearPlannedDatabases();
|
||||
|
||||
std::map<std::string, AgencyCommResultEntry>::iterator it = result._values.begin();
|
||||
|
||||
|
@ -491,6 +540,63 @@ void ClusterInfo::loadPlannedDatabases () {
|
|||
LOG_TRACE("Error while loading %s", prefix.c_str());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief (re-)load the information about current databases
|
||||
/// Usually one does not have to call this directly.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void ClusterInfo::loadCurrentDatabases () {
|
||||
static const std::string prefix = "Current/Databases";
|
||||
|
||||
AgencyCommResult result;
|
||||
|
||||
{
|
||||
AgencyCommLocker locker("Plan", "READ");
|
||||
|
||||
if (locker.successful()) {
|
||||
result = _agency.getValues(prefix, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.successful()) {
|
||||
result.parse(prefix + "/", true);
|
||||
|
||||
WRITE_LOCKER(_lock);
|
||||
clearCurrentDatabases();
|
||||
|
||||
std::map<std::string, AgencyCommResultEntry>::iterator it = result._values.begin();
|
||||
|
||||
while (it != result._values.end()) {
|
||||
const std::string& key = (*it).first;
|
||||
|
||||
// each entry consists of a database id and a collection id, separated by '/'
|
||||
std::vector<std::string> parts = triagens::basics::StringUtils::split(key, '/');
|
||||
|
||||
const std::string& database = parts[0];
|
||||
|
||||
std::map<std::string, std::map<ServerID, TRI_json_t*> >::iterator it2 = _currentDatabases.find(database);
|
||||
|
||||
if (it2 == _currentDatabases.end()) {
|
||||
// insert an empty list for this database
|
||||
std::map<ServerID, TRI_json_t*> empty;
|
||||
it2 = _currentDatabases.insert(std::make_pair<DatabaseID, std::map<ServerID, TRI_json_t*> >(database, empty)).first;
|
||||
}
|
||||
|
||||
if (parts.size() == 2) {
|
||||
// got a server name
|
||||
TRI_json_t* json = (*it).second._json;
|
||||
// steal the JSON
|
||||
(*it).second._json = 0;
|
||||
(*it2).second.insert(std::make_pair<ServerID, TRI_json_t*>(parts[1], json));
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
|
|
|
@ -302,6 +302,18 @@ namespace triagens {
|
|||
|
||||
void loadCurrentCollections ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief flushes the list of planned databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void clearPlannedDatabases ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief flushes the list of current databases
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void clearCurrentDatabases ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief (re-)load the information about planned databases
|
||||
/// Usually one does not have to call this directly.
|
||||
|
@ -309,6 +321,13 @@ namespace triagens {
|
|||
|
||||
void loadPlannedDatabases ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief (re-)load the information about current databases
|
||||
/// Usually one does not have to call this directly.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void loadCurrentDatabases ();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief ask about a collection
|
||||
/// If it is not found in the cache, the cache is reloaded once.
|
||||
|
@ -401,6 +420,8 @@ namespace triagens {
|
|||
|
||||
// Cached data from the agency, we reload whenever necessary:
|
||||
std::map<DatabaseID, struct TRI_json_s*> _plannedDatabases; // from Plan/Databases
|
||||
std::map<DatabaseID, std::map<ServerID, struct TRI_json_s*> > _currentDatabases; // from Current/Databases
|
||||
|
||||
AllCollections _collections; // from Current/Collections/
|
||||
bool _collectionsValid;
|
||||
std::map<ServerID, std::string> _servers; // from Current/ServersRegistered
|
||||
|
|
12
arangom
12
arangom
|
@ -29,34 +29,34 @@ function set() {
|
|||
value=$2
|
||||
if [ "x$value" == "x" ] ; then
|
||||
echo "Creating directory $PREFIX$key"
|
||||
$CURL -X PUT "$URL$PREFIX$key?dir=true" > /dev/null || exit 1
|
||||
$CURL -X PUT -L "$URL$PREFIX$key?dir=true" > /dev/null || exit 1
|
||||
else
|
||||
echo "Setting key $PREFIX$key to value $value"
|
||||
$CURL -X PUT "$URL$PREFIX$key" -d "value=$value" > /dev/null || exit 1
|
||||
$CURL -X PUT -L "$URL$PREFIX$key" -d "value=$value" > /dev/null || exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [ "$1" == "init" ] ; then
|
||||
$CURL -X DELETE "$URL$PREFIX?recursive=true" > /dev/null
|
||||
$CURL -X DELETE -L "$URL$PREFIX?recursive=true" > /dev/null
|
||||
set Target/MapLocalToID
|
||||
set Target/MapIDToEndpoint
|
||||
|
||||
set Target/Version 1
|
||||
set Target/Version "\"1\""
|
||||
set Target/Lock "\"UNLOCKED\""
|
||||
set Target/DBServers
|
||||
set Target/Coordinators
|
||||
set Target/Databases/@Usystem "{}"
|
||||
set Target/Collections/@Usystem
|
||||
|
||||
set Plan/Version 1
|
||||
set Plan/Version "\"1\""
|
||||
set Plan/Lock "\"UNLOCKED\""
|
||||
set Plan/DBServers
|
||||
set Plan/Coordinators
|
||||
set Plan/Databases/@Usystem "{}"
|
||||
set Plan/Collections/@Usystem
|
||||
|
||||
set Current/Version 1
|
||||
set Current/Version "\"1\""
|
||||
set Current/Lock "\"UNLOCKED\""
|
||||
set Current/DBServers
|
||||
set Current/Coordinators
|
||||
|
|
Loading…
Reference in New Issue