mirror of https://gitee.com/bigwinds/arangodb
agencycommresult with clientids
This commit is contained in:
parent
c3f7a0b774
commit
54ccffc0ee
|
@ -224,7 +224,7 @@ void AgencyWriteTransaction::toVelocyPack(VPackBuilder& builder) const {
|
|||
VPackObjectBuilder guard3(&builder);
|
||||
}
|
||||
|
||||
builder.add(VPackValue(transactionId)); // Transactions
|
||||
builder.add(VPackValue(clientId)); // Transactions
|
||||
}
|
||||
|
||||
bool AgencyWriteTransaction::validate(AgencyCommResult const& result) const {
|
||||
|
@ -283,7 +283,7 @@ void AgencyGeneralTransaction::toVelocyPack(VPackBuilder& builder) const {
|
|||
} else {
|
||||
std::get<0>(operation).toGeneralBuilder(builder);
|
||||
std::get<1>(operation).toGeneralBuilder(builder);
|
||||
builder.add(VPackValue(transactionId));
|
||||
builder.add(VPackValue(clientId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -328,18 +328,23 @@ AgencyCommResult::AgencyCommResult()
|
|||
_body(),
|
||||
_values(),
|
||||
_statusCode(0),
|
||||
_connected(false) {}
|
||||
_connected(false),
|
||||
_clientId("") {}
|
||||
|
||||
AgencyCommResult::AgencyCommResult(int code, std::string const& message)
|
||||
AgencyCommResult::AgencyCommResult(
|
||||
int code, std::string const& message, std::string const& clientId)
|
||||
: _location(),
|
||||
_message(message),
|
||||
_body(),
|
||||
_values(),
|
||||
_statusCode(code),
|
||||
_connected(false) {}
|
||||
_connected(false),
|
||||
_clientId(clientId) {}
|
||||
|
||||
bool AgencyCommResult::connected() const { return _connected; }
|
||||
|
||||
std::string AgencyCommResult::clientId() const { return _clientId; }
|
||||
|
||||
int AgencyCommResult::httpCode() const { return _statusCode; }
|
||||
|
||||
int AgencyCommResult::errorCode() const {
|
||||
|
|
|
@ -218,7 +218,9 @@ class AgencyOperation {
|
|||
class AgencyCommResult {
|
||||
public:
|
||||
AgencyCommResult();
|
||||
AgencyCommResult(int code, std::string const& message);
|
||||
AgencyCommResult(int code, std::string const& message,
|
||||
std::string const& transactionId = std::string());
|
||||
|
||||
~AgencyCommResult() = default;
|
||||
|
||||
public:
|
||||
|
@ -230,6 +232,8 @@ class AgencyCommResult {
|
|||
|
||||
int errorCode() const;
|
||||
|
||||
std::string clientId() const;
|
||||
|
||||
std::string errorMessage() const;
|
||||
|
||||
std::string errorDetails() const;
|
||||
|
@ -256,6 +260,8 @@ class AgencyCommResult {
|
|||
|
||||
private:
|
||||
std::shared_ptr<velocypack::Builder> _vpack;
|
||||
|
||||
std::string _clientId;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -272,7 +278,8 @@ public:
|
|||
virtual std::string toJson() const = 0;
|
||||
virtual void toVelocyPack(arangodb::velocypack::Builder&) const = 0;
|
||||
virtual std::string const& path() const = 0;
|
||||
|
||||
virtual std::string getClientId() const = 0;
|
||||
|
||||
virtual bool validate(AgencyCommResult const& result) const = 0;
|
||||
|
||||
};
|
||||
|
@ -285,14 +292,14 @@ struct AgencyGeneralTransaction : public AgencyTransaction {
|
|||
|
||||
explicit AgencyGeneralTransaction(
|
||||
std::pair<AgencyOperation,AgencyPrecondition> const& operation) :
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {
|
||||
clientId(to_string(boost::uuids::random_generator()())) {
|
||||
operations.push_back(operation);
|
||||
}
|
||||
|
||||
explicit AgencyGeneralTransaction(
|
||||
std::vector<std::pair<AgencyOperation,AgencyPrecondition>> const& _opers) :
|
||||
operations(_opers),
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {}
|
||||
clientId(to_string(boost::uuids::random_generator()())) {}
|
||||
|
||||
AgencyGeneralTransaction() = default;
|
||||
|
||||
|
@ -305,12 +312,16 @@ struct AgencyGeneralTransaction : public AgencyTransaction {
|
|||
|
||||
void push_back(std::pair<AgencyOperation,AgencyPrecondition> const&);
|
||||
|
||||
inline std::string const& path() const override final {
|
||||
inline virtual std::string const& path() const override final {
|
||||
return AgencyTransaction::TypeUrl[2];
|
||||
}
|
||||
|
||||
inline virtual std::string getClientId() const override final {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
virtual bool validate(AgencyCommResult const& result) const override final;
|
||||
std::string transactionId;
|
||||
std::string clientId;
|
||||
|
||||
};
|
||||
|
||||
|
@ -323,24 +334,24 @@ struct AgencyWriteTransaction : public AgencyTransaction {
|
|||
public:
|
||||
|
||||
explicit AgencyWriteTransaction(AgencyOperation const& operation) :
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {
|
||||
clientId(to_string(boost::uuids::random_generator()())) {
|
||||
operations.push_back(operation);
|
||||
}
|
||||
|
||||
explicit AgencyWriteTransaction (std::vector<AgencyOperation> const& _opers) :
|
||||
operations(_opers),
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {}
|
||||
clientId(to_string(boost::uuids::random_generator()())) {}
|
||||
|
||||
AgencyWriteTransaction(AgencyOperation const& operation,
|
||||
AgencyPrecondition const& precondition) :
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {
|
||||
clientId(to_string(boost::uuids::random_generator()())) {
|
||||
operations.push_back(operation);
|
||||
preconditions.push_back(precondition);
|
||||
}
|
||||
|
||||
AgencyWriteTransaction(std::vector<AgencyOperation> const& _operations,
|
||||
AgencyPrecondition const& precondition) :
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {
|
||||
clientId(to_string(boost::uuids::random_generator()())) {
|
||||
for (auto const& op : _operations) {
|
||||
operations.push_back(op);
|
||||
}
|
||||
|
@ -349,7 +360,7 @@ public:
|
|||
|
||||
AgencyWriteTransaction(std::vector<AgencyOperation> const& opers,
|
||||
std::vector<AgencyPrecondition> const& precs) :
|
||||
transactionId(to_string(boost::uuids::random_generator()())) {
|
||||
clientId(to_string(boost::uuids::random_generator()())) {
|
||||
for (auto const& op : opers) {
|
||||
operations.push_back(op);
|
||||
}
|
||||
|
@ -365,15 +376,19 @@ public:
|
|||
|
||||
std::string toJson() const override final;
|
||||
|
||||
inline std::string const& path() const override final {
|
||||
inline virtual std::string const& path() const override final {
|
||||
return AgencyTransaction::TypeUrl[1];
|
||||
}
|
||||
|
||||
inline virtual std::string getClientId() const override final {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
virtual bool validate(AgencyCommResult const& result) const override final;
|
||||
|
||||
std::vector<AgencyPrecondition> preconditions;
|
||||
std::vector<AgencyOperation> operations;
|
||||
std::string transactionId;
|
||||
std::string clientId;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -427,6 +442,10 @@ public:
|
|||
return AgencyTransaction::TypeUrl[3];
|
||||
}
|
||||
|
||||
inline virtual std::string getClientId() const override final {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
virtual bool validate(AgencyCommResult const& result) const override final;
|
||||
|
||||
std::vector<AgencyPrecondition> preconditions;
|
||||
|
@ -454,10 +473,14 @@ public:
|
|||
|
||||
std::string toJson() const override final;
|
||||
|
||||
inline std::string const& path() const override final {
|
||||
inline virtual std::string const& path() const override final {
|
||||
return AgencyTransaction::TypeUrl[0];
|
||||
}
|
||||
|
||||
inline virtual std::string getClientId() const override final {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
virtual bool validate(AgencyCommResult const& result) const override final;
|
||||
|
||||
std::vector<std::string> keys;
|
||||
|
|
|
@ -810,7 +810,6 @@ void Agent::run() {
|
|||
|
||||
} else {
|
||||
_appendCV.wait(1000000);
|
||||
updateConfiguration();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -910,9 +909,9 @@ void Agent::detectActiveAgentFailures() {
|
|||
system_clock::now() - lastAcked.at(id)).count();
|
||||
if (ds > 180.0) {
|
||||
std::string repl = _config.nextAgentInLine();
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Active agent " << id << " has failed. << "
|
||||
<< repl << " will be promoted to active agency membership";
|
||||
// Guarded in ::
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY)
|
||||
<< "Active agent " << id << " has failed. << " << repl
|
||||
<< " will be promoted to active agency membership";
|
||||
_activator = std::make_unique<AgentActivator>(this, id, repl);
|
||||
_activator->start();
|
||||
return;
|
||||
|
@ -923,13 +922,6 @@ void Agent::detectActiveAgentFailures() {
|
|||
}
|
||||
|
||||
|
||||
void Agent::updateConfiguration() {
|
||||
|
||||
// First ask last know leader
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// Orderly shutdown
|
||||
void Agent::beginShutdown() {
|
||||
Thread::beginShutdown();
|
||||
|
|
|
@ -223,9 +223,6 @@ class Agent : public arangodb::Thread {
|
|||
/// @brief persist agency configuration in RAFT
|
||||
void persistConfiguration(term_t t);
|
||||
|
||||
/// @brief Update my configuration as passive agent
|
||||
void updateConfiguration();
|
||||
|
||||
/// @brief Find out, if we've had acknowledged RPCs recent enough
|
||||
bool challengeLeadership();
|
||||
|
||||
|
|
Loading…
Reference in New Issue