1
0
Fork 0

add persistProperties() to PysicalCollection

This commit is contained in:
Jan Christoph Uhde 2017-02-22 12:47:03 +01:00
parent 6a659922ba
commit 3a201b4362
5 changed files with 35 additions and 35 deletions

View File

@ -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);
}

View File

@ -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<arangodb::velocypack::Builder>&) override;

View File

@ -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

View File

@ -683,16 +683,15 @@ void LogicalCollection::getPropertiesVPack(VPackBuilder& result, bool translateC
result.add("type", VPackValue(static_cast<int>(_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<uint32_t>(slice, "indexBuckets", _indexBuckets);
Helper::getNumericValue<uint32_t>(slice, "indexBuckets", _indexBuckets); //MMFiles
if (!_isLocal) {
// We need to inform the cluster as well

View File

@ -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;