mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'engine-api' of https://github.com/arangodb/arangodb into engine-api
This commit is contained in:
commit
87477d20a9
|
@ -44,6 +44,7 @@
|
||||||
#include "RocksDBEngine/RocksDBIndexFactory.h"
|
#include "RocksDBEngine/RocksDBIndexFactory.h"
|
||||||
#include "RocksDBEngine/RocksDBKey.h"
|
#include "RocksDBEngine/RocksDBKey.h"
|
||||||
#include "RocksDBEngine/RocksDBRestHandlers.h"
|
#include "RocksDBEngine/RocksDBRestHandlers.h"
|
||||||
|
#include "RocksDBEngine/RocksDBReplicationManager.h"
|
||||||
#include "RocksDBEngine/RocksDBTransactionCollection.h"
|
#include "RocksDBEngine/RocksDBTransactionCollection.h"
|
||||||
#include "RocksDBEngine/RocksDBTransactionContextData.h"
|
#include "RocksDBEngine/RocksDBTransactionContextData.h"
|
||||||
#include "RocksDBEngine/RocksDBTransactionState.h"
|
#include "RocksDBEngine/RocksDBTransactionState.h"
|
||||||
|
@ -205,6 +206,8 @@ void RocksDBEngine::start() {
|
||||||
TRI_ASSERT(false);
|
TRI_ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_replicationManager = new RocksDBReplicationManager{};
|
||||||
|
|
||||||
if (!systemDatabaseExists()) {
|
if (!systemDatabaseExists()) {
|
||||||
addSystemDatabase();
|
addSystemDatabase();
|
||||||
}
|
}
|
||||||
|
@ -228,6 +231,9 @@ void RocksDBEngine::unprepare() {
|
||||||
delete _db;
|
delete _db;
|
||||||
_db = nullptr;
|
_db = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete _replicationManager;
|
||||||
|
_replicationManager = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
transaction::ContextData* RocksDBEngine::createTransactionContextData() {
|
transaction::ContextData* RocksDBEngine::createTransactionContextData() {
|
||||||
|
@ -1026,4 +1032,9 @@ RocksDBCounterManager* RocksDBEngine::counterManager() {
|
||||||
return _counterManager.get();
|
return _counterManager.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RocksDBReplicationManager * RocksDBEngine::replicationManager() {
|
||||||
|
TRI_ASSERT(_replicationManager);
|
||||||
|
return _replicationManager;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -37,10 +37,11 @@
|
||||||
#include <velocypack/Slice.h>
|
#include <velocypack/Slice.h>
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
class RocksDBComparator;
|
|
||||||
class RocksDBCounterManager;
|
|
||||||
class PhysicalCollection;
|
class PhysicalCollection;
|
||||||
class PhysicalView;
|
class PhysicalView;
|
||||||
|
class RocksDBComparator;
|
||||||
|
class RocksDBCounterManager;
|
||||||
|
class RocksDBReplicationManager;
|
||||||
class TransactionCollection;
|
class TransactionCollection;
|
||||||
class TransactionState;
|
class TransactionState;
|
||||||
|
|
||||||
|
@ -259,11 +260,13 @@ class RocksDBEngine final : public StorageEngine {
|
||||||
static std::string const EngineName;
|
static std::string const EngineName;
|
||||||
static std::string const FeatureName;
|
static std::string const FeatureName;
|
||||||
RocksDBCounterManager* counterManager();
|
RocksDBCounterManager* counterManager();
|
||||||
|
RocksDBReplicationManager* replicationManager();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rocksdb::TransactionDB*
|
rocksdb::TransactionDB*
|
||||||
_db; // single rocksdb database used in this storage engine
|
_db; // single rocksdb database used in this storage engine
|
||||||
rocksdb::Options _options; // default read options
|
rocksdb::Options _options; // default read options
|
||||||
|
RocksDBReplicationManager* _replicationManager;
|
||||||
std::unique_ptr<RocksDBComparator>
|
std::unique_ptr<RocksDBComparator>
|
||||||
_cmp; // arangodb comparator - requried because of vpack in keys
|
_cmp; // arangodb comparator - requried because of vpack in keys
|
||||||
std::string _path; // path used by rocksdb (inside _basePath)
|
std::string _path; // path used by rocksdb (inside _basePath)
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RocksDBReplicationResult : public Result {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// ttl in seconds
|
/// ttl in seconds
|
||||||
double RocksDBReplicationContextTTL = 30 * 60.0;
|
const double RocksDBReplicationContextTTL = 30 * 60.0;
|
||||||
|
|
||||||
class RocksDBReplicationContext {
|
class RocksDBReplicationContext {
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "RocksDBReplicationManager.h"
|
#include "RocksDBReplicationManager.h"
|
||||||
#include "Basics/MutexLocker.h"
|
#include "Basics/MutexLocker.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
|
#include "RocksDBEngine/RocksDBEngine.h"
|
||||||
#include "RocksDBEngine/RocksDBCommon.h"
|
#include "RocksDBEngine/RocksDBCommon.h"
|
||||||
#include "RocksDBEngine/RocksDBReplicationContext.h"
|
#include "RocksDBEngine/RocksDBReplicationContext.h"
|
||||||
|
|
||||||
|
|
|
@ -64,11 +64,12 @@ class RocksDBReplicationManager {
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief find an existing context by id
|
/// @brief find an existing context by id
|
||||||
/// if found, the context will be returned with the usage flag set to true.
|
/// if found, the context will be returned with the isUsed() flag set to true.
|
||||||
/// it must be returned later using release() or destroy()
|
/// it must be returned later using release() or destroy()
|
||||||
|
/// the second parameter shows if the context you are looking for is busy or not
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
RocksDBReplicationContext* find(RocksDBReplicationId, bool&);
|
RocksDBReplicationContext* find(RocksDBReplicationId, bool& isBusy);
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief return a context for later use
|
/// @brief return a context for later use
|
||||||
|
|
|
@ -35,9 +35,13 @@
|
||||||
#include "GeneralServer/GeneralServer.h"
|
#include "GeneralServer/GeneralServer.h"
|
||||||
#include "Indexes/Index.h"
|
#include "Indexes/Index.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "MMFiles/MMFilesCollectionKeys.h"
|
#include "RocksDBEngine/RocksDBCommon.h"
|
||||||
#include "MMFiles/MMFilesLogfileManager.h"
|
#include "RocksDBEngine/RocksDBEngine.h"
|
||||||
#include "MMFiles/mmfiles-replication-dump.h"
|
#include "RocksDBEngine/RocksDBReplicationContext.h"
|
||||||
|
#include "RocksDBEngine/RocksDBReplicationManager.h"
|
||||||
|
//#include "MMFiles/MMFilesCollectionKeys.h"
|
||||||
|
//#include "MMFiles/MMFilesLogfileManager.h"
|
||||||
|
//#include "MMFiles/mmfiles-replication-dump.h"
|
||||||
#include "Replication/InitialSyncer.h"
|
#include "Replication/InitialSyncer.h"
|
||||||
#include "Rest/HttpRequest.h"
|
#include "Rest/HttpRequest.h"
|
||||||
#include "Rest/Version.h"
|
#include "Rest/Version.h"
|
||||||
|
@ -67,10 +71,12 @@
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::basics;
|
using namespace arangodb::basics;
|
||||||
using namespace arangodb::rest;
|
using namespace arangodb::rest;
|
||||||
|
using namespace arangodb::rocksutils;
|
||||||
|
|
||||||
RocksDBRestReplicationHandler::RocksDBRestReplicationHandler(
|
RocksDBRestReplicationHandler::RocksDBRestReplicationHandler(
|
||||||
GeneralRequest* request, GeneralResponse* response)
|
GeneralRequest* request, GeneralResponse* response)
|
||||||
: RestVocbaseBaseHandler(request, response) {}
|
: RestVocbaseBaseHandler(request, response),
|
||||||
|
_manager(globalRocksEngine()->replicationManager()) {}
|
||||||
|
|
||||||
RocksDBRestReplicationHandler::~RocksDBRestReplicationHandler() {}
|
RocksDBRestReplicationHandler::~RocksDBRestReplicationHandler() {}
|
||||||
|
|
||||||
|
@ -479,19 +485,21 @@ void RocksDBRestReplicationHandler::handleCommandDetermineOpenTransactions() {
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void RocksDBRestReplicationHandler::handleCommandInventory() {
|
void RocksDBRestReplicationHandler::handleCommandInventory() {
|
||||||
uint64_t contextId = TRI_CurrentTickServer();
|
RocksDBReplicationContext* context = _manager->createContext();
|
||||||
|
|
||||||
// add context id to store
|
// add context id to store
|
||||||
// TODO - add context id to store
|
// TODO - add context id to store
|
||||||
|
|
||||||
VPackBuilder builder;
|
VPackBuilder builder;
|
||||||
builder.openObject();
|
builder.openObject();
|
||||||
builder.add("contextId", VPackValue(std::to_string(contextId)));
|
builder.add("contextId", VPackValue(std::to_string(context->id())));
|
||||||
builder.close();
|
builder.close();
|
||||||
|
_manager->release(context);
|
||||||
|
|
||||||
generateError(rest::ResponseCode::NOT_IMPLEMENTED,
|
generateError(rest::ResponseCode::NOT_IMPLEMENTED,
|
||||||
TRI_ERROR_NOT_YET_IMPLEMENTED,
|
TRI_ERROR_NOT_YET_IMPLEMENTED,
|
||||||
"replication API is not fully implemented for RocksDB yet");
|
"replication API is not fully implemented for RocksDB yet");
|
||||||
//generateResult(rest::ResponseCode::OK, builder.slice());
|
// generateResult(rest::ResponseCode::OK, builder.slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -589,22 +597,23 @@ void RocksDBRestReplicationHandler::handleCommandDump() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get contextId
|
// get contextId
|
||||||
std::string const& contextIdString = _request->value("contextId", found);
|
std::string const& contextIdString = _request->value("contextId", found);
|
||||||
if (found) {
|
if (found) {
|
||||||
contextId = StringUtils::uint64(contextIdString);
|
contextId = StringUtils::uint64(contextIdString);
|
||||||
} else {
|
} else {
|
||||||
generateError(rest::ResponseCode::NOT_FOUND,
|
generateError(rest::ResponseCode::NOT_FOUND, TRI_ERROR_HTTP_BAD_PARAMETER,
|
||||||
TRI_ERROR_HTTP_BAD_PARAMETER,
|
|
||||||
"replication dump request misses contextId");
|
"replication dump request misses contextId");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isBusy = false;
|
||||||
|
_manager->find(contextId, isBusy);
|
||||||
// lock context id || die
|
// lock context id || die
|
||||||
|
|
||||||
// print request
|
// print request
|
||||||
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
LOG_TOPIC(TRACE, arangodb::Logger::FIXME)
|
||||||
<< "requested collection dump for collection '" << collection
|
<< "requested collection dump for collection '" << collection
|
||||||
<< "' using contextId '" << contextId
|
<< "' using contextId '" << contextId << "'";
|
||||||
<< "'";
|
|
||||||
|
|
||||||
// fail
|
// fail
|
||||||
generateError(rest::ResponseCode::NOT_IMPLEMENTED,
|
generateError(rest::ResponseCode::NOT_IMPLEMENTED,
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include "Basics/Common.h"
|
#include "Basics/Common.h"
|
||||||
|
|
||||||
|
#include "RocksDBEngine/RocksDBReplicationManager.h"
|
||||||
#include "RestHandler/RestVocbaseBaseHandler.h"
|
#include "RestHandler/RestVocbaseBaseHandler.h"
|
||||||
#include "VocBase/replication-common.h"
|
#include "VocBase/replication-common.h"
|
||||||
|
|
||||||
|
@ -246,6 +247,8 @@ class RocksDBRestReplicationHandler : public RestVocbaseBaseHandler {
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
void handleCommandGetIdForReadLockCollection();
|
void handleCommandGetIdForReadLockCollection();
|
||||||
|
|
||||||
|
RocksDBReplicationManager* _manager;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue