mirror of https://gitee.com/bigwinds/arangodb
Fixing issues
This commit is contained in:
parent
f8cbfa9d3b
commit
7254ad4c9e
|
@ -11,7 +11,7 @@ if (POLICY CMP0037)
|
|||
endif ()
|
||||
|
||||
option(VERBOSE OFF)
|
||||
#set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "deployment target for MacOSX")
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "deployment target for MacOSX")
|
||||
|
||||
project(ArangoDB)
|
||||
|
||||
|
|
|
@ -82,6 +82,18 @@ inline std::ostream& operator<< (std::ostream& os, std::list<T> const& l) {
|
|||
return os;
|
||||
}
|
||||
|
||||
|
||||
struct constituent_t { // Constituent type
|
||||
id_t id;
|
||||
std::string endpoint;
|
||||
};
|
||||
|
||||
typedef std::vector<constituent_t> constituency_t; // Constituency type
|
||||
typedef uint32_t state_t; // State type
|
||||
typedef std::chrono::duration<double> duration_t; // Duration type
|
||||
|
||||
using query_t = std::shared_ptr<arangodb::velocypack::Builder>;
|
||||
|
||||
struct AgentConfiguration {
|
||||
id_t id;
|
||||
float min_ping;
|
||||
|
@ -109,20 +121,22 @@ struct AgentConfiguration {
|
|||
s << *this;
|
||||
return s.str();
|
||||
}
|
||||
query_t toBuilder () {
|
||||
query_t ret = std::make_shared<arangodb::velocypack::Builder>();
|
||||
ret->openObject();
|
||||
ret->add("endpoints", VPackValue(VPackValueType::Array));
|
||||
for (auto const& i : end_points)
|
||||
ret->add(VPackValue(i));
|
||||
ret->close();
|
||||
ret->add("id",VPackValue(id));
|
||||
ret->add("min_ping",VPackValue(min_ping));
|
||||
ret->add("max_ping",VPackValue(max_ping));
|
||||
ret->close();
|
||||
return ret;
|
||||
}
|
||||
};
|
||||
typedef AgentConfiguration config_t;
|
||||
|
||||
struct constituent_t { // Constituent type
|
||||
id_t id;
|
||||
std::string endpoint;
|
||||
};
|
||||
|
||||
typedef std::vector<constituent_t> constituency_t; // Constituency type
|
||||
typedef uint32_t state_t; // State type
|
||||
typedef std::chrono::duration<double> duration_t; // Duration type
|
||||
|
||||
using query_t = std::shared_ptr<arangodb::velocypack::Builder>;
|
||||
|
||||
struct vote_ret_t {
|
||||
query_t result;
|
||||
vote_ret_t (query_t res) : result(res) {}
|
||||
|
|
|
@ -129,7 +129,7 @@ public:
|
|||
* @brief 1. Deal with appendEntries to slaves.
|
||||
* 2. Report success of write processes.
|
||||
*/
|
||||
void run ();
|
||||
void run () override final;
|
||||
void beginShutdown () override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -71,8 +71,7 @@ void ApplicationAgency::setupOptions(
|
|||
|
||||
bool ApplicationAgency::prepare() {
|
||||
|
||||
_disabled = _agency_endpoints.empty() ||
|
||||
_agent_id == std::numeric_limits<uint32_t>::max();
|
||||
_disabled = (_agent_id == std::numeric_limits<uint32_t>::max());
|
||||
|
||||
if (_disabled) {
|
||||
return true;
|
||||
|
|
|
@ -93,12 +93,12 @@ class ApplicationAgency : virtual public arangodb::rest::ApplicationFeature {
|
|||
public:
|
||||
|
||||
void setupOptions(std::map<std::string,
|
||||
arangodb::basics::ProgramOptionsDescription>&);
|
||||
arangodb::basics::ProgramOptionsDescription>&) override final;
|
||||
|
||||
bool prepare();
|
||||
bool start();
|
||||
bool open();
|
||||
void close();
|
||||
bool prepare() override final;
|
||||
bool start() override final;
|
||||
bool open() override final;
|
||||
void close() override final;
|
||||
|
||||
agent_t* agent() const;
|
||||
|
||||
|
|
|
@ -42,8 +42,12 @@ void Constituent::configure(Agent* agent) {
|
|||
_agent = agent;
|
||||
if (size() == 1) {
|
||||
_role = LEADER;
|
||||
} else {
|
||||
_votes.resize(size());
|
||||
} else {
|
||||
try {
|
||||
_votes.resize(size());
|
||||
} catch (std::exception const& e) {
|
||||
LOG(FATAL) << "Cannot resize votes vector to " << size();
|
||||
}
|
||||
_id = _agent->config().id;
|
||||
if (_agent->config().notify) {// (notify everyone)
|
||||
notifyAll();
|
||||
|
@ -190,8 +194,12 @@ const constituency_t& Constituent::gossip () {
|
|||
}
|
||||
|
||||
void Constituent::callElection() {
|
||||
|
||||
_votes[_id] = true; // vote for myself
|
||||
|
||||
try {
|
||||
_votes.at(_id) = true; // vote for myself
|
||||
} catch (std::out_of_range const& oor) {
|
||||
LOG(FATAL) << "_votes vector is not properly sized!";
|
||||
}
|
||||
_cast = true;
|
||||
if(_role == CANDIDATE)
|
||||
_term++; // raise my term
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
/**
|
||||
* @brief My daily business
|
||||
*/
|
||||
void run();
|
||||
void run() override final;
|
||||
|
||||
/**
|
||||
* @brief Who is leading
|
||||
|
|
|
@ -54,7 +54,7 @@ using namespace arangodb::velocypack;
|
|||
class StoreException : public std::exception {
|
||||
public:
|
||||
StoreException(std::string const& message) : _message(message) {}
|
||||
virtual char const* what() const noexcept { return _message.c_str(); }
|
||||
virtual char const* what() const noexcept override final { return _message.c_str(); }
|
||||
private:
|
||||
std::string _message;
|
||||
};
|
||||
|
|
|
@ -148,7 +148,7 @@ HttpHandler::status_t RestAgencyHandler::handleTest() {
|
|||
body.add("id", Value(_agent->id()));
|
||||
body.add("term", Value(_agent->term()));
|
||||
body.add("leaderId", Value(_agent->leaderID()));
|
||||
body.add("configuration", Value(_agent->config().toString()));
|
||||
body.add("configuration", _agent->config().toBuilder());
|
||||
body.close();
|
||||
generateResult(body.slice());
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
|
|
|
@ -466,13 +466,6 @@ class ArangoServer {
|
|||
|
||||
aql::QueryRegistry* _queryRegistry;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief the agent
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
consensus::Agent* _agent;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief ptr to pair of _applicationV8 and _queryRegistry for _api/aql
|
||||
/// handler
|
||||
|
|
|
@ -66,13 +66,13 @@ function agencyTestSuite () {
|
|||
return res;
|
||||
}
|
||||
|
||||
function writeAgencyRaw(list) {
|
||||
/* function writeAgencyRaw(list) {
|
||||
var res = request({url: agencyServers[whoseTurn] + "/_api/agency/write", method: "POST",
|
||||
followRedirects: true, body: list,
|
||||
headers: {"Content-Type": "application/json"}});
|
||||
res.bodyParsed = JSON.parse(res.body);
|
||||
return res;
|
||||
}
|
||||
}*/
|
||||
|
||||
function readAndCheck(list) {
|
||||
var res = readAgency(list);
|
||||
|
|
|
@ -96,7 +96,7 @@ class Exception : public virtual std::exception {
|
|||
~Exception() throw();
|
||||
|
||||
public:
|
||||
char const* what() const throw();
|
||||
char const* what() const throw() override;
|
||||
std::string message() const throw();
|
||||
int code() const throw();
|
||||
void addToMessage(std::string const&);
|
||||
|
|
Loading…
Reference in New Issue