mirror of https://gitee.com/bigwinds/arangodb
issue 380.2.2: remove extraneous pointers from StorageEngine API (#5589)
This commit is contained in:
parent
0470f945fa
commit
a5f274234a
|
@ -66,7 +66,12 @@ using namespace arangodb::options;
|
|||
|
||||
// create the storage engine
|
||||
ClusterEngine::ClusterEngine(application_features::ApplicationServer* server)
|
||||
: StorageEngine(server, "Cluster", "ClusterEngine", new ClusterIndexFactory()),
|
||||
: StorageEngine(
|
||||
server,
|
||||
"Cluster",
|
||||
"ClusterEngine",
|
||||
std::unique_ptr<IndexFactory>(new ClusterIndexFactory())
|
||||
),
|
||||
_actualEngine(nullptr) {
|
||||
setOptional(true);
|
||||
}
|
||||
|
@ -116,12 +121,14 @@ void ClusterEngine::start() {
|
|||
TRI_ASSERT(ServerState::instance()->isCoordinator());
|
||||
}
|
||||
|
||||
TransactionManager* ClusterEngine::createTransactionManager() {
|
||||
return new ClusterTransactionManager();
|
||||
std::unique_ptr<TransactionManager> ClusterEngine::createTransactionManager() {
|
||||
return std::unique_ptr<TransactionManager>(new ClusterTransactionManager());
|
||||
}
|
||||
|
||||
transaction::ContextData* ClusterEngine::createTransactionContextData() {
|
||||
return new ClusterTransactionContextData();
|
||||
std::unique_ptr<transaction::ContextData> ClusterEngine::createTransactionContextData() {
|
||||
return std::unique_ptr<transaction::ContextData>(
|
||||
new ClusterTransactionContextData()
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<TransactionState> ClusterEngine::createTransactionState(
|
||||
|
@ -133,10 +140,15 @@ std::unique_ptr<TransactionState> ClusterEngine::createTransactionState(
|
|||
);
|
||||
}
|
||||
|
||||
TransactionCollection* ClusterEngine::createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) {
|
||||
return new ClusterTransactionCollection(state, cid, accessType, nestingLevel);
|
||||
std::unique_ptr<TransactionCollection> ClusterEngine::createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) {
|
||||
return std::unique_ptr<TransactionCollection>(
|
||||
new ClusterTransactionCollection(&state, cid, accessType, nestingLevel)
|
||||
);
|
||||
}
|
||||
|
||||
void ClusterEngine::addParametersForNewCollection(VPackBuilder& builder,
|
||||
|
@ -155,9 +167,13 @@ void ClusterEngine::addParametersForNewIndex(VPackBuilder& builder,
|
|||
}
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* ClusterEngine::createPhysicalCollection(
|
||||
LogicalCollection* collection, VPackSlice const& info) {
|
||||
return new ClusterCollection(collection, engineType(), info);
|
||||
std::unique_ptr<PhysicalCollection> ClusterEngine::createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
VPackSlice const& info
|
||||
) {
|
||||
return std::unique_ptr<PhysicalCollection>(
|
||||
new ClusterCollection(&collection, engineType(), info)
|
||||
);
|
||||
}
|
||||
|
||||
void ClusterEngine::getStatistics(velocypack::Builder& builder) const {
|
||||
|
@ -210,7 +226,9 @@ std::string ClusterEngine::versionFilename(TRI_voc_tick_t id) const {
|
|||
}
|
||||
|
||||
VPackBuilder ClusterEngine::getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t* vocbase, int& status) {
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
return VPackBuilder();
|
||||
}
|
||||
|
@ -223,7 +241,7 @@ VPackBuilder ClusterEngine::getReplicationApplierConfiguration(int& status) {
|
|||
// database, collection and index management
|
||||
// -----------------------------------------
|
||||
|
||||
TRI_vocbase_t* ClusterEngine::openDatabase(
|
||||
std::unique_ptr<TRI_vocbase_t> ClusterEngine::openDatabase(
|
||||
arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) {
|
||||
VPackSlice idSlice = args.get("id");
|
||||
TRI_voc_tick_t id = static_cast<TRI_voc_tick_t>(
|
||||
|
@ -235,12 +253,13 @@ TRI_vocbase_t* ClusterEngine::openDatabase(
|
|||
return openExistingDatabase(id, name, true, isUpgrade);
|
||||
}
|
||||
|
||||
TRI_vocbase_t* ClusterEngine::createDatabase(
|
||||
std::unique_ptr<TRI_vocbase_t> ClusterEngine::createDatabase(
|
||||
TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) {
|
||||
status = TRI_ERROR_NO_ERROR;
|
||||
auto vocbase = std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id,
|
||||
args.get("name").copyString());
|
||||
return vocbase.release();
|
||||
|
||||
return std::make_unique<TRI_vocbase_t>(
|
||||
TRI_VOCBASE_TYPE_NORMAL, id, args.get("name").copyString()
|
||||
);
|
||||
}
|
||||
|
||||
int ClusterEngine::writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
||||
|
@ -248,12 +267,15 @@ int ClusterEngine::writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
|||
return id == 1 ? TRI_ERROR_NO_ERROR : TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void ClusterEngine::prepareDropDatabase(TRI_vocbase_t* vocbase,
|
||||
bool useWriteMarker, int& status) {
|
||||
void ClusterEngine::prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
Result ClusterEngine::dropDatabase(TRI_vocbase_t* database) {
|
||||
Result ClusterEngine::dropDatabase(TRI_vocbase_t& database) {
|
||||
TRI_ASSERT(false);
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
@ -276,7 +298,7 @@ void ClusterEngine::recoveryDone(TRI_vocbase_t& vocbase) {
|
|||
std::string ClusterEngine::createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t cid,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
TRI_ASSERT(cid != 0);
|
||||
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(cid));
|
||||
|
@ -285,21 +307,21 @@ std::string ClusterEngine::createCollection(
|
|||
|
||||
arangodb::Result ClusterEngine::persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
|
||||
arangodb::Result ClusterEngine::dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void ClusterEngine::destroyCollection(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalCollection* /*collection*/
|
||||
LogicalCollection& /*collection*/
|
||||
) {
|
||||
// not required
|
||||
}
|
||||
|
@ -307,17 +329,17 @@ void ClusterEngine::destroyCollection(
|
|||
void ClusterEngine::changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* parameters,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
arangodb::Result ClusterEngine::renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
std::string const& oldName
|
||||
) {
|
||||
TRI_vocbase_t& vocbase,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
@ -331,9 +353,9 @@ void ClusterEngine::createIndex(
|
|||
|
||||
void ClusterEngine::unloadCollection(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
collection->setStatus(TRI_VOC_COL_STATUS_UNLOADED);
|
||||
collection.setStatus(TRI_VOC_COL_STATUS_UNLOADED);
|
||||
}
|
||||
|
||||
void ClusterEngine::createView(
|
||||
|
@ -363,13 +385,15 @@ arangodb::Result ClusterEngine::persistView(
|
|||
|
||||
arangodb::Result ClusterEngine::dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view) {
|
||||
LogicalView& view
|
||||
) {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
void ClusterEngine::destroyView(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalView* /*view*/) noexcept {
|
||||
LogicalView& /*view*/
|
||||
) noexcept {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
|
@ -394,11 +418,11 @@ void ClusterEngine::changeView(
|
|||
}
|
||||
}
|
||||
|
||||
void ClusterEngine::signalCleanup(TRI_vocbase_t*) {
|
||||
void ClusterEngine::signalCleanup(TRI_vocbase_t&) {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
int ClusterEngine::shutdownDatabase(TRI_vocbase_t* vocbase) {
|
||||
int ClusterEngine::shutdownDatabase(TRI_vocbase_t& vocbase) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -423,8 +447,8 @@ void ClusterEngine::addV8Functions() {
|
|||
}
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void ClusterEngine::addRestHandlers(rest::RestHandlerFactory* handlerFactory) {
|
||||
ClusterRestHandlers::registerResources(handlerFactory);
|
||||
void ClusterEngine::addRestHandlers(rest::RestHandlerFactory& handlerFactory) {
|
||||
ClusterRestHandlers::registerResources(&handlerFactory);
|
||||
}
|
||||
|
||||
void ClusterEngine::waitForEstimatorSync(std::chrono::milliseconds maxWaitTime) {
|
||||
|
@ -434,14 +458,14 @@ void ClusterEngine::waitForEstimatorSync(std::chrono::milliseconds maxWaitTime)
|
|||
}
|
||||
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* ClusterEngine::openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade) {
|
||||
std::unique_ptr<TRI_vocbase_t> ClusterEngine::openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
) {
|
||||
// TODO make this a coordinator type vocbase
|
||||
auto vocbase =
|
||||
std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id, name);
|
||||
return vocbase.release();
|
||||
return std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id, name);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
@ -80,19 +80,24 @@ class ClusterEngine final : public StorageEngine {
|
|||
bool supportsDfdb() const override { return false; }
|
||||
bool useRawDocumentPointers() override { return false; }
|
||||
|
||||
TransactionManager* createTransactionManager() override;
|
||||
transaction::ContextData* createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionManager> createTransactionManager() override;
|
||||
std::unique_ptr<transaction::ContextData> createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionState> createTransactionState(
|
||||
CollectionNameResolver const& resolver,
|
||||
transaction::Options const& options
|
||||
) override;
|
||||
TransactionCollection* createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) override;
|
||||
std::unique_ptr<TransactionCollection> createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) override;
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* createPhysicalCollection(LogicalCollection*,
|
||||
velocypack::Slice const&) override;
|
||||
std::unique_ptr<PhysicalCollection> createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) override;
|
||||
|
||||
void getStatistics(velocypack::Builder& builder) const override;
|
||||
|
||||
|
@ -125,32 +130,40 @@ class ClusterEngine final : public StorageEngine {
|
|||
std::string databasePath(TRI_vocbase_t const* vocbase) const override {
|
||||
return _basePath;
|
||||
}
|
||||
std::string collectionPath(TRI_vocbase_t const* vocbase,
|
||||
TRI_voc_cid_t id) const override {
|
||||
std::string collectionPath(
|
||||
TRI_vocbase_t const& vocbase,
|
||||
TRI_voc_cid_t id
|
||||
) const override {
|
||||
return std::string(); // no path to be returned here
|
||||
}
|
||||
|
||||
velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
int& status) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(int& status) override;
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) override {
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t& vocbase) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
int removeReplicationApplierConfiguration() override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
arangodb::velocypack::Slice slice,
|
||||
bool doSync) override {
|
||||
int saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
int saveReplicationApplierConfiguration(arangodb::velocypack::Slice slice,
|
||||
bool doSync) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
Result handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) override {
|
||||
Result handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
Result createLoggerState(TRI_vocbase_t* vocbase,
|
||||
|
@ -163,10 +176,13 @@ class ClusterEngine final : public StorageEngine {
|
|||
Result firstTick(uint64_t& tick) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
Result lastLogger(TRI_vocbase_t* vocbase,
|
||||
std::shared_ptr<transaction::Context>, uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<velocypack::Builder>& builderSPtr) override {
|
||||
Result lastLogger(
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<velocypack::Builder>& builderSPtr
|
||||
) override {
|
||||
return TRI_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
WalAccess const* walAccess() const override {
|
||||
|
@ -186,16 +202,24 @@ class ClusterEngine final : public StorageEngine {
|
|||
}
|
||||
void waitForEstimatorSync(std::chrono::milliseconds maxWaitTime) override;
|
||||
|
||||
virtual TRI_vocbase_t* openDatabase(velocypack::Slice const& parameters,
|
||||
bool isUpgrade, int&) override;
|
||||
TRI_vocbase_t* createDatabase(TRI_voc_tick_t id,
|
||||
arangodb::velocypack::Slice const& args,
|
||||
int& status) override;
|
||||
virtual std::unique_ptr<TRI_vocbase_t> openDatabase(
|
||||
velocypack::Slice const& parameters,
|
||||
bool isUpgrade,
|
||||
int& status
|
||||
) override;
|
||||
std::unique_ptr<TRI_vocbase_t> createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& args,
|
||||
int& status
|
||||
) override;
|
||||
int writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
||||
velocypack::Slice const& slice) override;
|
||||
void prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker,
|
||||
int& status) override;
|
||||
Result dropDatabase(TRI_vocbase_t* database) override;
|
||||
void prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) override;
|
||||
Result dropDatabase(TRI_vocbase_t& database) override;
|
||||
void waitUntilDeletion(TRI_voc_tick_t id, bool force, int& status) override;
|
||||
|
||||
// wal in recovery
|
||||
|
@ -207,34 +231,34 @@ class ClusterEngine final : public StorageEngine {
|
|||
std::string createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
arangodb::Result persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
arangodb::Result dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) override;
|
||||
|
||||
arangodb::Result renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) override;
|
||||
|
||||
|
@ -247,7 +271,7 @@ class ClusterEngine final : public StorageEngine {
|
|||
|
||||
void unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void changeView(
|
||||
|
@ -265,7 +289,7 @@ class ClusterEngine final : public StorageEngine {
|
|||
|
||||
virtual void getViewProperties(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalView const* /*view*/,
|
||||
LogicalView const& /*view*/,
|
||||
VPackBuilder& /*builder*/
|
||||
) override {
|
||||
// does nothing
|
||||
|
@ -286,17 +310,17 @@ class ClusterEngine final : public StorageEngine {
|
|||
|
||||
arangodb::Result dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) override;
|
||||
|
||||
void destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) noexcept override;
|
||||
|
||||
void signalCleanup(TRI_vocbase_t* vocbase) override;
|
||||
void signalCleanup(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
int shutdownDatabase(TRI_vocbase_t* vocbase) override;
|
||||
int shutdownDatabase(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
/// @brief Add engine-specific AQL functions.
|
||||
void addAqlFunctions() override;
|
||||
|
@ -308,7 +332,7 @@ class ClusterEngine final : public StorageEngine {
|
|||
void addV8Functions() override;
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void addRestHandlers(rest::RestHandlerFactory*) override;
|
||||
void addRestHandlers(rest::RestHandlerFactory& handlerFactory) override;
|
||||
|
||||
void addParametersForNewCollection(arangodb::velocypack::Builder& builder,
|
||||
arangodb::velocypack::Slice info) override;
|
||||
|
@ -329,9 +353,12 @@ class ClusterEngine final : public StorageEngine {
|
|||
private:
|
||||
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown, bool isUpgrade);
|
||||
std::unique_ptr<TRI_vocbase_t> openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
);
|
||||
|
||||
public:
|
||||
static std::string const EngineName;
|
||||
|
|
|
@ -529,5 +529,5 @@ void GeneralServerFeature::defineHandlers() {
|
|||
// engine specific handlers
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
TRI_ASSERT(engine != nullptr); // Engine not loaded. Startup broken
|
||||
engine->addRestHandlers(_handlerFactory.get());
|
||||
engine->addRestHandlers(*_handlerFactory);
|
||||
}
|
||||
|
|
|
@ -960,7 +960,7 @@ IResearchView::~IResearchView() {
|
|||
if (deleted()) {
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
TRI_ASSERT(engine);
|
||||
engine->destroyView(vocbase(), this);
|
||||
engine->destroyView(vocbase(), *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -592,10 +592,11 @@ int MMFilesCollection::close() {
|
|||
application_features::ApplicationServer::getFeature<DatabaseFeature>(
|
||||
"Database")
|
||||
->forceSyncProperties();
|
||||
|
||||
engine->changeCollection(
|
||||
_logicalCollection->vocbase(),
|
||||
_logicalCollection->id(),
|
||||
_logicalCollection,
|
||||
*_logicalCollection,
|
||||
doSync
|
||||
);
|
||||
}
|
||||
|
@ -1839,10 +1840,11 @@ void MMFilesCollection::open(bool ignoreErrors) {
|
|||
"Database")
|
||||
->forceSyncProperties();
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
engine->changeCollection(
|
||||
_logicalCollection->vocbase(),
|
||||
_logicalCollection->id(),
|
||||
_logicalCollection,
|
||||
*_logicalCollection,
|
||||
doSync
|
||||
);
|
||||
}
|
||||
|
|
|
@ -157,7 +157,12 @@ std::string const MMFilesEngine::FeatureName("MMFilesEngine");
|
|||
|
||||
// create the storage engine
|
||||
MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server)
|
||||
: StorageEngine(server, EngineName, FeatureName, new MMFilesIndexFactory()),
|
||||
: StorageEngine(
|
||||
server,
|
||||
EngineName,
|
||||
FeatureName,
|
||||
std::unique_ptr<IndexFactory>(new MMFilesIndexFactory())
|
||||
),
|
||||
_isUpgrade(false),
|
||||
_maxTick(0),
|
||||
_walAccess(new MMFilesWalAccess()),
|
||||
|
@ -173,12 +178,12 @@ MMFilesEngine::MMFilesEngine(application_features::ApplicationServer* server)
|
|||
MMFilesEngine::~MMFilesEngine() {}
|
||||
|
||||
// perform a physical deletion of the database
|
||||
Result MMFilesEngine::dropDatabase(TRI_vocbase_t* database) {
|
||||
Result MMFilesEngine::dropDatabase(TRI_vocbase_t& database) {
|
||||
// drop logfile barriers for database
|
||||
MMFilesLogfileManager::instance()->dropLogfileBarriers(database->id());
|
||||
MMFilesLogfileManager::instance()->dropLogfileBarriers(database.id());
|
||||
|
||||
// delete persistent indexes for this database
|
||||
MMFilesPersistentIndexFeature::dropDatabase(database->id());
|
||||
MMFilesPersistentIndexFeature::dropDatabase(database.id());
|
||||
|
||||
// To shutdown the database (which destroys all LogicalCollection
|
||||
// objects of all collections) we need to make sure that the
|
||||
|
@ -186,9 +191,10 @@ Result MMFilesEngine::dropDatabase(TRI_vocbase_t* database) {
|
|||
// in a phase in which the collector thread does not have any
|
||||
// queued operations, a service which it offers:
|
||||
auto callback = [&database]() {
|
||||
database->shutdown();
|
||||
database.shutdown();
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(10000));
|
||||
};
|
||||
|
||||
while (
|
||||
!MMFilesLogfileManager::instance()->executeWhileNothingQueued(callback)) {
|
||||
LOG_TOPIC(TRACE, Logger::FIXME)
|
||||
|
@ -201,10 +207,10 @@ Result MMFilesEngine::dropDatabase(TRI_vocbase_t* database) {
|
|||
|
||||
{
|
||||
WRITE_LOCKER(locker, _pathsLock);
|
||||
_collectionPaths.erase(database->id());
|
||||
_collectionPaths.erase(database.id());
|
||||
}
|
||||
|
||||
return dropDatabaseDirectory(databaseDirectory(database->id()));
|
||||
return dropDatabaseDirectory(databaseDirectory(database.id()));
|
||||
}
|
||||
|
||||
// add the storage engine's specifc options to the global list of options
|
||||
|
@ -273,12 +279,14 @@ void MMFilesEngine::stop() {
|
|||
}
|
||||
}
|
||||
|
||||
TransactionManager* MMFilesEngine::createTransactionManager() {
|
||||
return new MMFilesTransactionManager();
|
||||
std::unique_ptr<TransactionManager> MMFilesEngine::createTransactionManager() {
|
||||
return std::unique_ptr<TransactionManager>(new MMFilesTransactionManager());
|
||||
}
|
||||
|
||||
transaction::ContextData* MMFilesEngine::createTransactionContextData() {
|
||||
return new MMFilesTransactionContextData();
|
||||
std::unique_ptr<transaction::ContextData> MMFilesEngine::createTransactionContextData() {
|
||||
return std::unique_ptr<transaction::ContextData>(
|
||||
new MMFilesTransactionContextData()
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<TransactionState> MMFilesEngine::createTransactionState(
|
||||
|
@ -290,17 +298,27 @@ std::unique_ptr<TransactionState> MMFilesEngine::createTransactionState(
|
|||
);
|
||||
}
|
||||
|
||||
TransactionCollection* MMFilesEngine::createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) {
|
||||
return new MMFilesTransactionCollection(state, cid, accessType, nestingLevel);
|
||||
std::unique_ptr<TransactionCollection> MMFilesEngine::createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) {
|
||||
return std::unique_ptr<TransactionCollection>(
|
||||
new MMFilesTransactionCollection(&state, cid, accessType, nestingLevel)
|
||||
);
|
||||
}
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* MMFilesEngine::createPhysicalCollection(
|
||||
LogicalCollection* collection, VPackSlice const& info) {
|
||||
std::unique_ptr<PhysicalCollection> MMFilesEngine::createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) {
|
||||
TRI_ASSERT(EngineSelectorFeature::ENGINE == this);
|
||||
return new MMFilesCollection(collection, info);
|
||||
|
||||
return std::unique_ptr<PhysicalCollection>(
|
||||
new MMFilesCollection(&collection, info)
|
||||
);
|
||||
}
|
||||
|
||||
void MMFilesEngine::recoveryDone(TRI_vocbase_t& vocbase) {
|
||||
|
@ -737,7 +755,7 @@ Result MMFilesEngine::flushWal(bool waitForSync, bool waitForCollector,
|
|||
waitForSync, waitForCollector, writeShutdownFile);
|
||||
}
|
||||
|
||||
TRI_vocbase_t* MMFilesEngine::openDatabase(
|
||||
std::unique_ptr<TRI_vocbase_t> MMFilesEngine::openDatabase(
|
||||
arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) {
|
||||
VPackSlice idSlice = args.get("id");
|
||||
TRI_voc_tick_t id = static_cast<TRI_voc_tick_t>(
|
||||
|
@ -751,7 +769,7 @@ TRI_vocbase_t* MMFilesEngine::openDatabase(
|
|||
return openExistingDatabase(id, name, wasCleanShutdown, isUpgrade);
|
||||
}
|
||||
|
||||
TRI_vocbase_t* MMFilesEngine::createDatabaseMMFiles(
|
||||
std::unique_ptr<TRI_vocbase_t> MMFilesEngine::createDatabaseMMFiles(
|
||||
TRI_voc_tick_t id, arangodb::velocypack::Slice const& data) {
|
||||
std::string const name = data.get("name").copyString();
|
||||
|
||||
|
@ -767,17 +785,18 @@ TRI_vocbase_t* MMFilesEngine::createDatabaseMMFiles(
|
|||
return openExistingDatabase(id, name, true, false);
|
||||
}
|
||||
|
||||
void MMFilesEngine::prepareDropDatabase(TRI_vocbase_t* vocbase,
|
||||
bool useWriteMarker, int& status) {
|
||||
// signal the compactor thread to finish
|
||||
beginShutdownCompactor(vocbase);
|
||||
|
||||
status = saveDatabaseParameters(vocbase->id(), vocbase->name(), true);
|
||||
void MMFilesEngine::prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) {
|
||||
beginShutdownCompactor(&vocbase); // signal the compactor thread to finish
|
||||
status = saveDatabaseParameters(vocbase.id(), vocbase.name(), true);
|
||||
|
||||
if (status == TRI_ERROR_NO_ERROR) {
|
||||
if (useWriteMarker) {
|
||||
// TODO: what shall happen in case writeDropMarker() fails?
|
||||
writeDropMarker(vocbase->id(), vocbase->name());
|
||||
writeDropMarker(vocbase.id(), vocbase.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -839,16 +858,16 @@ void MMFilesEngine::waitUntilDeletion(TRI_voc_tick_t id, bool force,
|
|||
std::string MMFilesEngine::createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* parameters
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
auto path = databasePath(&vocbase);
|
||||
|
||||
// sanity check
|
||||
if (sizeof(MMFilesDatafileHeaderMarker) + sizeof(MMFilesDatafileFooterMarker) >
|
||||
static_cast<MMFilesCollection*>(parameters->getPhysical())->journalSize()) {
|
||||
static_cast<MMFilesCollection*>(collection.getPhysical())->journalSize()) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "cannot create datafile '" << parameters->name() << "' in '" << path
|
||||
<< "', journal size '" << static_cast<MMFilesCollection*>(parameters->getPhysical())->journalSize()
|
||||
<< "cannot create datafile '" << collection.name() << "' in '" << path
|
||||
<< "', journal size '" << static_cast<MMFilesCollection*>(collection.getPhysical())->journalSize()
|
||||
<< "' is too small";
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_ARANGO_DATAFILE_FULL);
|
||||
}
|
||||
|
@ -868,7 +887,7 @@ std::string MMFilesEngine::createCollection(
|
|||
// directory must not exist
|
||||
if (TRI_ExistsFile(dirname.c_str())) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "cannot create collection '" << parameters->name()
|
||||
<< "cannot create collection '" << collection.name()
|
||||
<< "' in directory '" << dirname << "': directory already exists";
|
||||
THROW_ARANGO_EXCEPTION(
|
||||
TRI_ERROR_ARANGO_COLLECTION_DIRECTORY_ALREADY_EXISTS);
|
||||
|
@ -885,7 +904,7 @@ std::string MMFilesEngine::createCollection(
|
|||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "cannot create collection '" << parameters->name()
|
||||
<< "cannot create collection '" << collection.name()
|
||||
<< "' in directory '" << path << "': " << TRI_errno_string(res) << " - "
|
||||
<< systemError << " - " << errorMessage;
|
||||
THROW_ARANGO_EXCEPTION(res);
|
||||
|
@ -910,7 +929,7 @@ std::string MMFilesEngine::createCollection(
|
|||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "cannot create collection '" << parameters->name()
|
||||
<< "cannot create collection '" << collection.name()
|
||||
<< "' in directory '" << path << "': " << TRI_errno_string(res) << " - "
|
||||
<< systemError << " - " << errorMessage;
|
||||
TRI_RemoveDirectory(tmpname.c_str());
|
||||
|
@ -925,7 +944,7 @@ std::string MMFilesEngine::createCollection(
|
|||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME)
|
||||
<< "cannot create collection '" << parameters->name()
|
||||
<< "cannot create collection '" << collection.name()
|
||||
<< "' in directory '" << path << "': " << TRI_errno_string(res) << " - "
|
||||
<< systemError << " - " << errorMessage;
|
||||
TRI_RemoveDirectory(tmpname.c_str());
|
||||
|
@ -944,7 +963,7 @@ std::string MMFilesEngine::createCollection(
|
|||
"Database")
|
||||
->forceSyncProperties();
|
||||
|
||||
saveCollectionInfo(&vocbase, id, parameters, doSync);
|
||||
saveCollectionInfo(&vocbase, id, &collection, doSync);
|
||||
|
||||
return dirname;
|
||||
}
|
||||
|
@ -954,19 +973,18 @@ std::string MMFilesEngine::createCollection(
|
|||
// This call will write wal markers.
|
||||
arangodb::Result MMFilesEngine::persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
||||
if (inRecovery()) {
|
||||
// Nothing to do. In recovery we do not write markers.
|
||||
return {};
|
||||
}
|
||||
VPackBuilder builder =
|
||||
collection->toVelocyPackIgnore({"path", "statusString"}, true, false);
|
||||
collection.toVelocyPackIgnore({"path", "statusString"}, true, false);
|
||||
VPackSlice const slice = builder.slice();
|
||||
|
||||
auto cid = collection->id();
|
||||
auto cid = collection.id();
|
||||
|
||||
TRI_ASSERT(cid != 0);
|
||||
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(cid));
|
||||
|
||||
|
@ -1004,26 +1022,28 @@ arangodb::Result MMFilesEngine::persistCollection(
|
|||
// This call will write the WAL entry for collection deletion
|
||||
arangodb::Result MMFilesEngine::dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
if (inRecovery()) {
|
||||
// nothing to do here
|
||||
return {};
|
||||
}
|
||||
|
||||
int res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
try {
|
||||
VPackBuilder builder;
|
||||
|
||||
builder.openObject();
|
||||
builder.add("id", VPackValue(std::to_string(collection->id())));
|
||||
builder.add("name", VPackValue(collection->name()));
|
||||
builder.add("cuid", VPackValue(collection->guid()));
|
||||
builder.add("id", velocypack::Value(std::to_string(collection.id())));
|
||||
builder.add("name", velocypack::Value(collection.name()));
|
||||
builder.add("cuid", velocypack::Value(collection.guid()));
|
||||
builder.close();
|
||||
|
||||
MMFilesCollectionMarker marker(
|
||||
TRI_DF_MARKER_VPACK_DROP_COLLECTION,
|
||||
vocbase.id(),
|
||||
collection->id(),
|
||||
collection.id(),
|
||||
builder.slice()
|
||||
);
|
||||
MMFilesWalSlotInfoCopy slotInfo =
|
||||
|
@ -1052,16 +1072,17 @@ arangodb::Result MMFilesEngine::dropCollection(
|
|||
// assured that no one is using the collection anymore
|
||||
void MMFilesEngine::destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
std::string const name(collection->name());
|
||||
auto physical = static_cast<MMFilesCollection*>(collection->getPhysical());
|
||||
auto& name = collection.name();
|
||||
auto* physical = static_cast<MMFilesCollection*>(collection.getPhysical());
|
||||
|
||||
TRI_ASSERT(physical != nullptr);
|
||||
|
||||
unregisterCollectionPath(vocbase.id(), collection->id());
|
||||
unregisterCollectionPath(vocbase.id(), collection.id());
|
||||
|
||||
// delete persistent indexes
|
||||
MMFilesPersistentIndexFeature::dropCollection(vocbase.id(), collection->id());
|
||||
MMFilesPersistentIndexFeature::dropCollection(vocbase.id(), collection.id());
|
||||
|
||||
// rename collection directory
|
||||
if (physical->path().empty()) {
|
||||
|
@ -1158,17 +1179,17 @@ void MMFilesEngine::destroyCollection(
|
|||
void MMFilesEngine::changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* parameters,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) {
|
||||
saveCollectionInfo(&vocbase, id, parameters, doSync);
|
||||
saveCollectionInfo(&vocbase, id, &collection, doSync);
|
||||
}
|
||||
|
||||
// asks the storage engine to persist renaming of a collection
|
||||
// This will write a renameMarker if not in recovery
|
||||
Result MMFilesEngine::renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) {
|
||||
if (inRecovery()) {
|
||||
|
@ -1180,16 +1201,17 @@ Result MMFilesEngine::renameCollection(
|
|||
|
||||
try {
|
||||
VPackBuilder builder;
|
||||
|
||||
builder.openObject();
|
||||
builder.add("id", VPackValue(std::to_string(collection->id())));
|
||||
builder.add("id", velocypack::Value(std::to_string(collection.id())));
|
||||
builder.add("oldName", VPackValue(oldName));
|
||||
builder.add("name", VPackValue(collection->name()));
|
||||
builder.add("name", velocypack::Value(collection.name()));
|
||||
builder.close();
|
||||
|
||||
MMFilesCollectionMarker marker(
|
||||
TRI_DF_MARKER_VPACK_RENAME_COLLECTION,
|
||||
vocbase.id(),
|
||||
collection->id(),
|
||||
collection.id(),
|
||||
builder.slice()
|
||||
);
|
||||
MMFilesWalSlotInfoCopy slotInfo =
|
||||
|
@ -1367,11 +1389,11 @@ void MMFilesEngine::createView(
|
|||
|
||||
void MMFilesEngine::getViewProperties(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView const* view,
|
||||
LogicalView const& view,
|
||||
VPackBuilder& result
|
||||
) {
|
||||
TRI_ASSERT(result.isOpenObject());
|
||||
result.add("path", VPackValue(viewDirectory(vocbase.id(), view->id())));
|
||||
result.add("path", velocypack::Value(viewDirectory(vocbase.id(), view.id())));
|
||||
}
|
||||
|
||||
arangodb::Result MMFilesEngine::persistView(
|
||||
|
@ -1423,27 +1445,30 @@ arangodb::Result MMFilesEngine::persistView(
|
|||
|
||||
arangodb::Result MMFilesEngine::dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view) {
|
||||
LogicalView& view
|
||||
) {
|
||||
auto* db = application_features::ApplicationServer::getFeature<DatabaseFeature>("Database");
|
||||
|
||||
TRI_ASSERT(db);
|
||||
saveViewInfo(&vocbase, view->id(), view, db->forceSyncProperties());
|
||||
saveViewInfo(&vocbase, view.id(), &view, db->forceSyncProperties());
|
||||
|
||||
if (inRecovery()) {
|
||||
// nothing to do here
|
||||
return {};
|
||||
}
|
||||
|
||||
int res = TRI_ERROR_NO_ERROR;
|
||||
|
||||
try {
|
||||
VPackBuilder builder;
|
||||
|
||||
builder.openObject();
|
||||
builder.add("id", VPackValue(std::to_string(view->id())));
|
||||
builder.add("name", VPackValue(view->name()));
|
||||
builder.add("id", velocypack::Value(std::to_string(view.id())));
|
||||
builder.add("name", velocypack::Value(view.name()));
|
||||
builder.close();
|
||||
|
||||
MMFilesViewMarker marker(
|
||||
TRI_DF_MARKER_VPACK_DROP_VIEW, vocbase.id(), view->id(), builder.slice()
|
||||
TRI_DF_MARKER_VPACK_DROP_VIEW, vocbase.id(), view.id(), builder.slice()
|
||||
);
|
||||
MMFilesWalSlotInfoCopy slotInfo =
|
||||
MMFilesLogfileManager::instance()->allocateAndWrite(marker, false);
|
||||
|
@ -1467,9 +1492,10 @@ arangodb::Result MMFilesEngine::dropView(
|
|||
|
||||
void MMFilesEngine::destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view) noexcept {
|
||||
LogicalView& view
|
||||
) noexcept {
|
||||
try {
|
||||
auto directory = viewDirectory(vocbase.id(), view->id());
|
||||
auto directory = viewDirectory(vocbase.id(), view.id());
|
||||
|
||||
if (directory.empty()) {
|
||||
return;
|
||||
|
@ -1667,21 +1693,21 @@ static bool UnloadCollectionCallback(LogicalCollection* collection) {
|
|||
|
||||
void MMFilesEngine::unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
// add callback for unload
|
||||
arangodb::MMFilesCollection::toMMFilesCollection(collection)
|
||||
->ditches()
|
||||
->createMMFilesUnloadCollectionDitch(collection, UnloadCollectionCallback,
|
||||
__FILE__, __LINE__);
|
||||
arangodb::MMFilesCollection::toMMFilesCollection(&collection)
|
||||
->ditches()
|
||||
->createMMFilesUnloadCollectionDitch(
|
||||
&collection, UnloadCollectionCallback, __FILE__, __LINE__
|
||||
);
|
||||
|
||||
signalCleanup(&vocbase);
|
||||
signalCleanup(vocbase);
|
||||
}
|
||||
|
||||
void MMFilesEngine::signalCleanup(TRI_vocbase_t* vocbase) {
|
||||
void MMFilesEngine::signalCleanup(TRI_vocbase_t& vocbase) {
|
||||
MUTEX_LOCKER(locker, _threadsLock);
|
||||
|
||||
auto it = _cleanupThreads.find(vocbase);
|
||||
auto it = _cleanupThreads.find(&vocbase);
|
||||
|
||||
if (it == _cleanupThreads.end()) {
|
||||
return;
|
||||
|
@ -2077,10 +2103,12 @@ std::string MMFilesEngine::indexFilename(TRI_idx_iid_t id) const {
|
|||
}
|
||||
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* MMFilesEngine::openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade) {
|
||||
std::unique_ptr<TRI_vocbase_t> MMFilesEngine::openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
) {
|
||||
auto vocbase = std::make_unique<TRI_vocbase_t>(
|
||||
TRI_VOCBASE_TYPE_NORMAL, id, name
|
||||
);
|
||||
|
@ -2182,7 +2210,7 @@ TRI_vocbase_t* MMFilesEngine::openExistingDatabase(TRI_voc_tick_t id,
|
|||
// start cleanup thread
|
||||
startCleanup(vocbase.get());
|
||||
|
||||
return vocbase.release();
|
||||
return vocbase;
|
||||
} catch (std::exception const& ex) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "error while opening database collections: "
|
||||
<< ex.what();
|
||||
|
@ -2682,10 +2710,11 @@ bool MMFilesEngine::tryPreventCompaction(
|
|||
return false;
|
||||
}
|
||||
|
||||
int MMFilesEngine::shutdownDatabase(TRI_vocbase_t* vocbase) {
|
||||
int MMFilesEngine::shutdownDatabase(TRI_vocbase_t& vocbase) {
|
||||
try {
|
||||
stopCompactor(vocbase);
|
||||
return stopCleanup(vocbase);
|
||||
stopCompactor(&vocbase);
|
||||
|
||||
return stopCleanup(&vocbase);
|
||||
} catch (basics::Exception const& ex) {
|
||||
return ex.code();
|
||||
} catch (...) {
|
||||
|
@ -3170,8 +3199,8 @@ void MMFilesEngine::addV8Functions() {
|
|||
}
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void MMFilesEngine::addRestHandlers(rest::RestHandlerFactory* handlerFactory) {
|
||||
MMFilesRestHandlers::registerResources(handlerFactory);
|
||||
void MMFilesEngine::addRestHandlers(rest::RestHandlerFactory& handlerFactory) {
|
||||
MMFilesRestHandlers::registerResources(&handlerFactory);
|
||||
}
|
||||
|
||||
/// @brief transfer markers into a collection, actual work
|
||||
|
@ -3409,8 +3438,13 @@ int MMFilesEngine::writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
|||
return res;
|
||||
}
|
||||
|
||||
VPackBuilder MMFilesEngine::getReplicationApplierConfiguration(TRI_vocbase_t* vocbase, int& status) {
|
||||
std::string const filename = arangodb::basics::FileUtils::buildFilename(databasePath(vocbase), "REPLICATION-APPLIER-CONFIG");
|
||||
VPackBuilder MMFilesEngine::getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) {
|
||||
auto filename = arangodb::basics::FileUtils::buildFilename(
|
||||
databasePath(&vocbase), "REPLICATION-APPLIER-CONFIG"
|
||||
);
|
||||
|
||||
return getReplicationApplierConfiguration(filename, status);
|
||||
}
|
||||
|
@ -3449,8 +3483,13 @@ VPackBuilder MMFilesEngine::getReplicationApplierConfiguration(std::string const
|
|||
return builder;
|
||||
}
|
||||
|
||||
int MMFilesEngine::removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) {
|
||||
std::string const filename = arangodb::basics::FileUtils::buildFilename(databasePath(vocbase), "REPLICATION-APPLIER-CONFIG");
|
||||
int MMFilesEngine::removeReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase
|
||||
) {
|
||||
auto filename = arangodb::basics::FileUtils::buildFilename(
|
||||
databasePath(&vocbase), "REPLICATION-APPLIER-CONFIG"
|
||||
);
|
||||
|
||||
return removeReplicationApplierConfiguration(filename);
|
||||
}
|
||||
|
||||
|
@ -3467,8 +3506,15 @@ int MMFilesEngine::removeReplicationApplierConfiguration(std::string const& file
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
int MMFilesEngine::saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase, arangodb::velocypack::Slice slice, bool doSync) {
|
||||
std::string const filename = arangodb::basics::FileUtils::buildFilename(databasePath(vocbase), "REPLICATION-APPLIER-CONFIG");
|
||||
int MMFilesEngine::saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) {
|
||||
auto filename = arangodb::basics::FileUtils::buildFilename(
|
||||
databasePath(&vocbase), "REPLICATION-APPLIER-CONFIG"
|
||||
);
|
||||
|
||||
return saveReplicationApplierConfiguration(filename, slice, doSync);
|
||||
}
|
||||
|
||||
|
@ -3485,10 +3531,12 @@ int MMFilesEngine::saveReplicationApplierConfiguration(std::string const& filena
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
Result MMFilesEngine::handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) {
|
||||
return handleSyncKeysMMFiles(syncer, col, keysId);
|
||||
Result MMFilesEngine::handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) {
|
||||
return handleSyncKeysMMFiles(syncer, &col, keysId);
|
||||
}
|
||||
|
||||
Result MMFilesEngine::createLoggerState(TRI_vocbase_t* vocbase, VPackBuilder& builder){
|
||||
|
@ -3567,8 +3615,13 @@ Result MMFilesEngine::firstTick(uint64_t& tick){
|
|||
return Result{};
|
||||
};
|
||||
|
||||
Result MMFilesEngine::lastLogger(TRI_vocbase_t* /*vocbase*/, std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart, uint64_t tickEnd, std::shared_ptr<VPackBuilder>& builderSPtr) {
|
||||
Result MMFilesEngine::lastLogger(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<VPackBuilder>& builderSPtr
|
||||
) {
|
||||
Result res{};
|
||||
MMFilesReplicationDumpContext dump(transactionContext, 0, true, 0);
|
||||
int r = MMFilesDumpLogReplication(&dump, std::unordered_set<TRI_voc_tid_t>(),
|
||||
|
@ -3607,4 +3660,4 @@ WalAccess const* MMFilesEngine::walAccess() const {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
|
@ -98,39 +98,56 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
bool useRawDocumentPointers() override { return true; }
|
||||
|
||||
velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
int& status) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(int& status) override;
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) override;
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t& vocbase) override;
|
||||
int removeReplicationApplierConfiguration() override;
|
||||
int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
arangodb::velocypack::Slice slice,
|
||||
bool doSync) override;
|
||||
int saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) override;
|
||||
int saveReplicationApplierConfiguration(arangodb::velocypack::Slice slice,
|
||||
bool doSync) override;
|
||||
Result handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) override;
|
||||
Result handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) override;
|
||||
|
||||
Result createLoggerState(TRI_vocbase_t* vocbase, VPackBuilder& builder) override;
|
||||
Result createTickRanges(VPackBuilder& builder) override;
|
||||
Result firstTick(uint64_t& tick) override;
|
||||
Result lastLogger(TRI_vocbase_t* vocbase, std::shared_ptr<transaction::Context>, uint64_t tickStart, uint64_t tickEnd, std::shared_ptr<VPackBuilder>& builderSPtr) override;
|
||||
Result lastLogger(
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<VPackBuilder>& builderSPtr
|
||||
) override;
|
||||
WalAccess const* walAccess() const override;
|
||||
|
||||
TransactionManager* createTransactionManager() override;
|
||||
transaction::ContextData* createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionManager> createTransactionManager() override;
|
||||
std::unique_ptr<transaction::ContextData> createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionState> createTransactionState(
|
||||
CollectionNameResolver const& resolver,
|
||||
transaction::Options const& options
|
||||
) override;
|
||||
TransactionCollection* createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) override;
|
||||
std::unique_ptr<TransactionCollection> createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) override;
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* createPhysicalCollection(LogicalCollection*,
|
||||
VPackSlice const&) override;
|
||||
std::unique_ptr<PhysicalCollection> createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) override;
|
||||
|
||||
// inventory functionality
|
||||
// -----------------------
|
||||
|
@ -167,9 +184,11 @@ class MMFilesEngine final : public StorageEngine {
|
|||
) override;
|
||||
|
||||
// return the path for a collection
|
||||
std::string collectionPath(TRI_vocbase_t const* vocbase,
|
||||
TRI_voc_cid_t id) const override {
|
||||
return collectionDirectory(vocbase->id(), id);
|
||||
std::string collectionPath(
|
||||
TRI_vocbase_t const& vocbase,
|
||||
TRI_voc_cid_t id
|
||||
) const override {
|
||||
return collectionDirectory(vocbase.id(), id);
|
||||
}
|
||||
|
||||
// database, collection and index management
|
||||
|
@ -191,21 +210,26 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
void waitForEstimatorSync(std::chrono::milliseconds maxWaitTime) override {}
|
||||
|
||||
virtual TRI_vocbase_t* openDatabase(
|
||||
virtual std::unique_ptr<TRI_vocbase_t> openDatabase(
|
||||
arangodb::velocypack::Slice const& parameters, bool isUpgrade,
|
||||
int&) override;
|
||||
TRI_vocbase_t* createDatabase(TRI_voc_tick_t id,
|
||||
arangodb::velocypack::Slice const& args,
|
||||
int& status) override {
|
||||
std::unique_ptr<TRI_vocbase_t> createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& args,
|
||||
int& status
|
||||
) override {
|
||||
status = TRI_ERROR_NO_ERROR;
|
||||
return createDatabaseMMFiles(id, args);
|
||||
}
|
||||
int writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
||||
VPackSlice const& slice) override;
|
||||
|
||||
void prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker,
|
||||
int& status) override;
|
||||
Result dropDatabase(TRI_vocbase_t* database) override;
|
||||
void prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) override;
|
||||
Result dropDatabase(TRI_vocbase_t& database) override;
|
||||
void waitUntilDeletion(TRI_voc_tick_t id, bool force, int& status) override;
|
||||
|
||||
// wal in recovery
|
||||
|
@ -216,8 +240,10 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
private:
|
||||
int dropDatabaseMMFiles(TRI_vocbase_t* vocbase);
|
||||
TRI_vocbase_t* createDatabaseMMFiles(TRI_voc_tick_t id,
|
||||
arangodb::velocypack::Slice const& data);
|
||||
std::unique_ptr<TRI_vocbase_t> createDatabaseMMFiles(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& data
|
||||
);
|
||||
|
||||
public:
|
||||
// asks the storage engine to create a collection as specified in the VPack
|
||||
|
@ -233,7 +259,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
std::string createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
// asks the storage engine to persist the collection.
|
||||
|
@ -241,7 +267,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
// This call will write wal markers.
|
||||
arangodb::Result persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
// asks the storage engine to drop the specified collection and persist the
|
||||
|
@ -251,7 +277,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
// This call will write the WAL entry for collection deletion
|
||||
arangodb::Result dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
// perform a physical deletion of the collection
|
||||
|
@ -259,7 +285,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
// assured that no one is using the collection anymore
|
||||
void destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
// asks the storage engine to change properties of the collection as specified
|
||||
|
@ -273,7 +299,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
void changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) override;
|
||||
|
||||
|
@ -281,7 +307,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
// This will write a renameMarker if not in recovery
|
||||
arangodb::Result renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) override;
|
||||
|
||||
|
@ -322,7 +348,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
void unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void changeView(
|
||||
|
@ -340,7 +366,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
void getViewProperties(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView const* view,
|
||||
LogicalView const& view,
|
||||
VPackBuilder& builder
|
||||
) override;
|
||||
|
||||
|
@ -359,12 +385,12 @@ class MMFilesEngine final : public StorageEngine {
|
|||
|
||||
arangodb::Result dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) override;
|
||||
|
||||
void destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) noexcept override;
|
||||
|
||||
std::string createViewDirectoryName(std::string const& basePath,
|
||||
|
@ -373,7 +399,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
void saveViewInfo(TRI_vocbase_t* vocbase, TRI_voc_cid_t id,
|
||||
arangodb::LogicalView const*, bool forceSync) const;
|
||||
|
||||
void signalCleanup(TRI_vocbase_t* vocbase) override;
|
||||
void signalCleanup(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
/// @brief scans a collection and locates all files
|
||||
MMFilesEngineCollectionFiles scanCollectionDirectory(std::string const& path);
|
||||
|
@ -404,7 +430,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
std::function<void(TRI_vocbase_t*)> const& callback,
|
||||
bool checkForActiveBlockers);
|
||||
|
||||
int shutdownDatabase(TRI_vocbase_t* vocbase) override;
|
||||
int shutdownDatabase(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
int openCollection(TRI_vocbase_t* vocbase, LogicalCollection* collection,
|
||||
bool ignoreErrors);
|
||||
|
@ -419,7 +445,7 @@ class MMFilesEngine final : public StorageEngine {
|
|||
void addV8Functions() override;
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void addRestHandlers(rest::RestHandlerFactory*) override;
|
||||
void addRestHandlers(rest::RestHandlerFactory&) override;
|
||||
|
||||
/// @brief transfer markers into a collection
|
||||
int transferMarkers(LogicalCollection* collection, MMFilesCollectorCache*,
|
||||
|
@ -487,9 +513,12 @@ class MMFilesEngine final : public StorageEngine {
|
|||
std::string indexFilename(TRI_idx_iid_t indexId) const;
|
||||
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown, bool isUpgrade);
|
||||
std::unique_ptr<TRI_vocbase_t> openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
);
|
||||
|
||||
/// @brief note the maximum local tick
|
||||
void noteTick(TRI_voc_tick_t tick) {
|
||||
|
|
|
@ -788,7 +788,9 @@ Result DatabaseInitialSyncer::fetchCollectionSync(arangodb::LogicalCollection* c
|
|||
|
||||
// now we can fetch the complete chunk information from the master
|
||||
try {
|
||||
return EngineSelectorFeature::ENGINE->handleSyncKeys(*this, coll, keysId.copyString());
|
||||
return EngineSelectorFeature::ENGINE->handleSyncKeys(
|
||||
*this, *coll, keysId.copyString()
|
||||
);
|
||||
} catch (arangodb::basics::Exception const& ex) {
|
||||
return Result(ex.code(), ex.what());
|
||||
} catch (std::exception const& ex) {
|
||||
|
|
|
@ -91,7 +91,7 @@ void DatabaseReplicationApplier::forget() {
|
|||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
engine->removeReplicationApplierConfiguration(&_vocbase);
|
||||
engine->removeReplicationApplierConfiguration(_vocbase);
|
||||
_configuration.reset();
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ void DatabaseReplicationApplier::forget() {
|
|||
|
||||
if (vocbase.type() == TRI_VOCBASE_TYPE_NORMAL) {
|
||||
applier = std::make_unique<DatabaseReplicationApplier>(
|
||||
DatabaseReplicationApplier::loadConfiguration(&vocbase), vocbase
|
||||
DatabaseReplicationApplier::loadConfiguration(vocbase), vocbase
|
||||
);
|
||||
applier->loadState();
|
||||
} else {
|
||||
|
@ -114,7 +114,9 @@ void DatabaseReplicationApplier::forget() {
|
|||
}
|
||||
|
||||
/// @brief load a persisted configuration for the applier
|
||||
ReplicationApplierConfiguration DatabaseReplicationApplier::loadConfiguration(TRI_vocbase_t* vocbase) {
|
||||
ReplicationApplierConfiguration DatabaseReplicationApplier::loadConfiguration(
|
||||
TRI_vocbase_t& vocbase
|
||||
) {
|
||||
// TODO: move to ReplicationApplier
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
int res = TRI_ERROR_INTERNAL;
|
||||
|
@ -128,7 +130,9 @@ ReplicationApplierConfiguration DatabaseReplicationApplier::loadConfiguration(TR
|
|||
|
||||
TRI_ASSERT(!builder.isEmpty());
|
||||
|
||||
return ReplicationApplierConfiguration::fromVelocyPack(builder.slice(), vocbase->name());
|
||||
return ReplicationApplierConfiguration::fromVelocyPack(
|
||||
builder.slice(), vocbase.name()
|
||||
);
|
||||
}
|
||||
|
||||
/// @brief store the configuration for the applier
|
||||
|
@ -147,7 +151,7 @@ void DatabaseReplicationApplier::storeConfiguration(bool doSync) {
|
|||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
int res = engine->saveReplicationApplierConfiguration(
|
||||
&_vocbase, builder.slice(), doSync
|
||||
_vocbase, builder.slice(), doSync
|
||||
);
|
||||
|
||||
if (res != TRI_ERROR_NO_ERROR) {
|
||||
|
|
|
@ -66,7 +66,9 @@ class DatabaseReplicationApplier final : public ReplicationApplier {
|
|||
static DatabaseReplicationApplier* create(TRI_vocbase_t& vocbase);
|
||||
|
||||
/// @brief load a persisted configuration for the applier
|
||||
static ReplicationApplierConfiguration loadConfiguration(TRI_vocbase_t* vocbase);
|
||||
static ReplicationApplierConfiguration loadConfiguration(
|
||||
TRI_vocbase_t& vocbase
|
||||
);
|
||||
|
||||
std::unique_ptr<InitialSyncer> buildInitialSyncer() const override;
|
||||
std::unique_ptr<TailingSyncer> buildTailingSyncer(TRI_voc_tick_t initialTick, bool useTick, TRI_voc_tick_t barrierId) const override;
|
||||
|
|
|
@ -207,10 +207,10 @@ Result GlobalInitialSyncer::runInternal(bool incremental) {
|
|||
/// @brief add or remove databases such that the local inventory mirrors the masters
|
||||
Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& masterDatabases) {
|
||||
std::set<std::string> existingDBs;
|
||||
DatabaseFeature::DATABASE->enumerateDatabases([&](TRI_vocbase_t* vocbase) {
|
||||
existingDBs.insert(vocbase->name());
|
||||
});
|
||||
|
||||
DatabaseFeature::DATABASE->enumerateDatabases(
|
||||
[&](TRI_vocbase_t& vocbase)->void { existingDBs.insert(vocbase.name()); }
|
||||
);
|
||||
|
||||
for (auto const& database : VPackObjectIterator(masterDatabases)) {
|
||||
VPackSlice it = database.value;
|
||||
|
||||
|
@ -218,18 +218,21 @@ Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& masterDataba
|
|||
return Result(TRI_ERROR_REPLICATION_INVALID_RESPONSE,
|
||||
"database declaration is invalid in response");
|
||||
}
|
||||
|
||||
|
||||
VPackSlice const nameSlice = it.get("name");
|
||||
VPackSlice const idSlice = it.get("id");
|
||||
VPackSlice const collections = it.get("collections");
|
||||
|
||||
if (!nameSlice.isString() ||
|
||||
!idSlice.isString() ||
|
||||
!collections.isArray()) {
|
||||
return Result(TRI_ERROR_REPLICATION_INVALID_RESPONSE,
|
||||
"database declaration is invalid in response");
|
||||
}
|
||||
|
||||
std::string const dbName = nameSlice.copyString();
|
||||
TRI_vocbase_t* vocbase = resolveVocbase(nameSlice);
|
||||
|
||||
if (vocbase == nullptr) {
|
||||
// database is missing. we need to create it now
|
||||
Result r = methods::Databases::create(dbName, VPackSlice::emptyArraySlice(),
|
||||
|
@ -306,28 +309,30 @@ Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& masterDataba
|
|||
|
||||
TRI_vocbase_t* system = DatabaseFeature::DATABASE->systemDatabase();
|
||||
Result r = methods::Databases::drop(system, dbname);
|
||||
|
||||
if (r.fail()) {
|
||||
LOG_TOPIC(WARN, Logger::REPLICATION) << "Dropping db failed on replicant";
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
sendExtendBatch();
|
||||
sendExtendBarrier();
|
||||
}
|
||||
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
Result GlobalInitialSyncer::fetchInventory(VPackBuilder& builder) {
|
||||
std::string url = ReplicationUrl + "/inventory?serverId=" + _localServerIdString +
|
||||
"&batchId=" + std::to_string(_batchId) + "&global=true";
|
||||
|
||||
if (_configuration._includeSystem) {
|
||||
url += "&includeSystem=true";
|
||||
}
|
||||
|
||||
|
||||
// send request
|
||||
std::unique_ptr<SimpleHttpResult> response(_client->retryRequest(rest::RequestType::GET, url, nullptr, 0));
|
||||
|
||||
|
||||
if (hasFailed(response.get())) {
|
||||
sendFinishBatch();
|
||||
return buildHttpError(response.get(), url);
|
||||
|
@ -339,8 +344,9 @@ Result GlobalInitialSyncer::fetchInventory(VPackBuilder& builder) {
|
|||
return Result(r.errorNumber(), std::string("got invalid response from master at ") + _masterInfo._endpoint +
|
||||
": invalid response type for initial data. expecting array");
|
||||
}
|
||||
|
||||
|
||||
VPackSlice const slice = builder.slice();
|
||||
|
||||
if (!slice.isObject()) {
|
||||
LOG_TOPIC(DEBUG, Logger::REPLICATION) << "client: InitialSyncer::run - inventoryResponse is not an object";
|
||||
return Result(TRI_ERROR_REPLICATION_INVALID_RESPONSE, std::string("got invalid response from master at ") +
|
||||
|
|
|
@ -181,33 +181,46 @@ void RestUsersHandler::generateDatabaseResult(auth::UserManager* um,
|
|||
VPackBuilder data;
|
||||
data.openObject();
|
||||
Result res = um->accessUser(username, [&](auth::User const& user) {
|
||||
DatabaseFeature::DATABASE->enumerateDatabases([&](TRI_vocbase_t* vocbase) {
|
||||
|
||||
if (full) {
|
||||
auth::Level lvl = user.configuredDBAuthLevel(vocbase->name());
|
||||
std::string str = convertFromAuthLevel(lvl);
|
||||
VPackObjectBuilder b(&data, vocbase->name(), true);
|
||||
data.add("permission", VPackValue(str));
|
||||
VPackObjectBuilder b2(&data, "collections", true);
|
||||
methods::Collections::enumerate(
|
||||
vocbase, [&](LogicalCollection* c) {
|
||||
lvl = user.configuredCollectionAuthLevel(vocbase->name(), c->name());
|
||||
data.add(c->name(), VPackValue(convertFromAuthLevel(lvl)));
|
||||
});
|
||||
lvl = user.configuredCollectionAuthLevel(vocbase->name(), "*");
|
||||
data.add("*", VPackValue(convertFromAuthLevel(lvl)));
|
||||
} else { // hide db's without access
|
||||
auth::Level lvl = user.databaseAuthLevel(vocbase->name());
|
||||
if (lvl >= auth::Level::RO) {
|
||||
data.add(vocbase->name(), VPackValue(convertFromAuthLevel(lvl)));
|
||||
DatabaseFeature::DATABASE->enumerateDatabases(
|
||||
[&](TRI_vocbase_t& vocbase)->void {
|
||||
if (full) {
|
||||
auto lvl = user.configuredDBAuthLevel(vocbase.name());
|
||||
std::string str = convertFromAuthLevel(lvl);
|
||||
velocypack::ObjectBuilder b(&data, vocbase.name(), true);
|
||||
|
||||
data.add("permission", VPackValue(str));
|
||||
|
||||
velocypack::ObjectBuilder b2(&data, "collections", true);
|
||||
|
||||
methods::Collections::enumerate(
|
||||
&vocbase,
|
||||
[&](LogicalCollection* c)->void {
|
||||
lvl =
|
||||
user.configuredCollectionAuthLevel(vocbase.name(), c->name());
|
||||
data.add(
|
||||
c->name(),
|
||||
velocypack::Value(convertFromAuthLevel(lvl))
|
||||
);
|
||||
}
|
||||
);
|
||||
lvl = user.configuredCollectionAuthLevel(vocbase.name(), "*");
|
||||
data.add("*", velocypack::Value(convertFromAuthLevel(lvl)));
|
||||
} else { // hide db's without access
|
||||
auto lvl = user.databaseAuthLevel(vocbase.name());
|
||||
|
||||
if (lvl >= auth::Level::RO) {
|
||||
data.add(vocbase.name(), VPackValue(convertFromAuthLevel(lvl)));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
if (full) {
|
||||
auth::Level lvl = user.databaseAuthLevel("*");
|
||||
data("*", VPackValue(VPackValueType::Object))(
|
||||
"permission", VPackValue(convertFromAuthLevel(lvl)))();
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
});
|
||||
data.close();
|
||||
|
|
|
@ -366,9 +366,13 @@ void RestWalAccessHandler::handleCommandTail(WalAccess const* wal) {
|
|||
_response->setResponseCode(rest::ResponseCode::NO_CONTENT);
|
||||
}
|
||||
|
||||
DatabaseFeature::DATABASE->enumerateDatabases([&](TRI_vocbase_t* vocbase) {
|
||||
vocbase->updateReplicationClient(serverId, tickStart, InitialSyncer::defaultBatchTimeout);
|
||||
});
|
||||
DatabaseFeature::DATABASE->enumerateDatabases(
|
||||
[&](TRI_vocbase_t& vocbase)->void {
|
||||
vocbase.updateReplicationClient(
|
||||
serverId, tickStart, InitialSyncer::defaultBatchTimeout
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
void RestWalAccessHandler::handleCommandDetermineOpenTransactions(
|
||||
|
|
|
@ -161,7 +161,7 @@ void DatabaseManagerThread::run() {
|
|||
}
|
||||
|
||||
try {
|
||||
engine->dropDatabase(database);
|
||||
engine->dropDatabase(*database);
|
||||
} catch (std::exception const& ex) {
|
||||
LOG_TOPIC(ERR, Logger::FIXME) << "dropping database '" << database->name() << "' failed: " << ex.what();
|
||||
} catch (...) {
|
||||
|
@ -594,7 +594,7 @@ int DatabaseFeature::createDatabase(TRI_voc_tick_t id, std::string const& name,
|
|||
builder.close();
|
||||
|
||||
// createDatabase must return a valid database or throw
|
||||
vocbase.reset(engine->createDatabase(id, builder.slice()));
|
||||
vocbase = engine->createDatabase(id, builder.slice());
|
||||
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
|
||||
|
@ -782,7 +782,7 @@ int DatabaseFeature::dropDatabase(std::string const& name, bool waitForDeletion,
|
|||
#endif
|
||||
arangodb::aql::QueryCache::instance()->invalidate(vocbase);
|
||||
|
||||
engine->prepareDropDatabase(vocbase, !engine->inRecovery(), res);
|
||||
engine->prepareDropDatabase(*vocbase, !engine->inRecovery(), res);
|
||||
}
|
||||
// must not use the database after here, as it may now be
|
||||
// deleted by the DatabaseManagerThread!
|
||||
|
@ -1077,10 +1077,10 @@ TRI_vocbase_t* DatabaseFeature::lookupDatabase(std::string const& name) {
|
|||
if (name.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
auto unuser(_databasesProtector.use());
|
||||
auto theLists = _databasesLists.load();
|
||||
|
||||
|
||||
// database names with a number in front are invalid names
|
||||
if (name[0] >= '0' && name[0] <= '9') {
|
||||
TRI_voc_tick_t id = NumberUtils::atoi_zero<TRI_voc_tick_t>(name.data(), name.data() + name.size());
|
||||
|
@ -1110,7 +1110,7 @@ std::string DatabaseFeature::translateCollectionName(
|
|||
auto theLists = _databasesLists.load();
|
||||
auto itr = theLists->_databases.find(dbName);
|
||||
|
||||
if (itr == theLists->_coordinatorDatabases.end()) {
|
||||
if (itr == theLists->_databases.end()) {
|
||||
return std::string();
|
||||
}
|
||||
|
||||
|
@ -1130,7 +1130,9 @@ std::string DatabaseFeature::translateCollectionName(
|
|||
}
|
||||
}
|
||||
|
||||
void DatabaseFeature::enumerateDatabases(std::function<void(TRI_vocbase_t*)> func) {
|
||||
void DatabaseFeature::enumerateDatabases(
|
||||
std::function<void(TRI_vocbase_t& vocbase)> const& func
|
||||
) {
|
||||
if (ServerState::instance()->isCoordinator()) {
|
||||
auto unuser(_databasesProtector.use());
|
||||
auto theLists = _databasesLists.load();
|
||||
|
@ -1140,7 +1142,7 @@ void DatabaseFeature::enumerateDatabases(std::function<void(TRI_vocbase_t*)> fun
|
|||
// iterate over all databases
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
TRI_ASSERT(vocbase->type() == TRI_VOCBASE_TYPE_COORDINATOR);
|
||||
func(vocbase);
|
||||
func(*vocbase);
|
||||
}
|
||||
} else {
|
||||
auto unuser(_databasesProtector.use());
|
||||
|
@ -1151,7 +1153,7 @@ void DatabaseFeature::enumerateDatabases(std::function<void(TRI_vocbase_t*)> fun
|
|||
// iterate over all databases
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
TRI_ASSERT(vocbase->type() == TRI_VOCBASE_TYPE_NORMAL);
|
||||
func(vocbase);
|
||||
func(*vocbase);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1204,7 +1206,6 @@ void DatabaseFeature::stopAppliers() {
|
|||
TRI_vocbase_t* vocbase = p.second;
|
||||
TRI_ASSERT(vocbase != nullptr);
|
||||
TRI_ASSERT(vocbase->type() == TRI_VOCBASE_TYPE_NORMAL);
|
||||
|
||||
replicationFeature->stopApplier(vocbase);
|
||||
}
|
||||
}
|
||||
|
@ -1356,7 +1357,7 @@ int DatabaseFeature::iterateDatabases(VPackSlice const& databases) {
|
|||
// open the database and scan collections in it
|
||||
|
||||
// try to open this database
|
||||
TRI_vocbase_t* database = engine->openDatabase(it, _upgrade);
|
||||
auto* database = engine->openDatabase(it, _upgrade).release();
|
||||
|
||||
if (!ServerState::isCoordinator(role) && !ServerState::isAgent(role)) {
|
||||
try {
|
||||
|
|
|
@ -121,7 +121,9 @@ class DatabaseFeature : public application_features::ApplicationFeature {
|
|||
|
||||
TRI_vocbase_t* lookupDatabaseCoordinator(std::string const& name);
|
||||
TRI_vocbase_t* lookupDatabase(std::string const& name);
|
||||
void enumerateDatabases(std::function<void(TRI_vocbase_t*)>);
|
||||
void enumerateDatabases(
|
||||
std::function<void(TRI_vocbase_t& vocbase)> const& func
|
||||
);
|
||||
std::string translateCollectionName(std::string const& dbName, std::string const& collectionName);
|
||||
|
||||
void useSystemDatabase();
|
||||
|
@ -199,6 +201,7 @@ class DatabaseFeature : public application_features::ApplicationFeature {
|
|||
/// (addition, removal, change) of database objects
|
||||
VersionTracker _versionTracker;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -31,7 +31,7 @@ using namespace arangodb;
|
|||
using namespace arangodb::application_features;
|
||||
using namespace arangodb::basics;
|
||||
using namespace arangodb::options;
|
||||
|
||||
|
||||
std::unique_ptr<TransactionManager> TransactionManagerFeature::MANAGER;
|
||||
|
||||
TransactionManagerFeature::TransactionManagerFeature(ApplicationServer* server)
|
||||
|
@ -43,7 +43,7 @@ TransactionManagerFeature::TransactionManagerFeature(ApplicationServer* server)
|
|||
void TransactionManagerFeature::prepare() {
|
||||
TRI_ASSERT(MANAGER == nullptr);
|
||||
TRI_ASSERT(EngineSelectorFeature::ENGINE != nullptr);
|
||||
MANAGER.reset(EngineSelectorFeature::ENGINE->createTransactionManager());
|
||||
MANAGER = EngineSelectorFeature::ENGINE->createTransactionManager();
|
||||
}
|
||||
|
||||
void TransactionManagerFeature::unprepare() {
|
||||
|
|
|
@ -75,25 +75,31 @@ void RocksDBBackgroundThread::run() {
|
|||
}
|
||||
|
||||
bool force = isStopping();
|
||||
|
||||
_engine->replicationManager()->garbageCollect(force);
|
||||
|
||||
TRI_voc_tick_t minTick = rocksutils::latestSequenceNumber();
|
||||
auto cmTick = _engine->settingsManager()->earliestSeqNeeded();
|
||||
|
||||
if (cmTick < minTick) {
|
||||
minTick = cmTick;
|
||||
}
|
||||
|
||||
if (DatabaseFeature::DATABASE != nullptr) {
|
||||
DatabaseFeature::DATABASE->enumerateDatabases(
|
||||
[force, &minTick](TRI_vocbase_t* vocbase) {
|
||||
vocbase->cursorRepository()->garbageCollect(force);
|
||||
vocbase->garbageCollectReplicationClients(TRI_microtime());
|
||||
auto clients = vocbase->getReplicationClients();
|
||||
[force, &minTick](TRI_vocbase_t& vocbase)->void {
|
||||
vocbase.cursorRepository()->garbageCollect(force);
|
||||
vocbase.garbageCollectReplicationClients(TRI_microtime());
|
||||
|
||||
auto clients = vocbase.getReplicationClients();
|
||||
|
||||
for (auto c : clients) {
|
||||
if (std::get<3>(c) < minTick) {
|
||||
minTick = std::get<3>(c);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// only start pruning of obsolete WAL files a few minutes after
|
||||
|
@ -115,5 +121,6 @@ void RocksDBBackgroundThread::run() {
|
|||
<< "caught unknown exception in rocksdb background";
|
||||
}
|
||||
}
|
||||
|
||||
_engine->settingsManager()->sync(true); // final write on shutdown
|
||||
}
|
||||
|
|
|
@ -118,7 +118,12 @@ std::vector<std::shared_ptr<RocksDBRecoveryHelper>>
|
|||
|
||||
// create the storage engine
|
||||
RocksDBEngine::RocksDBEngine(application_features::ApplicationServer* server)
|
||||
: StorageEngine(server, EngineName, FeatureName, new RocksDBIndexFactory()),
|
||||
: StorageEngine(
|
||||
server,
|
||||
EngineName,
|
||||
FeatureName,
|
||||
std::unique_ptr<IndexFactory>(new RocksDBIndexFactory())
|
||||
),
|
||||
_db(nullptr),
|
||||
_vpackCmp(new RocksDBVPackComparator()),
|
||||
_walAccess(new RocksDBWalAccess()),
|
||||
|
@ -642,12 +647,14 @@ void RocksDBEngine::unprepare() {
|
|||
shutdownRocksDBInstance();
|
||||
}
|
||||
|
||||
TransactionManager* RocksDBEngine::createTransactionManager() {
|
||||
return new RocksDBTransactionManager();
|
||||
std::unique_ptr<TransactionManager> RocksDBEngine::createTransactionManager() {
|
||||
return std::unique_ptr<TransactionManager>(new RocksDBTransactionManager());
|
||||
}
|
||||
|
||||
transaction::ContextData* RocksDBEngine::createTransactionContextData() {
|
||||
return new RocksDBTransactionContextData();
|
||||
std::unique_ptr<transaction::ContextData> RocksDBEngine::createTransactionContextData() {
|
||||
return std::unique_ptr<transaction::ContextData>(
|
||||
new RocksDBTransactionContextData()
|
||||
);
|
||||
}
|
||||
|
||||
std::unique_ptr<TransactionState> RocksDBEngine::createTransactionState(
|
||||
|
@ -659,10 +666,15 @@ std::unique_ptr<TransactionState> RocksDBEngine::createTransactionState(
|
|||
);
|
||||
}
|
||||
|
||||
TransactionCollection* RocksDBEngine::createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) {
|
||||
return new RocksDBTransactionCollection(state, cid, accessType, nestingLevel);
|
||||
std::unique_ptr<TransactionCollection> RocksDBEngine::createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) {
|
||||
return std::unique_ptr<TransactionCollection>(
|
||||
new RocksDBTransactionCollection(&state, cid, accessType, nestingLevel)
|
||||
);
|
||||
}
|
||||
|
||||
void RocksDBEngine::addParametersForNewCollection(VPackBuilder& builder,
|
||||
|
@ -683,9 +695,13 @@ void RocksDBEngine::addParametersForNewIndex(VPackBuilder& builder,
|
|||
}
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* RocksDBEngine::createPhysicalCollection(
|
||||
LogicalCollection* collection, VPackSlice const& info) {
|
||||
return new RocksDBCollection(collection, info);
|
||||
std::unique_ptr<PhysicalCollection> RocksDBEngine::createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) {
|
||||
return std::unique_ptr<PhysicalCollection>(
|
||||
new RocksDBCollection(&collection, info)
|
||||
);
|
||||
}
|
||||
|
||||
// inventory functionality
|
||||
|
@ -867,9 +883,13 @@ std::string RocksDBEngine::versionFilename(TRI_voc_tick_t id) const {
|
|||
}
|
||||
|
||||
VPackBuilder RocksDBEngine::getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t* vocbase, int& status) {
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) {
|
||||
RocksDBKey key;
|
||||
key.constructReplicationApplierConfig(vocbase->id());
|
||||
|
||||
key.constructReplicationApplierConfig(vocbase.id());
|
||||
|
||||
return getReplicationApplierConfiguration(key, status);
|
||||
}
|
||||
|
||||
|
@ -899,9 +919,12 @@ VPackBuilder RocksDBEngine::getReplicationApplierConfiguration(
|
|||
}
|
||||
|
||||
int RocksDBEngine::removeReplicationApplierConfiguration(
|
||||
TRI_vocbase_t* vocbase) {
|
||||
TRI_vocbase_t& vocbase
|
||||
) {
|
||||
RocksDBKey key;
|
||||
key.constructReplicationApplierConfig(vocbase->id());
|
||||
|
||||
key.constructReplicationApplierConfig(vocbase.id());
|
||||
|
||||
return removeReplicationApplierConfiguration(key);
|
||||
}
|
||||
|
||||
|
@ -923,9 +946,14 @@ int RocksDBEngine::removeReplicationApplierConfiguration(
|
|||
}
|
||||
|
||||
int RocksDBEngine::saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t* vocbase, arangodb::velocypack::Slice slice, bool doSync) {
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) {
|
||||
RocksDBKey key;
|
||||
key.constructReplicationApplierConfig(vocbase->id());
|
||||
|
||||
key.constructReplicationApplierConfig(vocbase.id());
|
||||
|
||||
return saveReplicationApplierConfiguration(key, slice, doSync);
|
||||
}
|
||||
|
||||
|
@ -952,7 +980,7 @@ int RocksDBEngine::saveReplicationApplierConfiguration(
|
|||
// database, collection and index management
|
||||
// -----------------------------------------
|
||||
|
||||
TRI_vocbase_t* RocksDBEngine::openDatabase(
|
||||
std::unique_ptr<TRI_vocbase_t> RocksDBEngine::openDatabase(
|
||||
arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) {
|
||||
VPackSlice idSlice = args.get("id");
|
||||
TRI_voc_tick_t id = static_cast<TRI_voc_tick_t>(
|
||||
|
@ -964,12 +992,13 @@ TRI_vocbase_t* RocksDBEngine::openDatabase(
|
|||
return openExistingDatabase(id, name, true, isUpgrade);
|
||||
}
|
||||
|
||||
TRI_vocbase_t* RocksDBEngine::createDatabase(
|
||||
std::unique_ptr<TRI_vocbase_t> RocksDBEngine::createDatabase(
|
||||
TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) {
|
||||
status = TRI_ERROR_NO_ERROR;
|
||||
auto vocbase = std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id,
|
||||
args.get("name").copyString());
|
||||
return vocbase.release();
|
||||
|
||||
return std::make_unique<TRI_vocbase_t>(
|
||||
TRI_VOCBASE_TYPE_NORMAL, id, args.get("name").copyString()
|
||||
);
|
||||
}
|
||||
|
||||
int RocksDBEngine::writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
||||
|
@ -1014,24 +1043,29 @@ int RocksDBEngine::writeCreateCollectionMarker(TRI_voc_tick_t databaseId,
|
|||
return result.errorNumber();
|
||||
}
|
||||
|
||||
void RocksDBEngine::prepareDropDatabase(TRI_vocbase_t* vocbase,
|
||||
bool useWriteMarker, int& status) {
|
||||
void RocksDBEngine::prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) {
|
||||
VPackBuilder builder;
|
||||
|
||||
builder.openObject();
|
||||
builder.add("id", VPackValue(std::to_string(vocbase->id())));
|
||||
builder.add("name", VPackValue(vocbase->name()));
|
||||
builder.add("id", velocypack::Value(std::to_string(vocbase.id())));
|
||||
builder.add("name", velocypack::Value(vocbase.name()));
|
||||
builder.add("deleted", VPackValue(true));
|
||||
builder.close();
|
||||
|
||||
auto log = RocksDBLogValue::DatabaseDrop(vocbase->id());
|
||||
Result res =
|
||||
writeDatabaseMarker(vocbase->id(), builder.slice(), std::move(log));
|
||||
auto log = RocksDBLogValue::DatabaseDrop(vocbase.id());
|
||||
auto res = writeDatabaseMarker(vocbase.id(), builder.slice(), std::move(log));
|
||||
|
||||
status = res.errorNumber();
|
||||
}
|
||||
|
||||
Result RocksDBEngine::dropDatabase(TRI_vocbase_t* database) {
|
||||
replicationManager()->drop(database);
|
||||
return dropDatabase(database->id());
|
||||
Result RocksDBEngine::dropDatabase(TRI_vocbase_t& database) {
|
||||
replicationManager()->drop(&database);
|
||||
|
||||
return dropDatabase(database.id());
|
||||
}
|
||||
|
||||
void RocksDBEngine::waitUntilDeletion(TRI_voc_tick_t /* id */, bool /* force */,
|
||||
|
@ -1052,11 +1086,11 @@ void RocksDBEngine::recoveryDone(TRI_vocbase_t& vocbase) {
|
|||
std::string RocksDBEngine::createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t cid,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
VPackBuilder builder = collection->toVelocyPackIgnore(
|
||||
{"path", "statusString"}, /*translate cid*/ true,
|
||||
/*for persistence*/ true);
|
||||
auto builder = collection.toVelocyPackIgnore(
|
||||
{"path", "statusString"}, /*translate cid*/ true, /*for persistence*/ true
|
||||
);
|
||||
|
||||
TRI_ASSERT(cid != 0);
|
||||
TRI_UpdateTickServer(static_cast<TRI_voc_tick_t>(cid));
|
||||
|
@ -1073,7 +1107,8 @@ std::string RocksDBEngine::createCollection(
|
|||
}
|
||||
|
||||
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||
RocksDBCollection* rcoll = toRocksDBCollection(collection->getPhysical());
|
||||
auto* rcoll = toRocksDBCollection(collection.getPhysical());
|
||||
|
||||
TRI_ASSERT(rcoll->numberDocuments() == 0);
|
||||
#endif
|
||||
|
||||
|
@ -1082,18 +1117,17 @@ std::string RocksDBEngine::createCollection(
|
|||
|
||||
arangodb::Result RocksDBEngine::persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) {
|
||||
return {};
|
||||
}
|
||||
|
||||
arangodb::Result RocksDBEngine::dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
RocksDBCollection* coll = toRocksDBCollection(collection->getPhysical());
|
||||
auto* coll = toRocksDBCollection(collection.getPhysical());
|
||||
uint64_t const numberDocuments = coll->numberDocuments();
|
||||
|
||||
rocksdb::WriteOptions wo;
|
||||
|
||||
// If we get here the collection is safe to drop.
|
||||
|
@ -1113,17 +1147,19 @@ arangodb::Result RocksDBEngine::dropCollection(
|
|||
// (NOTE: The above fails can only occur on full HDD or Machine dying. No
|
||||
// write conflicts possible)
|
||||
|
||||
TRI_ASSERT(collection->status() == TRI_VOC_COL_STATUS_DELETED);
|
||||
TRI_ASSERT(collection.status() == TRI_VOC_COL_STATUS_DELETED);
|
||||
|
||||
// Prepare collection remove batch
|
||||
RocksDBLogValue logValue = RocksDBLogValue::CollectionDrop(
|
||||
vocbase.id(), collection->id(), StringRef(collection->guid())
|
||||
vocbase.id(), collection.id(), StringRef(collection.guid())
|
||||
);
|
||||
rocksdb::WriteBatch batch;
|
||||
|
||||
batch.PutLogData(logValue.slice());
|
||||
|
||||
RocksDBKey key;
|
||||
|
||||
key.constructCollection(vocbase.id(), collection->id());
|
||||
key.constructCollection(vocbase.id(), collection.id());
|
||||
batch.Delete(RocksDBColumnFamily::definitions(), key.string());
|
||||
|
||||
rocksdb::Status res = _db->Write(wo, &batch);
|
||||
|
@ -1143,7 +1179,7 @@ arangodb::Result RocksDBEngine::dropCollection(
|
|||
// remove from map
|
||||
{
|
||||
WRITE_LOCKER(guard, _mapLock);
|
||||
_collectionMap.erase(collection->id());
|
||||
_collectionMap.erase(collection.id());
|
||||
}
|
||||
|
||||
// delete documents
|
||||
|
@ -1203,7 +1239,7 @@ arangodb::Result RocksDBEngine::dropCollection(
|
|||
|
||||
void RocksDBEngine::destroyCollection(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalCollection* /*collection*/
|
||||
LogicalCollection& /*collection*/
|
||||
) {
|
||||
// not required
|
||||
}
|
||||
|
@ -1211,13 +1247,12 @@ void RocksDBEngine::destroyCollection(
|
|||
void RocksDBEngine::changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* parameters,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) {
|
||||
VPackBuilder builder = parameters->toVelocyPackIgnore(
|
||||
{"path", "statusString"}, /*translate cid*/ true,
|
||||
/*for persistence*/ true);
|
||||
|
||||
auto builder = collection.toVelocyPackIgnore(
|
||||
{"path", "statusString"}, /*translate cid*/ true, /*for persistence*/ true
|
||||
);
|
||||
int res = writeCreateCollectionMarker(
|
||||
vocbase.id(),
|
||||
id,
|
||||
|
@ -1232,17 +1267,17 @@ void RocksDBEngine::changeCollection(
|
|||
|
||||
arangodb::Result RocksDBEngine::renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) {
|
||||
VPackBuilder builder =
|
||||
collection->toVelocyPackIgnore({"path", "statusString"}, true, true);
|
||||
auto builder =
|
||||
collection.toVelocyPackIgnore({"path", "statusString"}, true, true);
|
||||
int res = writeCreateCollectionMarker(
|
||||
vocbase.id(),
|
||||
collection->id(),
|
||||
collection.id(),
|
||||
builder.slice(),
|
||||
RocksDBLogValue::CollectionRename(
|
||||
vocbase.id(), collection->id(), StringRef(oldName)
|
||||
vocbase.id(), collection.id(), StringRef(oldName)
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -1259,9 +1294,9 @@ void RocksDBEngine::createIndex(
|
|||
|
||||
void RocksDBEngine::unloadCollection(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) {
|
||||
collection->setStatus(TRI_VOC_COL_STATUS_UNLOADED);
|
||||
collection.setStatus(TRI_VOC_COL_STATUS_UNLOADED);
|
||||
}
|
||||
|
||||
void RocksDBEngine::createView(
|
||||
|
@ -1328,18 +1363,19 @@ arangodb::Result RocksDBEngine::persistView(
|
|||
|
||||
arangodb::Result RocksDBEngine::dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view) {
|
||||
LogicalView& view
|
||||
) {
|
||||
VPackBuilder builder;
|
||||
|
||||
builder.openObject();
|
||||
view->toVelocyPack(builder, true, true);
|
||||
view.toVelocyPack(builder, true, true);
|
||||
builder.close();
|
||||
|
||||
auto logValue =
|
||||
RocksDBLogValue::ViewDrop(vocbase.id(), view->id(), builder.slice());
|
||||
RocksDBLogValue::ViewDrop(vocbase.id(), view.id(), builder.slice());
|
||||
RocksDBKey key;
|
||||
|
||||
key.constructView(vocbase.id(), view->id());
|
||||
key.constructView(vocbase.id(), view.id());
|
||||
|
||||
rocksdb::WriteBatch batch;
|
||||
rocksdb::WriteOptions wo; // TODO: check which options would make sense
|
||||
|
@ -1353,7 +1389,8 @@ arangodb::Result RocksDBEngine::dropView(
|
|||
|
||||
void RocksDBEngine::destroyView(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalView* /*view*/) noexcept {
|
||||
LogicalView& /*view*/
|
||||
) noexcept {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
|
@ -1378,11 +1415,11 @@ void RocksDBEngine::changeView(
|
|||
}
|
||||
}
|
||||
|
||||
void RocksDBEngine::signalCleanup(TRI_vocbase_t*) {
|
||||
void RocksDBEngine::signalCleanup(TRI_vocbase_t& vocbase) {
|
||||
// nothing to do here
|
||||
}
|
||||
|
||||
int RocksDBEngine::shutdownDatabase(TRI_vocbase_t* vocbase) {
|
||||
int RocksDBEngine::shutdownDatabase(TRI_vocbase_t& vocbase) {
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
|
@ -1402,8 +1439,8 @@ void RocksDBEngine::addV8Functions() {
|
|||
}
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void RocksDBEngine::addRestHandlers(rest::RestHandlerFactory* handlerFactory) {
|
||||
RocksDBRestHandlers::registerResources(handlerFactory);
|
||||
void RocksDBEngine::addRestHandlers(rest::RestHandlerFactory& handlerFactory) {
|
||||
RocksDBRestHandlers::registerResources(&handlerFactory);
|
||||
}
|
||||
|
||||
void RocksDBEngine::addCollectionMapping(uint64_t objectId, TRI_voc_tick_t did,
|
||||
|
@ -1730,10 +1767,12 @@ void RocksDBEngine::addSystemDatabase() {
|
|||
}
|
||||
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* RocksDBEngine::openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade) {
|
||||
std::unique_ptr<TRI_vocbase_t> RocksDBEngine::openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
) {
|
||||
auto vocbase =
|
||||
std::make_unique<TRI_vocbase_t>(TRI_VOCBASE_TYPE_NORMAL, id, name);
|
||||
|
||||
|
@ -1807,7 +1846,7 @@ TRI_vocbase_t* RocksDBEngine::openExistingDatabase(TRI_voc_tick_t id,
|
|||
<< collection->name() << "'";
|
||||
}
|
||||
|
||||
return vocbase.release();
|
||||
return vocbase;
|
||||
} catch (std::exception const& ex) {
|
||||
LOG_TOPIC(ERR, arangodb::Logger::FIXME) << "error while opening database: "
|
||||
<< ex.what();
|
||||
|
@ -1939,10 +1978,12 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const {
|
|||
builder.close();
|
||||
}
|
||||
|
||||
Result RocksDBEngine::handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) {
|
||||
return handleSyncKeysRocksDB(syncer, col, keysId);
|
||||
Result RocksDBEngine::handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) {
|
||||
return handleSyncKeysRocksDB(syncer, &col, keysId);
|
||||
}
|
||||
|
||||
Result RocksDBEngine::createLoggerState(TRI_vocbase_t* vocbase,
|
||||
|
@ -2050,7 +2091,7 @@ Result RocksDBEngine::firstTick(uint64_t& tick) {
|
|||
}
|
||||
|
||||
Result RocksDBEngine::lastLogger(
|
||||
TRI_vocbase_t* vocbase,
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart, uint64_t tickEnd,
|
||||
std::shared_ptr<VPackBuilder>& builderSPtr) {
|
||||
|
@ -2062,8 +2103,11 @@ Result RocksDBEngine::lastLogger(
|
|||
std::make_unique<VPackBuilder>(transactionContext->getVPackOptions());
|
||||
|
||||
builder->openArray();
|
||||
|
||||
RocksDBReplicationResult rep = rocksutils::tailWal(
|
||||
vocbase, tickStart, tickEnd, chunkSize, includeSystem, 0, *builder);
|
||||
&vocbase, tickStart, tickEnd, chunkSize, includeSystem, 0, *builder
|
||||
);
|
||||
|
||||
builder->close();
|
||||
builderSPtr = std::move(builder);
|
||||
|
||||
|
|
|
@ -102,19 +102,24 @@ class RocksDBEngine final : public StorageEngine {
|
|||
bool supportsDfdb() const override { return false; }
|
||||
bool useRawDocumentPointers() override { return false; }
|
||||
|
||||
TransactionManager* createTransactionManager() override;
|
||||
transaction::ContextData* createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionManager> createTransactionManager() override;
|
||||
std::unique_ptr<transaction::ContextData> createTransactionContextData() override;
|
||||
std::unique_ptr<TransactionState> createTransactionState(
|
||||
CollectionNameResolver const& resolver,
|
||||
transaction::Options const& options
|
||||
) override;
|
||||
TransactionCollection* createTransactionCollection(
|
||||
TransactionState* state, TRI_voc_cid_t cid, AccessMode::Type accessType,
|
||||
int nestingLevel) override;
|
||||
std::unique_ptr<TransactionCollection> createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) override;
|
||||
|
||||
// create storage-engine specific collection
|
||||
PhysicalCollection* createPhysicalCollection(LogicalCollection*,
|
||||
velocypack::Slice const&) override;
|
||||
std::unique_ptr<PhysicalCollection> createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) override;
|
||||
|
||||
void getStatistics(velocypack::Builder& builder) const override;
|
||||
|
||||
|
@ -147,32 +152,43 @@ class RocksDBEngine final : public StorageEngine {
|
|||
std::string databasePath(TRI_vocbase_t const* /*vocbase*/) const override {
|
||||
return _basePath;
|
||||
}
|
||||
std::string collectionPath(TRI_vocbase_t const* /*vocbase*/,
|
||||
TRI_voc_cid_t /*id*/) const override {
|
||||
std::string collectionPath(
|
||||
TRI_vocbase_t const& /*vocbase*/,
|
||||
TRI_voc_cid_t /*id*/
|
||||
) const override {
|
||||
return std::string(); // no path to be returned here
|
||||
}
|
||||
|
||||
velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
int& status) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) override;
|
||||
velocypack::Builder getReplicationApplierConfiguration(int& status) override;
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) override;
|
||||
int removeReplicationApplierConfiguration(TRI_vocbase_t& vocbase) override;
|
||||
int removeReplicationApplierConfiguration() override;
|
||||
int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
arangodb::velocypack::Slice slice,
|
||||
bool doSync) override;
|
||||
int saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) override;
|
||||
int saveReplicationApplierConfiguration(arangodb::velocypack::Slice slice,
|
||||
bool doSync) override;
|
||||
Result handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) override;
|
||||
Result handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) override;
|
||||
Result createLoggerState(TRI_vocbase_t* vocbase,
|
||||
velocypack::Builder& builder) override;
|
||||
Result createTickRanges(velocypack::Builder& builder) override;
|
||||
Result firstTick(uint64_t& tick) override;
|
||||
Result lastLogger(TRI_vocbase_t* vocbase,
|
||||
std::shared_ptr<transaction::Context>, uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<velocypack::Builder>& builderSPtr) override;
|
||||
Result lastLogger(
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<velocypack::Builder>& builderSPtr
|
||||
) override;
|
||||
WalAccess const* walAccess() const override;
|
||||
|
||||
// database, collection and index management
|
||||
|
@ -185,16 +201,24 @@ class RocksDBEngine final : public StorageEngine {
|
|||
bool writeShutdownFile) override;
|
||||
void waitForEstimatorSync(std::chrono::milliseconds maxWaitTime) override;
|
||||
|
||||
virtual TRI_vocbase_t* openDatabase(velocypack::Slice const& parameters,
|
||||
bool isUpgrade, int&) override;
|
||||
TRI_vocbase_t* createDatabase(TRI_voc_tick_t id,
|
||||
arangodb::velocypack::Slice const& args,
|
||||
int& status) override;
|
||||
virtual std::unique_ptr<TRI_vocbase_t> openDatabase(
|
||||
velocypack::Slice const& args,
|
||||
bool isUpgrade,
|
||||
int& status
|
||||
) override;
|
||||
std::unique_ptr<TRI_vocbase_t> createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& args,
|
||||
int& status
|
||||
) override;
|
||||
int writeCreateDatabaseMarker(TRI_voc_tick_t id,
|
||||
velocypack::Slice const& slice) override;
|
||||
void prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker,
|
||||
int& status) override;
|
||||
Result dropDatabase(TRI_vocbase_t* database) override;
|
||||
void prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) override;
|
||||
Result dropDatabase(TRI_vocbase_t& database) override;
|
||||
void waitUntilDeletion(TRI_voc_tick_t id, bool force, int& status) override;
|
||||
|
||||
// wal in recovery
|
||||
|
@ -207,34 +231,34 @@ class RocksDBEngine final : public StorageEngine {
|
|||
std::string createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
arangodb::Result persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) override;
|
||||
|
||||
arangodb::Result dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) override;
|
||||
|
||||
arangodb::Result renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) override;
|
||||
|
||||
|
@ -247,7 +271,7 @@ class RocksDBEngine final : public StorageEngine {
|
|||
|
||||
void unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) override;
|
||||
|
||||
void changeView(
|
||||
|
@ -264,9 +288,9 @@ class RocksDBEngine final : public StorageEngine {
|
|||
) override;
|
||||
|
||||
virtual void getViewProperties(
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
arangodb::LogicalView const* /*view*/,
|
||||
VPackBuilder& /*builder*/
|
||||
TRI_vocbase_t& /*vocbase*/,
|
||||
LogicalView const& /*view*/,
|
||||
velocypack::Builder& /*builder*/
|
||||
) override {
|
||||
// does nothing
|
||||
}
|
||||
|
@ -286,17 +310,17 @@ class RocksDBEngine final : public StorageEngine {
|
|||
|
||||
arangodb::Result dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) override;
|
||||
|
||||
void destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) noexcept override;
|
||||
|
||||
void signalCleanup(TRI_vocbase_t* vocbase) override;
|
||||
void signalCleanup(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
int shutdownDatabase(TRI_vocbase_t* vocbase) override;
|
||||
int shutdownDatabase(TRI_vocbase_t& vocbase) override;
|
||||
|
||||
/// @brief Add engine-specific AQL functions.
|
||||
void addAqlFunctions() override;
|
||||
|
@ -308,7 +332,7 @@ class RocksDBEngine final : public StorageEngine {
|
|||
void addV8Functions() override;
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
void addRestHandlers(rest::RestHandlerFactory*) override;
|
||||
void addRestHandlers(rest::RestHandlerFactory& handlerFactory) override;
|
||||
|
||||
void addParametersForNewCollection(arangodb::velocypack::Builder& builder,
|
||||
arangodb::velocypack::Slice info) override;
|
||||
|
@ -352,9 +376,12 @@ class RocksDBEngine final : public StorageEngine {
|
|||
bool systemDatabaseExists();
|
||||
void addSystemDatabase();
|
||||
/// @brief open an existing database. internal function
|
||||
TRI_vocbase_t* openExistingDatabase(TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown, bool isUpgrade);
|
||||
std::unique_ptr<TRI_vocbase_t> openExistingDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
std::string const& name,
|
||||
bool wasCleanShutdown,
|
||||
bool isUpgrade
|
||||
);
|
||||
|
||||
std::string getCompressionSupport() const;
|
||||
|
||||
|
|
|
@ -69,13 +69,14 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
public:
|
||||
|
||||
// create the storage engine
|
||||
StorageEngine(application_features::ApplicationServer* server,
|
||||
std::string const& engineName, std::string const& featureName,
|
||||
IndexFactory* indexFactory)
|
||||
: application_features::ApplicationFeature(server, featureName),
|
||||
_indexFactory(indexFactory),
|
||||
_typeName(engineName) {
|
||||
|
||||
StorageEngine(
|
||||
application_features::ApplicationServer* server,
|
||||
std::string const& engineName,
|
||||
std::string const& featureName,
|
||||
std::unique_ptr<IndexFactory>&& indexFactory
|
||||
): application_features::ApplicationFeature(server, featureName),
|
||||
_indexFactory(std::move(indexFactory)),
|
||||
_typeName(engineName) {
|
||||
// each specific storage engine feature is optional. the storage engine selection feature
|
||||
// will make sure that exactly one engine is selected at startup
|
||||
setOptional(true);
|
||||
|
@ -92,14 +93,18 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
|
||||
virtual bool supportsDfdb() const = 0;
|
||||
|
||||
virtual TransactionManager* createTransactionManager() = 0;
|
||||
virtual transaction::ContextData* createTransactionContextData() = 0;
|
||||
virtual std::unique_ptr<TransactionManager> createTransactionManager() = 0;
|
||||
virtual std::unique_ptr<transaction::ContextData> createTransactionContextData() = 0;
|
||||
virtual std::unique_ptr<TransactionState> createTransactionState(
|
||||
CollectionNameResolver const& resolver,
|
||||
transaction::Options const& options
|
||||
) = 0;
|
||||
virtual TransactionCollection* createTransactionCollection(TransactionState*, TRI_voc_cid_t,
|
||||
AccessMode::Type, int nestingLevel) = 0;
|
||||
virtual std::unique_ptr<TransactionCollection> createTransactionCollection(
|
||||
TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
AccessMode::Type accessType,
|
||||
int nestingLevel
|
||||
) = 0;
|
||||
|
||||
// when a new collection is created, this method is called to augment the collection
|
||||
// creation data with engine-specific information
|
||||
|
@ -110,7 +115,10 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
virtual void addParametersForNewIndex(VPackBuilder&, VPackSlice /*info*/) {}
|
||||
|
||||
// create storage-engine specific collection
|
||||
virtual PhysicalCollection* createPhysicalCollection(LogicalCollection*, VPackSlice const&) = 0;
|
||||
virtual std::unique_ptr<PhysicalCollection> createPhysicalCollection(
|
||||
LogicalCollection& collection,
|
||||
velocypack::Slice const& info
|
||||
) = 0;
|
||||
|
||||
// minimum timeout for the synchronous replication
|
||||
virtual double minimumSyncReplicationTimeout() const = 0;
|
||||
|
@ -160,7 +168,10 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
virtual std::string databasePath(TRI_vocbase_t const* vocbase) const = 0;
|
||||
|
||||
// return the path for a collection
|
||||
virtual std::string collectionPath(TRI_vocbase_t const* vocbase, TRI_voc_cid_t id) const = 0;
|
||||
virtual std::string collectionPath(
|
||||
TRI_vocbase_t const& vocbase,
|
||||
TRI_voc_cid_t id
|
||||
) const = 0;
|
||||
|
||||
|
||||
// database, collection and index management
|
||||
|
@ -181,10 +192,17 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
//// operations on databasea
|
||||
|
||||
/// @brief opens a database
|
||||
virtual TRI_vocbase_t* openDatabase(arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) = 0;
|
||||
TRI_vocbase_t* openDatabase(arangodb::velocypack::Slice const& args, bool isUpgrade) {
|
||||
virtual std::unique_ptr<TRI_vocbase_t> openDatabase(
|
||||
arangodb::velocypack::Slice const& args,
|
||||
bool isUpgrade,
|
||||
int& status
|
||||
) = 0;
|
||||
std::unique_ptr<TRI_vocbase_t> openDatabase(
|
||||
velocypack::Slice const& args,
|
||||
bool isUpgrade
|
||||
) {
|
||||
int status;
|
||||
TRI_vocbase_t* rv = openDatabase(args, isUpgrade, status);
|
||||
auto rv = openDatabase(args, isUpgrade, status);
|
||||
TRI_ASSERT(status == TRI_ERROR_NO_ERROR);
|
||||
TRI_ASSERT(rv != nullptr);
|
||||
return rv;
|
||||
|
@ -199,10 +217,17 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// the WAL entry for the database creation will be written *after* the call
|
||||
// to "createDatabase" returns
|
||||
// no way to acquire id within this function?!
|
||||
virtual TRI_vocbase_t* createDatabase(TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) = 0;
|
||||
TRI_vocbase_t* createDatabase(TRI_voc_tick_t id, arangodb::velocypack::Slice const& args ){
|
||||
virtual std::unique_ptr<TRI_vocbase_t> createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& args,
|
||||
int& status
|
||||
) = 0;
|
||||
std::unique_ptr<TRI_vocbase_t> createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
velocypack::Slice const& args
|
||||
) {
|
||||
int status;
|
||||
TRI_vocbase_t* rv = createDatabase(id, args, status);
|
||||
auto rv = createDatabase(id, args, status);
|
||||
TRI_ASSERT(status == TRI_ERROR_NO_ERROR);
|
||||
TRI_ASSERT(rv != nullptr);
|
||||
return rv;
|
||||
|
@ -220,15 +245,19 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// to "prepareDropDatabase" returns
|
||||
//
|
||||
// is done under a lock in database feature
|
||||
virtual void prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker, int& status) = 0;
|
||||
void prepareDropDatabase(TRI_vocbase_t* db, bool useWriteMarker){
|
||||
virtual void prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) = 0;
|
||||
void prepareDropDatabase(TRI_vocbase_t& db, bool useWriteMarker) {
|
||||
int status = 0;
|
||||
prepareDropDatabase(db, useWriteMarker, status);
|
||||
TRI_ASSERT(status == TRI_ERROR_NO_ERROR);
|
||||
};
|
||||
|
||||
// perform a physical deletion of the database
|
||||
virtual Result dropDatabase(TRI_vocbase_t*) = 0;
|
||||
virtual Result dropDatabase(TRI_vocbase_t& database) = 0;
|
||||
|
||||
/// @brief wait until a database directory disappears - not under lock in databaseFreature
|
||||
virtual void waitUntilDeletion(TRI_voc_tick_t id, bool force, int& status) = 0;
|
||||
|
@ -251,14 +280,14 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
virtual std::string createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) = 0;
|
||||
|
||||
// asks the storage engine to persist the collection.
|
||||
// After this call the collection is persisted over recovery.
|
||||
virtual arangodb::Result persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
LogicalCollection const& collection
|
||||
) = 0;
|
||||
|
||||
// asks the storage engine to drop the specified collection and persist the
|
||||
|
@ -271,7 +300,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// to "dropCollection" returns
|
||||
virtual arangodb::Result dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) = 0;
|
||||
|
||||
// perform a physical deletion of the collection
|
||||
|
@ -279,7 +308,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// assured that no one is using the collection anymore
|
||||
virtual void destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) = 0;
|
||||
|
||||
// asks the storage engine to change properties of the collection as specified in
|
||||
|
@ -291,14 +320,14 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
virtual void changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) = 0;
|
||||
|
||||
// asks the storage engine to persist renaming of a collection
|
||||
virtual arangodb::Result renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) = 0;
|
||||
|
||||
|
@ -334,7 +363,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// specific properties into a specified builder
|
||||
virtual void getViewProperties(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView const* view,
|
||||
LogicalView const& view,
|
||||
VPackBuilder& builder
|
||||
) = 0;
|
||||
|
||||
|
@ -362,7 +391,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// to "dropView" returns
|
||||
virtual arangodb::Result dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) = 0;
|
||||
|
||||
// perform a physical deletion of the view
|
||||
|
@ -371,7 +400,7 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
// 'noexcept' becuase it may be used in destructor
|
||||
virtual void destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
LogicalView& view
|
||||
) noexcept = 0;
|
||||
|
||||
// asks the storage engine to create an index as specified in the VPack
|
||||
|
@ -402,12 +431,12 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
|
||||
virtual void unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
LogicalCollection& collection
|
||||
) = 0;
|
||||
|
||||
virtual void signalCleanup(TRI_vocbase_t* vocbase) = 0;
|
||||
virtual void signalCleanup(TRI_vocbase_t& vocbase) = 0;
|
||||
|
||||
virtual int shutdownDatabase(TRI_vocbase_t* vocbase) = 0;
|
||||
virtual int shutdownDatabase(TRI_vocbase_t& vocbase) = 0;
|
||||
|
||||
// AQL functions
|
||||
// -------------
|
||||
|
@ -422,32 +451,42 @@ class StorageEngine : public application_features::ApplicationFeature {
|
|||
virtual void addV8Functions() {}
|
||||
|
||||
/// @brief Add engine-specific REST handlers
|
||||
virtual void addRestHandlers(rest::RestHandlerFactory*) {}
|
||||
virtual void addRestHandlers(rest::RestHandlerFactory& handlerFactory) {}
|
||||
|
||||
// replication
|
||||
virtual arangodb::velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t*, int&) = 0;
|
||||
virtual velocypack::Builder getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& status
|
||||
) = 0;
|
||||
virtual arangodb::velocypack::Builder getReplicationApplierConfiguration(int&) = 0;
|
||||
|
||||
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t* vocbase) = 0;
|
||||
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t& vocbase) = 0;
|
||||
virtual int removeReplicationApplierConfiguration() = 0;
|
||||
|
||||
virtual int saveReplicationApplierConfiguration(TRI_vocbase_t* vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync) = 0;
|
||||
virtual int saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
velocypack::Slice slice,
|
||||
bool doSync
|
||||
) = 0;
|
||||
virtual int saveReplicationApplierConfiguration(velocypack::Slice slice,
|
||||
bool doSync) = 0;
|
||||
|
||||
virtual Result handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection* col,
|
||||
std::string const& keysId) = 0;
|
||||
virtual Result handleSyncKeys(
|
||||
DatabaseInitialSyncer& syncer,
|
||||
LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) = 0;
|
||||
virtual Result createLoggerState(TRI_vocbase_t* vocbase,
|
||||
velocypack::Builder& builder) = 0;
|
||||
virtual Result createTickRanges(velocypack::Builder& builder) = 0;
|
||||
virtual Result firstTick(uint64_t& tick) = 0;
|
||||
virtual Result lastLogger(TRI_vocbase_t* vocbase
|
||||
,std::shared_ptr<transaction::Context>
|
||||
,uint64_t tickStart, uint64_t tickEnd
|
||||
,std::shared_ptr<velocypack::Builder>& builderSPtr) = 0;
|
||||
virtual Result lastLogger(
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<velocypack::Builder>& builderSPtr
|
||||
) = 0;
|
||||
virtual WalAccess const* walAccess() const = 0;
|
||||
|
||||
virtual bool useRawDocumentPointers() = 0;
|
||||
|
|
|
@ -179,8 +179,10 @@ int TransactionState::addCollection(TRI_voc_cid_t cid,
|
|||
TRI_ASSERT(trxCollection == nullptr);
|
||||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
trxCollection =
|
||||
engine->createTransactionCollection(this, cid, accessType, nestingLevel);
|
||||
|
||||
trxCollection = engine->createTransactionCollection(
|
||||
*this, cid, accessType, nestingLevel
|
||||
).release();
|
||||
|
||||
TRI_ASSERT(trxCollection != nullptr);
|
||||
|
||||
|
|
|
@ -196,7 +196,7 @@ transaction::ContextData* transaction::Context::contextData() {
|
|||
if (_contextData == nullptr) {
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
_contextData.reset(engine->createTransactionContextData());
|
||||
_contextData = engine->createTransactionContextData();
|
||||
}
|
||||
|
||||
return _contextData.get();
|
||||
|
|
|
@ -152,7 +152,7 @@ static void JS_LastLoggerReplication( v8::FunctionCallbackInfo<v8::Value> const&
|
|||
auto transactionContext = transaction::V8Context::Create(vocbase, false);
|
||||
auto builderSPtr = std::make_shared<VPackBuilder>();
|
||||
Result res = EngineSelectorFeature::ENGINE->lastLogger(
|
||||
&vocbase, transactionContext, tickStart, tickEnd, builderSPtr
|
||||
vocbase, transactionContext, tickStart, tickEnd, builderSPtr
|
||||
);
|
||||
v8::Handle<v8::Value> result;
|
||||
|
||||
|
|
|
@ -488,15 +488,22 @@ static void JS_GetPermission(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
} else {
|
||||
// return the current database permissions
|
||||
v8::Handle<v8::Object> result = v8::Object::New(isolate);
|
||||
DatabaseFeature::DATABASE->enumerateDatabases([&](TRI_vocbase_t* vocbase) {
|
||||
auth::Level lvl = um->databaseAuthLevel(username, vocbase->name());
|
||||
if (lvl != auth::Level::NONE) { // hide non accessible collections
|
||||
result->ForceSet(TRI_V8_STD_STRING(isolate, vocbase->name()),
|
||||
TRI_V8_STD_STRING(isolate, auth::convertFromAuthLevel(lvl)));
|
||||
|
||||
DatabaseFeature::DATABASE->enumerateDatabases(
|
||||
[&](TRI_vocbase_t& vocbase)->void {
|
||||
auto lvl = um->databaseAuthLevel(username, vocbase.name());
|
||||
|
||||
if (lvl != auth::Level::NONE) { // hide non accessible collections
|
||||
result->ForceSet(
|
||||
TRI_V8_STD_STRING(isolate, vocbase.name()),
|
||||
TRI_V8_STD_STRING(isolate, auth::convertFromAuthLevel(lvl))
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
);
|
||||
TRI_V8_RETURN(result);
|
||||
}
|
||||
|
||||
TRI_V8_RETURN_UNDEFINED();
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
|
|
@ -215,7 +215,8 @@ LogicalCollection::LogicalCollection(
|
|||
_keyOptions(nullptr),
|
||||
_keyGenerator(),
|
||||
_physical(
|
||||
EngineSelectorFeature::ENGINE->createPhysicalCollection(this, info)),
|
||||
EngineSelectorFeature::ENGINE->createPhysicalCollection(*this, info)
|
||||
),
|
||||
_clusterEstimateTTL(0) {
|
||||
TRI_ASSERT(info.isObject());
|
||||
|
||||
|
@ -654,7 +655,7 @@ Result LogicalCollection::rename(std::string&& newName, bool doSync) {
|
|||
TRI_ASSERT(engine != nullptr);
|
||||
|
||||
name(std::move(newName));
|
||||
engine->changeCollection(vocbase(), id(), this, doSync);
|
||||
engine->changeCollection(vocbase(), id(), *this, doSync);
|
||||
} catch (basics::Exception const& ex) {
|
||||
// Engine Rename somehow failed. Reset to old name
|
||||
name(std::move(oldName));
|
||||
|
@ -693,7 +694,7 @@ arangodb::Result LogicalCollection::drop() {
|
|||
TRI_ASSERT(!ServerState::instance()->isCoordinator());
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
engine->destroyCollection(vocbase(), this);
|
||||
engine->destroyCollection(vocbase(), *this);
|
||||
deleted(true);
|
||||
_physical->drop();
|
||||
|
||||
|
@ -976,7 +977,8 @@ arangodb::Result LogicalCollection::updateProperties(VPackSlice const& slice,
|
|||
}
|
||||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
engine->changeCollection(vocbase(), id(), this, doSync);
|
||||
|
||||
engine->changeCollection(vocbase(), id(), *this, doSync);
|
||||
|
||||
if (DatabaseFeature::DATABASE != nullptr &&
|
||||
DatabaseFeature::DATABASE->versionTracker() != nullptr) {
|
||||
|
@ -1055,7 +1057,7 @@ void LogicalCollection::persistPhysicalCollection() {
|
|||
// We have not yet persisted this collection!
|
||||
TRI_ASSERT(getPhysical()->path().empty());
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
auto path = engine->createCollection(vocbase(), id(), this);
|
||||
auto path = engine->createCollection(vocbase(), id(), *this);
|
||||
|
||||
getPhysical()->setPath(path);
|
||||
}
|
||||
|
@ -1289,4 +1291,4 @@ Result LogicalCollection::compareChecksums(VPackSlice checksumSlice, std::string
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- END-OF-FILE
|
||||
// -----------------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------------
|
|
@ -157,7 +157,7 @@ DBServerLogicalView::~DBServerLogicalView() {
|
|||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
TRI_ASSERT(engine);
|
||||
|
||||
engine->destroyView(vocbase(), this);
|
||||
engine->destroyView(vocbase(), *this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ arangodb::Result DBServerLogicalView::appendVelocyPack(
|
|||
return TRI_ERROR_INTERNAL;
|
||||
}
|
||||
|
||||
engine->getViewProperties(vocbase(), this, builder);
|
||||
engine->getViewProperties(vocbase(), *this, builder);
|
||||
}
|
||||
|
||||
if (detailed) {
|
||||
|
@ -270,7 +270,7 @@ arangodb::Result DBServerLogicalView::drop() {
|
|||
|
||||
if (res.ok()) {
|
||||
deleted(true);
|
||||
engine->dropView(vocbase(), this);
|
||||
engine->dropView(vocbase(), *this);
|
||||
}
|
||||
|
||||
return res;
|
||||
|
|
|
@ -224,7 +224,8 @@ bool TRI_vocbase_t::markAsDropped() {
|
|||
/// @brief signal the cleanup thread to wake up
|
||||
void TRI_vocbase_t::signalCleanup() {
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
engine->signalCleanup(this);
|
||||
|
||||
engine->signalCleanup(*this);
|
||||
}
|
||||
|
||||
void TRI_vocbase_t::checkCollectionInvariants() const {
|
||||
|
@ -775,8 +776,11 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
|||
|
||||
if (!collection->deleted()) {
|
||||
collection->deleted(true);
|
||||
|
||||
try {
|
||||
engine->changeCollection(*this, collection->id(), collection, doSync);
|
||||
engine->changeCollection(
|
||||
*this, collection->id(), *collection, doSync
|
||||
);
|
||||
} catch (arangodb::basics::Exception const& ex) {
|
||||
collection->deleted(false);
|
||||
events::DropCollection(colName, ex.code());
|
||||
|
@ -796,7 +800,7 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
|||
writeLocker.unlock();
|
||||
|
||||
TRI_ASSERT(engine != nullptr);
|
||||
engine->dropCollection(*this, collection);
|
||||
engine->dropCollection(*this, *collection);
|
||||
|
||||
DropCollectionCallback(collection);
|
||||
break;
|
||||
|
@ -828,7 +832,7 @@ int TRI_vocbase_t::dropCollectionWorker(arangodb::LogicalCollection* collection,
|
|||
locker.unlock();
|
||||
writeLocker.unlock();
|
||||
|
||||
engine->dropCollection(*this, collection);
|
||||
engine->dropCollection(*this, *collection);
|
||||
state = DROP_PERFORM;
|
||||
break;
|
||||
}
|
||||
|
@ -876,8 +880,8 @@ void TRI_vocbase_t::shutdown() {
|
|||
setState(TRI_vocbase_t::State::SHUTDOWN_COMPACTOR);
|
||||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
// shutdownDatabase() stops all threads
|
||||
engine->shutdownDatabase(this);
|
||||
|
||||
engine->shutdownDatabase(*this); // shutdownDatabase() stops all threads
|
||||
|
||||
// this will signal the cleanup thread to do one last iteration
|
||||
setState(TRI_vocbase_t::State::SHUTDOWN_CLEANUP);
|
||||
|
@ -1193,7 +1197,7 @@ arangodb::LogicalCollection* TRI_vocbase_t::createCollection(
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto res2 = engine->persistCollection(*this, collection.get());
|
||||
auto res2 = engine->persistCollection(*this, *collection);
|
||||
// API compatibility, we always return the collection, even if creation
|
||||
// failed.
|
||||
|
||||
|
@ -1268,7 +1272,8 @@ int TRI_vocbase_t::unloadCollection(arangodb::LogicalCollection* collection,
|
|||
|
||||
// wake up the cleanup thread
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
engine->unloadCollection(*this, collection);
|
||||
|
||||
engine->unloadCollection(*this, *collection);
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
@ -1312,8 +1317,7 @@ arangodb::Result TRI_vocbase_t::dropCollection(
|
|||
DropCollectionCallback(collection);
|
||||
} else {
|
||||
collection->deferDropCollection(DropCollectionCallback);
|
||||
// wake up the cleanup thread
|
||||
engine->signalCleanup(&(collection->vocbase()));
|
||||
engine->signalCleanup(collection->vocbase()); // wake up the cleanup thread
|
||||
}
|
||||
|
||||
if (DatabaseFeature::DATABASE != nullptr &&
|
||||
|
@ -1512,9 +1516,10 @@ int TRI_vocbase_t::renameCollection(
|
|||
|
||||
// Tell the engine.
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
|
||||
TRI_ASSERT(engine != nullptr);
|
||||
arangodb::Result res2 =
|
||||
engine->renameCollection(*this, collection, oldName);
|
||||
|
||||
auto res2 = engine->renameCollection(*this, *collection, oldName);
|
||||
|
||||
return res2.errorNumber();
|
||||
}
|
||||
|
@ -1815,7 +1820,8 @@ TRI_vocbase_t::~TRI_vocbase_t() {
|
|||
}
|
||||
|
||||
StorageEngine* engine = EngineSelectorFeature::ENGINE;
|
||||
engine->shutdownDatabase(this);
|
||||
|
||||
engine->shutdownDatabase(*this);
|
||||
|
||||
// do a final cleanup of collections
|
||||
for (auto& it : _collections) {
|
||||
|
|
|
@ -29,14 +29,11 @@
|
|||
#include "Basics/VelocyPackHelper.h"
|
||||
#include "Indexes/IndexIterator.h"
|
||||
#include "Indexes/SimpleAttributeEqualityMatcher.h"
|
||||
|
||||
#ifdef USE_IRESEARCH
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "IResearch/IResearchMMFilesLink.h"
|
||||
#include "IResearch/IResearchLinkCoordinator.h"
|
||||
#endif
|
||||
|
||||
#include "IResearch/IResearchCommon.h"
|
||||
#include "IResearch/IResearchMMFilesLink.h"
|
||||
#include "IResearch/IResearchLinkCoordinator.h"
|
||||
#include "IResearch/VelocyPackHelper.h"
|
||||
#include "StorageEngine/TransactionManager.h"
|
||||
#include "Transaction/Methods.h"
|
||||
#include "Utils/OperationOptions.h"
|
||||
#include "velocypack/Iterator.h"
|
||||
|
@ -964,7 +961,12 @@ std::function<void()> StorageEngineMock::before = []()->void {};
|
|||
bool StorageEngineMock::inRecoveryResult = false;
|
||||
|
||||
StorageEngineMock::StorageEngineMock()
|
||||
: StorageEngine(nullptr, "Mock", "", new IndexFactoryMock()),
|
||||
: StorageEngine(
|
||||
nullptr,
|
||||
"Mock",
|
||||
"",
|
||||
std::unique_ptr<arangodb::IndexFactory>(new IndexFactoryMock())
|
||||
),
|
||||
_releasedTick(0) {
|
||||
}
|
||||
|
||||
|
@ -983,7 +985,9 @@ void StorageEngineMock::addOptimizerRules() {
|
|||
// NOOP
|
||||
}
|
||||
|
||||
void StorageEngineMock::addRestHandlers(arangodb::rest::RestHandlerFactory*) {
|
||||
void StorageEngineMock::addRestHandlers(
|
||||
arangodb::rest::RestHandlerFactory& handlerFactory
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
}
|
||||
|
||||
|
@ -994,7 +998,7 @@ void StorageEngineMock::addV8Functions() {
|
|||
void StorageEngineMock::changeCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* parameters,
|
||||
arangodb::LogicalCollection const& collection,
|
||||
bool doSync
|
||||
) {
|
||||
// NOOP, assume physical collection changed OK
|
||||
|
@ -1016,7 +1020,10 @@ void StorageEngineMock::changeView(
|
|||
views[std::make_pair(vocbase.id(), view.id())] = std::move(builder);
|
||||
}
|
||||
|
||||
std::string StorageEngineMock::collectionPath(TRI_vocbase_t const* vocbase, TRI_voc_cid_t id) const {
|
||||
std::string StorageEngineMock::collectionPath(
|
||||
TRI_vocbase_t const& vocbase,
|
||||
TRI_voc_cid_t id
|
||||
) const {
|
||||
TRI_ASSERT(false);
|
||||
return "<invalid>";
|
||||
}
|
||||
|
@ -1024,12 +1031,16 @@ std::string StorageEngineMock::collectionPath(TRI_vocbase_t const* vocbase, TRI_
|
|||
std::string StorageEngineMock::createCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
TRI_voc_cid_t id,
|
||||
arangodb::LogicalCollection const* collection
|
||||
arangodb::LogicalCollection const& collection
|
||||
) {
|
||||
return "<invalid>"; // physical path of the new collection
|
||||
}
|
||||
|
||||
TRI_vocbase_t* StorageEngineMock::createDatabase(TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) {
|
||||
std::unique_ptr<TRI_vocbase_t> StorageEngineMock::createDatabase(
|
||||
TRI_voc_tick_t id,
|
||||
arangodb::velocypack::Slice const& args,
|
||||
int& status
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1048,9 +1059,14 @@ arangodb::Result StorageEngineMock::createLoggerState(TRI_vocbase_t*, VPackBuild
|
|||
return arangodb::Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
arangodb::PhysicalCollection* StorageEngineMock::createPhysicalCollection(arangodb::LogicalCollection* collection, VPackSlice const& info) {
|
||||
std::unique_ptr<arangodb::PhysicalCollection> StorageEngineMock::createPhysicalCollection(
|
||||
arangodb::LogicalCollection& collection,
|
||||
arangodb::velocypack::Slice const& info
|
||||
) {
|
||||
before();
|
||||
return new PhysicalCollectionMock(collection, info);
|
||||
return std::unique_ptr<arangodb::PhysicalCollection>(
|
||||
new PhysicalCollectionMock(&collection, info)
|
||||
);
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::createTickRanges(VPackBuilder&) {
|
||||
|
@ -1058,16 +1074,25 @@ arangodb::Result StorageEngineMock::createTickRanges(VPackBuilder&) {
|
|||
return arangodb::Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
arangodb::TransactionCollection* StorageEngineMock::createTransactionCollection(arangodb::TransactionState* state, TRI_voc_cid_t cid, arangodb::AccessMode::Type, int nestingLevel) {
|
||||
return new TransactionCollectionMock(state, cid);
|
||||
std::unique_ptr<arangodb::TransactionCollection> StorageEngineMock::createTransactionCollection(
|
||||
arangodb::TransactionState& state,
|
||||
TRI_voc_cid_t cid,
|
||||
arangodb::AccessMode::Type,
|
||||
int nestingLevel
|
||||
) {
|
||||
return std::unique_ptr<arangodb::TransactionCollection>(
|
||||
new TransactionCollectionMock(&state, cid)
|
||||
);
|
||||
}
|
||||
|
||||
arangodb::transaction::ContextData* StorageEngineMock::createTransactionContextData() {
|
||||
std::unique_ptr<arangodb::transaction::ContextData> StorageEngineMock::createTransactionContextData() {
|
||||
before();
|
||||
return new ContextDataMock();
|
||||
return std::unique_ptr<arangodb::transaction::ContextData>(
|
||||
new ContextDataMock()
|
||||
);
|
||||
}
|
||||
|
||||
arangodb::TransactionManager* StorageEngineMock::createTransactionManager() {
|
||||
std::unique_ptr<arangodb::TransactionManager> StorageEngineMock::createTransactionManager() {
|
||||
TRI_ASSERT(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -1092,7 +1117,7 @@ void StorageEngineMock::createView(
|
|||
|
||||
void StorageEngineMock::getViewProperties(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView const* view,
|
||||
arangodb::LogicalView const& view,
|
||||
VPackBuilder& builder
|
||||
) {
|
||||
before();
|
||||
|
@ -1111,14 +1136,14 @@ std::string StorageEngineMock::databasePath(TRI_vocbase_t const* vocbase) const
|
|||
|
||||
void StorageEngineMock::destroyCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
arangodb::LogicalCollection& collection
|
||||
) {
|
||||
// NOOP, assume physical collection destroyed OK
|
||||
}
|
||||
|
||||
void StorageEngineMock::destroyView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
arangodb::LogicalView& view
|
||||
) noexcept {
|
||||
before();
|
||||
// NOOP, assume physical view destroyed OK
|
||||
|
@ -1126,24 +1151,23 @@ void StorageEngineMock::destroyView(
|
|||
|
||||
arangodb::Result StorageEngineMock::dropCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
arangodb::LogicalCollection& collection
|
||||
) {
|
||||
return arangodb::Result(TRI_ERROR_NO_ERROR); // assume physical collection dropped OK
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::dropDatabase(TRI_vocbase_t*) {
|
||||
arangodb::Result StorageEngineMock::dropDatabase(TRI_vocbase_t& vocbase) {
|
||||
TRI_ASSERT(false);
|
||||
return arangodb::Result();
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::dropView(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalView* view
|
||||
arangodb::LogicalView& view
|
||||
) {
|
||||
before();
|
||||
TRI_ASSERT(view);
|
||||
TRI_ASSERT(views.find(std::make_pair(vocbase.id(), view->id())) != views.end());
|
||||
views.erase(std::make_pair(vocbase.id(), view->id()));
|
||||
TRI_ASSERT(views.find(std::make_pair(vocbase.id(), view.id())) != views.end());
|
||||
views.erase(std::make_pair(vocbase.id(), view.id()));
|
||||
|
||||
return arangodb::Result(TRI_ERROR_NO_ERROR); // assume mock view dropped OK
|
||||
}
|
||||
|
@ -1196,7 +1220,10 @@ void StorageEngineMock::getDatabases(arangodb::velocypack::Builder& result) {
|
|||
result.close();
|
||||
}
|
||||
|
||||
arangodb::velocypack::Builder StorageEngineMock::getReplicationApplierConfiguration(TRI_vocbase_t* vocbase, int& result) {
|
||||
arangodb::velocypack::Builder StorageEngineMock::getReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
int& result
|
||||
) {
|
||||
before();
|
||||
result = TRI_ERROR_FILE_NOT_FOUND; // assume no ReplicationApplierConfiguration for vocbase
|
||||
|
||||
|
@ -1225,7 +1252,11 @@ int StorageEngineMock::getViews(
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::handleSyncKeys(arangodb::DatabaseInitialSyncer&, arangodb::LogicalCollection*, std::string const&) {
|
||||
arangodb::Result StorageEngineMock::handleSyncKeys(
|
||||
arangodb::DatabaseInitialSyncer& syncer,
|
||||
arangodb::LogicalCollection& col,
|
||||
std::string const& keysId
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
return arangodb::Result();
|
||||
}
|
||||
|
@ -1234,12 +1265,22 @@ bool StorageEngineMock::inRecovery() {
|
|||
return inRecoveryResult;
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::lastLogger(TRI_vocbase_t*, std::shared_ptr<arangodb::transaction::Context>, uint64_t, uint64_t, std::shared_ptr<VPackBuilder>&) {
|
||||
arangodb::Result StorageEngineMock::lastLogger(
|
||||
TRI_vocbase_t& vocbase,
|
||||
std::shared_ptr<arangodb::transaction::Context> transactionContext,
|
||||
uint64_t tickStart,
|
||||
uint64_t tickEnd,
|
||||
std::shared_ptr<VPackBuilder>& builderSPtr
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
return arangodb::Result(TRI_ERROR_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
TRI_vocbase_t* StorageEngineMock::openDatabase(arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) {
|
||||
std::unique_ptr<TRI_vocbase_t> StorageEngineMock::openDatabase(
|
||||
arangodb::velocypack::Slice const& args,
|
||||
bool isUpgrade,
|
||||
int& status
|
||||
) {
|
||||
before();
|
||||
|
||||
if (!args.isObject() || !args.hasKey("name") || !args.get("name").isString()) {
|
||||
|
@ -1248,20 +1289,16 @@ TRI_vocbase_t* StorageEngineMock::openDatabase(arangodb::velocypack::Slice const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
auto vocbase = std::make_unique<TRI_vocbase_t>(
|
||||
return std::make_unique<TRI_vocbase_t>(
|
||||
TRI_vocbase_type_e::TRI_VOCBASE_TYPE_NORMAL,
|
||||
vocbases.size(),
|
||||
vocbaseCount++,
|
||||
args.get("name").copyString()
|
||||
);
|
||||
|
||||
vocbases.emplace_back(std::move(vocbase));
|
||||
|
||||
return vocbases.back().get();
|
||||
}
|
||||
|
||||
arangodb::Result StorageEngineMock::persistCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection
|
||||
arangodb::LogicalCollection const& collection
|
||||
) {
|
||||
before();
|
||||
return arangodb::Result(TRI_ERROR_NO_ERROR); // assume mock collection persisted OK
|
||||
|
@ -1283,7 +1320,11 @@ arangodb::Result StorageEngineMock::persistView(
|
|||
return arangodb::Result(TRI_ERROR_NO_ERROR); // assume mock view persisted OK
|
||||
}
|
||||
|
||||
void StorageEngineMock::prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker, int& status) {
|
||||
void StorageEngineMock::prepareDropDatabase(
|
||||
TRI_vocbase_t& vocbase,
|
||||
bool useWriteMarker,
|
||||
int& status
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
}
|
||||
|
||||
|
@ -1297,7 +1338,9 @@ void StorageEngineMock::releaseTick(TRI_voc_tick_t tick) {
|
|||
_releasedTick = tick;
|
||||
}
|
||||
|
||||
int StorageEngineMock::removeReplicationApplierConfiguration(TRI_vocbase_t*) {
|
||||
int StorageEngineMock::removeReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
@ -1309,7 +1352,7 @@ int StorageEngineMock::removeReplicationApplierConfiguration() {
|
|||
|
||||
arangodb::Result StorageEngineMock::renameCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection const* collection,
|
||||
arangodb::LogicalCollection const& collection,
|
||||
std::string const& oldName
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
|
@ -1333,7 +1376,11 @@ arangodb::Result StorageEngineMock::renameView(
|
|||
return arangodb::Result(TRI_ERROR_NO_ERROR); // assume mock view renames OK
|
||||
}
|
||||
|
||||
int StorageEngineMock::saveReplicationApplierConfiguration(TRI_vocbase_t*, arangodb::velocypack::Slice, bool) {
|
||||
int StorageEngineMock::saveReplicationApplierConfiguration(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::velocypack::Slice slice,
|
||||
bool doSync
|
||||
) {
|
||||
TRI_ASSERT(false);
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
@ -1343,12 +1390,12 @@ int StorageEngineMock::saveReplicationApplierConfiguration(arangodb::velocypack:
|
|||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
int StorageEngineMock::shutdownDatabase(TRI_vocbase_t* vocbase) {
|
||||
int StorageEngineMock::shutdownDatabase(TRI_vocbase_t& vocbase) {
|
||||
before();
|
||||
return TRI_ERROR_NO_ERROR; // assume shutdown successful
|
||||
}
|
||||
|
||||
void StorageEngineMock::signalCleanup(TRI_vocbase_t* vocbase) {
|
||||
void StorageEngineMock::signalCleanup(TRI_vocbase_t& vocbase) {
|
||||
before();
|
||||
// NOOP, assume cleanup thread signaled OK
|
||||
}
|
||||
|
@ -1360,7 +1407,7 @@ bool StorageEngineMock::supportsDfdb() const {
|
|||
|
||||
void StorageEngineMock::unloadCollection(
|
||||
TRI_vocbase_t& vocbase,
|
||||
arangodb::LogicalCollection* collection
|
||||
arangodb::LogicalCollection& collection
|
||||
) {
|
||||
before();
|
||||
// NOOP assume collection unloaded OK
|
||||
|
|
|
@ -139,65 +139,65 @@ class StorageEngineMock: public arangodb::StorageEngine {
|
|||
static std::function<void()> before;
|
||||
static bool inRecoveryResult;
|
||||
std::map<std::pair<TRI_voc_tick_t, TRI_voc_cid_t>, arangodb::velocypack::Builder> views;
|
||||
std::vector<std::unique_ptr<TRI_vocbase_t>> vocbases; // must allocate on heap because TRI_vocbase_t does not have a 'noexcept' move constructor
|
||||
std::atomic<size_t> vocbaseCount;
|
||||
|
||||
StorageEngineMock();
|
||||
virtual void addAqlFunctions() override;
|
||||
virtual void addOptimizerRules() override;
|
||||
virtual void addRestHandlers(arangodb::rest::RestHandlerFactory*) override;
|
||||
virtual void addRestHandlers(arangodb::rest::RestHandlerFactory& handlerFactory) override;
|
||||
virtual void addV8Functions() override;
|
||||
virtual void changeCollection(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalCollection const* parameters, bool doSync) override;
|
||||
virtual void changeCollection(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalCollection const& collection, bool doSync) override;
|
||||
virtual void changeView(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalView const& view, bool doSync) override;
|
||||
virtual std::string collectionPath(TRI_vocbase_t const* vocbase, TRI_voc_cid_t id) const override;
|
||||
virtual std::string createCollection(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalCollection const* collection) override;
|
||||
virtual TRI_vocbase_t* createDatabase(TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) override;
|
||||
virtual std::string collectionPath(TRI_vocbase_t const& vocbase, TRI_voc_cid_t id) const override;
|
||||
virtual std::string createCollection(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalCollection const& collection) override;
|
||||
virtual std::unique_ptr<TRI_vocbase_t> createDatabase(TRI_voc_tick_t id, arangodb::velocypack::Slice const& args, int& status) override;
|
||||
virtual void createIndex(TRI_vocbase_t& vocbase, TRI_voc_cid_t collectionId, TRI_idx_iid_t id, arangodb::velocypack::Slice const& data) override;
|
||||
virtual arangodb::Result createLoggerState(TRI_vocbase_t*, VPackBuilder&) override;
|
||||
virtual arangodb::PhysicalCollection* createPhysicalCollection(arangodb::LogicalCollection* collection, VPackSlice const& info) override;
|
||||
virtual std::unique_ptr<arangodb::PhysicalCollection> createPhysicalCollection(arangodb::LogicalCollection& collection, arangodb::velocypack::Slice const& info) override;
|
||||
virtual arangodb::Result createTickRanges(VPackBuilder&) override;
|
||||
virtual arangodb::TransactionCollection* createTransactionCollection(arangodb::TransactionState* state, TRI_voc_cid_t cid, arangodb::AccessMode::Type, int nestingLevel) override;
|
||||
virtual arangodb::transaction::ContextData* createTransactionContextData() override;
|
||||
virtual arangodb::TransactionManager* createTransactionManager() override;
|
||||
virtual std::unique_ptr<arangodb::TransactionCollection> createTransactionCollection(arangodb::TransactionState& state, TRI_voc_cid_t cid, arangodb::AccessMode::Type, int nestingLevel) override;
|
||||
virtual std::unique_ptr<arangodb::transaction::ContextData> createTransactionContextData() override;
|
||||
virtual std::unique_ptr<arangodb::TransactionManager> createTransactionManager() override;
|
||||
virtual std::unique_ptr<arangodb::TransactionState> createTransactionState(arangodb::CollectionNameResolver const& resolver, arangodb::transaction::Options const& options) override;
|
||||
virtual void createView(TRI_vocbase_t& vocbase, TRI_voc_cid_t id, arangodb::LogicalView const& view) override;
|
||||
virtual void getViewProperties(TRI_vocbase_t& vocbase, arangodb::LogicalView const* view, VPackBuilder& builder) override;
|
||||
virtual void getViewProperties(TRI_vocbase_t& vocbase, arangodb::LogicalView const& view, VPackBuilder& builder) override;
|
||||
virtual TRI_voc_tick_t currentTick() const override;
|
||||
virtual std::string databasePath(TRI_vocbase_t const* vocbase) const override;
|
||||
virtual void destroyCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection* collection) override;
|
||||
virtual void destroyView(TRI_vocbase_t& vocbase, arangodb::LogicalView* view) noexcept override;
|
||||
virtual arangodb::Result dropCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection* collection) override;
|
||||
virtual arangodb::Result dropDatabase(TRI_vocbase_t*) override;
|
||||
virtual arangodb::Result dropView(TRI_vocbase_t& vocbase, arangodb::LogicalView* view) override;
|
||||
virtual void destroyCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection& collection) override;
|
||||
virtual void destroyView(TRI_vocbase_t& vocbase, arangodb::LogicalView& view) noexcept override;
|
||||
virtual arangodb::Result dropCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection& collection) override;
|
||||
virtual arangodb::Result dropDatabase(TRI_vocbase_t& vocbase) override;
|
||||
virtual arangodb::Result dropView(TRI_vocbase_t& vocbase, arangodb::LogicalView& view) override;
|
||||
virtual arangodb::Result firstTick(uint64_t&) override;
|
||||
virtual arangodb::Result flushWal(bool waitForSync, bool waitForCollector, bool writeShutdownFile) override;
|
||||
virtual void getCollectionInfo(TRI_vocbase_t& vocbase, TRI_voc_cid_t cid, arangodb::velocypack::Builder& result, bool includeIndexes, TRI_voc_tick_t maxTick) override;
|
||||
virtual int getCollectionsAndIndexes(TRI_vocbase_t& vocbase, arangodb::velocypack::Builder& result, bool wasCleanShutdown, bool isUpgrade) override;
|
||||
virtual void getDatabases(arangodb::velocypack::Builder& result) override;
|
||||
virtual arangodb::velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t* vocbase, int& result) override;
|
||||
virtual arangodb::velocypack::Builder getReplicationApplierConfiguration(TRI_vocbase_t& vocbase, int& result) override;
|
||||
virtual arangodb::velocypack::Builder getReplicationApplierConfiguration(int& result) override;
|
||||
virtual int getViews(TRI_vocbase_t& vocbase, arangodb::velocypack::Builder& result) override;
|
||||
virtual arangodb::Result handleSyncKeys(arangodb::DatabaseInitialSyncer&, arangodb::LogicalCollection*, std::string const& keysId) override;
|
||||
virtual arangodb::Result handleSyncKeys(arangodb::DatabaseInitialSyncer& syncer, arangodb::LogicalCollection& col, std::string const& keysId) override;
|
||||
virtual bool inRecovery() override;
|
||||
virtual arangodb::Result lastLogger(TRI_vocbase_t*, std::shared_ptr<arangodb::transaction::Context>, uint64_t, uint64_t, std::shared_ptr<VPackBuilder>&) override;
|
||||
virtual arangodb::Result lastLogger(TRI_vocbase_t& vocbase, std::shared_ptr<arangodb::transaction::Context> transactionContext, uint64_t tickStart, uint64_t tickEnd, std::shared_ptr<VPackBuilder>& builderSPtr) override;
|
||||
virtual double minimumSyncReplicationTimeout() const override { return 1.0; }
|
||||
virtual TRI_vocbase_t* openDatabase(arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) override;
|
||||
virtual arangodb::Result persistCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection const* collection) override;
|
||||
virtual std::unique_ptr<TRI_vocbase_t> openDatabase(arangodb::velocypack::Slice const& args, bool isUpgrade, int& status) override;
|
||||
virtual arangodb::Result persistCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection const& collection) override;
|
||||
virtual arangodb::Result persistView(TRI_vocbase_t& vocbase, arangodb::LogicalView const& view) override;
|
||||
virtual void prepareDropDatabase(TRI_vocbase_t* vocbase, bool useWriteMarker, int& status) override;
|
||||
virtual void prepareDropDatabase(TRI_vocbase_t& vocbase, bool useWriteMarker, int& status) override;
|
||||
using StorageEngine::registerCollection;
|
||||
using StorageEngine::registerView;
|
||||
virtual TRI_voc_tick_t releasedTick() const override;
|
||||
virtual void releaseTick(TRI_voc_tick_t) override;
|
||||
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t*) override;
|
||||
virtual int removeReplicationApplierConfiguration(TRI_vocbase_t& vocbase) override;
|
||||
virtual int removeReplicationApplierConfiguration() override;
|
||||
virtual arangodb::Result renameCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection const* collection, std::string const& oldName) override;
|
||||
virtual arangodb::Result renameCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection const& collection, std::string const& oldName) override;
|
||||
virtual arangodb::Result renameView(TRI_vocbase_t& vocbase, arangodb::LogicalView const& view, std::string const& oldName) override;
|
||||
virtual int saveReplicationApplierConfiguration(TRI_vocbase_t*, arangodb::velocypack::Slice, bool) override;
|
||||
virtual int saveReplicationApplierConfiguration(TRI_vocbase_t& vocbase, arangodb::velocypack::Slice slice, bool doSync) override;
|
||||
virtual int saveReplicationApplierConfiguration(arangodb::velocypack::Slice, bool) override;
|
||||
virtual int shutdownDatabase(TRI_vocbase_t* vocbase) override;
|
||||
virtual void signalCleanup(TRI_vocbase_t* vocbase) override;
|
||||
virtual int shutdownDatabase(TRI_vocbase_t& vocbase) override;
|
||||
virtual void signalCleanup(TRI_vocbase_t& vocbase) override;
|
||||
virtual bool supportsDfdb() const override;
|
||||
virtual void unloadCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection* collection) override;
|
||||
virtual void unloadCollection(TRI_vocbase_t& vocbase, arangodb::LogicalCollection& collection) override;
|
||||
virtual bool useRawDocumentPointers() override { return false; }
|
||||
virtual std::string versionFilename(TRI_voc_tick_t) const override;
|
||||
virtual void waitForEstimatorSync(std::chrono::milliseconds maxWaitTime) override;
|
||||
|
|
Loading…
Reference in New Issue