diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-19 16:15:23 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-10-21 09:18:50 +0200 |
commit | 9a5f0a14714ec9a6a71a003b72e5ed3520dfa125 (patch) | |
tree | 78b2b4ac6fff648998b6e42aa0e4e0d8fb8144b7 | |
parent | 67ec34a8df3a2c3fe5ffbfd74ef06ee8a52ed2bb (diff) | |
download | sink-9a5f0a14714ec9a6a71a003b72e5ed3520dfa125.tar.gz sink-9a5f0a14714ec9a6a71a003b72e5ed3520dfa125.zip |
Removed the whole revision cleanup into the entitystore
-rw-r--r-- | common/genericresource.cpp | 12 | ||||
-rw-r--r-- | common/pipeline.cpp | 17 | ||||
-rw-r--r-- | common/pipeline.h | 11 | ||||
-rw-r--r-- | common/storage/entitystore.cpp | 9 | ||||
-rw-r--r-- | common/storage/entitystore.h | 1 | ||||
-rw-r--r-- | tests/pipelinetest.cpp | 4 |
6 files changed, 18 insertions, 36 deletions
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 | |||
57 | SINK_DEBUG_AREA("commandprocessor") | 57 | SINK_DEBUG_AREA("commandprocessor") |
58 | 58 | ||
59 | public: | 59 | public: |
60 | CommandProcessor(Sink::Pipeline *pipeline, QList<MessageQueue *> commandQueues) : QObject(), mPipeline(pipeline), mCommandQueues(commandQueues), mProcessingLock(false) | 60 | CommandProcessor(Sink::Pipeline *pipeline, QList<MessageQueue *> commandQueues) : QObject(), mPipeline(pipeline), mCommandQueues(commandQueues), mProcessingLock(false), mLowerBoundRevision(0) |
61 | { | 61 | { |
62 | mPipeline->startTransaction(); | ||
63 | mLowerBoundRevision = mPipeline->revision(); | ||
64 | mPipeline->commit(); | ||
65 | |||
66 | for (auto queue : mCommandQueues) { | 62 | for (auto queue : mCommandQueues) { |
67 | const bool ret = connect(queue, &MessageQueue::messageReady, this, &CommandProcessor::process); | 63 | const bool ret = connect(queue, &MessageQueue::messageReady, this, &CommandProcessor::process); |
68 | Q_UNUSED(ret); | 64 | Q_UNUSED(ret); |
@@ -191,10 +187,7 @@ private slots: | |||
191 | auto time = QSharedPointer<QTime>::create(); | 187 | auto time = QSharedPointer<QTime>::create(); |
192 | time->start(); | 188 | time->start(); |
193 | mPipeline->startTransaction(); | 189 | mPipeline->startTransaction(); |
194 | SinkTrace() << "Cleaning up from " << mPipeline->cleanedUpRevision() + 1 << " to " << mLowerBoundRevision; | 190 | mPipeline->cleanupRevisions(mLowerBoundRevision); |
195 | for (qint64 revision = mPipeline->cleanedUpRevision() + 1; revision <= mLowerBoundRevision; revision++) { | ||
196 | mPipeline->cleanupRevision(revision); | ||
197 | } | ||
198 | mPipeline->commit(); | 191 | mPipeline->commit(); |
199 | SinkTrace() << "Cleanup done." << Log::TraceTime(time->elapsed()); | 192 | SinkTrace() << "Cleanup done." << Log::TraceTime(time->elapsed()); |
200 | 193 | ||
@@ -280,7 +273,6 @@ GenericResource::GenericResource(const ResourceContext &resourceContext, const Q | |||
280 | auto ret = QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); | 273 | auto ret = QObject::connect(mPipeline.data(), &Pipeline::revisionUpdated, this, &Resource::revisionUpdated); |
281 | Q_ASSERT(ret); | 274 | Q_ASSERT(ret); |
282 | } | 275 | } |
283 | mClientLowerBoundRevision = mPipeline->cleanedUpRevision(); | ||
284 | 276 | ||
285 | mCommitQueueTimer.setInterval(sCommitInterval); | 277 | mCommitQueueTimer.setInterval(sCommitInterval); |
286 | mCommitQueueTimer.setSingleShot(true); | 278 | 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<qint64> Pipeline::deletedEntity(void const *command, size_t size) | |||
282 | return KAsync::value(d->entityStore.maxRevision()); | 282 | return KAsync::value(d->entityStore.maxRevision()); |
283 | } | 283 | } |
284 | 284 | ||
285 | void Pipeline::cleanupRevision(qint64 revision) | 285 | void Pipeline::cleanupRevisions(qint64 revision) |
286 | { | 286 | { |
287 | d->entityStore.cleanupRevision(revision); | 287 | d->entityStore.cleanupRevisions(revision); |
288 | d->revisionChanged = true; | 288 | d->revisionChanged = true; |
289 | } | 289 | } |
290 | 290 | ||
291 | qint64 Pipeline::cleanedUpRevision() | ||
292 | { | ||
293 | /* return d->entityStore.cleanedUpRevision(); */ | ||
294 | /* return DataStore::cleanedUpRevision(d->transaction); */ | ||
295 | //FIXME Just move the whole cleanup revision iteration into the entitystore | ||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | qint64 Pipeline::revision() | ||
300 | { | ||
301 | //FIXME Just move the whole cleanup revision iteration into the entitystore | ||
302 | return 0; | ||
303 | } | ||
304 | 291 | ||
305 | class Preprocessor::Private { | 292 | class Preprocessor::Private { |
306 | public: | 293 | 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: | |||
58 | KAsync::Job<qint64> deletedEntity(void const *command, size_t size); | 58 | KAsync::Job<qint64> deletedEntity(void const *command, size_t size); |
59 | 59 | ||
60 | /* | 60 | /* |
61 | * Cleans up a single revision. | 61 | * Cleans up all revisions until @param revision. |
62 | * | ||
63 | * This has to be called for every revision in consecutive order. | ||
64 | */ | 62 | */ |
65 | void cleanupRevision(qint64 revision); | 63 | void cleanupRevisions(qint64 revision); |
66 | 64 | ||
67 | /* | ||
68 | * Returns the latest cleaned up revision. | ||
69 | */ | ||
70 | qint64 cleanedUpRevision(); | ||
71 | qint64 revision(); | ||
72 | 65 | ||
73 | signals: | 66 | signals: |
74 | void revisionUpdated(qint64); | 67 | 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) | |||
303 | DataStore::setCleanedUpRevision(d->transaction, revision); | 303 | DataStore::setCleanedUpRevision(d->transaction, revision); |
304 | } | 304 | } |
305 | 305 | ||
306 | void EntityStore::cleanupRevisions(qint64 revision) | ||
307 | { | ||
308 | const auto lastCleanRevision = DataStore::cleanedUpRevision(d->transaction); | ||
309 | SinkTrace() << "Cleaning up from " << lastCleanRevision + 1 << " to " << revision; | ||
310 | for (qint64 rev = lastCleanRevision + 1; rev <= revision; rev++) { | ||
311 | cleanupRevision(revision); | ||
312 | } | ||
313 | } | ||
314 | |||
306 | QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) | 315 | QVector<QByteArray> EntityStore::fullScan(const QByteArray &type) |
307 | { | 316 | { |
308 | SinkTrace() << "Looking for : " << type; | 317 | 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: | |||
47 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); | 47 | bool modify(const QByteArray &type, const ApplicationDomain::ApplicationDomainType &, const QByteArrayList &deletions, bool replayToSource, const PreprocessModification &); |
48 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); | 48 | bool remove(const QByteArray &type, const QByteArray &uid, bool replayToSource, const PreprocessRemoval &); |
49 | void cleanupRevision(qint64 revision); | 49 | void cleanupRevision(qint64 revision); |
50 | void cleanupRevisions(qint64 revision); | ||
50 | 51 | ||
51 | void startTransaction(Sink::Storage::DataStore::AccessMode); | 52 | void startTransaction(Sink::Storage::DataStore::AccessMode); |
52 | void commitTransaction(); | 53 | void commitTransaction(); |
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 4e04152..5c294bb 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp | |||
@@ -272,7 +272,7 @@ private slots: | |||
272 | 272 | ||
273 | // Cleanup old revisions | 273 | // Cleanup old revisions |
274 | pipeline.startTransaction(); | 274 | pipeline.startTransaction(); |
275 | pipeline.cleanupRevision(2); | 275 | pipeline.cleanupRevisions(2); |
276 | pipeline.commit(); | 276 | pipeline.commit(); |
277 | 277 | ||
278 | // And now only the latest revision is left | 278 | // And now only the latest revision is left |
@@ -350,7 +350,7 @@ private slots: | |||
350 | 350 | ||
351 | // Cleanup old revisions | 351 | // Cleanup old revisions |
352 | pipeline.startTransaction(); | 352 | pipeline.startTransaction(); |
353 | pipeline.cleanupRevision(2); | 353 | pipeline.cleanupRevisions(2); |
354 | pipeline.commit(); | 354 | pipeline.commit(); |
355 | 355 | ||
356 | // And all revisions are gone | 356 | // And all revisions are gone |