1
0
Fork 0

Agency write sensitive to X-ArangoDB-Agency-Mode

This commit is contained in:
Kaveh Vahedipour 2016-03-24 14:14:33 +01:00
parent a6bd03c609
commit 1bdfe53ec2
14 changed files with 239 additions and 242 deletions

View File

@ -35,7 +35,7 @@ using namespace arangodb::velocypack;
namespace arangodb {
namespace consensus {
Agent::Agent () : Thread ("Agent"), _last_commit_index(0), _stopping(false) {}
Agent::Agent () : Thread ("Agent"), _last_commit_index(0) {}
Agent::Agent (config_t const& config) :
Thread ("Agent"), _config(config), _last_commit_index(0) {
@ -50,16 +50,22 @@ Agent::~Agent () {
shutdown();
}
State const& Agent::state() const {
State const& Agent::state () const {
return _state;
}
/// @brief Start all agency threads
bool Agent::start() {
LOG(INFO) << "AGENCY: Starting constituent thread.";
LOG_TOPIC(INFO, Logger::AGENCY) << "Starting constituent personality.";
_constituent.start();
LOG(INFO) << "AGENCY: Starting spearhead thread.";
LOG_TOPIC(INFO, Logger::AGENCY) << "Starting spearhead worker.";
_spearhead.start();
LOG_TOPIC(INFO, Logger::AGENCY) << "Starting agency comm worker.";
Thread::start();
return true;
}
@ -141,8 +147,8 @@ void Agent::reportIn (id_t id, index_t index) {
}
if (n>size()/2) { // catch up read database and commit index
LOG(INFO) << "AGENCY: Critical mass for commiting " << _last_commit_index+1
<< " through " << index << " to read db";
LOG_TOPIC(INFO, Logger::AGENCY) << "Critical mass for commiting " <<
_last_commit_index+1 << " through " << index << " to read db";
_read_db.apply(_state.slices(_last_commit_index+1, index));
_last_commit_index = index;
@ -157,29 +163,29 @@ bool Agent::recvAppendEntriesRPC (term_t term, id_t leaderId, index_t prevIndex,
//Update commit index
if (queries->slice().type() != VPackValueType::Array) {
LOG(WARN) << "AGENCY: Received malformed entries for appending. Discarting!";
LOG_TOPIC(WARN, Logger::AGENCY) << "Received malformed entries for appending. Discarting!";
return false;
}
if (queries->slice().length()) {
LOG(INFO) << "AGENCY: Appending "<< queries->slice().length()
LOG_TOPIC(INFO, Logger::AGENCY) << "Appending "<< queries->slice().length()
<< " entries to state machine.";
} else {
// heart-beat
}
if (_last_commit_index < leaderCommitIndex) {
LOG(INFO) << "Updating last commited index to " << leaderCommitIndex;
LOG_TOPIC(INFO, Logger::AGENCY) << "Updating last commited index to " << leaderCommitIndex;
}
_last_commit_index = leaderCommitIndex;
// Sanity
if (this->term() > term) { // (§5.1)
LOG(WARN) << "AGENCY: I have a higher term than RPC caller.";
LOG_TOPIC(WARN, Logger::AGENCY) << "I have a higher term than RPC caller.";
throw LOWER_TERM_APPEND_ENTRIES_RPC;
}
if (!_state.findit(prevIndex, prevTerm)) { // (§5.3)
LOG(WARN)
<< "AGENCY: I have no matching set of prevLogIndex/prevLogTerm "
LOG_TOPIC(WARN, Logger::AGENCY)
<< "No matching set of prevLogIndex/prevLogTerm "
<< "in my own state machine. This is trouble!";
throw NO_MATCHING_PREVLOG;
}
@ -220,7 +226,7 @@ append_entries_t Agent::sendAppendEntriesRPC (
// Send
if (unconfirmed.size() > 1) {
LOG(INFO) << "AGENCY: Appending " << unconfirmed.size() << " entries up to index "
LOG_TOPIC(INFO, Logger::AGENCY) << "Appending " << unconfirmed.size() << " entries up to index "
<< last << " to follower " << slave_id;
}
arangodb::ClusterComm::instance()->asyncRequest
@ -236,9 +242,9 @@ append_entries_t Agent::sendAppendEntriesRPC (
bool Agent::load () {
LOG(INFO) << "AGENCY: Loading persistent state.";
LOG_TOPIC(INFO, Logger::AGENCY) << "Loading persistent state.";
if (!_state.load())
LOG(FATAL) << "AGENCY: Failed to load persistent state on statup.";
LOG(FATAL) << "Failed to load persistent state on statup.";
return true;
}

View File

@ -37,127 +37,92 @@ class Agent : public arangodb::Thread {
public:
/**
* @brief Default ctor
*/
/// @brief Default ctor
Agent ();
/**
* @brief Construct with program options
*/
/// @brief Construct with program options
explicit Agent (config_t const&);
/**
* @brief Clean up
*/
/// @brief Clean up
virtual ~Agent();
/**
* @brief Get current term
*/
/// @brief Get current term
term_t term() const;
/**
* @brief Get current term
*/
/// @brief Get current term
id_t id() const;
/**
* @brief Vote request
*/
/// @brief Vote request
priv_rpc_ret_t requestVote(term_t , id_t, index_t, index_t, query_t const&);
/**
* @brief Provide configuration
*/
/// @brief Provide configuration
config_t const& config () const;
/**
* @brief Start thread
*/
/// @brief Start thread
bool start ();
/**
* @brief Verbose print of myself
*/
/// @brief Verbose print of myself
////
void print (arangodb::LoggerStream&) const;
/**
* @brief Are we fit to run?
*/
/// @brief Are we fit to run?
bool fitness () const;
/**
* @brief Leader ID
*/
/// @brief Leader ID
id_t leaderID () const;
bool leading () const;
/// @brief Pick up leadership tasks
bool lead ();
/// @brief Load persistent state
bool load ();
/**
* @brief Attempt write
*/
/// @brief Attempt write
write_ret_t write (query_t const&);
/**
* @brief Read from agency
*/
/// @brief Read from agency
read_ret_t read (query_t const&) const;
/**
* @brief Received by followers to replicate log entries (§5.3);
* also used as heartbeat (§5.2).
*/
/// @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,
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).
*/
/// @brief Invoked by leader to replicate log entries (§5.3);
/// also used as heartbeat (§5.2).
append_entries_t sendAppendEntriesRPC (id_t slave_id);
/**
* @brief 1. Deal with appendEntries to slaves.
* 2. Report success of write processes.
*/
/// @brief 1. Deal with appendEntries to slaves.
/// 2. Report success of write processes.
void run () override final;
/// @brief Start orderly shutdown of threads
void beginShutdown () override final;
/**
* @brief Report appended entries from AgentCallback
*/
/// @brief Report appended entries from AgentCallback
void reportIn (id_t id, index_t idx);
/**
* @brief Wait for slaves to confirm appended entries
*/
/// @brief Wait for slaves to confirm appended entries
bool waitFor (index_t last_entry, duration_t timeout = duration_t(2.0));
/**
* @brief Convencience size of agency
*/
/// @brief Convencience size of agency
size_t size() const;
/**
* @brief Rebuild DBs by applying state log to empty DB
*/
/// @brief Rebuild DBs by applying state log to empty DB
bool rebuildDBs();
/**
* @brief Last log entry
*/
/// @brief Last log entry
log_t const& lastLog () const;
/// @brief Pipe configuration to ostream
friend std::ostream& operator<< (std::ostream& o, Agent const& a) {
o << a.config();
return o;
}
State const& state() const;
/// @brief State machine
State const& state () const;
private:
@ -165,22 +130,17 @@ private:
State _state; /**< @brief Log replica */
config_t _config; /**< @brief Command line arguments */
std::atomic<index_t> _last_commit_index;
std::atomic<index_t> _last_commit_index; /**< @brief Last commit index */
arangodb::Mutex _uncommitedLock;
arangodb::Mutex _uncommitedLock; /**< @brief */
Store _spearhead;
Store _read_db;
Store _spearhead; /**< @brief Spearhead key value store */
Store _read_db; /**< @brief Read key value store */
AgentCallback _agent_callback;
arangodb::basics::ConditionVariable _cv; /**< @brief Internal callbacks */
arangodb::basics::ConditionVariable _rest_cv; /**< @brief Rest handler */
arangodb::basics::ConditionVariable _cv; // agency callbacks
arangodb::basics::ConditionVariable _rest_cv; // rest handler
std::atomic<bool> _stopping;
std::vector<index_t> _confirmed;
std::vector<index_t> _confirmed;
arangodb::Mutex _ioLock;
};

View File

@ -79,7 +79,7 @@ term_t Constituent::term() const {
void Constituent::term(term_t t) {
if (t != _term) {
LOG(INFO) << "Updating term to " << t;
LOG_TOPIC(INFO, Logger::AGENCY) << "Updating term to " << t;
}
_term = t;
}
@ -90,7 +90,7 @@ role_t Constituent::role () const {
void Constituent::follow (term_t t) {
if (_role != FOLLOWER) {
LOG(INFO) << "Role change: Converted to follower in term " << t;
LOG_TOPIC(INFO, Logger::AGENCY) << "Role change: Converted to follower in term " << t;
}
this->term(t);
_votes.assign(_votes.size(),false); // void all votes
@ -99,7 +99,7 @@ void Constituent::follow (term_t t) {
void Constituent::lead () {
if (_role != LEADER) {
LOG(INFO) << "Role change: Converted to leader in term " << _term ;
LOG_TOPIC(INFO, Logger::AGENCY) << "Role change: Converted to leader in term " << _term ;
_agent->lead(); // We need to rebuild spear_head and read_db;
}
_role = LEADER;
@ -108,7 +108,7 @@ void Constituent::lead () {
void Constituent::candidate () {
if (_role != CANDIDATE)
LOG(INFO) << "Role change: Converted to candidate in term " << _term ;
LOG_TOPIC(INFO, Logger::AGENCY) << "Role change: Converted to candidate in term " << _term ;
_role = CANDIDATE;
}

View File

@ -75,7 +75,7 @@ bool State::save (arangodb::velocypack::Slice const& slice, index_t index,
body.toJson(), headerFields, 0.0);
if (res->status != CL_COMM_SENT) {
//LOG(WARN) << res->errorMessage;
//LOG_TOPIC(WARN, Logger::AGENCY) << res->errorMessage;
}
return (res->status == CL_COMM_SENT); // TODO: More verbose result
@ -203,7 +203,7 @@ bool State::checkDB (std::string const& name) {
"", headerFields, 1.0);
if(res->result->wasHttpError()) {
LOG(WARN) << "Creating collection " << name;
LOG_TOPIC(WARN, Logger::AGENCY) << "Creating collection " << name;
return createCollection(name);
}
}
@ -244,14 +244,14 @@ bool State::loadCollection (std::string const& name) {
// Check success
if(res->result->wasHttpError()) {
LOG(WARN) << "ERROR";
LOG(WARN) << res->endpoint;
LOG_TOPIC(WARN, Logger::AGENCY) << "ERROR";
LOG_TOPIC(WARN, Logger::AGENCY) << res->endpoint;
} else {
std::shared_ptr<Builder> body = res->result->getBodyVelocyPack();
}
//LOG(WARN) << body->toJson();
//LOG_TOPIC(WARN, Logger::AGENCY) << body->toJson();
/* for (auto const& i : VPackArrayIterator(body->slice()))
LOG(WARN) << typeid(i).name();*/
LOG_TOPIC(WARN, Logger::AGENCY) << typeid(i).name();*/
return true;
} else {

View File

@ -78,10 +78,10 @@ public:
std::vector<log_t> get (
index_t = 0, index_t = (std::numeric_limits<uint64_t>::max())) const;
index_t = 0, index_t = (std::numeric_limits<uint64_t>::max)()) const;
std::vector<VPackSlice> slices (
index_t = 0, index_t = (std::numeric_limits<uint64_t>::max())) const;
index_t = 0, index_t = (std::numeric_limits<uint64_t>::max)()) const;
/// @brief log entry at index i

View File

@ -198,8 +198,8 @@ bool Node::applies (VPackSlice const& slice) {
return _parent->removeChild(_name);
} else if (oper == "set") { //
if (!slice.hasKey("new")) {
LOG(WARN) << "Operator set without new value";
LOG(WARN) << slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY) << "Operator set without new value";
LOG_TOPIC(WARN, Logger::AGENCY) << slice.toJson();
return false;
}
if (slice.hasKey("ttl")) {
@ -209,8 +209,9 @@ bool Node::applies (VPackSlice const& slice) {
return true;
} else if (oper == "increment") { // Increment
if (!(self.isInt() || self.isUInt())) {
LOG(WARN) << "Element to increment must be integral type: We are "
<< slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Element to increment must be integral type: We are "
<< slice.toJson();
return false;
}
Builder tmp;
@ -220,8 +221,9 @@ bool Node::applies (VPackSlice const& slice) {
return true;
} else if (oper == "decrement") { // Decrement
if (!(self.isInt() || self.isUInt())) {
LOG(WARN) << "Element to decrement must be integral type. We are "
<< slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Element to decrement must be integral type. We are "
<< slice.toJson();
return false;
}
Builder tmp;
@ -231,7 +233,8 @@ bool Node::applies (VPackSlice const& slice) {
return true;
} else if (oper == "push") { // Push
if (!slice.hasKey("new")) {
LOG(WARN) << "Operator push without new value: " << slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Operator push without new value: " << slice.toJson();
return false;
}
Builder tmp;
@ -261,8 +264,8 @@ bool Node::applies (VPackSlice const& slice) {
return true;
} else if (oper == "prepend") { // Prepend
if (!slice.hasKey("new")) {
LOG(WARN) << "Operator prepend without new value: "
<< slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Operator prepend without new value: " << slice.toJson();
return false;
}
Builder tmp;
@ -293,7 +296,7 @@ bool Node::applies (VPackSlice const& slice) {
*this = tmp.slice();
return true;
} else {
LOG(WARN) << "Unknown operation " << oper;
LOG_TOPIC(WARN, Logger::AGENCY) << "Unknown operation " << oper;
return false;
}
} else if (slice.hasKey("new")) { // new without set
@ -348,12 +351,13 @@ std::vector<bool> Store::apply (query_t const& query) {
if (check(i[1])) {
applied.push_back(applies(i[0])); // precondition
} else {
LOG(WARN) << "Precondition failed!";
LOG_TOPIC(WARN, Logger::AGENCY) << "Precondition failed!";
applied.push_back(false);
}
break;
default: // wrong
LOG(FATAL) << "We can only handle log entry with or without precondition!";
LOG_TOPIC(ERR, Logger::AGENCY)
<< "We can only handle log entry with or without precondition!";
applied.push_back(false);
break;
}
@ -374,7 +378,8 @@ std::vector<bool> Store::apply( std::vector<VPackSlice> const& queries) {
bool Store::check (VPackSlice const& slice) const {
if (slice.type() != VPackValueType::Object) {
LOG(WARN) << "Cannot check precondition: " << slice.toJson();
LOG_TOPIC(WARN, Logger::AGENCY) << "Cannot check precondition: "
<< slice.toJson();
return false;
}
for (auto const& precond : VPackObjectIterator(slice)) {
@ -428,7 +433,7 @@ query_t Store::read (query_t const& queries) const { // list of list of paths
}
result->close();
} else {
LOG(FATAL) << "Read queries to stores must be arrays";
LOG_TOPIC(ERR, Logger::AGENCY) << "Read queries to stores must be arrays";
}
return result;
}

View File

@ -126,12 +126,12 @@ class ClusterTraversalPath : public TraversalPath {
const arangodb::basics::EnumeratedPath<std::string, std::string>& path)
: _path(path), _traverser(traverser) {}
arangodb::basics::Json* pathToJson(Transaction*, CollectionNameResolver*);
arangodb::basics::Json* pathToJson(Transaction*, CollectionNameResolver*) override ;
arangodb::basics::Json* lastEdgeToJson(Transaction*, CollectionNameResolver*);
arangodb::basics::Json* lastEdgeToJson(Transaction*, CollectionNameResolver*) override;
arangodb::basics::Json* lastVertexToJson(Transaction*,
CollectionNameResolver*);
CollectionNameResolver*) override;
private:
arangodb::basics::EnumeratedPath<std::string, std::string> _path;

View File

@ -48,7 +48,7 @@ class HttpListenTask : public ListenTask {
HttpListenTask(HttpServer* server, Endpoint* endpoint);
protected:
bool handleConnected(TRI_socket_t s, ConnectionInfo const& info);
bool handleConnected(TRI_socket_t s, ConnectionInfo const& info) override ;
private:
//////////////////////////////////////////////////////////////////////////////

View File

@ -52,19 +52,21 @@ RestAgencyHandler::RestAgencyHandler(HttpRequest* request, Agent* agent)
bool RestAgencyHandler::isDirect() const { return false; }
inline HttpHandler::status_t RestAgencyHandler::reportErrorEmptyRequest () {
LOG(WARN) << "Empty request to public agency interface.";
LOG_TOPIC(WARN, Logger::AGENCY) << "Empty request to public agency interface.";
generateError(HttpResponse::NOT_FOUND,404);
return HttpHandler::status_t(HANDLER_DONE);
}
inline HttpHandler::status_t RestAgencyHandler::reportTooManySuffices () {
LOG(WARN) << "Too many suffixes. Agency public interface takes one path.";
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Too many suffixes. Agency public interface takes one path.";
generateError(HttpResponse::NOT_FOUND,404);
return HttpHandler::status_t(HANDLER_DONE);
}
inline HttpHandler::status_t RestAgencyHandler::reportUnknownMethod () {
LOG(WARN) << "Too many suffixes. Agency public interface takes one path.";
LOG_TOPIC(WARN, Logger::AGENCY)
<< "Public REST interface has no method " << _request->suffix()[0];
generateError(HttpResponse::NOT_FOUND,404);
return HttpHandler::status_t(HANDLER_DONE);
}
@ -80,32 +82,54 @@ void RestAgencyHandler::redirectRequest (id_t leaderId) {
inline HttpHandler::status_t RestAgencyHandler::handleWrite () {
arangodb::velocypack::Options options; // TODO: User not wait.
if (_request->requestType() == HttpRequest::HTTP_REQUEST_POST) {
query_t query;
try {
query = _request->toVelocyPack(&options);
} catch (std::exception const& e) {
LOG(FATAL) << e.what();
LOG_TOPIC(ERR, Logger::AGENCY) << e.what();
generateError(HttpResponse::UNPROCESSABLE_ENTITY,422);
return HttpHandler::status_t(HANDLER_DONE);
}
write_ret_t ret = _agent->write (query);
if (ret.accepted) { // We're leading and handling the request
if (ret.accepted) { // We're leading and handling the request
std::string call_mode (_request->header("x-arangodb-agency-mode"));
size_t errors = 0;
Builder body;
body.add(VPackValue(VPackValueType::Object));
_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) {
errors++;
body.openObject();
if (call_mode!="noWait") {
// Note success/error
body.add("results", VPackValue(VPackValueType::Array));
for (auto const& index : ret.indices) {
body.add(VPackValue(index));
}
body.close();
// Wait for commit of highest except if it is 0?
if (call_mode=="waitForCommitted") {
index_t max_index =
*std::max_element(ret.indices.begin(),ret.indices.end());
if (max_index>0) {
_agent->waitFor (max_index);
}
}
}
body.close();
if (errors > 0) { // Some/all requests failed
generateResult(HttpResponse::PRECONDITION_FAILED,body.slice());
} else { // All good
generateResult(body.slice());
}
}
} else { // Redirect to leader
redirectRequest(ret.redirect);
}
@ -122,7 +146,7 @@ inline HttpHandler::status_t RestAgencyHandler::handleRead () {
try {
query = _request->toVelocyPack(&options);
} catch (std::exception const& e) {
LOG(WARN) << e.what();
LOG_TOPIC(WARN, Logger::AGENCY) << e.what();
generateError(HttpResponse::BAD,400);
return HttpHandler::status_t(HANDLER_DONE);
}

View File

@ -72,7 +72,7 @@ class RestBatchHandler : public RestVocbaseBaseHandler {
~RestBatchHandler();
public:
HttpHandler::status_t execute();
HttpHandler::status_t execute() override;
private:
//////////////////////////////////////////////////////////////////////////////

View File

@ -38,24 +38,24 @@ struct VersionTest : public BenchmarkOperation {
~VersionTest() {}
bool setUp(SimpleHttpClient* client) { return true; }
bool setUp(SimpleHttpClient* client) override { return true; }
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return _url;
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_GET;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
static char const* payload = "";
*mustFree = false;
@ -71,15 +71,15 @@ struct DocumentCrudAppendTest : public BenchmarkOperation {
~DocumentCrudAppendTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -94,7 +94,7 @@ struct DocumentCrudAppendTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -113,7 +113,7 @@ struct DocumentCrudAppendTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 4;
if (mod == 0 || mod == 2) {
@ -162,15 +162,15 @@ struct DocumentCrudWriteReadTest : public BenchmarkOperation {
~DocumentCrudWriteReadTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -185,7 +185,7 @@ struct DocumentCrudWriteReadTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -197,7 +197,7 @@ struct DocumentCrudWriteReadTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -243,15 +243,15 @@ struct ShapesTest : public BenchmarkOperation {
~ShapesTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -266,7 +266,7 @@ struct ShapesTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -280,7 +280,7 @@ struct ShapesTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -329,15 +329,15 @@ struct ShapesAppendTest : public BenchmarkOperation {
~ShapesAppendTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -352,7 +352,7 @@ struct ShapesAppendTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -363,7 +363,7 @@ struct ShapesAppendTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 2;
if (mod == 0) {
@ -414,15 +414,15 @@ struct RandomShapesTest : public BenchmarkOperation {
~RandomShapesTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -438,7 +438,7 @@ struct RandomShapesTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -452,7 +452,7 @@ struct RandomShapesTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 3;
if (mod == 0) {
@ -506,15 +506,15 @@ struct DocumentCrudTest : public BenchmarkOperation {
~DocumentCrudTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 5;
if (mod == 0) {
@ -529,7 +529,7 @@ struct DocumentCrudTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 5;
if (mod == 0) {
@ -550,7 +550,7 @@ struct DocumentCrudTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 5;
if (mod == 0 || mod == 2) {
@ -599,15 +599,15 @@ struct EdgeCrudTest : public BenchmarkOperation {
~EdgeCrudTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 3);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -626,7 +626,7 @@ struct EdgeCrudTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -651,7 +651,7 @@ struct EdgeCrudTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 4;
if (mod == 0 || mod == 2) {
@ -700,16 +700,16 @@ struct SkiplistTest : public BenchmarkOperation {
~SkiplistTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2) &&
CreateIndex(client, ARANGOB->collection(), "skiplist", "[\"value\"]");
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -724,7 +724,7 @@ struct SkiplistTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -743,7 +743,7 @@ struct SkiplistTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 4;
if (mod == 0 || mod == 2) {
@ -783,16 +783,16 @@ struct HashTest : public BenchmarkOperation {
~HashTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2) &&
CreateIndex(client, ARANGOB->collection(), "hash", "[\"value\"]");
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -807,7 +807,7 @@ struct HashTest : public BenchmarkOperation {
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
size_t const mod = globalCounter % 4;
if (mod == 0) {
@ -826,7 +826,7 @@ struct HashTest : public BenchmarkOperation {
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 4;
if (mod == 0 || mod == 2) {
@ -881,27 +881,27 @@ struct DocumentImportTest : public BenchmarkOperation {
~DocumentImportTest() { TRI_FreeStringBuffer(TRI_UNKNOWN_MEM_ZONE, _buffer); }
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return _url;
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
*mustFree = false;
*length = _length;
return (char const*)_buffer->_buffer;
@ -941,27 +941,27 @@ struct DocumentCreationTest : public BenchmarkOperation {
TRI_FreeStringBuffer(TRI_UNKNOWN_MEM_ZONE, _buffer);
}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return _url;
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
*mustFree = false;
*length = _length;
return (char const*)_buffer->_buffer;
@ -981,24 +981,24 @@ struct CollectionCreationTest : public BenchmarkOperation {
~CollectionCreationTest() {}
bool setUp(SimpleHttpClient* client) { return true; }
bool setUp(SimpleHttpClient* client) override { return true; }
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return _url;
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
TRI_string_buffer_t* buffer;
char* data;
@ -1033,7 +1033,7 @@ struct TransactionAqlTest : public BenchmarkOperation {
~TransactionAqlTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
_c1 = std::string(ARANGOB->collection() + "1");
_c2 = std::string(ARANGOB->collection() + "2");
_c3 = std::string(ARANGOB->collection() + "3");
@ -1043,22 +1043,22 @@ struct TransactionAqlTest : public BenchmarkOperation {
CreateCollection(client, _c2, 2) && CreateCollection(client, _c3, 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/cursor");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 8;
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1127,27 +1127,27 @@ struct TransactionCountTest : public BenchmarkOperation {
~TransactionCountTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/transaction");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1177,7 +1177,7 @@ struct TransactionDeadlockTest : public BenchmarkOperation {
~TransactionDeadlockTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
_c1 = std::string(ARANGOB->collection() + "1");
_c2 = std::string(ARANGOB->collection() + "2");
@ -1187,22 +1187,22 @@ struct TransactionDeadlockTest : public BenchmarkOperation {
CreateDocument(client, _c2, "{ \"_key\": \"sum\", \"count\": 0 }");
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/transaction");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 2;
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1246,7 +1246,7 @@ struct TransactionMultiTest : public BenchmarkOperation {
~TransactionMultiTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
_c1 = std::string(ARANGOB->collection() + "1");
_c2 = std::string(ARANGOB->collection() + "2");
@ -1256,22 +1256,22 @@ struct TransactionMultiTest : public BenchmarkOperation {
CreateDocument(client, _c2, "{ \"_key\": \"sum\", \"count\": 0 }");
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/transaction");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
size_t const mod = globalCounter % 2;
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1330,7 +1330,7 @@ struct TransactionMultiCollectionTest : public BenchmarkOperation {
~TransactionMultiCollectionTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
_c1 = std::string(ARANGOB->collection() + "1");
_c2 = std::string(ARANGOB->collection() + "2");
@ -1338,22 +1338,22 @@ struct TransactionMultiCollectionTest : public BenchmarkOperation {
CreateCollection(client, _c1, 2) && CreateCollection(client, _c2, 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/transaction");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1406,27 +1406,27 @@ struct AqlInsertTest : public BenchmarkOperation {
~AqlInsertTest() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/cursor");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);
@ -1460,27 +1460,27 @@ struct AqlV8Test : public BenchmarkOperation {
~AqlV8Test() {}
bool setUp(SimpleHttpClient* client) {
bool setUp(SimpleHttpClient* client) override {
return DeleteCollection(client, ARANGOB->collection()) &&
CreateCollection(client, ARANGOB->collection(), 2);
}
void tearDown() {}
void tearDown() override {}
std::string url(int const threadNumber, size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return std::string("/_api/cursor");
}
HttpRequest::HttpRequestType type(int const threadNumber,
size_t const threadCounter,
size_t const globalCounter) {
size_t const globalCounter) override {
return HttpRequest::HTTP_REQUEST_POST;
}
char const* payload(size_t* length, int const threadNumber,
size_t const threadCounter, size_t const globalCounter,
bool* mustFree) {
bool* mustFree) override {
TRI_string_buffer_t* buffer;
buffer = TRI_CreateSizedStringBuffer(TRI_UNKNOWN_MEM_ZONE, 256);

View File

@ -32,12 +32,12 @@ namespace arangodb {
class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
public:
virtual void* Allocate(size_t length) {
virtual void* Allocate(size_t length) override {
void* data = AllocateUninitialized(length);
return data == nullptr ? data : memset(data, 0, length);
}
virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
virtual void Free(void* data, size_t) { free(data); }
virtual void* AllocateUninitialized(size_t length) override { return malloc(length); }
virtual void Free(void* data, size_t) override { free(data); }
};
class V8PlatformFeature final : public application_features::ApplicationFeature {

View File

@ -725,7 +725,7 @@ class LogThread : public Thread {
~LogThread() { shutdown(); }
public:
void run();
void run() override;
};
void LogThread::run() {
@ -788,6 +788,7 @@ LoggerStream::~LoggerStream() {
/// @brief predefined topics
////////////////////////////////////////////////////////////////////////////////
LogTopic Logger::AGENCY("agency", LogLevel::INFO);
LogTopic Logger::COLLECTOR("collector");
LogTopic Logger::COMPACTOR("compactor");
LogTopic Logger::CONFIG("config");

View File

@ -271,6 +271,7 @@ class Logger {
/// @brief predefined topics
//////////////////////////////////////////////////////////////////////////////
static LogTopic AGENCY;
static LogTopic COLLECTOR;
static LogTopic COMPACTOR;
static LogTopic CONFIG;