mirror of https://gitee.com/bigwinds/arangodb
agency configuration persisted to state machine
This commit is contained in:
parent
c3ed09f642
commit
c8178239e1
|
@ -559,6 +559,23 @@ bool Agent::lead() {
|
||||||
guard.broadcast();
|
guard.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Agency configuration
|
||||||
|
auto agency = std::make_shared<Builder>();
|
||||||
|
agency->openArray();
|
||||||
|
agency->openArray();
|
||||||
|
agency->openObject();
|
||||||
|
agency->add(".agency", VPackValue(VPackValueType::Object));
|
||||||
|
agency->add("term", VPackValue(term()));
|
||||||
|
agency->add("id", VPackValue(id()));
|
||||||
|
agency->add("active", _config.activeToBuilder()->slice());
|
||||||
|
agency->add("pool", _config.poolToBuilder()->slice());
|
||||||
|
agency->close();
|
||||||
|
agency->close();
|
||||||
|
agency->close();
|
||||||
|
agency->close();
|
||||||
|
write(agency);
|
||||||
|
|
||||||
// Wake up supervision
|
// Wake up supervision
|
||||||
_supervision.wakeUp();
|
_supervision.wakeUp();
|
||||||
|
|
||||||
|
|
|
@ -243,6 +243,19 @@ query_t config_t::activeToBuilder () const {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
query_t config_t::activeAgentsToBuilder () const {
|
||||||
|
query_t ret = std::make_shared<arangodb::velocypack::Builder>();
|
||||||
|
ret->openObject();
|
||||||
|
{
|
||||||
|
READ_LOCKER(readLocker, _lock);
|
||||||
|
for (auto const& i : _active) {
|
||||||
|
ret->add(i, VPackValue(_pool.at(i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret->close();
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
query_t config_t::poolToBuilder () const {
|
query_t config_t::poolToBuilder () const {
|
||||||
query_t ret = std::make_shared<arangodb::velocypack::Builder>();
|
query_t ret = std::make_shared<arangodb::velocypack::Builder>();
|
||||||
ret->openObject();
|
ret->openObject();
|
||||||
|
|
|
@ -142,6 +142,7 @@ struct config_t {
|
||||||
|
|
||||||
/// @brief of active agents
|
/// @brief of active agents
|
||||||
query_t activeToBuilder () const;
|
query_t activeToBuilder () const;
|
||||||
|
query_t activeAgentsToBuilder () const;
|
||||||
query_t poolToBuilder () const;
|
query_t poolToBuilder () const;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -130,6 +130,9 @@ RestHandler::status RestAgencyPrivHandler::execute() {
|
||||||
return reportBadQuery(); // bad query
|
return reportBadQuery(); // bad query
|
||||||
}
|
}
|
||||||
} else if (_request->suffix()[0] == "gossip") {
|
} else if (_request->suffix()[0] == "gossip") {
|
||||||
|
if (_request->requestType() != GeneralRequest::RequestType::POST) {
|
||||||
|
return reportMethodNotAllowed();
|
||||||
|
}
|
||||||
arangodb::velocypack::Options options;
|
arangodb::velocypack::Options options;
|
||||||
query_t query = _request->toVelocyPackBuilderPtr(&options);
|
query_t query = _request->toVelocyPackBuilderPtr(&options);
|
||||||
try {
|
try {
|
||||||
|
@ -140,6 +143,11 @@ RestHandler::status RestAgencyPrivHandler::execute() {
|
||||||
} catch (std::exception const& e) {
|
} catch (std::exception const& e) {
|
||||||
return reportBadQuery(e.what());
|
return reportBadQuery(e.what());
|
||||||
}
|
}
|
||||||
|
} else if (_request->suffix()[0] == "activeAgents") {
|
||||||
|
if (_request->requestType() != GeneralRequest::RequestType::GET) {
|
||||||
|
return reportMethodNotAllowed();
|
||||||
|
}
|
||||||
|
result.add("active", _agent->config().activeAgentsToBuilder()->slice());
|
||||||
} else if (_request->suffix()[0] == "inform") {
|
} else if (_request->suffix()[0] == "inform") {
|
||||||
arangodb::velocypack::Options options;
|
arangodb::velocypack::Options options;
|
||||||
query_t query = _request->toVelocyPackBuilderPtr(&options);
|
query_t query = _request->toVelocyPackBuilderPtr(&options);
|
||||||
|
|
|
@ -316,7 +316,9 @@ bool Supervision::updateSnapshot() {
|
||||||
if (_agent == nullptr || this->isStopping()) {
|
if (_agent == nullptr || this->isStopping()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_snapshot = _agent->readDB().get(_agencyPrefix);
|
try {
|
||||||
|
_snapshot = _agent->readDB().get(_agencyPrefix);
|
||||||
|
} catch (...) {}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue