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;
|
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){
|
PhysicalCollection* MMFilesCollection::clone(LogicalCollection* logical,PhysicalCollection* physical){
|
||||||
return new MMFilesCollection(logical, 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 updateProperties(VPackSlice const& slice, bool doSync) override;
|
||||||
|
virtual int persistProperties() noexcept override;
|
||||||
|
|
||||||
virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) override;
|
virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) override;
|
||||||
|
|
||||||
TRI_voc_rid_t revision() const override;
|
TRI_voc_rid_t revision() const override;
|
||||||
|
|
|
@ -1422,25 +1422,7 @@ static void JS_PropertiesVocbaseCol(
|
||||||
TRI_V8_THROW_EXCEPTION(res);
|
TRI_V8_THROW_EXCEPTION(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
res = collection->getPhysical()->persistProperties();
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (res != TRI_ERROR_NO_ERROR) {
|
if (res != TRI_ERROR_NO_ERROR) {
|
||||||
// TODO: what to do here
|
// 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("type", VPackValue(static_cast<int>(_type)));
|
||||||
result.add("status", VPackValue(_status));
|
result.add("status", VPackValue(_status));
|
||||||
result.add("deleted", VPackValue(_isDeleted));
|
result.add("deleted", VPackValue(_isDeleted));
|
||||||
result.add("doCompact", VPackValue(getPhysical()->doCompact()));
|
|
||||||
result.add("isSystem", VPackValue(_isSystem));
|
result.add("isSystem", VPackValue(_isSystem));
|
||||||
result.add("isVolatile", VPackValue(_isVolatile));
|
|
||||||
result.add("waitForSync", VPackValue(_waitForSync));
|
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
|
//TODO
|
||||||
// created in this place or maybe just split info in logical and pysical part
|
result.add("isVolatile", VPackValue(_isVolatile)); //MMFiles
|
||||||
// that would probably result in bigger changes TODO FIXME
|
result.add("journalSize", VPackValue(getPhysical()->journalSize())); //MMFiles
|
||||||
result.add("journalSize", VPackValue(getPhysical()->journalSize()));
|
result.add("doCompact", VPackValue(getPhysical()->doCompact())); //MMFiles
|
||||||
result.add("indexBuckets", VPackValue(_indexBuckets));
|
result.add("indexBuckets", VPackValue(_indexBuckets)); //MMFiles
|
||||||
|
|
||||||
result.add("replicationFactor", VPackValue(_replicationFactor));
|
result.add("replicationFactor", VPackValue(_replicationFactor));
|
||||||
if (!_distributeShardsLike.empty()) {
|
if (!_distributeShardsLike.empty()) {
|
||||||
if (translateCids) {
|
if (translateCids) {
|
||||||
|
@ -967,7 +966,7 @@ int LogicalCollection::updateProperties(VPackSlice const& slice, bool doSync) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVolatile() != arangodb::basics::VelocyPackHelper::getBooleanValue(
|
if (isVolatile() != arangodb::basics::VelocyPackHelper::getBooleanValue(
|
||||||
slice, "isVolatile", isVolatile())) {
|
slice, "isVolatile", isVolatile())) { //MMFiles
|
||||||
THROW_ARANGO_EXCEPTION_MESSAGE(
|
THROW_ARANGO_EXCEPTION_MESSAGE(
|
||||||
TRI_ERROR_BAD_PARAMETER,
|
TRI_ERROR_BAD_PARAMETER,
|
||||||
"isVolatile option cannot be changed at runtime");
|
"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);
|
_waitForSync = Helper::getBooleanValue(slice, "waitForSync", _waitForSync);
|
||||||
getPhysical()->updateProperties(slice,doSync);
|
getPhysical()->updateProperties(slice,doSync);
|
||||||
_indexBuckets =
|
_indexBuckets =
|
||||||
Helper::getNumericValue<uint32_t>(slice, "indexBuckets", _indexBuckets);
|
Helper::getNumericValue<uint32_t>(slice, "indexBuckets", _indexBuckets); //MMFiles
|
||||||
|
|
||||||
if (!_isLocal) {
|
if (!_isLocal) {
|
||||||
// We need to inform the cluster as well
|
// 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
|
virtual void setPath(std::string const&) = 0; // should be set during collection creation
|
||||||
// creation happens atm in engine->createCollection
|
// creation happens atm in engine->createCollection
|
||||||
virtual int updateProperties(VPackSlice const& slice, bool doSync) = 0;
|
virtual int updateProperties(VPackSlice const& slice, bool doSync) = 0;
|
||||||
|
virtual int persistProperties() noexcept = 0;
|
||||||
|
|
||||||
virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) = 0;
|
virtual PhysicalCollection* clone(LogicalCollection*, PhysicalCollection*) = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue