mirror of https://gitee.com/bigwinds/arangodb
cppcheck warnings
This commit is contained in:
parent
3c2d341c1a
commit
934b7ca107
|
@ -102,28 +102,32 @@ struct AgentConfiguration {
|
|||
std::string end_point;
|
||||
std::vector<std::string> end_points;
|
||||
bool notify;
|
||||
bool sanity_check;
|
||||
bool supervision;
|
||||
bool wait_for_sync;
|
||||
double supervision_frequency;
|
||||
|
||||
AgentConfiguration () :
|
||||
id(0),
|
||||
min_ping(.15),
|
||||
max_ping(.3f),
|
||||
min_ping(0.3f),
|
||||
max_ping(1.0f),
|
||||
end_point("tcp://localhost:8529"),
|
||||
notify(false),
|
||||
sanity_check(false),
|
||||
wait_for_sync(true) {}
|
||||
supervision(false),
|
||||
wait_for_sync(true),
|
||||
supervision_frequency(5.0) {}
|
||||
|
||||
AgentConfiguration (uint32_t i, double min_p, double max_p, std::string ep,
|
||||
std::vector<std::string> const& eps, bool n,
|
||||
bool s, bool w) :
|
||||
bool s, bool w, double f) :
|
||||
id(i),
|
||||
min_ping(min_p),
|
||||
max_ping(max_p),
|
||||
end_point(ep),
|
||||
end_points(eps),
|
||||
notify(n),
|
||||
sanity_check(s),
|
||||
wait_for_sync(w) {}
|
||||
supervision(s),
|
||||
wait_for_sync(w),
|
||||
supervision_frequency(f){}
|
||||
|
||||
inline size_t size() const {return end_points.size();}
|
||||
friend std::ostream& operator<<(std::ostream& o, AgentConfiguration const& c) {
|
||||
|
@ -143,9 +147,13 @@ struct AgentConfiguration {
|
|||
for (auto const& i : end_points)
|
||||
ret->add(VPackValue(i));
|
||||
ret->close();
|
||||
ret->add("endpoint", VPackValue(end_point));
|
||||
ret->add("id",VPackValue(id));
|
||||
ret->add("min_ping",VPackValue(min_ping));
|
||||
ret->add("max_ping",VPackValue(max_ping));
|
||||
ret->add("notify peers", VPackValue(notify));
|
||||
ret->add("supervision", VPackValue(supervision));
|
||||
ret->add("supervision frequency", VPackValue(supervision_frequency));
|
||||
ret->close();
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -316,9 +316,9 @@ bool Agent::load () {
|
|||
LOG_TOPIC(INFO, Logger::AGENCY) << "Starting constituent personality.";
|
||||
_constituent.start(_vocbase, _applicationV8, _queryRegistry);
|
||||
|
||||
if (_config.sanity_check) {
|
||||
if (_config.supervision) {
|
||||
LOG_TOPIC(INFO, Logger::AGENCY) << "Starting cluster sanity facilities";
|
||||
_sanity_check.start(this);
|
||||
_supervision.start(this);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -395,8 +395,8 @@ void Agent::beginShutdown() {
|
|||
_constituent.beginShutdown();
|
||||
_spearhead.beginShutdown();
|
||||
_read_db.beginShutdown();
|
||||
if (_config.sanity_check) {
|
||||
_sanity_check.beginShutdown();
|
||||
if (_config.supervision) {
|
||||
_supervision.beginShutdown();
|
||||
}
|
||||
|
||||
// Wake up all waiting REST handler (waitFor)
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "AgencyCommon.h"
|
||||
#include "AgentCallback.h"
|
||||
#include "Constituent.h"
|
||||
#include "SanityCheck.h"
|
||||
#include "Supervision.h"
|
||||
#include "State.h"
|
||||
#include "Store.h"
|
||||
|
||||
|
@ -152,7 +152,7 @@ public:
|
|||
aql::QueryRegistry* _queryRegistry;
|
||||
|
||||
Constituent _constituent; /**< @brief Leader election delegate */
|
||||
SanityCheck _sanity_check; /**< @brief sanitychecking */
|
||||
Supervision _supervision; /**< @brief sanitychecking */
|
||||
State _state; /**< @brief Log replica */
|
||||
|
||||
config_t _config; /**< @brief Command line arguments */
|
||||
|
|
|
@ -48,12 +48,13 @@ ApplicationAgency::ApplicationAgency(
|
|||
_max_election_timeout(1.0),
|
||||
_election_call_rate_mul(0.85),
|
||||
_notify(false),
|
||||
_sanity_check(false),
|
||||
_supervision(false),
|
||||
_agent_id((std::numeric_limits<uint32_t>::max)()),
|
||||
_endpointServer(aes),
|
||||
_applicationV8(applicationV8),
|
||||
_queryRegistry(queryRegistry),
|
||||
_wait_for_sync(true) {
|
||||
_wait_for_sync(true),
|
||||
_supervision_frequency(5.0) {
|
||||
}
|
||||
|
||||
|
||||
|
@ -75,8 +76,10 @@ void ApplicationAgency::setupOptions(
|
|||
"Multiplier (<1.0) defining how long the election timeout is with respect "
|
||||
"to the minumum election timeout")
|
||||
("agency.notify", &_notify, "Notify others")
|
||||
("agency.sanity-check", &_sanity_check,
|
||||
("agency.supervision", &_supervision,
|
||||
"Perform arangodb cluster sanity checking")
|
||||
("agency.supervision-frequency", &_supervision_frequency,
|
||||
"Cluster supervision frequency ")
|
||||
("agency.wait-for-sync", &_wait_for_sync,
|
||||
"Wait for hard disk syncs on every persistence call (Must for production)");
|
||||
|
||||
|
@ -155,7 +158,8 @@ bool ApplicationAgency::prepare() {
|
|||
new agent_t(
|
||||
_server, arangodb::consensus::config_t(
|
||||
_agent_id, _min_election_timeout, _max_election_timeout,
|
||||
endpoint, _agency_endpoints, _notify, _sanity_check, _wait_for_sync),
|
||||
endpoint, _agency_endpoints, _notify, _supervision, _wait_for_sync,
|
||||
_supervision_frequency),
|
||||
_applicationV8, _queryRegistry));
|
||||
|
||||
return true;
|
||||
|
|
|
@ -106,8 +106,9 @@ class ApplicationAgency : virtual public arangodb::rest::ApplicationFeature {
|
|||
double _max_election_timeout; /**< @brief: max election timeout */
|
||||
double _election_call_rate_mul; /**< @brief: */
|
||||
bool _notify;
|
||||
bool _sanity_check;
|
||||
bool _supervision;
|
||||
/**< @brief interval between retry to slaves*/
|
||||
|
||||
std::vector<std::string> _agency_endpoints; /**< @brief agency adresses */
|
||||
std::unique_ptr<agent_t> _agent;
|
||||
|
||||
|
@ -118,6 +119,7 @@ class ApplicationAgency : virtual public arangodb::rest::ApplicationFeature {
|
|||
aql::QueryRegistry* _queryRegistry;
|
||||
|
||||
bool _wait_for_sync;
|
||||
double _supervision_frequency;
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ void Constituent::term(term_t t) {
|
|||
options.silent = true;
|
||||
|
||||
OperationResult result = trx.insert("election", body.slice(), options);
|
||||
res = trx.finish(result.code);
|
||||
/*res = */trx.finish(result.code); // OMG
|
||||
|
||||
}
|
||||
|
||||
|
@ -426,6 +426,7 @@ void Constituent::run() {
|
|||
} catch (std::exception const& e) {
|
||||
LOG_TOPIC(ERR, Logger::AGENCY)
|
||||
<< "Persisted election entries corrupt! Defaulting term,vote (0,0)";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "Supervision.h"
|
||||
#include "Agent.h"
|
||||
#include "Store.h"
|
||||
|
||||
#include "Basics/ConditionLocker.h"
|
||||
|
||||
|
@ -29,7 +30,7 @@ void Supervision::run() {
|
|||
while (!this->isStopping()) {
|
||||
|
||||
if (_agent->leading()) {
|
||||
timedout = _cv.wait(250000);//quarter second
|
||||
timedout = _cv.wait(_frequency);//quarter second
|
||||
} else {
|
||||
_cv.wait();
|
||||
}
|
||||
|
@ -49,6 +50,7 @@ bool Supervision::start () {
|
|||
// Start thread with agent
|
||||
bool Supervision::start (Agent* agent) {
|
||||
_agent = agent;
|
||||
_frequency = static_cast<long>(1.0e6*_agent->config().supervision_frequency);
|
||||
return start();
|
||||
}
|
||||
|
||||
|
@ -56,3 +58,7 @@ void Supervision::beginShutdown() {
|
|||
// Personal hygiene
|
||||
Thread::beginShutdown();
|
||||
}
|
||||
|
||||
Store const& Supervision::store() const {
|
||||
return _agent->readDB();
|
||||
}
|
||||
|
|
|
@ -27,10 +27,13 @@
|
|||
#include "Basics/Thread.h"
|
||||
#include "Basics/ConditionVariable.h"
|
||||
|
||||
|
||||
|
||||
namespace arangodb {
|
||||
namespace consensus {
|
||||
|
||||
class Agent;
|
||||
class Store;
|
||||
|
||||
class Supervision : public arangodb::Thread {
|
||||
|
||||
|
@ -60,7 +63,7 @@ public:
|
|||
private:
|
||||
|
||||
/// @brief Read db
|
||||
Store const& store ();
|
||||
Store const& store () const;
|
||||
|
||||
/// @brief Perform sanity checking
|
||||
bool doChecks(bool);
|
||||
|
@ -69,6 +72,8 @@ private:
|
|||
|
||||
arangodb::basics::ConditionVariable _cv; /**< @brief Control if thread should run */
|
||||
|
||||
long _frequency;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue