1
0
Fork 0

Merge branch 'engine-api' of https://github.com/arangodb/arangodb into engine-api

This commit is contained in:
jsteemann 2017-04-18 22:01:40 +02:00
commit 35d951877d
6 changed files with 96 additions and 96 deletions

View File

@ -250,7 +250,6 @@ SET(ARANGOD_SOURCES
RestHandler/RestPregelHandler.cpp RestHandler/RestPregelHandler.cpp
RestHandler/RestQueryCacheHandler.cpp RestHandler/RestQueryCacheHandler.cpp
RestHandler/RestQueryHandler.cpp RestHandler/RestQueryHandler.cpp
RestHandler/RestReplicationHandler.cpp
RestHandler/RestShutdownHandler.cpp RestHandler/RestShutdownHandler.cpp
RestHandler/RestSimpleHandler.cpp RestHandler/RestSimpleHandler.cpp
RestHandler/RestSimpleQueryHandler.cpp RestHandler/RestSimpleQueryHandler.cpp

View File

@ -59,7 +59,6 @@
#include "RestHandler/RestPregelHandler.h" #include "RestHandler/RestPregelHandler.h"
#include "RestHandler/RestQueryCacheHandler.h" #include "RestHandler/RestQueryCacheHandler.h"
#include "RestHandler/RestQueryHandler.h" #include "RestHandler/RestQueryHandler.h"
#include "RestHandler/RestReplicationHandler.h"
#include "RestHandler/RestShutdownHandler.h" #include "RestHandler/RestShutdownHandler.h"
#include "RestHandler/RestSimpleHandler.h" #include "RestHandler/RestSimpleHandler.h"
#include "RestHandler/RestSimpleQueryHandler.h" #include "RestHandler/RestSimpleQueryHandler.h"
@ -362,10 +361,6 @@ void GeneralServerFeature::defineHandlers() {
RestVocbaseBaseHandler::IMPORT_PATH, RestVocbaseBaseHandler::IMPORT_PATH,
RestHandlerCreator<RestImportHandler>::createNoData); RestHandlerCreator<RestImportHandler>::createNoData);
_handlerFactory->addPrefixHandler(
RestVocbaseBaseHandler::REPLICATION_PATH,
RestHandlerCreator<RestReplicationHandler>::createNoData);
_handlerFactory->addPrefixHandler( _handlerFactory->addPrefixHandler(
RestVocbaseBaseHandler::SIMPLE_QUERY_ALL_PATH, RestVocbaseBaseHandler::SIMPLE_QUERY_ALL_PATH,
RestHandlerCreator<RestSimpleQueryHandler>::createData< RestHandlerCreator<RestSimpleQueryHandler>::createData<
@ -411,9 +406,9 @@ void GeneralServerFeature::defineHandlers() {
_handlerFactory->addPrefixHandler( _handlerFactory->addPrefixHandler(
"/_api/query-cache", "/_api/query-cache",
RestHandlerCreator<RestQueryCacheHandler>::createNoData); RestHandlerCreator<RestQueryCacheHandler>::createNoData);
_handlerFactory->addPrefixHandler("/_api/pregel", _handlerFactory->addPrefixHandler(
RestHandlerCreator<RestPregelHandler>::createNoData); "/_api/pregel", RestHandlerCreator<RestPregelHandler>::createNoData);
if (agency->isEnabled()) { if (agency->isEnabled()) {
_handlerFactory->addPrefixHandler( _handlerFactory->addPrefixHandler(
@ -450,7 +445,7 @@ void GeneralServerFeature::defineHandlers() {
_handlerFactory->addHandler( _handlerFactory->addHandler(
"/_api/version", RestHandlerCreator<RestVersionHandler>::createNoData); "/_api/version", RestHandlerCreator<RestVersionHandler>::createNoData);
_handlerFactory->addHandler( _handlerFactory->addHandler(
"/_api/engine", RestHandlerCreator<RestEngineHandler>::createNoData); "/_api/engine", RestHandlerCreator<RestEngineHandler>::createNoData);

View File

@ -39,6 +39,7 @@ set(MMFILES_SOURCES
MMFiles/MMFilesRemoverThread.cpp MMFiles/MMFilesRemoverThread.cpp
MMFiles/MMFilesRestExportHandler.cpp MMFiles/MMFilesRestExportHandler.cpp
MMFiles/MMFilesRestHandlers.cpp MMFiles/MMFilesRestHandlers.cpp
MMFiles/MMFilesRestReplicationHandler.cpp
MMFiles/MMFilesRestWalHandler.cpp MMFiles/MMFilesRestWalHandler.cpp
MMFiles/MMFilesRevisionsCache.cpp MMFiles/MMFilesRevisionsCache.cpp
MMFiles/MMFilesSkiplistIndex.cpp MMFiles/MMFilesSkiplistIndex.cpp

View File

@ -24,15 +24,22 @@
#include "MMFilesRestHandlers.h" #include "MMFilesRestHandlers.h"
#include "GeneralServer/RestHandlerFactory.h" #include "GeneralServer/RestHandlerFactory.h"
#include "MMFiles/MMFilesRestExportHandler.h" #include "MMFiles/MMFilesRestExportHandler.h"
#include "MMFiles/MMFilesRestReplicationHandler.h"
#include "MMFiles/MMFilesRestWalHandler.h" #include "MMFiles/MMFilesRestWalHandler.h"
#include "RestHandler/RestHandlerCreator.h" #include "RestHandler/RestHandlerCreator.h"
using namespace arangodb; using namespace arangodb;
void MMFilesRestHandlers::registerResources(rest::RestHandlerFactory* handlerFactory) { void MMFilesRestHandlers::registerResources(
rest::RestHandlerFactory* handlerFactory) {
handlerFactory->addPrefixHandler( handlerFactory->addPrefixHandler(
"/_admin/wal", RestHandlerCreator<MMFilesRestWalHandler>::createNoData); "/_admin/wal", RestHandlerCreator<MMFilesRestWalHandler>::createNoData);
handlerFactory->addPrefixHandler( handlerFactory->addPrefixHandler(
"/_api/export", RestHandlerCreator<MMFilesRestExportHandler>::createNoData); "/_api/export",
RestHandlerCreator<MMFilesRestExportHandler>::createNoData);
handlerFactory->addPrefixHandler(
"/_api/replication",
RestHandlerCreator<MMFilesRestReplicationHandler>::createNoData);
} }

View File

@ -21,7 +21,7 @@
/// @author Jan Steemann /// @author Jan Steemann
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include "RestReplicationHandler.h" #include "MMFilesRestReplicationHandler.h"
#include "ApplicationFeatures/ApplicationServer.h" #include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/ConditionLocker.h" #include "Basics/ConditionLocker.h"
#include "Basics/ReadLocker.h" #include "Basics/ReadLocker.h"
@ -67,16 +67,16 @@ using namespace arangodb;
using namespace arangodb::basics; using namespace arangodb::basics;
using namespace arangodb::rest; using namespace arangodb::rest;
uint64_t const RestReplicationHandler::defaultChunkSize = 128 * 1024; uint64_t const MMFilesRestReplicationHandler::defaultChunkSize = 128 * 1024;
uint64_t const RestReplicationHandler::maxChunkSize = 128 * 1024 * 1024; uint64_t const MMFilesRestReplicationHandler::maxChunkSize = 128 * 1024 * 1024;
RestReplicationHandler::RestReplicationHandler(GeneralRequest* request, MMFilesRestReplicationHandler::MMFilesRestReplicationHandler(
GeneralResponse* response) GeneralRequest* request, GeneralResponse* response)
: RestVocbaseBaseHandler(request, response) {} : RestVocbaseBaseHandler(request, response) {}
RestReplicationHandler::~RestReplicationHandler() {} MMFilesRestReplicationHandler::~MMFilesRestReplicationHandler() {}
RestStatus RestReplicationHandler::execute() { RestStatus MMFilesRestReplicationHandler::execute() {
// extract the request type // extract the request type
auto const type = _request->requestType(); auto const type = _request->requestType();
auto const& suffixes = _request->suffixes(); auto const& suffixes = _request->suffixes();
@ -320,7 +320,7 @@ BAD_CALL:
/// @brief comparator to sort collections /// @brief comparator to sort collections
/// sort order is by collection type first (vertices before edges, this is /// sort order is by collection type first (vertices before edges, this is
/// because edges depend on vertices being there), then name /// because edges depend on vertices being there), then name
bool RestReplicationHandler::sortCollections( bool MMFilesRestReplicationHandler::sortCollections(
arangodb::LogicalCollection const* l, arangodb::LogicalCollection const* l,
arangodb::LogicalCollection const* r) { arangodb::LogicalCollection const* r) {
if (l->type() != r->type()) { if (l->type() != r->type()) {
@ -333,7 +333,7 @@ bool RestReplicationHandler::sortCollections(
} }
/// @brief filter a collection based on collection attributes /// @brief filter a collection based on collection attributes
bool RestReplicationHandler::filterCollection( bool MMFilesRestReplicationHandler::filterCollection(
arangodb::LogicalCollection* collection, void* data) { arangodb::LogicalCollection* collection, void* data) {
bool includeSystem = *((bool*)data); bool includeSystem = *((bool*)data);
@ -357,7 +357,7 @@ bool RestReplicationHandler::filterCollection(
/// @brief creates an error if called on a coordinator server /// @brief creates an error if called on a coordinator server
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
bool RestReplicationHandler::isCoordinatorError() { bool MMFilesRestReplicationHandler::isCoordinatorError() {
if (_vocbase->type() == TRI_VOCBASE_TYPE_COORDINATOR) { if (_vocbase->type() == TRI_VOCBASE_TYPE_COORDINATOR) {
generateError(rest::ResponseCode::NOT_IMPLEMENTED, generateError(rest::ResponseCode::NOT_IMPLEMENTED,
TRI_ERROR_CLUSTER_UNSUPPORTED, TRI_ERROR_CLUSTER_UNSUPPORTED,
@ -372,7 +372,8 @@ bool RestReplicationHandler::isCoordinatorError() {
/// @brief insert the applier action into an action list /// @brief insert the applier action into an action list
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::insertClient(TRI_voc_tick_t lastServedTick) { void MMFilesRestReplicationHandler::insertClient(
TRI_voc_tick_t lastServedTick) {
bool found; bool found;
std::string const& value = _request->value("serverId", found); std::string const& value = _request->value("serverId", found);
@ -389,7 +390,7 @@ void RestReplicationHandler::insertClient(TRI_voc_tick_t lastServedTick) {
/// @brief determine the chunk size /// @brief determine the chunk size
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
uint64_t RestReplicationHandler::determineChunkSize() const { uint64_t MMFilesRestReplicationHandler::determineChunkSize() const {
// determine chunk size // determine chunk size
uint64_t chunkSize = defaultChunkSize; uint64_t chunkSize = defaultChunkSize;
@ -413,7 +414,7 @@ uint64_t RestReplicationHandler::determineChunkSize() const {
/// @brief was docuBlock JSF_get_api_replication_logger_return_state /// @brief was docuBlock JSF_get_api_replication_logger_return_state
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandLoggerState() { void MMFilesRestReplicationHandler::handleCommandLoggerState() {
VPackBuilder builder; VPackBuilder builder;
builder.add(VPackValue(VPackValueType::Object)); // Base builder.add(VPackValue(VPackValueType::Object)); // Base
@ -464,7 +465,7 @@ void RestReplicationHandler::handleCommandLoggerState() {
/// @brief was docuBlock JSF_get_api_replication_logger_tick_ranges /// @brief was docuBlock JSF_get_api_replication_logger_tick_ranges
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandLoggerTickRanges() { void MMFilesRestReplicationHandler::handleCommandLoggerTickRanges() {
auto const& ranges = MMFilesLogfileManager::instance()->ranges(); auto const& ranges = MMFilesLogfileManager::instance()->ranges();
VPackBuilder b; VPackBuilder b;
b.add(VPackValue(VPackValueType::Array)); b.add(VPackValue(VPackValueType::Array));
@ -486,7 +487,7 @@ void RestReplicationHandler::handleCommandLoggerTickRanges() {
/// @brief was docuBlock JSF_get_api_replication_logger_first_tick /// @brief was docuBlock JSF_get_api_replication_logger_first_tick
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandLoggerFirstTick() { void MMFilesRestReplicationHandler::handleCommandLoggerFirstTick() {
auto const& ranges = MMFilesLogfileManager::instance()->ranges(); auto const& ranges = MMFilesLogfileManager::instance()->ranges();
VPackBuilder b; VPackBuilder b;
@ -517,7 +518,7 @@ void RestReplicationHandler::handleCommandLoggerFirstTick() {
/// @brief was docuBlock JSF_delete_batch_replication /// @brief was docuBlock JSF_delete_batch_replication
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandBatch() { void MMFilesRestReplicationHandler::handleCommandBatch() {
// extract the request type // extract the request type
auto const type = _request->requestType(); auto const type = _request->requestType();
auto const& suffixes = _request->suffixes(); auto const& suffixes = _request->suffixes();
@ -609,7 +610,7 @@ void RestReplicationHandler::handleCommandBatch() {
/// @brief add or remove a WAL logfile barrier /// @brief add or remove a WAL logfile barrier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandBarrier() { void MMFilesRestReplicationHandler::handleCommandBarrier() {
// extract the request type // extract the request type
auto const type = _request->requestType(); auto const type = _request->requestType();
std::vector<std::string> const& suffixes = _request->suffixes(); std::vector<std::string> const& suffixes = _request->suffixes();
@ -730,7 +731,7 @@ void RestReplicationHandler::handleCommandBarrier() {
/// @brief forward a command in the coordinator case /// @brief forward a command in the coordinator case
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleTrampolineCoordinator() { void MMFilesRestReplicationHandler::handleTrampolineCoordinator() {
bool useVpp = false; bool useVpp = false;
if (_request->transportType() == Endpoint::TransportType::VPP) { if (_request->transportType() == Endpoint::TransportType::VPP) {
useVpp = true; useVpp = true;
@ -852,7 +853,7 @@ void RestReplicationHandler::handleTrampolineCoordinator() {
/// @brief was docuBlock JSF_get_api_replication_logger_returns /// @brief was docuBlock JSF_get_api_replication_logger_returns
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandLoggerFollow() { void MMFilesRestReplicationHandler::handleCommandLoggerFollow() {
bool useVpp = false; bool useVpp = false;
if (_request->transportType() == Endpoint::TransportType::VPP) { if (_request->transportType() == Endpoint::TransportType::VPP) {
useVpp = true; useVpp = true;
@ -1038,7 +1039,7 @@ void RestReplicationHandler::handleCommandLoggerFollow() {
/// be called by client drivers directly /// be called by client drivers directly
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandDetermineOpenTransactions() { void MMFilesRestReplicationHandler::handleCommandDetermineOpenTransactions() {
// determine start and end tick // determine start and end tick
MMFilesLogfileManagerState const state = MMFilesLogfileManagerState const state =
MMFilesLogfileManager::instance()->state(); MMFilesLogfileManager::instance()->state();
@ -1114,7 +1115,7 @@ void RestReplicationHandler::handleCommandDetermineOpenTransactions() {
/// @brief was docuBlock JSF_put_api_replication_inventory /// @brief was docuBlock JSF_put_api_replication_inventory
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandInventory() { void MMFilesRestReplicationHandler::handleCommandInventory() {
TRI_voc_tick_t tick = TRI_CurrentTickServer(); TRI_voc_tick_t tick = TRI_CurrentTickServer();
// include system collections? // include system collections?
@ -1130,7 +1131,7 @@ void RestReplicationHandler::handleCommandInventory() {
std::shared_ptr<VPackBuilder> collectionsBuilder; std::shared_ptr<VPackBuilder> collectionsBuilder;
collectionsBuilder = collectionsBuilder =
_vocbase->inventory(tick, &filterCollection, (void*)&includeSystem, true, _vocbase->inventory(tick, &filterCollection, (void*)&includeSystem, true,
RestReplicationHandler::sortCollections); MMFilesRestReplicationHandler::sortCollections);
VPackSlice const collections = collectionsBuilder->slice(); VPackSlice const collections = collectionsBuilder->slice();
TRI_ASSERT(collections.isArray()); TRI_ASSERT(collections.isArray());
@ -1166,7 +1167,7 @@ void RestReplicationHandler::handleCommandInventory() {
/// @brief was docuBlock JSF_get_api_replication_cluster_inventory /// @brief was docuBlock JSF_get_api_replication_cluster_inventory
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandClusterInventory() { void MMFilesRestReplicationHandler::handleCommandClusterInventory() {
std::string const& dbName = _request->databaseName(); std::string const& dbName = _request->databaseName();
bool found; bool found;
bool includeSystem = true; bool includeSystem = true;
@ -1201,9 +1202,8 @@ void RestReplicationHandler::handleCommandClusterInventory() {
/// @brief creates a collection, based on the VelocyPack provided TODO: MOVE /// @brief creates a collection, based on the VelocyPack provided TODO: MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::createCollection(VPackSlice slice, int MMFilesRestReplicationHandler::createCollection(
arangodb::LogicalCollection** dst, VPackSlice slice, arangodb::LogicalCollection** dst, bool reuseId) {
bool reuseId) {
if (dst != nullptr) { if (dst != nullptr) {
*dst = nullptr; *dst = nullptr;
} }
@ -1292,12 +1292,12 @@ int RestReplicationHandler::createCollection(VPackSlice slice,
/// @brief restores the structure of a collection TODO MOVE /// @brief restores the structure of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandRestoreCollection() { void MMFilesRestReplicationHandler::handleCommandRestoreCollection() {
std::shared_ptr<VPackBuilder> parsedRequest; std::shared_ptr<VPackBuilder> parsedRequest;
try { try {
parsedRequest = _request->toVelocyPackBuilderPtr(); parsedRequest = _request->toVelocyPackBuilderPtr();
} catch(arangodb::velocypack::Exception const& e) { } catch (arangodb::velocypack::Exception const& e) {
std::string errorMsg = "invalid JSON: "; std::string errorMsg = "invalid JSON: ";
errorMsg += e.what(); errorMsg += e.what();
generateError(rest::ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER, generateError(rest::ResponseCode::BAD, TRI_ERROR_HTTP_BAD_PARAMETER,
@ -1374,7 +1374,7 @@ void RestReplicationHandler::handleCommandRestoreCollection() {
/// @brief restores the indexes of a collection TODO MOVE /// @brief restores the indexes of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandRestoreIndexes() { void MMFilesRestReplicationHandler::handleCommandRestoreIndexes() {
std::shared_ptr<VPackBuilder> parsedRequest; std::shared_ptr<VPackBuilder> parsedRequest;
try { try {
@ -1417,7 +1417,7 @@ void RestReplicationHandler::handleCommandRestoreIndexes() {
/// @brief restores the structure of a collection TODO MOVE /// @brief restores the structure of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreCollection( int MMFilesRestReplicationHandler::processRestoreCollection(
VPackSlice const& collection, bool dropExisting, bool reuseId, bool force, VPackSlice const& collection, bool dropExisting, bool reuseId, bool force,
std::string& errorMsg) { std::string& errorMsg) {
if (!collection.isObject()) { if (!collection.isObject()) {
@ -1540,7 +1540,7 @@ int RestReplicationHandler::processRestoreCollection(
/// @brief restores the structure of a collection, coordinator case /// @brief restores the structure of a collection, coordinator case
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreCollectionCoordinator( int MMFilesRestReplicationHandler::processRestoreCollectionCoordinator(
VPackSlice const& collection, bool dropExisting, bool reuseId, bool force, VPackSlice const& collection, bool dropExisting, bool reuseId, bool force,
uint64_t numberOfShards, std::string& errorMsg, uint64_t numberOfShards, std::string& errorMsg,
uint64_t replicationFactor) { uint64_t replicationFactor) {
@ -1688,9 +1688,8 @@ int RestReplicationHandler::processRestoreCollectionCoordinator(
/// @brief restores the indexes of a collection TODO MOVE /// @brief restores the indexes of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection, int MMFilesRestReplicationHandler::processRestoreIndexes(
bool force, VPackSlice const& collection, bool force, std::string& errorMsg) {
std::string& errorMsg) {
if (!collection.isObject()) { if (!collection.isObject()) {
errorMsg = "collection declaration is invalid"; errorMsg = "collection declaration is invalid";
@ -1798,7 +1797,7 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection,
/// @brief restores the indexes of a collection, coordinator case /// @brief restores the indexes of a collection, coordinator case
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreIndexesCoordinator( int MMFilesRestReplicationHandler::processRestoreIndexesCoordinator(
VPackSlice const& collection, bool force, std::string& errorMsg) { VPackSlice const& collection, bool force, std::string& errorMsg) {
if (!collection.isObject()) { if (!collection.isObject()) {
errorMsg = "collection declaration is invalid"; errorMsg = "collection declaration is invalid";
@ -1883,7 +1882,7 @@ int RestReplicationHandler::processRestoreIndexesCoordinator(
/// @brief apply the data from a collection dump or the continuous log /// @brief apply the data from a collection dump or the continuous log
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::applyCollectionDumpMarker( int MMFilesRestReplicationHandler::applyCollectionDumpMarker(
transaction::Methods& trx, CollectionNameResolver const& resolver, transaction::Methods& trx, CollectionNameResolver const& resolver,
std::string const& collectionName, TRI_replication_operation_e type, std::string const& collectionName, TRI_replication_operation_e type,
VPackSlice const& old, VPackSlice const& slice, std::string& errorMsg) { VPackSlice const& old, VPackSlice const& slice, std::string& errorMsg) {
@ -2034,7 +2033,7 @@ static int restoreDataParser(char const* ptr, char const* pos,
/// @brief restores the data of a collection TODO MOVE /// @brief restores the data of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreDataBatch( int MMFilesRestReplicationHandler::processRestoreDataBatch(
transaction::Methods& trx, std::string const& collectionName, transaction::Methods& trx, std::string const& collectionName,
bool useRevision, bool force, std::string& errorMsg) { bool useRevision, bool force, std::string& errorMsg) {
std::string const invalidMsg = std::string const invalidMsg =
@ -2245,9 +2244,9 @@ int RestReplicationHandler::processRestoreDataBatch(
/// @brief restores the data of a collection TODO MOVE /// @brief restores the data of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int RestReplicationHandler::processRestoreData(std::string const& colName, int MMFilesRestReplicationHandler::processRestoreData(
bool useRevision, bool force, std::string const& colName, bool useRevision, bool force,
std::string& errorMsg) { std::string& errorMsg) {
SingleCollectionTransaction trx( SingleCollectionTransaction trx(
transaction::StandaloneContext::Create(_vocbase), colName, transaction::StandaloneContext::Create(_vocbase), colName,
AccessMode::Type::WRITE); AccessMode::Type::WRITE);
@ -2271,7 +2270,7 @@ int RestReplicationHandler::processRestoreData(std::string const& colName,
/// @brief restores the data of a collection TODO MOVE /// @brief restores the data of a collection TODO MOVE
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandRestoreData() { void MMFilesRestReplicationHandler::handleCommandRestoreData() {
std::string const& colName = _request->value("collection"); std::string const& colName = _request->value("collection");
if (colName.empty()) { if (colName.empty()) {
@ -2318,7 +2317,7 @@ void RestReplicationHandler::handleCommandRestoreData() {
/// @brief produce list of keys for a specific collection /// @brief produce list of keys for a specific collection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandCreateKeys() { void MMFilesRestReplicationHandler::handleCommandCreateKeys() {
std::string const& collection = _request->value("collection"); std::string const& collection = _request->value("collection");
if (collection.empty()) { if (collection.empty()) {
@ -2385,7 +2384,7 @@ void RestReplicationHandler::handleCommandCreateKeys() {
/// @brief returns all key ranges /// @brief returns all key ranges
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandGetKeys() { void MMFilesRestReplicationHandler::handleCommandGetKeys() {
std::vector<std::string> const& suffixes = _request->suffixes(); std::vector<std::string> const& suffixes = _request->suffixes();
if (suffixes.size() != 2) { if (suffixes.size() != 2) {
@ -2463,7 +2462,7 @@ void RestReplicationHandler::handleCommandGetKeys() {
/// @brief returns date for a key range /// @brief returns date for a key range
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandFetchKeys() { void MMFilesRestReplicationHandler::handleCommandFetchKeys() {
std::vector<std::string> const& suffixes = _request->suffixes(); std::vector<std::string> const& suffixes = _request->suffixes();
if (suffixes.size() != 2) { if (suffixes.size() != 2) {
@ -2561,7 +2560,7 @@ void RestReplicationHandler::handleCommandFetchKeys() {
} }
} }
void RestReplicationHandler::handleCommandRemoveKeys() { void MMFilesRestReplicationHandler::handleCommandRemoveKeys() {
std::vector<std::string> const& suffixes = _request->suffixes(); std::vector<std::string> const& suffixes = _request->suffixes();
if (suffixes.size() != 2) { if (suffixes.size() != 2) {
@ -2599,7 +2598,7 @@ void RestReplicationHandler::handleCommandRemoveKeys() {
/// @brief was docuBlock JSF_get_api_replication_dump /// @brief was docuBlock JSF_get_api_replication_dump
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandDump() { void MMFilesRestReplicationHandler::handleCommandDump() {
std::string const& collection = _request->value("collection"); std::string const& collection = _request->value("collection");
if (collection.empty()) { if (collection.empty()) {
@ -2756,7 +2755,7 @@ void RestReplicationHandler::handleCommandDump() {
/// @brief was docuBlock JSF_put_api_replication_makeSlave /// @brief was docuBlock JSF_put_api_replication_makeSlave
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandMakeSlave() { void MMFilesRestReplicationHandler::handleCommandMakeSlave() {
bool success; bool success;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -2932,7 +2931,7 @@ void RestReplicationHandler::handleCommandMakeSlave() {
/// @brief was docuBlock JSF_put_api_replication_synchronize /// @brief was docuBlock JSF_put_api_replication_synchronize
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandSync() { void MMFilesRestReplicationHandler::handleCommandSync() {
bool success; bool success;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3045,7 +3044,7 @@ void RestReplicationHandler::handleCommandSync() {
/// @brief was docuBlock JSF_put_api_replication_serverID /// @brief was docuBlock JSF_put_api_replication_serverID
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandServerId() { void MMFilesRestReplicationHandler::handleCommandServerId() {
VPackBuilder result; VPackBuilder result;
result.add(VPackValue(VPackValueType::Object)); result.add(VPackValue(VPackValueType::Object));
std::string const serverId = StringUtils::itoa(ServerIdFeature::getId()); std::string const serverId = StringUtils::itoa(ServerIdFeature::getId());
@ -3058,7 +3057,7 @@ void RestReplicationHandler::handleCommandServerId() {
/// @brief was docuBlock JSF_put_api_replication_applier /// @brief was docuBlock JSF_put_api_replication_applier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierGetConfig() { void MMFilesRestReplicationHandler::handleCommandApplierGetConfig() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
TRI_replication_applier_configuration_t config; TRI_replication_applier_configuration_t config;
@ -3075,7 +3074,7 @@ void RestReplicationHandler::handleCommandApplierGetConfig() {
/// @brief was docuBlock JSF_put_api_replication_applier_adjust /// @brief was docuBlock JSF_put_api_replication_applier_adjust
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierSetConfig() { void MMFilesRestReplicationHandler::handleCommandApplierSetConfig() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
TRI_replication_applier_configuration_t config; TRI_replication_applier_configuration_t config;
@ -3197,7 +3196,7 @@ void RestReplicationHandler::handleCommandApplierSetConfig() {
/// @brief was docuBlock JSF_put_api_replication_applier_start /// @brief was docuBlock JSF_put_api_replication_applier_start
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierStart() { void MMFilesRestReplicationHandler::handleCommandApplierStart() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
bool found; bool found;
@ -3234,7 +3233,7 @@ void RestReplicationHandler::handleCommandApplierStart() {
/// @brief was docuBlock JSF_put_api_replication_applier_stop /// @brief was docuBlock JSF_put_api_replication_applier_stop
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierStop() { void MMFilesRestReplicationHandler::handleCommandApplierStop() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
int res = _vocbase->replicationApplier()->stop(true); int res = _vocbase->replicationApplier()->stop(true);
@ -3250,7 +3249,7 @@ void RestReplicationHandler::handleCommandApplierStop() {
/// @brief was docuBlock JSF_get_api_replication_applier_state /// @brief was docuBlock JSF_get_api_replication_applier_state
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierGetState() { void MMFilesRestReplicationHandler::handleCommandApplierGetState() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
std::shared_ptr<VPackBuilder> result = std::shared_ptr<VPackBuilder> result =
@ -3262,7 +3261,7 @@ void RestReplicationHandler::handleCommandApplierGetState() {
/// @brief delete the state of the replication applier /// @brief delete the state of the replication applier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandApplierDeleteState() { void MMFilesRestReplicationHandler::handleCommandApplierDeleteState() {
TRI_ASSERT(_vocbase->replicationApplier() != nullptr); TRI_ASSERT(_vocbase->replicationApplier() != nullptr);
int res = _vocbase->replicationApplier()->forget(); int res = _vocbase->replicationApplier()->forget();
@ -3278,7 +3277,7 @@ void RestReplicationHandler::handleCommandApplierDeleteState() {
/// @brief add a follower of a shard to the list of followers /// @brief add a follower of a shard to the list of followers
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandAddFollower() { void MMFilesRestReplicationHandler::handleCommandAddFollower() {
bool success = false; bool success = false;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3324,7 +3323,7 @@ void RestReplicationHandler::handleCommandAddFollower() {
/// @brief remove a follower of a shard from the list of followers /// @brief remove a follower of a shard from the list of followers
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandRemoveFollower() { void MMFilesRestReplicationHandler::handleCommandRemoveFollower() {
bool success = false; bool success = false;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3369,7 +3368,7 @@ void RestReplicationHandler::handleCommandRemoveFollower() {
/// @brief hold a read lock on a collection to stop writes temporarily /// @brief hold a read lock on a collection to stop writes temporarily
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandHoldReadLockCollection() { void MMFilesRestReplicationHandler::handleCommandHoldReadLockCollection() {
bool success = false; bool success = false;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3487,7 +3486,7 @@ void RestReplicationHandler::handleCommandHoldReadLockCollection() {
/// @brief check the holding of a read lock on a collection /// @brief check the holding of a read lock on a collection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandCheckHoldReadLockCollection() { void MMFilesRestReplicationHandler::handleCommandCheckHoldReadLockCollection() {
bool success = false; bool success = false;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3537,7 +3536,8 @@ void RestReplicationHandler::handleCommandCheckHoldReadLockCollection() {
/// @brief cancel the holding of a read lock on a collection /// @brief cancel the holding of a read lock on a collection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandCancelHoldReadLockCollection() { void MMFilesRestReplicationHandler::
handleCommandCancelHoldReadLockCollection() {
bool success = false; bool success = false;
std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success); std::shared_ptr<VPackBuilder> parsedBody = parseVelocyPackBody(success);
if (!success) { if (!success) {
@ -3588,7 +3588,7 @@ void RestReplicationHandler::handleCommandCancelHoldReadLockCollection() {
/// @brief get ID for a read lock job /// @brief get ID for a read lock job
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
void RestReplicationHandler::handleCommandGetIdForReadLockCollection() { void MMFilesRestReplicationHandler::handleCommandGetIdForReadLockCollection() {
std::string id = std::to_string(TRI_NewTickServer()); std::string id = std::to_string(TRI_NewTickServer());
VPackBuilder b; VPackBuilder b;
@ -3604,11 +3604,12 @@ void RestReplicationHandler::handleCommandGetIdForReadLockCollection() {
/// @brief condition locker to wake up holdReadLockCollection jobs /// @brief condition locker to wake up holdReadLockCollection jobs
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
arangodb::basics::ConditionVariable RestReplicationHandler::_condVar; arangodb::basics::ConditionVariable MMFilesRestReplicationHandler::_condVar;
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @brief global table of flags to cancel holdReadLockCollection jobs, if /// @brief global table of flags to cancel holdReadLockCollection jobs, if
/// the flag is set of the ID of a job, the job is cancelled /// the flag is set of the ID of a job, the job is cancelled
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
std::unordered_map<std::string, bool> RestReplicationHandler::_holdReadLockJobs; std::unordered_map<std::string, bool>
MMFilesRestReplicationHandler::_holdReadLockJobs;

View File

@ -21,8 +21,8 @@
/// @author Jan Steemann /// @author Jan Steemann
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#ifndef ARANGOD_REST_HANDLER_REST_REPLICATION_HANDLER_H #ifndef ARANGOD_MMFILES_MMFILES_REST_REPLICATION_HANDLER_H
#define ARANGOD_REST_HANDLER_REST_REPLICATION_HANDLER_H 1 #define ARANGOD_MMFILES_MMFILES_REST_REPLICATION_HANDLER_H 1
#include "Basics/Common.h" #include "Basics/Common.h"
@ -35,21 +35,22 @@ class CollectionNameResolver;
class LogicalCollection; class LogicalCollection;
namespace transaction { namespace transaction {
class Methods; class Methods;
} };
;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief replication request handler /// @brief replication request handler
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
class RestReplicationHandler : public RestVocbaseBaseHandler { class MMFilesRestReplicationHandler : public RestVocbaseBaseHandler {
public: public:
RestReplicationHandler(GeneralRequest*, GeneralResponse*); MMFilesRestReplicationHandler(GeneralRequest*, GeneralResponse*);
~RestReplicationHandler(); ~MMFilesRestReplicationHandler();
public: public:
RestStatus execute() override; RestStatus execute() override;
char const* name() const override final { return "RestReplicationHandler"; } char const* name() const override final {
return "MMFilesRestReplicationHandler";
}
public: public:
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -98,7 +99,7 @@ class RestReplicationHandler : public RestVocbaseBaseHandler {
/// @response VPackObject describing the ServerState in a certain point /// @response VPackObject describing the ServerState in a certain point
/// * state (server state) /// * state (server state)
/// * server (version / id) /// * server (version / id)
/// * clients (list of followers) /// * clients (list of followers)
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
void handleCommandLoggerState(); void handleCommandLoggerState();
@ -229,25 +230,22 @@ class RestReplicationHandler : public RestVocbaseBaseHandler {
int applyCollectionDumpMarker(transaction::Methods&, int applyCollectionDumpMarker(transaction::Methods&,
CollectionNameResolver const&, CollectionNameResolver const&,
std::string const&, std::string const&, TRI_replication_operation_e,
TRI_replication_operation_e, VPackSlice const&, VPackSlice const&,
VPackSlice const&, std::string&);
VPackSlice const&, std::string&);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @brief restores the data of a collection TODO MOVE /// @brief restores the data of a collection TODO MOVE
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int processRestoreDataBatch(transaction::Methods&, int processRestoreDataBatch(transaction::Methods&, std::string const&, bool,
std::string const&, bool, bool, bool, std::string&);
std::string&);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @brief restores the data of a collection TODO MOVE /// @brief restores the data of a collection TODO MOVE
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
int processRestoreData(std::string const&, bool, int processRestoreData(std::string const&, bool, bool, std::string&);
bool, std::string&);
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
/// @brief handle a restore command for a specific collection /// @brief handle a restore command for a specific collection
@ -394,14 +392,13 @@ class RestReplicationHandler : public RestVocbaseBaseHandler {
/// read lock has been started, the bool is changed to true once /// read lock has been started, the bool is changed to true once
/// this read lock is acquired. To cancel the read lock, remove /// this read lock is acquired. To cancel the read lock, remove
/// the entry here (under the protection of the mutex of /// the entry here (under the protection of the mutex of
/// condVar) and send a broadcast to the condition variable, /// condVar) and send a broadcast to the condition variable,
/// the job with that id is terminated. If it timeouts, then /// the job with that id is terminated. If it timeouts, then
/// the read lock is released automatically and the entry here /// the read lock is released automatically and the entry here
/// is deleted. /// is deleted.
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
static std::unordered_map<std::string, bool> _holdReadLockJobs; static std::unordered_map<std::string, bool> _holdReadLockJobs;
}; };
} }