From 3a201b4362eb3f41e406c3fadd73ab2af46c0eb0 Mon Sep 17 00:00:00 2001 From: Jan Christoph Uhde Date: Wed, 22 Feb 2017 12:47:03 +0100 Subject: [PATCH] add persistProperties() to PysicalCollection --- arangod/MMFiles/MMFilesCollection.cpp | 16 ++++++++++++++++ arangod/MMFiles/MMFilesCollection.h | 8 +++++--- arangod/V8Server/v8-collection.cpp | 20 +------------------- arangod/VocBase/LogicalCollection.cpp | 19 +++++++++---------- arangod/VocBase/PhysicalCollection.h | 7 ++++--- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/arangod/MMFiles/MMFilesCollection.cpp b/arangod/MMFiles/MMFilesCollection.cpp index 57cfd59ec8..7619019afa 100644 --- a/arangod/MMFiles/MMFilesCollection.cpp +++ b/arangod/MMFiles/MMFilesCollection.cpp @@ -123,6 +123,22 @@ int MMFilesCollection::updateProperties(VPackSlice const& slice, bool doSync){ return TRI_ERROR_NO_ERROR; } +int MMFilesCollection::persistProperties() noexcept { + try { + VPackBuilder infoBuilder; + _logicalCollection->toVelocyPack(infoBuilder, false); + + MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CHANGE_COLLECTION, _logicalCollection->vocbase()->id(), _logicalCollection->cid(), infoBuilder.slice()); + MMFilesWalSlotInfoCopy slotInfo = + MMFilesLogfileManager::instance()->allocateAndWrite(marker, false); + return slotInfo.errorCode; + } catch (arangodb::basics::Exception const& ex) { + return ex.code(); + } catch (...) { + return TRI_ERROR_INTERNAL; + } +} + PhysicalCollection* MMFilesCollection::clone(LogicalCollection* logical,PhysicalCollection* physical){ return new MMFilesCollection(logical, physical); } diff --git a/arangod/MMFiles/MMFilesCollection.h b/arangod/MMFiles/MMFilesCollection.h index 7712fad1ca..7155b6602e 100644 --- a/arangod/MMFiles/MMFilesCollection.h +++ b/arangod/MMFiles/MMFilesCollection.h @@ -106,16 +106,18 @@ class MMFilesCollection final : public PhysicalCollection { explicit MMFilesCollection(LogicalCollection*, PhysicalCollection*); //use in cluster only!!!!! ~MMFilesCollection(); - + std::string const& path() const override { return _path; }; - + void setPath(std::string const& path) override { _path = path; }; virtual int updateProperties(VPackSlice const& slice, bool doSync) override; + virtual int persistProperties() noexcept override; + virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) override; TRI_voc_rid_t revision() const override; @@ -129,7 +131,7 @@ class MMFilesCollection final : public PhysicalCollection { size_t journalSize() const override { return _journalSize; }; TRI_voc_tick_t maxTick() const { return _maxTick; } void maxTick(TRI_voc_tick_t value) { _maxTick = value; } - + /// @brief return engine-specific figures void figuresSpecific(std::shared_ptr&) override; diff --git a/arangod/V8Server/v8-collection.cpp b/arangod/V8Server/v8-collection.cpp index af9d91815b..aa51e303c7 100644 --- a/arangod/V8Server/v8-collection.cpp +++ b/arangod/V8Server/v8-collection.cpp @@ -1422,25 +1422,7 @@ static void JS_PropertiesVocbaseCol( TRI_V8_THROW_EXCEPTION(res); } - try { - VPackBuilder infoBuilder; - collection->toVelocyPack(infoBuilder, false); - - // now log the property changes - res = TRI_ERROR_NO_ERROR; - - MMFilesCollectionMarker marker(TRI_DF_MARKER_VPACK_CHANGE_COLLECTION, collection->vocbase()->id(), collection->cid(), infoBuilder.slice()); - MMFilesWalSlotInfoCopy slotInfo = - MMFilesLogfileManager::instance()->allocateAndWrite(marker, false); - - if (slotInfo.errorCode != TRI_ERROR_NO_ERROR) { - THROW_ARANGO_EXCEPTION(slotInfo.errorCode); - } - } catch (arangodb::basics::Exception const& ex) { - res = ex.code(); - } catch (...) { - res = TRI_ERROR_INTERNAL; - } + res = collection->getPhysical()->persistProperties(); if (res != TRI_ERROR_NO_ERROR) { // TODO: what to do here diff --git a/arangod/VocBase/LogicalCollection.cpp b/arangod/VocBase/LogicalCollection.cpp index b3b659397c..146adaaf87 100644 --- a/arangod/VocBase/LogicalCollection.cpp +++ b/arangod/VocBase/LogicalCollection.cpp @@ -683,16 +683,15 @@ void LogicalCollection::getPropertiesVPack(VPackBuilder& result, bool translateC result.add("type", VPackValue(static_cast(_type))); result.add("status", VPackValue(_status)); result.add("deleted", VPackValue(_isDeleted)); - result.add("doCompact", VPackValue(getPhysical()->doCompact())); result.add("isSystem", VPackValue(_isSystem)); - result.add("isVolatile", VPackValue(_isVolatile)); result.add("waitForSync", VPackValue(_waitForSync)); - // maybe add journalsize in Pysical - problem we need ot create one object - // we shold not merge one silice created by they physical with the one - // created in this place or maybe just split info in logical and pysical part - // that would probably result in bigger changes TODO FIXME - result.add("journalSize", VPackValue(getPhysical()->journalSize())); - result.add("indexBuckets", VPackValue(_indexBuckets)); + + //TODO + result.add("isVolatile", VPackValue(_isVolatile)); //MMFiles + result.add("journalSize", VPackValue(getPhysical()->journalSize())); //MMFiles + result.add("doCompact", VPackValue(getPhysical()->doCompact())); //MMFiles + result.add("indexBuckets", VPackValue(_indexBuckets)); //MMFiles + result.add("replicationFactor", VPackValue(_replicationFactor)); if (!_distributeShardsLike.empty()) { if (translateCids) { @@ -967,7 +966,7 @@ int LogicalCollection::updateProperties(VPackSlice const& slice, bool doSync) { } if (isVolatile() != arangodb::basics::VelocyPackHelper::getBooleanValue( - slice, "isVolatile", isVolatile())) { + slice, "isVolatile", isVolatile())) { //MMFiles THROW_ARANGO_EXCEPTION_MESSAGE( TRI_ERROR_BAD_PARAMETER, "isVolatile option cannot be changed at runtime"); @@ -986,7 +985,7 @@ int LogicalCollection::updateProperties(VPackSlice const& slice, bool doSync) { _waitForSync = Helper::getBooleanValue(slice, "waitForSync", _waitForSync); getPhysical()->updateProperties(slice,doSync); _indexBuckets = - Helper::getNumericValue(slice, "indexBuckets", _indexBuckets); + Helper::getNumericValue(slice, "indexBuckets", _indexBuckets); //MMFiles if (!_isLocal) { // We need to inform the cluster as well diff --git a/arangod/VocBase/PhysicalCollection.h b/arangod/VocBase/PhysicalCollection.h index c7e5c962d5..4821077f6d 100644 --- a/arangod/VocBase/PhysicalCollection.h +++ b/arangod/VocBase/PhysicalCollection.h @@ -50,17 +50,18 @@ class PhysicalCollection { public: virtual ~PhysicalCollection() = default; - + //path to logical collection virtual std::string const& path() const = 0; virtual void setPath(std::string const&) = 0; // should be set during collection creation // creation happens atm in engine->createCollection virtual int updateProperties(VPackSlice const& slice, bool doSync) = 0; - + virtual int persistProperties() noexcept = 0; + virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) = 0; virtual TRI_voc_rid_t revision() const = 0; - + virtual int64_t initialCount() const = 0; virtual void updateCount(int64_t) = 0;