mirror of https://gitee.com/bigwinds/arangodb
add persistProperties() to PysicalCollection
This commit is contained in:
parent
6a659922ba
commit
3a201b4362
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -116,6 +116,8 @@ class MMFilesCollection final : public PhysicalCollection {
|
|||
};
|
||||
|
||||
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,6 +56,7 @@ class PhysicalCollection {
|
|||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue