mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of https://github.com/arangodb/arangodb into devel
This commit is contained in:
commit
6abcc57459
|
@ -410,6 +410,7 @@ else ()
|
|||
CFLAGS=${V8_CFLAGS}
|
||||
CXXFLAGS=${V8_CXXFLAGS}
|
||||
LDFLAGS=${V8_LDFLAGS}
|
||||
PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
|
||||
)
|
||||
|
||||
list(APPEND V8_COMPILE_ARGS icui18n icuuc icudata)
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
},
|
||||
'host_arch%': '<(host_arch)',
|
||||
'target_arch%': '<(host_arch)',
|
||||
'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
|
||||
'base_dir%': '<!(cd <(DEPTH) && ${PYTHON_EXECUTABLE} -c "import os; print os.getcwd()")',
|
||||
|
||||
# Instrument for code coverage with gcov.
|
||||
'coverage%': 0,
|
||||
|
@ -421,7 +421,7 @@
|
|||
# (defines are passed via the command line, and build systems rebuild
|
||||
# things when their commandline changes). Nothing should ever read this
|
||||
# define.
|
||||
'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
|
||||
'defines': ['CR_CLANG_REVISION=<!(${PYTHON_EXECUTABLE} <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
|
||||
'conditions': [
|
||||
['host_clang==1', {
|
||||
'target_conditions': [
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
'ubsan%': 0,
|
||||
'ubsan_vptr%': 0,
|
||||
'v8_target_arch%': '<(target_arch)',
|
||||
'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
|
||||
'v8_host_byteorder%': '<!(${PYTHON_EXECUTABLE} -c "import sys; print sys.byteorder")',
|
||||
# Native Client builds currently use the V8 ARM JIT and
|
||||
# arm/simulator-arm.cc to defer the significant effort required
|
||||
# for NaCl JIT support. The nacl_target_arch variable provides
|
||||
|
|
|
@ -1839,14 +1839,14 @@
|
|||
'<(PRODUCT_DIR)/natives_blob_host.bin',
|
||||
],
|
||||
'action': [
|
||||
'python', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob_host.bin'
|
||||
'$(PYTHON_EXECUTABLE)', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob_host.bin'
|
||||
],
|
||||
}, {
|
||||
'outputs': [
|
||||
'<(PRODUCT_DIR)/natives_blob.bin',
|
||||
],
|
||||
'action': [
|
||||
'python', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob.bin'
|
||||
'$(PYTHON_EXECUTABLE)', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob.bin'
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
@ -1855,7 +1855,7 @@
|
|||
'<(PRODUCT_DIR)/natives_blob.bin',
|
||||
],
|
||||
'action': [
|
||||
'python', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob.bin'
|
||||
'$(PYTHON_EXECUTABLE)', '<@(_inputs)', '<(PRODUCT_DIR)/natives_blob.bin'
|
||||
],
|
||||
}],
|
||||
],
|
||||
|
@ -1952,7 +1952,7 @@
|
|||
],
|
||||
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/libraries.cc'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
|
||||
'CORE',
|
||||
|
@ -1969,7 +1969,7 @@
|
|||
],
|
||||
'outputs': ['<@(libraries_bin_file)'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/libraries.cc',
|
||||
'CORE',
|
||||
|
@ -1987,7 +1987,7 @@
|
|||
],
|
||||
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
|
||||
'EXPERIMENTAL',
|
||||
|
@ -2002,7 +2002,7 @@
|
|||
],
|
||||
'outputs': ['<@(libraries_experimental_bin_file)'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/experimental-libraries.cc',
|
||||
'EXPERIMENTAL',
|
||||
|
@ -2019,7 +2019,7 @@
|
|||
],
|
||||
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
|
||||
'EXTRAS',
|
||||
|
@ -2034,7 +2034,7 @@
|
|||
],
|
||||
'outputs': ['<@(libraries_extras_bin_file)'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/extras-libraries.cc',
|
||||
'EXTRAS',
|
||||
|
@ -2053,7 +2053,7 @@
|
|||
'<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
|
||||
'EXPERIMENTAL_EXTRAS',
|
||||
|
@ -2068,7 +2068,7 @@
|
|||
],
|
||||
'outputs': ['<@(libraries_experimental_extras_bin_file)'],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/js2c.py',
|
||||
'<(SHARED_INTERMEDIATE_DIR)/experimental-extras-libraries.cc',
|
||||
'EXPERIMENTAL_EXTRAS',
|
||||
|
@ -2099,7 +2099,7 @@
|
|||
'<(SHARED_INTERMEDIATE_DIR)/debug-support.cc',
|
||||
],
|
||||
'action': [
|
||||
'python',
|
||||
'$(PYTHON_EXECUTABLE)',
|
||||
'../../tools/gen-postmortem-metadata.py',
|
||||
'<@(_outputs)',
|
||||
'<@(heapobject_files)'
|
||||
|
|
1
3rdParty/etcd/Godeps/_workspace/src/github.com/prometheus/procfs/fixtures/26231/exe
generated
vendored
1
3rdParty/etcd/Godeps/_workspace/src/github.com/prometheus/procfs/fixtures/26231/exe
generated
vendored
|
@ -1 +0,0 @@
|
|||
/usr/bin/vim
|
|
@ -251,7 +251,7 @@ static void copyString32to8(char* dst, size_t dstLen, const char32_t* src) {
|
|||
}
|
||||
|
||||
static void copyString32(char32_t* dst, const char32_t* src, size_t len) {
|
||||
while (*src && 1 < len) {
|
||||
while (0 < len && *src) {
|
||||
*dst++ = *src++;
|
||||
--len;
|
||||
}
|
||||
|
@ -1963,7 +1963,7 @@ int InputBuffer::completeLine(PromptBase& pi) {
|
|||
int tailIndex = startIndex + longestCommonPrefix;
|
||||
memcpy(&displayText[tailIndex], &buf32[pos],
|
||||
sizeof(char32_t) * (displayLength - tailIndex + 1));
|
||||
copyString32(buf32, displayText.get(), buflen + 1);
|
||||
copyString32(buf32, displayText.get(), displayLength);
|
||||
pos = startIndex + longestCommonPrefix;
|
||||
len = displayLength;
|
||||
refreshLine(pi);
|
||||
|
@ -2303,7 +2303,7 @@ int InputBuffer::incrementalHistorySearch(PromptBase& pi, int startChar) {
|
|||
--dp.searchTextLen;
|
||||
dp.searchText[dp.searchTextLen] = 0;
|
||||
copyString32(tempUnicode.get(), dp.searchText.get(),
|
||||
dp.searchTextLen + 1);
|
||||
dp.searchTextLen);
|
||||
dp.updateSearchText(tempUnicode.get());
|
||||
} else {
|
||||
beep();
|
||||
|
@ -2318,7 +2318,7 @@ int InputBuffer::incrementalHistorySearch(PromptBase& pi, int startChar) {
|
|||
unique_ptr<char32_t[]> tempUnicode(
|
||||
new char32_t[dp.searchTextLen + 2]);
|
||||
copyString32(tempUnicode.get(), dp.searchText.get(),
|
||||
dp.searchTextLen + 2);
|
||||
dp.searchTextLen);
|
||||
tempUnicode[dp.searchTextLen] = c;
|
||||
tempUnicode[dp.searchTextLen + 1] = 0;
|
||||
dp.updateSearchText(tempUnicode.get());
|
||||
|
@ -2395,7 +2395,7 @@ int InputBuffer::incrementalHistorySearch(PromptBase& pi, int startChar) {
|
|||
Utf32String tempUnicode(pb.promptBytes + 1);
|
||||
|
||||
copyString32(tempUnicode.get(), &pi.promptText[pi.promptLastLinePosition],
|
||||
pb.promptBytes + 1);
|
||||
pb.promptBytes - pi.promptLastLinePosition);
|
||||
tempUnicode.initFromBuffer();
|
||||
pb.promptText = tempUnicode;
|
||||
pb.promptExtraLines = 0;
|
||||
|
|
|
@ -83,7 +83,7 @@ struct Exception : std::exception {
|
|||
|
||||
explicit Exception(ExceptionType type) : Exception(type, message(type)) {}
|
||||
|
||||
char const* what() const throw() { return _msg.c_str(); }
|
||||
char const* what() const throw() override final { return _msg.c_str(); }
|
||||
|
||||
ExceptionType errorCode() const throw() { return _type; }
|
||||
|
||||
|
|
|
@ -213,8 +213,6 @@ unsigned int const Slice::FirstSubMap[32] = {
|
|||
8, // 0x12, object with unsorted index table
|
||||
0};
|
||||
|
||||
static char const* NullStr = "0x18";
|
||||
|
||||
// creates a Slice from Json and adds it to a scope
|
||||
Slice Slice::fromJson(SliceScope& scope, std::string const& json,
|
||||
Options const* options) {
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
@ -175,11 +175,11 @@ if (WINDOWS)
|
|||
set(BASE_C_FLAGS "" CACHE STRING "base C flags")
|
||||
set(BASE_CXX_FLAGS "/GR /EHsc" CACHE STRING "base C++flags")
|
||||
else ()
|
||||
set(BASE_FLAGS "" CACHE STRING "base flags")
|
||||
set(BASE_C_FLAGS "${CMAKE_C_FLAGS}" CACHE STRING "base C flags")
|
||||
set(BASE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "base C++ flags")
|
||||
set(BASE_LD_FLAGS "$ENV{LDFLAGS}" CACHE STRING "base linker flags")
|
||||
set(BASE_LIBS "$ENV{LIBS}" CACHE STRING "base libraries")
|
||||
set(BASE_FLAGS "" CACHE STRING "base flags")
|
||||
set(BASE_C_FLAGS "${CMAKE_C_FLAGS} $ENV{CFLAGS}" CACHE STRING "base C flags")
|
||||
set(BASE_CXX_FLAGS "${CMAKE_CXX_FLAGS} $ENV{CXXFLAGS}" CACHE STRING "base C++ flags")
|
||||
set(BASE_LD_FLAGS "$ENV{LDFLAGS}" CACHE STRING "base linker flags")
|
||||
set(BASE_LIBS "$ENV{LIBS}" CACHE STRING "base libraries")
|
||||
endif ()
|
||||
|
||||
if (SOLARIS)
|
||||
|
@ -447,13 +447,13 @@ if (VERBOSE)
|
|||
message(STATUS)
|
||||
endif ()
|
||||
|
||||
set(CMAKE_C_FLAGS "${BASE_FLAGS} ${BASE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${BASE_FLAGS} ${BASE_C_FLAGS} ${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${BASE_FLAGS} ${BASE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${BASE_FLAGS} ${BASE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${BASE_FLAGS} ${BASE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "${BASE_FLAGS} ${BASE_C_FLAGS} ${CMAKE_C_FLAGS_MINSIZEREL}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${BASE_FLAGS} ${BASE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${BASE_FLAGS} ${BASE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${BASE_FLAGS} ${BASE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${BASE_FLAGS} ${BASE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${BASE_FLAGS} ${BASE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
|
|
|
@ -52,8 +52,7 @@ help:
|
|||
@echo " -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl"
|
||||
@echo " sets the location of the openssl includes and libraries"
|
||||
@echo ""
|
||||
@echo "BOOST supports:"
|
||||
@echo ""
|
||||
@echo "TCMALLOC supports:"
|
||||
@echo " -DUSE_TCMALLOC=on"
|
||||
@echo " if ON, link against TCMALLOC"
|
||||
@echo ""
|
||||
|
|
|
@ -82,16 +82,27 @@ 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;
|
||||
float max_ping;
|
||||
float election_timeout;
|
||||
float append_entries_retry_interval;
|
||||
std::vector<std::string> end_points;
|
||||
std::string end_point_persist;
|
||||
bool notify;
|
||||
AgentConfiguration () : min_ping(.15), max_ping(.3) {};
|
||||
AgentConfiguration () : id(0), min_ping(.15), max_ping(.3), notify(false) {};
|
||||
AgentConfiguration (uint32_t i, float min_p, float max_p, float appent_i,
|
||||
std::vector<std::string> const& end_p, bool n = false) :
|
||||
id(i), min_ping(min_p), max_ping(max_p),
|
||||
|
@ -109,23 +120,25 @@ struct AgentConfiguration {
|
|||
s << *this;
|
||||
return s.str();
|
||||
}
|
||||
query_t const toBuilder () const {
|
||||
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) {}
|
||||
explicit vote_ret_t (query_t res) : result(res) {}
|
||||
};
|
||||
|
||||
struct read_ret_t {
|
||||
|
|
|
@ -167,7 +167,7 @@ bool Agent::recvAppendEntriesRPC (term_t term, id_t leaderId, index_t prevIndex,
|
|||
if (queries->slice().length()) {
|
||||
LOG(INFO) << "AGENCY: Appending "<< queries->slice().length()
|
||||
<< " entries to state machine.";
|
||||
} else {
|
||||
} else {
|
||||
// heart-beat
|
||||
}
|
||||
|
||||
|
@ -223,8 +223,10 @@ append_entries_t Agent::sendAppendEntriesRPC (
|
|||
builder.close();
|
||||
|
||||
// Send
|
||||
LOG(INFO) << "AGENCY: Appending " << unconfirmed.size() << " entries up to index "
|
||||
<< last << " to follower " << slave_id;
|
||||
if (unconfirmed.size() > 1) {
|
||||
LOG(INFO) << "AGENCY: Appending " << unconfirmed.size() << " entries up to index "
|
||||
<< last << " to follower " << slave_id;
|
||||
}
|
||||
arangodb::ClusterComm::instance()->asyncRequest
|
||||
("1", 1, _config.end_points[slave_id],
|
||||
rest::HttpRequest::HTTP_REQUEST_POST,
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
/**
|
||||
* @brief Construct with program options
|
||||
*/
|
||||
Agent (config_t const&);
|
||||
explicit Agent (config_t const&);
|
||||
|
||||
/**
|
||||
* @brief Clean up
|
||||
|
@ -129,8 +129,8 @@ public:
|
|||
* @brief 1. Deal with appendEntries to slaves.
|
||||
* 2. Report success of write processes.
|
||||
*/
|
||||
void run ();
|
||||
void beginShutdown () override;
|
||||
void run () override final;
|
||||
void beginShutdown () override final;
|
||||
|
||||
/**
|
||||
* @brief Report appended entries from AgentCallback
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
using namespace arangodb::consensus;
|
||||
using namespace arangodb::velocypack;
|
||||
|
||||
AgentCallback::AgentCallback() : _agent(0) {}
|
||||
AgentCallback::AgentCallback() : _agent(0), _last(0), _slave_id(0) {}
|
||||
|
||||
AgentCallback::AgentCallback(Agent* agent, id_t slave_id, index_t last) :
|
||||
_agent(agent), _last(last), _slave_id(slave_id) {}
|
||||
|
|
|
@ -35,11 +35,10 @@ using namespace arangodb::basics;
|
|||
using namespace arangodb::rest;
|
||||
|
||||
ApplicationAgency::ApplicationAgency()
|
||||
: ApplicationFeature("agency"), _size(1), _min_election_timeout(0.5),
|
||||
_max_election_timeout(2.0), _election_call_rate_mul(2.5),
|
||||
: ApplicationFeature("agency"), _size(1), _min_election_timeout(0.1),
|
||||
_max_election_timeout(1.0), _election_call_rate_mul(0.85),
|
||||
_append_entries_retry_interval(1.0),
|
||||
_agent_id(std::numeric_limits<uint32_t>::max()) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,8 +70,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();
|
||||
|
@ -51,8 +55,9 @@ void Constituent::configure(Agent* agent) {
|
|||
}
|
||||
}
|
||||
|
||||
Constituent::Constituent() : Thread("Constituent"), _term(0), _id(0),
|
||||
_gen(std::random_device()()), _role(FOLLOWER), _agent(0) {}
|
||||
Constituent::Constituent() :
|
||||
Thread("Constituent"), _term(0), _id(0), _gen(std::random_device()()),
|
||||
_role(FOLLOWER), _leader_id(0), _agent(0) {}
|
||||
|
||||
Constituent::~Constituent() {
|
||||
shutdown();
|
||||
|
@ -131,7 +136,6 @@ std::vector<std::string> const& Constituent::end_points() const {
|
|||
size_t Constituent::notifyAll () {
|
||||
|
||||
// Last process notifies everyone
|
||||
std::vector<ClusterCommResult> results(_agent->config().end_points.size());
|
||||
std::stringstream path;
|
||||
|
||||
path << "/_api/agency_priv/notifyAll?term=" << _term << "&agencyId=" << _id;
|
||||
|
@ -151,7 +155,7 @@ size_t Constituent::notifyAll () {
|
|||
if (i != _id) {
|
||||
std::unique_ptr<std::map<std::string, std::string>> headerFields =
|
||||
std::make_unique<std::map<std::string, std::string> >();
|
||||
results[i] = arangodb::ClusterComm::instance()->asyncRequest(
|
||||
arangodb::ClusterComm::instance()->asyncRequest(
|
||||
"1", 1, end_point(i), rest::HttpRequest::HTTP_REQUEST_POST, path.str(),
|
||||
std::make_shared<std::string>(body.toString()), headerFields, nullptr,
|
||||
0.0, true);
|
||||
|
@ -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 @@ public:
|
|||
|
||||
|
||||
/// @brief Default constructor
|
||||
State (std::string const& end_point = "tcp://localhost:8529");
|
||||
explicit State (std::string const& end_point = "tcp://localhost:8529");
|
||||
|
||||
|
||||
/// @brief Default Destructor
|
||||
|
|
|
@ -53,8 +53,8 @@ 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(); }
|
||||
explicit StoreException(std::string const& message) : _message(message) {}
|
||||
virtual char const* what() const noexcept override final { return _message.c_str(); }
|
||||
private:
|
||||
std::string _message;
|
||||
};
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
typedef std::map<TimePoint, std::shared_ptr<Node>> TimeTable;
|
||||
|
||||
/// @brief Construct with name
|
||||
Node (std::string const& name);
|
||||
explicit Node (std::string const& name);
|
||||
|
||||
/// @brief Construct with name and introduce to tree under parent
|
||||
Node (std::string const& name, Node* parent);
|
||||
|
@ -175,7 +175,7 @@ class Store : public Node, public arangodb::Thread {
|
|||
public:
|
||||
|
||||
/// @brief Construct with name
|
||||
Store (std::string const& name = "root");
|
||||
explicit Store (std::string const& name = "root");
|
||||
|
||||
/// @brief Destruct
|
||||
virtual ~Store ();
|
||||
|
|
|
@ -53,9 +53,9 @@ class DispatcherThread : public Thread {
|
|||
~DispatcherThread() {shutdown();}
|
||||
|
||||
protected:
|
||||
void run();
|
||||
void run() override;
|
||||
|
||||
void addStatus(arangodb::velocypack::Builder* b);
|
||||
void addStatus(arangodb::velocypack::Builder* b) override;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -70,12 +70,14 @@ inline HttpHandler::status_t RestAgencyHandler::reportUnknownMethod () {
|
|||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
|
||||
inline HttpHandler::status_t RestAgencyHandler::redirect (id_t leader_id) {
|
||||
LOG(WARN) << "Redirecting request to " << leader_id;
|
||||
generateError(HttpResponse::NOT_FOUND,404);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
void RestAgencyHandler::redirectRequest (id_t leaderId) {
|
||||
std::string rendpoint = _agent->config().end_points.at(leaderId);
|
||||
rendpoint = rendpoint.substr(6,rendpoint.size()-6);
|
||||
rendpoint = std::string("http://" + rendpoint + _request->requestPath());
|
||||
createResponse(HttpResponse::TEMPORARY_REDIRECT);
|
||||
_response->setHeader("Location", rendpoint);
|
||||
}
|
||||
#include <iostream>
|
||||
|
||||
inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
|
||||
arangodb::velocypack::Options options; // TODO: User not wait.
|
||||
if (_request->requestType() == HttpRequest::HTTP_REQUEST_POST) {
|
||||
|
@ -89,10 +91,10 @@ inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
|
|||
}
|
||||
write_ret_t ret = _agent->write (query);
|
||||
size_t errors = 0;
|
||||
if (ret.accepted) {
|
||||
if (ret.accepted) { // We're leading and handling the request
|
||||
Builder body;
|
||||
body.add(VPackValue(VPackValueType::Object));
|
||||
_agent->waitFor (ret.indices.back()); // Wait for confirmation (last entry is enough)
|
||||
_agent->waitFor (ret.indices.back()); // Wait for confirmation
|
||||
for (size_t i = 0; i < ret.indices.size(); ++i) {
|
||||
body.add(std::to_string(i), Value(ret.indices[i]));
|
||||
if (ret.indices[i] == 0) {
|
||||
|
@ -100,19 +102,16 @@ inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
|
|||
}
|
||||
}
|
||||
body.close();
|
||||
if (errors > 0) { // epic fail
|
||||
if (errors > 0) { // Some/all requests failed
|
||||
generateResult(HttpResponse::PRECONDITION_FAILED,body.slice());
|
||||
} else {// full success
|
||||
} else { // All good
|
||||
generateResult(body.slice());
|
||||
}
|
||||
} else {
|
||||
//_response->setHeader("Location", _agent->config().end_points[ret.redirect]);
|
||||
generateError(HttpResponse::TEMPORARY_REDIRECT,307);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
} else { // Redirect to leader
|
||||
redirectRequest(ret.redirect);
|
||||
}
|
||||
} else {
|
||||
} else { // Unknown method
|
||||
generateError(HttpResponse::METHOD_NOT_ALLOWED,405);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
|
@ -124,15 +123,16 @@ inline HttpHandler::status_t RestAgencyHandler::handleRead () {
|
|||
try {
|
||||
query = _request->toVelocyPack(&options);
|
||||
} catch (std::exception const& e) {
|
||||
LOG(FATAL) << e.what();
|
||||
generateError(HttpResponse::UNPROCESSABLE_ENTITY,422);
|
||||
LOG(WARN) << e.what();
|
||||
generateError(HttpResponse::BAD,400);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
read_ret_t ret = _agent->read (query);
|
||||
if (ret.accepted) {
|
||||
|
||||
if (ret.accepted) { // I am leading
|
||||
generateResult(ret.result->slice());
|
||||
} else {
|
||||
generateError(HttpResponse::TEMPORARY_REDIRECT,307);
|
||||
} else { // Redirect to leader
|
||||
redirectRequest(ret.redirect);
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
}
|
||||
} else {
|
||||
|
@ -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()->slice());
|
||||
body.close();
|
||||
generateResult(body.slice());
|
||||
return HttpHandler::status_t(HANDLER_DONE);
|
||||
|
|
|
@ -48,13 +48,13 @@ class RestAgencyHandler : public arangodb::RestBaseHandler {
|
|||
status_t reportErrorEmptyRequest() ;
|
||||
status_t reportTooManySuffices() ;
|
||||
status_t reportUnknownMethod() ;
|
||||
status_t redirect(id_t leader_id) ;
|
||||
status_t handleRead() ;
|
||||
status_t handleWrite() ;
|
||||
status_t handleTest();
|
||||
status_t reportMethodNotAllowed();
|
||||
status_t handleState();
|
||||
|
||||
|
||||
void redirectRequest (id_t leaderId);
|
||||
consensus::Agent* _agent;
|
||||
|
||||
};
|
||||
|
|
|
@ -46,7 +46,7 @@ class RestBaseHandler : public rest::HttpHandler {
|
|||
explicit RestBaseHandler(rest::HttpRequest* request);
|
||||
|
||||
public:
|
||||
void handleError(basics::Exception const&);
|
||||
void handleError(basics::Exception const&) override;
|
||||
|
||||
public:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -88,13 +88,13 @@ class VocbaseContext : public arangodb::rest::RequestContext {
|
|||
/// @brief return authentication realm
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
char const* getRealm() const;
|
||||
char const* getRealm() const override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks the authentication
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
rest::HttpResponse::HttpResponseCode authenticate();
|
||||
rest::HttpResponse::HttpResponseCode authenticate() override final;
|
||||
|
||||
public:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -80,17 +80,17 @@ class ApplicationScheduler : public ApplicationFeature {
|
|||
void disableControlCHandler();
|
||||
|
||||
public:
|
||||
void setupOptions(std::map<std::string, basics::ProgramOptionsDescription>&);
|
||||
void setupOptions(std::map<std::string, basics::ProgramOptionsDescription>&) override;
|
||||
|
||||
bool afterOptionParsing(basics::ProgramOptions&);
|
||||
bool afterOptionParsing(basics::ProgramOptions&) override;
|
||||
|
||||
bool prepare();
|
||||
bool prepare() override ;
|
||||
|
||||
bool start();
|
||||
bool start() override;
|
||||
|
||||
bool open();
|
||||
bool open() override;
|
||||
|
||||
void stop();
|
||||
void stop() override;
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -69,7 +69,7 @@ struct CustomTypeHandlerImpl : public VPackCustomTypeHandler {
|
|||
: resolver(resolver) {}
|
||||
|
||||
void toJson(VPackSlice const& value, VPackDumper* dumper,
|
||||
VPackSlice const& base) {
|
||||
VPackSlice const& base) override {
|
||||
if (value.head() == 0xf0) {
|
||||
// _id
|
||||
if (!base.isObject()) {
|
||||
|
@ -110,7 +110,7 @@ struct CustomTypeHandlerImpl : public VPackCustomTypeHandler {
|
|||
throw "unknown type!";
|
||||
}
|
||||
|
||||
VPackValueLength byteSize(VPackSlice const& value) {
|
||||
VPackValueLength byteSize(VPackSlice const& value) override {
|
||||
if (value.head() == 0xf0) {
|
||||
// _id
|
||||
return 1 + 8; // 0xf0 + 8 bytes for collection id
|
||||
|
|
|
@ -81,7 +81,7 @@ class BenchmarkThread : public arangodb::Thread {
|
|||
/// @brief the thread program
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void run() {
|
||||
void run() override {
|
||||
try {
|
||||
_httpClient = _client->createHttpClient();
|
||||
} catch (...) {
|
||||
|
|
|
@ -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&);
|
||||
|
|
|
@ -73,31 +73,31 @@ class EndpointIp : public Endpoint {
|
|||
/// @brief connect the endpoint
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TRI_socket_t connect(double, double);
|
||||
TRI_socket_t connect(double, double) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief disconnect the endpoint
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual void disconnect();
|
||||
virtual void disconnect() override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief init an incoming connection
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
virtual bool initIncoming(TRI_socket_t);
|
||||
virtual bool initIncoming(TRI_socket_t) override;
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get port
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getPort() const { return _port; }
|
||||
int getPort() const override { return _port; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get host
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string getHost() const { return _host; }
|
||||
std::string getHost() const override { return _host; }
|
||||
|
||||
private:
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -51,13 +51,13 @@ class EndpointIpV4 final : public EndpointIp {
|
|||
/// @brief get endpoint domain
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getDomain() const { return AF_INET; }
|
||||
int getDomain() const override { return AF_INET; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get host string for HTTP requests
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string getHostString() const {
|
||||
std::string getHostString() const override{
|
||||
return getHost() + ':' + arangodb::basics::StringUtils::itoa(getPort());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -51,13 +51,13 @@ class EndpointIpV6 final : public EndpointIp {
|
|||
/// @brief get endpoint domain
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int getDomain() const { return AF_INET6; }
|
||||
int getDomain() const override { return AF_INET6; }
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief get host string for HTTP requests
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::string getHostString() const {
|
||||
std::string getHostString() const override {
|
||||
return '[' + getHost() + "]:" +
|
||||
arangodb::basics::StringUtils::itoa(getPort());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue