mirror of https://gitee.com/bigwinds/arangodb
cleaning up log messages. corrected agency test for failed precondition.
This commit is contained in:
parent
a0edfe2b8d
commit
8ac7491e53
|
@ -35,7 +35,7 @@ using namespace arangodb::basics;
|
|||
using namespace arangodb::rest;
|
||||
|
||||
ApplicationAgency::ApplicationAgency()
|
||||
: ApplicationFeature("agency"), _size(1), _min_election_timeout(0.1),
|
||||
: ApplicationFeature("agency"), _size(1), _min_election_timeout(0.15),
|
||||
_max_election_timeout(1.0), _election_call_rate_mul(0.85), _notify(false),
|
||||
_agent_id((std::numeric_limits<uint32_t>::max)()) {
|
||||
}
|
||||
|
@ -61,9 +61,16 @@ 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");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool ApplicationAgency::afterOptionParsing (ProgramOptions& opts) {
|
||||
// LOG_TOPIC(WARN, Logger::AGENCY) << "Server endpoint " << opts.has("server.endpoint");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ApplicationAgency::prepare() {
|
||||
|
||||
_disabled = (_agent_id == (std::numeric_limits<uint32_t>::max)());
|
||||
|
|
|
@ -95,6 +95,8 @@ class ApplicationAgency : virtual public arangodb::rest::ApplicationFeature {
|
|||
void setupOptions(std::map<std::string,
|
||||
arangodb::basics::ProgramOptionsDescription>&) override final;
|
||||
|
||||
virtual bool afterOptionParsing (arangodb::basics::ProgramOptions &) override final;
|
||||
|
||||
bool prepare() override final;
|
||||
bool start() override final;
|
||||
bool open() override final;
|
||||
|
|
|
@ -345,6 +345,23 @@ void Node::toBuilder (Builder& builder) const {
|
|||
|
||||
}
|
||||
|
||||
std::ostream& Node::print (std::ostream& o) const {
|
||||
Node const* par = _parent;
|
||||
while (par != 0) {
|
||||
par = par->_parent;
|
||||
o << " ";
|
||||
}
|
||||
o << _node_name << " : ";
|
||||
if (type() == NODE) {
|
||||
o << std::endl;
|
||||
for (auto const& i : _children)
|
||||
o << *(i.second);
|
||||
} else {
|
||||
o << ((slice().type() == ValueType::None) ? "NONE" : slice().toJson()) << std::endl;
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
Store::Store (std::string const& name) : Node(name), Thread(name) {}
|
||||
|
||||
Store::~Store () {}
|
||||
|
@ -360,7 +377,7 @@ std::vector<bool> Store::apply (query_t const& query) {
|
|||
if (check(i[1])) {
|
||||
applied.push_back(applies(i[0])); // precondition
|
||||
} else {
|
||||
LOG_TOPIC(WARN, Logger::AGENCY) << "Precondition failed!";
|
||||
LOG_TOPIC(DEBUG, Logger::AGENCY) << "Precondition failed!";
|
||||
applied.push_back(false);
|
||||
}
|
||||
break;
|
||||
|
@ -539,3 +556,4 @@ void Store::run() {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -61,6 +61,11 @@ private:
|
|||
|
||||
enum NODE_EXCEPTION {PATH_NOT_FOUND};
|
||||
|
||||
class Node;
|
||||
|
||||
typedef std::chrono::system_clock::time_point TimePoint;
|
||||
typedef std::map<TimePoint, std::shared_ptr<Node>> TimeTable;
|
||||
|
||||
/// @brief Simple tree implementation
|
||||
class Node {
|
||||
|
||||
|
@ -68,8 +73,6 @@ public:
|
|||
|
||||
typedef std::vector<std::string> PathType;
|
||||
typedef std::map<std::string, std::shared_ptr<Node>> Children;
|
||||
typedef std::chrono::system_clock::time_point TimePoint;
|
||||
typedef std::map<TimePoint, std::shared_ptr<Node>> TimeTable;
|
||||
|
||||
/// @brief Construct with name
|
||||
explicit Node (std::string const& name);
|
||||
|
@ -120,22 +123,7 @@ public:
|
|||
Node& root();
|
||||
|
||||
/// @brief Dump to ostream
|
||||
friend std::ostream& operator<<(std::ostream& os, const Node& n) {
|
||||
Node const* par = n._parent;
|
||||
while (par != 0) {
|
||||
par = par->_parent;
|
||||
os << " ";
|
||||
}
|
||||
os << n._node_name << " : ";
|
||||
if (n.type() == NODE) {
|
||||
os << std::endl;
|
||||
for (auto const& i : n._children)
|
||||
os << *(i.second);
|
||||
} else {
|
||||
os << ((n.slice().type() == ValueType::None) ? "NONE" : n.slice().toJson()) << std::endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
std::ostream& print (std::ostream&) const;
|
||||
|
||||
/// #brief Get path of this node
|
||||
std::string path ();
|
||||
|
@ -168,6 +156,10 @@ protected:
|
|||
|
||||
};
|
||||
|
||||
inline std::ostream& operator<< (std::ostream& o, Node const& n) {
|
||||
return n.print(o);
|
||||
}
|
||||
|
||||
class Agent;
|
||||
|
||||
/// @brief Key value tree
|
||||
|
@ -196,6 +188,7 @@ public:
|
|||
/// @brief Start thread
|
||||
bool start ();
|
||||
|
||||
/// @brief Start thread with access to agent
|
||||
bool start (Agent*);
|
||||
|
||||
/// @brief Set name
|
||||
|
|
|
@ -1867,7 +1867,7 @@ int ArangoServer::runServer(TRI_vocbase_t* vocbase) {
|
|||
waitForHeartbeat();
|
||||
HttpHandlerFactory::setMaintenance(false);
|
||||
|
||||
LOG(WARN) << "LOADING PERSISTENT AGENCY STATE";
|
||||
// Loading persisten agency state
|
||||
if(_applicationAgency->agent()!=nullptr)
|
||||
_applicationAgency->agent()->load();
|
||||
|
||||
|
|
|
@ -138,9 +138,9 @@ function agencyTestSuite () {
|
|||
assertEqual(readAndCheck([["a"]]), [{a:12}]);
|
||||
writeAndCheck([[{"a":13},{"a":12}]]);
|
||||
assertEqual(readAndCheck([["a"]]), [{a:13}]);
|
||||
/*var res =*/ writeAgency([[{"a":14},{"a":12}]]);
|
||||
var res = writeAgency([[{"a":14},{"a":12}]]);
|
||||
assertEqual(res.statusCode, 412);
|
||||
//assertEqual(res.bodyParsed, {error:true, successes:[]});
|
||||
assertEqual(res.bodyParsed, {"results":[0]});
|
||||
writeAndCheck([[{a:{op:"delete"}}]]);
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue