From 9a5f0a14714ec9a6a71a003b72e5ed3520dfa125 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 19 Oct 2016 16:15:23 +0200 Subject: Removed the whole revision cleanup into the entitystore --- common/genericresource.cpp | 12 ++---------- common/pipeline.cpp | 17 ++--------------- common/pipeline.h | 11 ++--------- common/storage/entitystore.cpp | 9 +++++++++ common/storage/entitystore.h | 1 + 5 files changed, 16 insertions(+), 34 deletions(-) (limited to 'common') diff --git a/common/genericresource.cpp b/common/genericresource.cpp index 8f08f3d..39bd39e 100644 --- a/common/genericresource.cpp +++ b/common/genericresource.cpp @@ -57,12 +57,8 @@ class CommandProcessor : public QObject SINK_DEBUG_AREA("commandprocessor") public: - CommandProcessor(Sink::Pipeline *pipeline, QList commandQueues) : QObject(), mPipeline(pipeline), mCommandQueues(commandQueues), mProcessingLock(false) + CommandProcessor(Sink::Pipeline *pipeline, QList commandQueues) : QObject(), mPipeline(pipeline), mCommandQueues(commandQueues), mProcessingLock(false), mLowerBoundRevision(0) { - mPipeline->startTransaction(); - mLowerBoundRevision = mPipeline->revision(); - mPipeline->commit(); - for (auto queue : mCommandQueues) { const bool ret = connect(queue, &MessageQueue::messageReady, this, &CommandProcessor::process); Q_UNUSED(ret); @@ -191,10 +187,7 @@ private slots: auto time = QSharedPointer::create(); time->start(); mPipeline->startTransaction(); - SinkTrace() << "Cleaning up from " << mPipeline->cleanedUpRevision() + 1 << " to " << mLowerBoundRevision; - for (qint64 revision = mPipeline->cleanedUpRevision() + 1; revision <= mLowerBoundRevision; revision++) { - mPipeline->cleanupRevision(revision); - } + mPipeline->cleanupRevisions(mLowerBoundRevision); mPipeline->commit(); SinkTrace() << "Cleanup done." << Log::TraceTime(time->elapsed()); @@ -280,7 +273,6 @@ GenericResource::GenericResource(const ResourceContext &resourceContext, const Q auto ret = QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); Q_ASSERT(ret); } - mClientLowerBoundRevision = mPipeline->cleanedUpRevision(); mCommitQueueTimer.setInterval(sCommitInterval); mCommitQueueTimer.setSingleShot(true); diff --git a/common/pipeline.cpp b/common/pipeline.cpp index b1c2c58..bb40a85 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -282,25 +282,12 @@ KAsync::Job Pipeline::deletedEntity(void const *command, size_t size) return KAsync::value(d->entityStore.maxRevision()); } -void Pipeline::cleanupRevision(qint64 revision) +void Pipeline::cleanupRevisions(qint64 revision) { - d->entityStore.cleanupRevision(revision); + d->entityStore.cleanupRevisions(revision); d->revisionChanged = true; } -qint64 Pipeline::cleanedUpRevision() -{ - /* return d->entityStore.cleanedUpRevision(); */ - /* return DataStore::cleanedUpRevision(d->transaction); */ - //FIXME Just move the whole cleanup revision iteration into the entitystore - return 0; -} - -qint64 Pipeline::revision() -{ - //FIXME Just move the whole cleanup revision iteration into the entitystore - return 0; -} class Preprocessor::Private { public: diff --git a/common/pipeline.h b/common/pipeline.h index c6efaa6..b663dea 100644 --- a/common/pipeline.h +++ b/common/pipeline.h @@ -58,17 +58,10 @@ public: KAsync::Job deletedEntity(void const *command, size_t size); /* - * Cleans up a single revision. - * - * This has to be called for every revision in consecutive order. + * Cleans up all revisions until @param revision. */ - void cleanupRevision(qint64 revision); + void cleanupRevisions(qint64 revision); - /* - * Returns the latest cleaned up revision. - */ - qint64 cleanedUpRevision(); - qint64 revision(); signals: void revisionUpdated(qint64); diff --git a/common/storage/entitystore.cpp b/common/storage/entitystore.cpp index 30c7a71..a3d9997 100644 --- a/common/storage/entitystore.cpp +++ b/common/storage/entitystore.cpp @@ -303,6 +303,15 @@ void EntityStore::cleanupRevision(qint64 revision) DataStore::setCleanedUpRevision(d->transaction, revision); } +void EntityStore::cleanupRevisions(qint64 revision) +{ + const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); + SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << revision; + for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) { + cleanupRevision(revision); + } +} + QVector EntityStore::fullScan(const QByteArray &type) { SinkTrace() << "Looking for : " << type; diff --git a/common/storage/entitystore.h b/common/storage/entitystore.h index 39f5fc1..0e7572a 100644 --- a/common/storage/entitystore.h +++ b/common/storage/entitystore.h @@ -47,6 +47,7 @@ public: bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); void cleanupRevision(qint64 revision); + void cleanupRevisions(qint64 revision); void startTransaction(Sink::Storage::DataStore::AccessMode); void commitTransaction(); -- cgit v1.2.3