From 9ea023acb1db33cf13b9da21892bbed739b23bae Mon Sep 17 00:00:00 2001 From: Kaveh Vahedipour Date: Wed, 15 Jun 2016 16:08:17 +0200 Subject: [PATCH] store documentation --- arangod/Agency/Store.cpp | 50 +++++++++++++++++++++++++--------------- arangod/Agency/Store.h | 2 +- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/arangod/Agency/Store.cpp b/arangod/Agency/Store.cpp index 165c0e16b0..913c08ff00 100644 --- a/arangod/Agency/Store.cpp +++ b/arangod/Agency/Store.cpp @@ -68,7 +68,7 @@ inline std::vector split(const std::string& value, } -// Build endpoint from URL +/// Build endpoint from URL inline static bool endpointPathFromUrl( std::string const& url, std::string& endpoint, std::string& path) { @@ -103,11 +103,11 @@ inline static bool endpointPathFromUrl( } -// Create with name +/// Ctor with name Store::Store(std::string const& name) : Thread(name), _node(name, this) {} -// Copy constructor +/// Copy ctor Store::Store(Store const& other) : Thread(other._node.name()), _agent(other._agent), _timeTable(other._timeTable), _observerTable(other._observerTable), _observedTable(other._observedTable), @@ -122,6 +122,7 @@ Store::Store(Store&& other) : _observedTable(std::move(other._observedTable)), _node(std::move(other._node)) {} + // Copy assignment operator Store& Store::operator=(Store const& rhs) { _agent = rhs._agent; @@ -132,6 +133,7 @@ Store& Store::operator=(Store const& rhs) { return *this; } + // Move assignment operator Store& Store::operator=(Store&& rhs) { _agent = std::move(rhs._agent); @@ -142,45 +144,55 @@ Store& Store::operator=(Store&& rhs) { return *this; } + // Default dtor Store::~Store() { shutdown(); } -// Apply queries multiple queries to store -std::vector Store::apply(query_t const& query) { - std::vector applied; +// Apply array of queries multiple queries to store +// Return vector of according success +std::vector Store::apply(query_t const& query, bool verbose) { + + std::vector success; MUTEX_LOCKER(storeLocker, _storeLock); try { + for (auto const& i : VPackArrayIterator(query->slice())) { + switch (i.length()) { - case 1: - applied.push_back(applies(i[0])); - break; // no precond - case 2: - if (check(i[1])) { // precondition - applied.push_back(applies(i[0])); + case 1: // No precondition + success.push_back(applies(i[0])); + break; + case 2: // precondition + if (check(i[1])) { + success.push_back(applies(i[0])); } else { // precondition failed LOG_TOPIC(TRACE, Logger::AGENCY) << "Precondition failed!"; - applied.push_back(false); + success.push_back(false); } break; - default: // wrong + default: // Wrong LOG_TOPIC(ERR, Logger::AGENCY) << "We can only handle log entry with or without precondition!"; - applied.push_back(false); + success.push_back(false); break; } + } - _cv.signal(); - } catch (std::exception const& e) { + + //Wake up TTL processing + _cv.signal(); + + } catch (std::exception const& e) { // Catch any erorrs LOG_TOPIC(ERR, Logger::AGENCY) << __FILE__ << ":" << __LINE__ << " " << e.what(); } - return applied; + return success; + } // Get name @@ -294,7 +306,7 @@ std::vector Store::apply( } -// Check single precondition +/// Check precodition object bool Store::check(VPackSlice const& slice) const { if (!slice.isObject()) { // Must be object diff --git a/arangod/Agency/Store.h b/arangod/Agency/Store.h index 4c58c47aef..9fe865aa06 100644 --- a/arangod/Agency/Store.h +++ b/arangod/Agency/Store.h @@ -53,7 +53,7 @@ class Store : public arangodb::Thread { Store& operator= (Store&& rhs); /// @brief Apply entry in query - std::vector apply(query_t const& query); + std::vector apply(query_t const& query, bool verbose = false); /// @brief Apply entry in query std::vector apply(std::vector const& query, bool inform = true);