From f5298b5681981f09c7d1bc743c2d5cfb8f780004 Mon Sep 17 00:00:00 2001 From: Piotr M Date: Sat, 7 Jan 2017 23:26:34 +0100 Subject: [PATCH 1/2] Group requests to ensure balance between bandwidth utilization and bookkeeping This fixes issues: #5391 #5390 #4498 #1633 #4454 --- src/libsync/CMakeLists.txt | 1 + src/libsync/capabilities.cpp | 9 ++ src/libsync/capabilities.h | 1 + src/libsync/configfile.cpp | 7 ++ src/libsync/configfile.h | 1 + src/libsync/owncloudpropagator.cpp | 95 +++++++++++--- src/libsync/owncloudpropagator.h | 32 ++++- src/libsync/propagatedownload.h | 2 +- src/libsync/propagateupload.h | 96 +++++++++++++- src/libsync/propagateuploadbundle.cpp | 173 ++++++++++++++++++++++++++ 10 files changed, 394 insertions(+), 23 deletions(-) create mode 100644 src/libsync/propagateuploadbundle.cpp diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt index cbece4b41c7..97311792f4b 100644 --- a/src/libsync/CMakeLists.txt +++ b/src/libsync/CMakeLists.txt @@ -52,6 +52,7 @@ set(libsync_SRCS propagateupload.cpp propagateuploadv1.cpp propagateuploadng.cpp + propagateuploadbundle.cpp propagateremotedelete.cpp propagateremotemove.cpp propagateremotemkdir.cpp diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 5bd5d1c4c31..75d126259e0 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -108,6 +108,15 @@ QByteArray Capabilities::uploadChecksumType() const return QByteArray(); } +bool Capabilities::bundling() const +{ + static const auto bundling = qgetenv("OWNCLOUD_BUNDLING"); + if (bundling == "0") return false; + if (bundling == "1") return true; + + return _capabilities["dav"].toMap()["bundling"].toByteArray() >= "1.0"; +} + bool Capabilities::chunkingNg() const { static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG"); diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index 76e2b6f224d..398042b7172 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -40,6 +40,7 @@ class OWNCLOUDSYNC_EXPORT Capabilities { bool sharePublicLinkEnforceExpireDate() const; int sharePublicLinkExpireDateDays() const; bool shareResharing() const; + bool bundling() const; bool chunkingNg() const; /// disable parallel upload in chunking diff --git a/src/libsync/configfile.cpp b/src/libsync/configfile.cpp index 4c8a30bf6f9..cfdae09a7d4 100644 --- a/src/libsync/configfile.cpp +++ b/src/libsync/configfile.cpp @@ -52,6 +52,7 @@ static const char updateCheckIntervalC[] = "updateCheckInterval"; static const char geometryC[] = "geometry"; static const char timeoutC[] = "timeout"; static const char chunkSizeC[] = "chunkSize"; +static const char smallFileSizeC[] = "smallFileSize"; static const char proxyHostC[] = "Proxy/host"; static const char proxyTypeC[] = "Proxy/type"; @@ -128,6 +129,12 @@ quint64 ConfigFile::chunkSize() const return settings.value(QLatin1String(chunkSizeC), 10*1000*1000).toLongLong(); // default to 10 MB } +quint64 ConfigFile::smallFileSize() const +{ + QSettings settings(configFile(), QSettings::IniFormat); + return settings.value(QLatin1String(smallFileSizeC), 1*1000*1000).toLongLong(); // default to 1 MB +} + void ConfigFile::setOptionalDesktopNotifications(bool show) { QSettings settings(configFile(), QSettings::IniFormat); diff --git a/src/libsync/configfile.h b/src/libsync/configfile.h index cd95f1a0bce..01c3b44cc1a 100644 --- a/src/libsync/configfile.h +++ b/src/libsync/configfile.h @@ -113,6 +113,7 @@ class OWNCLOUDSYNC_EXPORT ConfigFile int timeout() const; quint64 chunkSize() const; + quint64 smallFileSize() const; void saveGeometry(QWidget *w); void restoreGeometry(QWidget *w); diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index aa406494316..a86ae8532df 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -313,6 +313,7 @@ void OwncloudPropagator::start(const SyncFileItemVector& items) directories.push(qMakePair(QString(), _rootJob.data())); QVector directoriesToRemove; QString removedDirectory; + bool enableBundledRequests = account()->capabilities().bundling(); foreach(const SyncFileItemPtr &item, items) { if (!removedDirectory.isEmpty() && item->_file.startsWith(removedDirectory)) { @@ -389,13 +390,30 @@ void OwncloudPropagator::start(const SyncFileItemVector& items) currentDirJob->append(dir); } directories.push(qMakePair(item->destination() + "/" , dir)); - } else if (PropagateItemJob* current = createJob(item)) { - if (item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE) { - // will delete directories, so defer execution - directoriesToRemove.prepend(current); - removedDirectory = item->_file + "/"; - } else { - directories.top().second->append(current); + } else { + // Ensure that only files under or equal to chunk size are being inserted to Normal Upload + if (enableBundledRequests && item->_size <= chunkSize() + && item->_instruction == CSYNC_INSTRUCTION_NEW + && item->_direction == SyncFileItem::Up ) { + // Get PropagateNormalUpload container job + PropagateNormalUpload* bundleJob = 0; + if (directories.top().second->_bundledUploadJob.isNull()) { + bundleJob = new PropagateNormalUpload(this); + directories.top().second->_bundledUploadJob.reset(bundleJob); + } else { + bundleJob = qobject_cast(directories.top().second->_bundledUploadJob.data()); + } + + // Append Upload job + bundleJob->append(item); + } else if (PropagateItemJob* current = createJob(item)) { + if (item->_instruction == CSYNC_INSTRUCTION_TYPE_CHANGE) { + // will delete directories, so defer execution + directoriesToRemove.prepend(current); + removedDirectory = item->_file + "/"; + } else { + directories.top().second->append(current); + } } } } @@ -459,6 +477,20 @@ quint64 OwncloudPropagator::chunkSize() return chunkSize; } +quint64 OwncloudPropagator::smallFileSize() +{ + // Small filesize item is the file which transfer time + // typicaly will be lower than its bookkeping time. + static uint smallFileSize; + if (!smallFileSize) { + smallFileSize = qgetenv("OWNCLOUD_SMALLFILE_SIZE").toUInt(); + if (smallFileSize == 0) { + ConfigFile cfg; + smallFileSize = cfg.smallFileSize(); + } + } + return smallFileSize; +} bool OwncloudPropagator::localFileNameClash( const QString& relFile ) { @@ -591,6 +623,13 @@ PropagatorJob::JobParallelism PropagateDirectory::parallelism() return FullParallelism; } +void PropagateDirectory::append(PropagatorJob *subJob) { + if (!subJob->isJobsContainer()){ + // This is standard job, so increase global counter + _propagator->_standardJobsCount++; + } + _subJobs.append(subJob); +} bool PropagateDirectory::scheduleNextJob() { @@ -601,15 +640,25 @@ bool PropagateDirectory::scheduleNextJob() if (_state == NotYetStarted) { _state = Running; - // At the begining of the Directory Job, update expected number of Jobs to be synced - _totalJobs = _subJobs.count(); - if (_firstJob) - _totalJobs++; + if(_bundledUploadJob){ + // PropagateNormalUpload is not a standard job, since it is abstract object + PropagateNormalUpload* bundle = qobject_cast(_bundledUploadJob.take()); + append(bundle); + } if (!_firstJob && _subJobs.isEmpty()) { finalize(); return true; } + + // At the begining of the Directory Job, update expected number of Jobs to be synced + _totalJobs = _subJobs.count(); + if (_firstJob) { + // _firstJob is a standard job, since it does interact with server + _propagator->_standardJobsCount++; + _totalJobs++; + } + } if (_firstJob && _firstJob->_state == NotYetStarted) { @@ -626,14 +675,20 @@ bool PropagateDirectory::scheduleNextJob() while (subJobsIterator.hasNext()) { subJobsIterator.next(); - // Get the state of the state of the sub job pointed by call next() - // Function value() will directly access the item through hash in the QList at that subjob + // Get the state of the sub job pointed by call next() if (subJobsIterator.value()->_state == Finished) { - // If this items is finish, remove it from the _subJobs list as it is not needed anymore + // If this items is finished, remove it from the _subJobs as it is not needed anymore // Note that in this case remove() from QVector will just perform memmove of pointer array items. - PropagatorJob * jobPointer = subJobsIterator.value(); + PropagatorJob * job = subJobsIterator.value(); subJobsIterator.remove(); - delete jobPointer; + + // Delete only containers now, we need items in slotSubJobFinished + // Items will be deleted when one will call delete on parent container later + if (job->isJobsContainer()){ + delete job; + } else { + _finishedSubJobs.append(job); + } continue; } @@ -669,12 +724,20 @@ void PropagateDirectory::slotSubJobFinished(SyncFileItem::Status status) } else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) { _hasError = status; } + + PropagatorJob *job = qobject_cast(sender()); + if (job && !job->isJobsContainer()){ + // The finished job was an item, decrease global counter as it is finished + _propagator->_standardJobsCount--; + } + _runningNow--; _jobsFinished++; // We finished processing all the jobs // check if we finished if (_jobsFinished >= _totalJobs) { + Q_ASSERT(_propagator->_standardJobsCount>=0); Q_ASSERT(!_runningNow); // how can we be finished if there are still jobs running now finalize(); } else { diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index 6ab87724bc4..c56b1840c3f 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -100,6 +100,12 @@ class PropagatorJob : public QObject { */ virtual qint64 committedDiskSpace() const { return 0; } + /** + * As in the description, this class can be job or job container + * This flag will allow to detect it + */ + virtual bool isJobsContainer() const { return false; } + public slots: virtual void abort() {} @@ -185,11 +191,18 @@ class OWNCLOUDSYNC_EXPORT PropagateDirectory : public PropagatorJob { Q_OBJECT public: // e.g: create the directory - QScopedPointer_firstJob; + QScopedPointer _firstJob; + + // e.g: create class which will handle bundled uploads and bandwidth utilization vs bookkeeping balance + QScopedPointer _bundledUploadJob; // all the sub files or sub directories. QVector _subJobs; + // all the finished sub PropagatorJob items which are not PropagateItemJob. + // one might need PropagatorJobs (PropagateDirectory, PropagateNormalUpload) + QVector _finishedSubJobs; + SyncFileItemPtr _item; int _jobsFinished; // number of jobs that have completed @@ -199,16 +212,16 @@ class OWNCLOUDSYNC_EXPORT PropagateDirectory : public PropagatorJob { explicit PropagateDirectory(OwncloudPropagator *propagator, const SyncFileItemPtr &item = SyncFileItemPtr(new SyncFileItem)) : PropagatorJob(propagator) - , _firstJob(0), _item(item), _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus), _totalJobs(0) + , _firstJob(0), _bundledUploadJob(0), _item(item), _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus), _totalJobs(0) + { } virtual ~PropagateDirectory() { qDeleteAll(_subJobs); + qDeleteAll(_finishedSubJobs); } - void append(PropagatorJob *subJob) { - _subJobs.append(subJob); - } + void append(PropagatorJob *subJob); virtual bool scheduleNextJob() Q_DECL_OVERRIDE; virtual JobParallelism parallelism() Q_DECL_OVERRIDE; @@ -227,6 +240,8 @@ class OWNCLOUDSYNC_EXPORT PropagateDirectory : public PropagatorJob { qint64 committedDiskSpace() const Q_DECL_OVERRIDE; + bool isJobsContainer() const Q_DECL_OVERRIDE { return true; } + private slots: bool possiblyRunNextJob(PropagatorJob *next) { if (next->_state == NotYetStarted) { @@ -281,6 +296,9 @@ class OwncloudPropagator : public QObject { , _journal(progressDb) , _finishedEmited(false) , _bandwidthManager(this) + , _activeDBJobs(0) + , _dbJobsCount(0) + , _standardJobsCount(0) , _anotherSyncNeeded(false) , _account(account) { } @@ -302,6 +320,9 @@ class OwncloudPropagator : public QObject { Jobs can be several time on the list (example, when several chunks are uploaded in parallel) */ QList _activeJobList; + qint8 _activeDBJobs; // number of active DB jobs running + qint64 _dbJobsCount; // number of all jobs in which db operations are major factor + qint64 _standardJobsCount; // number of all jobs which are rare or in which db operations are not a major factor /** We detected that another sync is required after this one */ bool _anotherSyncNeeded; @@ -327,6 +348,7 @@ class OwncloudPropagator : public QObject { /** returns the size of chunks in bytes */ static quint64 chunkSize(); + static quint64 smallFileSize(); AccountPtr account() const; diff --git a/src/libsync/propagatedownload.h b/src/libsync/propagatedownload.h index 1317dda869c..fb55c36fcf9 100644 --- a/src/libsync/propagatedownload.h +++ b/src/libsync/propagatedownload.h @@ -115,7 +115,7 @@ class PropagateDownloadFile : public PropagateItemJob { qint64 committedDiskSpace() const Q_DECL_OVERRIDE; // We think it might finish quickly because it is a small file. - bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < 100*1024; } + bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < _propagator->smallFileSize(); } /** * Whether an existing folder with the same name may be deleted before diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index bac3e112ba5..8285f9e09e5 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -1,5 +1,6 @@ /* * Copyright (C) by Olivier Goffart + * Copyright (C) by Piotr Mrowczynski * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -209,7 +210,7 @@ class PropagateUploadFileCommon : public PropagateItemJob { void start() Q_DECL_OVERRIDE; - bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return _item->_size < 100*1024; } + bool isLikelyFinishedQuickly() Q_DECL_OVERRIDE { return false; } private slots: void slotComputeContentChecksum(); @@ -321,6 +322,99 @@ private slots: void slotUploadProgress(qint64,qint64); }; +/** + * @brief The PropagateUploadBundle class is a container class for upload jobs under chunking size. + * + * It will also ensure proper bandwidth utilization vs bookkeeping balance, and that in case no other items then under chunk uploads are available, + * it will parallelise itself into 3 flows. + * + * + * @ingroup libsync + * + * State Machine: + * + * _________________________________________________ _________________________________________ + * | | | + * | (Are there any STANDARD jobs to run in whole sync?) | + * | Yes | | No | + * | (Is there any DB job running in whole sync?) (Is there any DB job within this class?) | + * | Yes | | No No | | Yes | + * | | | | | | + * |<-[Schedule STANDARD job] | | [Schedule DB job]-> + * | | | + * | | | + * | (Is there any DB job within this class?) | + * ^ Yes | | No | + * | | | | + * |<-[Schedule DB job] | | + * | | | + * | | | + * ^ (Are there at least 2 STANDARD jobs | + * | already running within this class?) | + * | No | | Yes | + * | | | | + * <-[Schedule STANDARD job] ->[Try in next container]<- + * + */ +class PropagateNormalUpload : public PropagatorJob { + Q_OBJECT +public: + // all the sub files which are equal or smaller _propagator->smallFileSize() + QVector _dbJobs; + + // all the sub files which are over _propagator->smallFileSize() + QVector _standardJobs; + + // all the sub files which were deleted inside this job + QVector _finishedSubJobs; + + int _jobsFinished; // number of jobs that have completed + int _runningNow; // number of subJobs running right now + SyncFileItem::Status _hasError; // NoStatus, or NormalError / SoftError if there was an error + int _totalJobs; + + explicit PropagateNormalUpload(OwncloudPropagator *propagator) + : PropagatorJob(propagator) + , _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus), _totalJobs(0) { } + + virtual ~PropagateNormalUpload() { + qDeleteAll(_dbJobs); + qDeleteAll(_standardJobs); + qDeleteAll(_finishedSubJobs); + } + + void append(const SyncFileItemPtr &item); + bool scheduleNextJobRoutine(QVector &subJobs); + virtual bool scheduleNextJob() Q_DECL_OVERRIDE; + + virtual void abort() Q_DECL_OVERRIDE { + foreach (PropagatorJob *n, _standardJobs) + n->abort(); + foreach (PropagatorJob *s, _dbJobs) + s->abort(); + } + + void finalize(); + + qint64 committedDiskSpace() const Q_DECL_OVERRIDE; + + bool isJobsContainer() const Q_DECL_OVERRIDE { return true; } + +private slots: + bool possiblyRunNextJob(PropagatorJob *next) { + if (next->_state == NotYetStarted) { + connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)), Qt::QueuedConnection); + connect(next, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)), + this, SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &))); + connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64))); + connect(next, SIGNAL(ready()), this, SIGNAL(ready())); + _runningNow++; + } + return next->scheduleNextJob(); + } + + void slotSubJobFinished(SyncFileItem::Status status); +}; } diff --git a/src/libsync/propagateuploadbundle.cpp b/src/libsync/propagateuploadbundle.cpp new file mode 100644 index 00000000000..e3b7ecefd18 --- /dev/null +++ b/src/libsync/propagateuploadbundle.cpp @@ -0,0 +1,173 @@ +/* + * Copyright (C) by Piotr Mrowczynski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "propagateupload.h" + +namespace OCC { + + +qint64 PropagateNormalUpload::committedDiskSpace() const +{ + qint64 needed = 0; + foreach (PropagatorJob* job, _dbJobs) { + needed += job->committedDiskSpace(); + } + foreach (PropagatorJob* job, _standardJobs) { + needed += job->committedDiskSpace(); + } + return needed; +} + +bool PropagateNormalUpload::scheduleNextJobRoutine(QVector &subJobs) { + QMutableVectorIterator subJobsIterator(subJobs); + while (subJobsIterator.hasNext()) { + subJobsIterator.next(); + // Get the state of the sub job pointed by call next() + if (subJobsIterator.value()->_state == Finished) { + // If this items is finish, remove it from the _subJobs list as it is not needed anymore + // Note that in this case remove() from QVector will just perform memmove of pointer array items. + PropagatorJob * job = subJobsIterator.value(); + subJobsIterator.remove(); + + // In this case de dont delete job, but save it in _finishedSubJobs queue + // We might need this job in slotSubJobFinished + // The PropagateNormalUpload class will be destroyed in PropagateDirectory + // when it will detect that we finished PropagateNormalUpload + _finishedSubJobs.append(job); + continue; + } + + if (possiblyRunNextJob(subJobsIterator.value())) { + return true; + } + + Q_ASSERT(subJobsIterator.value()->_state == Running); + } + return false; +} + +void PropagateNormalUpload::append(const SyncFileItemPtr &item) { + // In case of bundles, in here we should append BundledUpload jobs with new files to the .top() of _subJobs until reached chunking size + // Role of this class is also to control how much data is going into the container class + // In version 1.0 append just PUTs + + PropagateUploadFileV1* subJob = new PropagateUploadFileV1(_propagator, item); + if (item->_size <= _propagator->smallFileSize()){ + _propagator->_dbJobsCount++; // This item db operations take considerably longer then any other factors. + _dbJobs.append(subJob); + } else { + _propagator->_standardJobsCount++; // This item is not a small upload file, so it is standard + _standardJobs.append(subJob); + } +} + +bool PropagateNormalUpload::scheduleNextJob() +{ + if (_state == Finished) { + return false; + } + + if (_state == NotYetStarted) { + _state = Running; + + if (_dbJobs.isEmpty() && _standardJobs.isEmpty()) { + finalize(); + return true; + } + + // At the begining of the Directory Job, update expected number of Jobs to be synced + _totalJobs = _standardJobs.count() + _dbJobs.count(); + } + + // Check if there are standard jobs in whole sync waiting for sync or pending + if (_propagator->_standardJobsCount > 0){ + // Check if there are already some dbJobs running + if(_propagator->_activeDBJobs > 0){ + // Run standardJobs represented by _propagator->_standardJobsCount + return scheduleNextJobRoutine(_standardJobs); + } else { + // There is no running dbJob, try to schedule one + if(scheduleNextJobRoutine(_dbJobs)){ + // This container contains dbJobs and will sync it + _propagator->_activeDBJobs++; + return true; + } else { + // This container does not contain any remaining dbJobs + if(_runningNow > 1){ + // There are some jobs running in this container, + // but for sure not dbJobs, search in different container for db jobs + return false; + } + return scheduleNextJobRoutine(_standardJobs); + } + } + } else { + // There are no remaining or pending standard jobs in whole sync + // This also means that _standardJobs is empty + Q_ASSERT(!scheduleNextJobRoutine(_standardJobs)); + + // Parallelise itself into more flows flows + if(scheduleNextJobRoutine(_dbJobs)){ + _propagator->_activeDBJobs++; + return true; + } + return false; + } +} + + +void PropagateNormalUpload::slotSubJobFinished(SyncFileItem::Status status) +{ + if (status == SyncFileItem::FatalError) { + abort(); + _state = Finished; + emit finished(status); + return; + } else if (status == SyncFileItem::NormalError || status == SyncFileItem::SoftError) { + _hasError = status; + } + + // We need to ensure that this PropagateItemJob exists by not deleting it prematurely + PropagateItemJob *job = qobject_cast(sender()); + Q_ASSERT(job); + + // Reduce the global counter of db or standard jobs + if (job->_item->_size <= _propagator->smallFileSize()){ + _propagator->_dbJobsCount--; + _propagator->_activeDBJobs--; + } else { + _propagator->_standardJobsCount--; // This item is not a small upload file, so it is standard + } + + _runningNow--; + _jobsFinished++; + + // We finished processing all the jobs + // check if we finished + if (_jobsFinished >= _totalJobs) { + Q_ASSERT(_propagator->_standardJobsCount>=0); + Q_ASSERT(!_runningNow); // how can we be finished if there are still jobs running now + finalize(); + } else { + emit ready(); + } +} + +void PropagateNormalUpload::finalize() +{ + _state = Finished; + emit finished(_hasError == SyncFileItem::NoStatus ? SyncFileItem::Success : _hasError); +} + +} From 6429aa48b3577726668b1470cc160180f44279b6 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 9 Jan 2017 11:33:10 +0545 Subject: [PATCH 2/2] Suggestions for comments --- src/libsync/owncloudpropagator.cpp | 18 +++++++++--------- src/libsync/owncloudpropagator.h | 6 +++--- src/libsync/propagateupload.h | 2 +- src/libsync/propagateuploadbundle.cpp | 22 +++++++++++----------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index a86ae8532df..5e76f153d35 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -479,8 +479,8 @@ quint64 OwncloudPropagator::chunkSize() quint64 OwncloudPropagator::smallFileSize() { - // Small filesize item is the file which transfer time - // typicaly will be lower than its bookkeping time. + // A small filesize item is a file whose transfer time + // typically will be lower than its bookkeeping time. static uint smallFileSize; if (!smallFileSize) { smallFileSize = qgetenv("OWNCLOUD_SMALLFILE_SIZE").toUInt(); @@ -625,7 +625,7 @@ PropagatorJob::JobParallelism PropagateDirectory::parallelism() void PropagateDirectory::append(PropagatorJob *subJob) { if (!subJob->isJobsContainer()){ - // This is standard job, so increase global counter + // This is a standard job, so increase global counter _propagator->_standardJobsCount++; } _subJobs.append(subJob); @@ -641,7 +641,7 @@ bool PropagateDirectory::scheduleNextJob() _state = Running; if(_bundledUploadJob){ - // PropagateNormalUpload is not a standard job, since it is abstract object + // PropagateNormalUpload is not a standard job, since it is an abstract object PropagateNormalUpload* bundle = qobject_cast(_bundledUploadJob.take()); append(bundle); } @@ -651,10 +651,10 @@ bool PropagateDirectory::scheduleNextJob() return true; } - // At the begining of the Directory Job, update expected number of Jobs to be synced + // At the beginning of the Directory Job, update the expected number of Jobs to be synced _totalJobs = _subJobs.count(); if (_firstJob) { - // _firstJob is a standard job, since it does interact with server + // _firstJob is a standard job, since it does interact with the server _propagator->_standardJobsCount++; _totalJobs++; } @@ -675,15 +675,15 @@ bool PropagateDirectory::scheduleNextJob() while (subJobsIterator.hasNext()) { subJobsIterator.next(); - // Get the state of the sub job pointed by call next() + // Get the state of the sub job pointed at by call next() if (subJobsIterator.value()->_state == Finished) { - // If this items is finished, remove it from the _subJobs as it is not needed anymore + // If this item is finished, remove it from _subJobs as it is not needed anymore // Note that in this case remove() from QVector will just perform memmove of pointer array items. PropagatorJob * job = subJobsIterator.value(); subJobsIterator.remove(); // Delete only containers now, we need items in slotSubJobFinished - // Items will be deleted when one will call delete on parent container later + // Items will be deleted later when one of them calls delete on the parent container if (job->isJobsContainer()){ delete job; } else { diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index c56b1840c3f..7e1e7df9e85 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -101,8 +101,8 @@ class PropagatorJob : public QObject { virtual qint64 committedDiskSpace() const { return 0; } /** - * As in the description, this class can be job or job container - * This flag will allow to detect it + * As in the description, this class can be a job or job container. + * This flag will allow it to be detected. */ virtual bool isJobsContainer() const { return false; } @@ -321,7 +321,7 @@ class OwncloudPropagator : public QObject { */ QList _activeJobList; qint8 _activeDBJobs; // number of active DB jobs running - qint64 _dbJobsCount; // number of all jobs in which db operations are major factor + qint64 _dbJobsCount; // number of all jobs in which db operations are a major factor qint64 _standardJobsCount; // number of all jobs which are rare or in which db operations are not a major factor /** We detected that another sync is required after this one */ diff --git a/src/libsync/propagateupload.h b/src/libsync/propagateupload.h index 8285f9e09e5..fe2c0a1091c 100644 --- a/src/libsync/propagateupload.h +++ b/src/libsync/propagateupload.h @@ -359,7 +359,7 @@ private slots: class PropagateNormalUpload : public PropagatorJob { Q_OBJECT public: - // all the sub files which are equal or smaller _propagator->smallFileSize() + // all the sub files which are equal to or smaller than _propagator->smallFileSize() QVector _dbJobs; // all the sub files which are over _propagator->smallFileSize() diff --git a/src/libsync/propagateuploadbundle.cpp b/src/libsync/propagateuploadbundle.cpp index e3b7ecefd18..fd21c3b2918 100644 --- a/src/libsync/propagateuploadbundle.cpp +++ b/src/libsync/propagateuploadbundle.cpp @@ -33,14 +33,14 @@ bool PropagateNormalUpload::scheduleNextJobRoutine(QVector &sub QMutableVectorIterator subJobsIterator(subJobs); while (subJobsIterator.hasNext()) { subJobsIterator.next(); - // Get the state of the sub job pointed by call next() + // Get the state of the sub job pointed at by call next() if (subJobsIterator.value()->_state == Finished) { - // If this items is finish, remove it from the _subJobs list as it is not needed anymore + // If this item is finished, remove it from the _subJobs list as it is not needed anymore // Note that in this case remove() from QVector will just perform memmove of pointer array items. PropagatorJob * job = subJobsIterator.value(); subJobsIterator.remove(); - // In this case de dont delete job, but save it in _finishedSubJobs queue + // In this case we dont delete the job, but save it in the _finishedSubJobs queue // We might need this job in slotSubJobFinished // The PropagateNormalUpload class will be destroyed in PropagateDirectory // when it will detect that we finished PropagateNormalUpload @@ -58,16 +58,16 @@ bool PropagateNormalUpload::scheduleNextJobRoutine(QVector &sub } void PropagateNormalUpload::append(const SyncFileItemPtr &item) { - // In case of bundles, in here we should append BundledUpload jobs with new files to the .top() of _subJobs until reached chunking size - // Role of this class is also to control how much data is going into the container class + // In case of bundles, in here we should append BundledUpload jobs with new files to the .top() of _subJobs until chunking size is reached. + // The role of this class is also to control how much data is going into the container class. // In version 1.0 append just PUTs PropagateUploadFileV1* subJob = new PropagateUploadFileV1(_propagator, item); if (item->_size <= _propagator->smallFileSize()){ - _propagator->_dbJobsCount++; // This item db operations take considerably longer then any other factors. + _propagator->_dbJobsCount++; // Db operations for this item take considerably longer then any other factors. _dbJobs.append(subJob); } else { - _propagator->_standardJobsCount++; // This item is not a small upload file, so it is standard + _propagator->_standardJobsCount++; // This item is not a small upload file, so it is standard. _standardJobs.append(subJob); } } @@ -86,11 +86,11 @@ bool PropagateNormalUpload::scheduleNextJob() return true; } - // At the begining of the Directory Job, update expected number of Jobs to be synced + // At the beginning of the Directory Job, update the expected number of Jobs to be synced _totalJobs = _standardJobs.count() + _dbJobs.count(); } - // Check if there are standard jobs in whole sync waiting for sync or pending + // Check if there are standard jobs in the whole sync waiting for sync or pending if (_propagator->_standardJobsCount > 0){ // Check if there are already some dbJobs running if(_propagator->_activeDBJobs > 0){ @@ -106,14 +106,14 @@ bool PropagateNormalUpload::scheduleNextJob() // This container does not contain any remaining dbJobs if(_runningNow > 1){ // There are some jobs running in this container, - // but for sure not dbJobs, search in different container for db jobs + // but they are not dbJobs, so search in a different container for db jobs return false; } return scheduleNextJobRoutine(_standardJobs); } } } else { - // There are no remaining or pending standard jobs in whole sync + // There are no remaining or pending standard jobs in the whole sync // This also means that _standardJobs is empty Q_ASSERT(!scheduleNextJobRoutine(_standardJobs));