mirror of https://gitee.com/bigwinds/arangodb
fixed for short names in frontend shard view
This commit is contained in:
parent
e4345d1949
commit
fe48bcb982
|
@ -2637,3 +2637,13 @@ std::shared_ptr<VPackBuilder> ClusterInfo::getCurrent() {
|
||||||
READ_LOCKER(readLocker, _currentProt.lock);
|
READ_LOCKER(readLocker, _currentProt.lock);
|
||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::unordered_map<ServerID, std::string> ClusterInfo::getServerAliases() {
|
||||||
|
READ_LOCKER(readLocker, _serversProt.lock);
|
||||||
|
std::unordered_map<std::string,std::string> ret;
|
||||||
|
for (const auto& i : _serverAliases) {
|
||||||
|
ret.emplace(i.second,i.first);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -499,6 +499,8 @@ class ClusterInfo {
|
||||||
std::vector<std::string> const& getFailedServers() { MUTEX_LOCKER(guard, _failedServersMutex); return _failedServers; }
|
std::vector<std::string> const& getFailedServers() { MUTEX_LOCKER(guard, _failedServersMutex); return _failedServers; }
|
||||||
void setFailedServers(std::vector<std::string> const& failedServers) { MUTEX_LOCKER(guard, _failedServersMutex); _failedServers = failedServers; }
|
void setFailedServers(std::vector<std::string> const& failedServers) { MUTEX_LOCKER(guard, _failedServersMutex); _failedServers = failedServers; }
|
||||||
|
|
||||||
|
std::unordered_map<ServerID, std::string> getServerAliases();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -745,16 +745,24 @@ static void JS_GetCollectionInfoClusterInfo(
|
||||||
result->Set(TRI_V8_ASCII_STRING("shardKeys"), shardKeys);
|
result->Set(TRI_V8_ASCII_STRING("shardKeys"), shardKeys);
|
||||||
|
|
||||||
auto shardMap = ci->shardIds();
|
auto shardMap = ci->shardIds();
|
||||||
|
auto serverAliases = ClusterInfo::instance()->getServerAliases();
|
||||||
v8::Handle<v8::Object> shardIds = v8::Object::New(isolate);
|
v8::Handle<v8::Object> shardIds = v8::Object::New(isolate);
|
||||||
|
v8::Handle<v8::Object> shardShorts = v8::Object::New(isolate);
|
||||||
for (auto const& p : *shardMap) {
|
for (auto const& p : *shardMap) {
|
||||||
v8::Handle<v8::Array> list = v8::Array::New(isolate, (int)p.second.size());
|
v8::Handle<v8::Array> list = v8::Array::New(isolate, (int)p.second.size());
|
||||||
|
v8::Handle<v8::Array> shorts = v8::Array::New(isolate, (int)p.second.size());
|
||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
for (auto const& s : p.second) {
|
for (auto const& s : p.second) {
|
||||||
|
try{
|
||||||
|
shorts->Set(pos, TRI_V8_STD_STRING(serverAliases.at(s)));
|
||||||
|
} catch (...) {}
|
||||||
list->Set(pos++, TRI_V8_STD_STRING(s));
|
list->Set(pos++, TRI_V8_STD_STRING(s));
|
||||||
}
|
}
|
||||||
shardIds->Set(TRI_V8_STD_STRING(p.first), list);
|
shardIds->Set(TRI_V8_STD_STRING(p.first), list);
|
||||||
|
shardShorts->Set(TRI_V8_STD_STRING(p.first), shorts);
|
||||||
}
|
}
|
||||||
result->Set(TRI_V8_ASCII_STRING("shards"), shardIds);
|
result->Set(TRI_V8_ASCII_STRING("shards"), shardIds);
|
||||||
|
result->Set(TRI_V8_ASCII_STRING("shardShorts"), shardShorts);
|
||||||
VPackBuilder tmp;
|
VPackBuilder tmp;
|
||||||
ci->getIndexesVPack(tmp, false);
|
ci->getIndexesVPack(tmp, false);
|
||||||
v8::Handle<v8::Value> indexes = TRI_VPackToV8(isolate, tmp.slice());
|
v8::Handle<v8::Value> indexes = TRI_VPackToV8(isolate, tmp.slice());
|
||||||
|
@ -816,11 +824,18 @@ static void JS_GetCollectionInfoCurrentClusterInfo(
|
||||||
auto servers = cic->servers(shardID);
|
auto servers = cic->servers(shardID);
|
||||||
v8::Handle<v8::Array> list =
|
v8::Handle<v8::Array> list =
|
||||||
v8::Array::New(isolate, static_cast<int>(servers.size()));
|
v8::Array::New(isolate, static_cast<int>(servers.size()));
|
||||||
|
v8::Handle<v8::Array> shorts =
|
||||||
|
v8::Array::New(isolate, static_cast<int>(servers.size()));
|
||||||
|
auto serverAliases = ClusterInfo::instance()->getServerAliases();
|
||||||
uint32_t pos = 0;
|
uint32_t pos = 0;
|
||||||
for (auto const& s : servers) {
|
for (auto const& s : servers) {
|
||||||
|
try {
|
||||||
|
shorts->Set(pos, TRI_V8_STD_STRING(serverAliases.at(s)));
|
||||||
|
} catch (...) {}
|
||||||
list->Set(pos++, TRI_V8_STD_STRING(s));
|
list->Set(pos++, TRI_V8_STD_STRING(s));
|
||||||
}
|
}
|
||||||
result->Set(TRI_V8_ASCII_STRING("servers"), list);
|
result->Set(TRI_V8_ASCII_STRING("servers"), list);
|
||||||
|
result->Set(TRI_V8_ASCII_STRING("shorts"), shorts);
|
||||||
|
|
||||||
TRI_V8_RETURN(result);
|
TRI_V8_RETURN(result);
|
||||||
TRI_V8_TRY_CATCH_END
|
TRI_V8_TRY_CATCH_END
|
||||||
|
|
|
@ -1772,9 +1772,9 @@ function shardDistribution () {
|
||||||
for (var j = 0; j < shardNames.length; ++j) {
|
for (var j = 0; j < shardNames.length; ++j) {
|
||||||
collInfoCurrent[shardNames[j]] =
|
collInfoCurrent[shardNames[j]] =
|
||||||
global.ArangoClusterInfo.getCollectionInfoCurrent(
|
global.ArangoClusterInfo.getCollectionInfoCurrent(
|
||||||
dbName, collName, shardNames[j]).servers;
|
dbName, collName, shardNames[j]).shorts;
|
||||||
}
|
}
|
||||||
result[collName] = {Plan: format(collInfo.shards),
|
result[collName] = {Plan: format(collInfo.shardShorts),
|
||||||
Current: format(collInfoCurrent)};
|
Current: format(collInfoCurrent)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue