From 724c5dd6c7dd4c8784b56092959af1b9a08aa757 Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Mon, 25 Apr 2016 16:51:54 +0000 Subject: [PATCH] solaris' ineptness --- arangod/Agency/Agent.cpp | 16 ++++++++-------- arangod/Agency/Agent.h | 14 +++++++------- arangod/Agency/AgentCallback.cpp | 2 +- arangod/Agency/AgentCallback.h | 4 ++-- arangod/Agency/AgentConfiguration.h | 2 +- arangod/Agency/Constituent.cpp | 14 +++++++------- arangod/Agency/Constituent.h | 12 ++++++------ arangod/Agency/RestAgencyHandler.cpp | 2 +- arangod/Agency/RestAgencyPrivHandler.cpp | 2 +- arangod/Agency/State.cpp | 10 +++++----- arangod/Agency/State.h | 6 +++--- 11 files changed, 42 insertions(+), 42 deletions(-) diff --git a/arangod/Agency/Agent.cpp b/arangod/Agency/Agent.cpp index c42aa157f9..8e89e47406 100644 --- a/arangod/Agency/Agent.cpp +++ b/arangod/Agency/Agent.cpp @@ -52,7 +52,7 @@ Agent::Agent (config_t const& config) } // This agent's id -id_t Agent::id() const { +arangodb::consensus::id_t Agent::id() const { return _config.id; } @@ -84,7 +84,7 @@ inline size_t Agent::size() const { } // Handle vote request -priv_rpc_ret_t Agent::requestVote(term_t t, id_t id, index_t lastLogIndex, +priv_rpc_ret_t Agent::requestVote(term_t t, arangodb::consensus::id_t id, index_t lastLogIndex, index_t lastLogTerm, query_t const& query) { /// Are we receiving new endpoints @@ -110,7 +110,7 @@ config_t const& Agent::config () const { } // Leader's id -id_t Agent::leaderID () const { +arangodb::consensus::id_t Agent::leaderID () const { return _constituent.leaderID(); } @@ -120,7 +120,7 @@ bool Agent::leading() const { } // Persist term and id we vote for -void Agent::persist(term_t t, id_t i) { +void Agent::persist(term_t t, arangodb::consensus::id_t i) { // _state.persist(t, i); } @@ -156,7 +156,7 @@ bool Agent::waitFor (index_t index, double timeout) { } // AgentCallback reports id of follower and its highest processed index -void Agent::reportIn (id_t id, index_t index) { +void Agent::reportIn (arangodb::consensus::id_t id, index_t index) { MUTEX_LOCKER(mutexLocker, _ioLock); if (index > _confirmed[id]) // progress this follower? @@ -181,7 +181,7 @@ void Agent::reportIn (id_t id, index_t index) { } // Followers' append entries -bool Agent::recvAppendEntriesRPC (term_t term, id_t leaderId, index_t prevIndex, +bool Agent::recvAppendEntriesRPC (term_t term, arangodb::consensus::id_t leaderId, index_t prevIndex, term_t prevTerm, index_t leaderCommitIndex, query_t const& queries) { //Update commit index @@ -233,7 +233,7 @@ bool Agent::recvAppendEntriesRPC (term_t term, id_t leaderId, index_t prevIndex, } // Leader's append entries -append_entries_t Agent::sendAppendEntriesRPC (id_t follower_id) { +append_entries_t Agent::sendAppendEntriesRPC (arangodb::consensus::id_t follower_id) { index_t last_confirmed = _confirmed[follower_id]; std::vector unconfirmed = _state.get(last_confirmed); @@ -374,7 +374,7 @@ void Agent::run() { _appendCV.wait(); // Just sit there doing nothing // Collect all unacknowledged - for (id_t i = 0; i < size(); ++i) { + for (arangodb::consensus::id_t i = 0; i < size(); ++i) { if (i != id()) { sendAppendEntriesRPC(i); } diff --git a/arangod/Agency/Agent.h b/arangod/Agency/Agent.h index b058127502..5b11009009 100644 --- a/arangod/Agency/Agent.h +++ b/arangod/Agency/Agent.h @@ -50,10 +50,10 @@ public: term_t term() const; /// @brief Get current term - id_t id() const; + arangodb::consensus::id_t id() const; /// @brief Vote request - priv_rpc_ret_t requestVote(term_t, id_t, index_t, index_t, query_t const&); + priv_rpc_ret_t requestVote(term_t, arangodb::consensus::id_t, index_t, index_t, query_t const&); /// @brief Provide configuration config_t const& config() const; @@ -69,7 +69,7 @@ public: bool fitness() const; /// @brief Leader ID - id_t leaderID() const; + arangodb::consensus::id_t leaderID() const; /// @brief Are we leading? bool leading() const; @@ -88,13 +88,13 @@ public: /// @brief Received by followers to replicate log entries ($5.3); /// also used as heartbeat ($5.2). - bool recvAppendEntriesRPC(term_t term, id_t leaderId, index_t prevIndex, + bool recvAppendEntriesRPC(term_t term, arangodb::consensus::id_t leaderId, index_t prevIndex, term_t prevTerm, index_t lastCommitIndex, query_t const& queries); /// @brief Invoked by leader to replicate log entries ($5.3); /// also used as heartbeat ($5.2). - append_entries_t sendAppendEntriesRPC(id_t slave_id); + append_entries_t sendAppendEntriesRPC(arangodb::consensus::id_t slave_id); /// @brief 1. Deal with appendEntries to slaves. /// 2. Report success of write processes. @@ -104,7 +104,7 @@ public: void beginShutdown() override final; /// @brief Report appended entries from AgentCallback - void reportIn(id_t id, index_t idx); + void reportIn(arangodb::consensus::id_t id, index_t idx); /// @brief Wait for slaves to confirm appended entries bool waitFor(index_t last_entry, double timeout = 2.0); @@ -119,7 +119,7 @@ public: log_t const& lastLog() const; /// @brief Persist term - void persist (term_t, id_t); + void persist (term_t, arangodb::consensus::id_t); /// @brief State machine State const& state() const; diff --git a/arangod/Agency/AgentCallback.cpp b/arangod/Agency/AgentCallback.cpp index 84a761997d..10840cd652 100644 --- a/arangod/Agency/AgentCallback.cpp +++ b/arangod/Agency/AgentCallback.cpp @@ -30,7 +30,7 @@ using namespace arangodb::velocypack; AgentCallback::AgentCallback() : _agent(0), _last(0), _slaveID(0) {} -AgentCallback::AgentCallback(Agent* agent, id_t slaveID, index_t last) : +AgentCallback::AgentCallback(Agent* agent, arangodb::consensus::id_t slaveID, index_t last) : _agent(agent), _last(last), _slaveID(slaveID) {} void AgentCallback::shutdown() { diff --git a/arangod/Agency/AgentCallback.h b/arangod/Agency/AgentCallback.h index 5bc3e700c2..82ecea4cca 100644 --- a/arangod/Agency/AgentCallback.h +++ b/arangod/Agency/AgentCallback.h @@ -38,7 +38,7 @@ public: AgentCallback(); - AgentCallback(Agent*, id_t, index_t); + AgentCallback(Agent*, arangodb::consensus::id_t, index_t); virtual bool operator()(arangodb::ClusterCommResult*) override final; @@ -47,7 +47,7 @@ public: private: Agent* _agent; index_t _last; - id_t _slaveID; + arangodb::consensus::id_t _slaveID; }; diff --git a/arangod/Agency/AgentConfiguration.h b/arangod/Agency/AgentConfiguration.h index f481fe51ac..e60f8b783f 100644 --- a/arangod/Agency/AgentConfiguration.h +++ b/arangod/Agency/AgentConfiguration.h @@ -29,7 +29,7 @@ namespace consensus { struct config_t { - id_t id; + arangodb::consensus::id_t id; double minPing; double maxPing; std::string endpoint; diff --git a/arangod/Agency/Constituent.cpp b/arangod/Agency/Constituent.cpp index eb862c54b0..a889aa76bd 100644 --- a/arangod/Agency/Constituent.cpp +++ b/arangod/Agency/Constituent.cpp @@ -211,13 +211,13 @@ bool Constituent::running() const { } /// @brief Get current leader's id -id_t Constituent::leaderID() const { return _leaderID; } +arangodb::consensus::id_t Constituent::leaderID() const { return _leaderID; } /// @brief Agency size size_t Constituent::size() const { return config().size(); } /// @brief Get endpoint to an id -std::string const& Constituent::endpoint(id_t id) const { +std::string const& Constituent::endpoint(arangodb::consensus::id_t id) const { return config().endpoints[id]; } @@ -230,7 +230,7 @@ std::vector const& Constituent::endpoints() const { void Constituent::notifyAll () { std::vector toNotify; // Send request to all but myself - for (id_t i = 0; i < size(); ++i) { + for (arangodb::consensus::id_t i = 0; i < size(); ++i) { if (i != _id) { toNotify.push_back(endpoint(i)); } @@ -256,10 +256,10 @@ void Constituent::notifyAll () { } /// @brief Vote -bool Constituent::vote(term_t term, id_t id, index_t prevLogIndex, +bool Constituent::vote(term_t term, arangodb::consensus::id_t id, index_t prevLogIndex, term_t prevLogTerm) { term_t t = 0; - id_t lid = 0; + arangodb::consensus::id_t lid = 0; { MUTEX_LOCKER(guard, _castLock); t = _term; @@ -303,7 +303,7 @@ void Constituent::callElection() { << "&prevLogTerm=" << _agent->lastLog().term; // Ask everyone for their vote - for (id_t i = 0; i < config().endpoints.size(); ++i) { + for (arangodb::consensus::id_t i = 0; i < config().endpoints.size(); ++i) { if (i != _id && endpoint(i) != "") { std::unique_ptr> headerFields = std::make_unique>(); @@ -319,7 +319,7 @@ void Constituent::callElection() { sleepFor(.5 * config().minPing, .8 * config().minPing)); // Collect votes - for (id_t i = 0; i < config().endpoints.size(); ++i) { + for (arangodb::consensus::id_t i = 0; i < config().endpoints.size(); ++i) { if (i != _id && endpoint(i) != "") { ClusterCommResult res = arangodb::ClusterComm::instance()->enquire(results[i].operationID); diff --git a/arangod/Agency/Constituent.h b/arangod/Agency/Constituent.h index 9fd32900b5..193d843496 100644 --- a/arangod/Agency/Constituent.h +++ b/arangod/Agency/Constituent.h @@ -78,13 +78,13 @@ public: bool running() const; /// @brief Called by REST handler - bool vote(term_t, id_t, index_t, term_t); + bool vote(term_t, arangodb::consensus::id_t, index_t, term_t); /// @brief My daily business void run() override final; /// @brief Who is leading - id_t leaderID () const; + arangodb::consensus::id_t leaderID () const; /// @brief Configuration config_t const& config () const; @@ -109,7 +109,7 @@ private: std::vector const& endpoints() const; /// @brief Endpoint of agent with id - std::string const& endpoint(id_t) const; + std::string const& endpoint(arangodb::consensus::id_t) const; /// @brief Run for leadership void candidate(); @@ -141,13 +141,13 @@ private: std::atomic _cast; /**< @brief cast a vote this term */ std::atomic _state; /**< @brief State (follower, candidate, leader)*/ - id_t _leaderID; /**< @brief Current leader */ - id_t _id; /**< @brief My own id */ + arangodb::consensus::id_t _leaderID; /**< @brief Current leader */ + arangodb::consensus::id_t _id; /**< @brief My own id */ constituency_t _constituency; /**< @brief List of consituents */ std::mt19937 _gen; /**< @brief Random number generator */ role_t _role; /**< @brief My role */ Agent* _agent; /**< @brief My boss */ - id_t _votedFor; + arangodb::consensus::id_t _votedFor; std::unique_ptr _notifier; diff --git a/arangod/Agency/RestAgencyHandler.cpp b/arangod/Agency/RestAgencyHandler.cpp index 164e6310f9..c3639d826e 100644 --- a/arangod/Agency/RestAgencyHandler.cpp +++ b/arangod/Agency/RestAgencyHandler.cpp @@ -68,7 +68,7 @@ inline HttpHandler::status_t RestAgencyHandler::reportUnknownMethod() { return HttpHandler::status_t(HANDLER_DONE); } -void RestAgencyHandler::redirectRequest(id_t leaderId) { +void RestAgencyHandler::redirectRequest(arangodb::consensus::id_t leaderId) { try { std::string url = Endpoint::uriForm( diff --git a/arangod/Agency/RestAgencyPrivHandler.cpp b/arangod/Agency/RestAgencyPrivHandler.cpp index 5c80ef83ad..f6d5a0d2cc 100644 --- a/arangod/Agency/RestAgencyPrivHandler.cpp +++ b/arangod/Agency/RestAgencyPrivHandler.cpp @@ -82,7 +82,7 @@ HttpHandler::status_t RestAgencyPrivHandler::execute() { return reportTooManySuffices(); } else { term_t term, prevLogTerm; - id_t id; // leaderId for appendEntries, cadidateId for requestVote + arangodb::consensus::id_t id; // leaderId for appendEntries, cadidateId for requestVote index_t prevLogIndex, leaderCommit; if (_request->suffix()[0] == "appendEntries") { // appendEntries if (_request->requestType() != GeneralRequest::RequestType::POST) { diff --git a/arangod/Agency/State.cpp b/arangod/Agency/State.cpp index 0ce0d127f3..bfe3aa32a5 100644 --- a/arangod/Agency/State.cpp +++ b/arangod/Agency/State.cpp @@ -57,13 +57,13 @@ State::State(std::string const& endpoint) VPackSlice value = arangodb::basics::VelocyPackHelper::EmptyObjectValue(); buf->append(value.startAs(), value.byteSize()); if (!_log.size()) { - _log.push_back(log_t(index_t(0), term_t(0), id_t(0), buf)); + _log.push_back(log_t(index_t(0), term_t(0), arangodb::consensus::id_t(0), buf)); } } State::~State() {} -bool State::persist(index_t index, term_t term, id_t lid, +bool State::persist(index_t index, term_t term, arangodb::consensus::id_t lid, arangodb::velocypack::Slice const& entry) { Builder body; body.add(VPackValue(VPackValueType::Object)); @@ -95,7 +95,7 @@ bool State::persist(index_t index, term_t term, id_t lid, //Leader std::vector State::log ( - query_t const& query, std::vector const& appl, term_t term, id_t lid) { + query_t const& query, std::vector const& appl, term_t term, arangodb::consensus::id_t lid) { std::vector idx(appl.size()); std::vector good = appl; @@ -117,7 +117,7 @@ std::vector State::log ( } // Follower -bool State::log(query_t const& queries, term_t term, id_t lid, +bool State::log(query_t const& queries, term_t term, arangodb::consensus::id_t lid, index_t prevLogIndex, term_t prevLogTerm) { // TODO: Throw exc if (queries->slice().type() != VPackValueType::Array) { return false; @@ -257,7 +257,7 @@ bool State::loadCollection(std::string const& name) { _log.push_back( log_t(std::stoi(i.get(TRI_VOC_ATTRIBUTE_KEY).copyString()), static_cast(i.get("term").getUInt()), - static_cast(i.get("leader").getUInt()), tmp)); + static_cast(i.get("leader").getUInt()), tmp)); } } diff --git a/arangod/Agency/State.h b/arangod/Agency/State.h index ab06912e3e..6e2f6f528d 100644 --- a/arangod/Agency/State.h +++ b/arangod/Agency/State.h @@ -62,11 +62,11 @@ public: /// @brief Log entries (leader) - std::vector log (query_t const& query, std::vector const& indices, term_t term, id_t lid); + std::vector log (query_t const& query, std::vector const& indices, term_t term, arangodb::consensus::id_t lid); /// @brief Log entries (followers) - bool log (query_t const& queries, term_t term, id_t leaderId, index_t prevLogIndex, term_t prevLogTerm); + bool log (query_t const& queries, term_t term, arangodb::consensus::id_t leaderId, index_t prevLogIndex, term_t prevLogTerm); /// @brief Find entry at index with term @@ -114,7 +114,7 @@ private: bool snapshot (); /// @brief Save currentTerm, votedFor, log entries - bool persist (index_t index, term_t term, id_t lid, + bool persist (index_t index, term_t term, arangodb::consensus::id_t lid, arangodb::velocypack::Slice const& entry); /// @brief Load collection from persistent store