[Box Backup-commit] COMMIT r2848 - box/trunk/bin/bbackupd

subversion at boxbackup.org subversion at boxbackup.org
Wed Jan 12 00:13:12 GMT 2011


Author: chris
Date: 2011-01-12 00:13:11 +0000 (Wed, 12 Jan 2011)
New Revision: 2848

Modified:
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
   box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h
   box/trunk/bin/bbackupd/BackupDaemon.cpp
Log:
Rate limit file uploads using the configured MaxUploadRate, if any.


Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2011-01-12 00:11:53 UTC (rev 2847)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.cpp	2011-01-12 00:13:11 UTC (rev 2848)
@@ -18,21 +18,22 @@
 #include <string.h>
 
 #include "autogen_BackupProtocolClient.h"
+#include "Archive.h"
+#include "BackupClientContext.h"
 #include "BackupClientDirectoryRecord.h"
-#include "BackupClientContext.h"
+#include "BackupClientInodeToIDMap.h"
+#include "BackupDaemon.h"
+#include "BackupStoreException.h"
+#include "BackupStoreFile.h"
 #include "BackupStoreFileEncodeStream.h"
-#include "IOStream.h"
-#include "MemBlockStream.h"
 #include "CommonException.h"
 #include "CollectInBufferStream.h"
-#include "BackupStoreFile.h"
-#include "BackupClientInodeToIDMap.h"
 #include "FileModificationTime.h"
-#include "BackupDaemon.h"
-#include "BackupStoreException.h"
-#include "Archive.h"
+#include "IOStream.h"
+#include "Logging.h"
+#include "MemBlockStream.h"
 #include "PathUtils.h"
-#include "Logging.h"
+#include "RateLimitingStream.h"
 #include "ReadLoggingStream.h"
 
 #include "MemLeakFindOn.h"
@@ -1573,11 +1574,24 @@
 	
 				rContext.UnManageDiffProcess();
 
+				RateLimitingStream rateLimit(*patchStream,
+					rParams.mMaxUploadRate);
+				IOStream* pStreamToUpload;
+
+				if(rParams.mMaxUploadRate > 0)
+				{
+					pStreamToUpload = &rateLimit;
+				}
+				else
+				{
+					pStreamToUpload = patchStream.get();
+				}
+
 				//
 				// Upload the patch to the store
 				//
 				std::auto_ptr<BackupProtocolClientSuccess> stored(connection.QueryStoreFile(mObjectID, ModificationTime,
-						AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *patchStream));
+						AttributesHash, isCompletelyDifferent?(0):(diffFromID), rStoreFilename, *pStreamToUpload));
 				
 				// Get object ID from the result		
 				objID = stored->GetObjectID();
@@ -1602,14 +1616,27 @@
 					mObjectID, rStoreFilename, NULL,
 					&rParams,
 					&(rParams.mrRunStatusProvider)));
-		
+
+			RateLimitingStream rateLimit(*upload,
+				rParams.mMaxUploadRate);
+			IOStream* pStreamToUpload;
+
+			if(rParams.mMaxUploadRate > 0)
+			{
+				pStreamToUpload = &rateLimit;
+			}
+			else
+			{
+				pStreamToUpload = upload.get();
+			}
+	
 			// Send to store
 			std::auto_ptr<BackupProtocolClientSuccess> stored(
 				connection.QueryStoreFile(
 					mObjectID, ModificationTime,
 					AttributesHash, 
 					0 /* no diff from file ID */, 
-					rStoreFilename, *upload));
+					rStoreFilename, *pStreamToUpload));
 	
 			// Get object ID from the result		
 			objID = stored->GetObjectID();
@@ -1696,19 +1723,20 @@
 	SysadminNotifier &rSysadminNotifier,
 	ProgressNotifier &rProgressNotifier,
 	BackupClientContext &rContext)
-	: mSyncPeriodStart(0),
-	  mSyncPeriodEnd(0),
-	  mMaxUploadWait(0),
-	  mMaxFileTimeInFuture(99999999999999999LL),
-	  mFileTrackingSizeThreshold(16*1024),
-	  mDiffingUploadSizeThreshold(16*1024),
-	  mrRunStatusProvider(rRunStatusProvider),
-	  mrSysadminNotifier(rSysadminNotifier),
-	  mrProgressNotifier(rProgressNotifier),
-	  mrContext(rContext),
-	  mReadErrorsOnFilesystemObjects(false),
-	  mUploadAfterThisTimeInTheFuture(99999999999999999LL),
-	  mHaveLoggedWarningAboutFutureFileTimes(false)
+: mSyncPeriodStart(0),
+  mSyncPeriodEnd(0),
+  mMaxUploadWait(0),
+  mMaxFileTimeInFuture(99999999999999999LL),
+  mFileTrackingSizeThreshold(16*1024),
+  mDiffingUploadSizeThreshold(16*1024),
+  mrRunStatusProvider(rRunStatusProvider),
+  mrSysadminNotifier(rSysadminNotifier),
+  mrProgressNotifier(rProgressNotifier),
+  mrContext(rContext),
+  mReadErrorsOnFilesystemObjects(false),
+  mMaxUploadRate(0),
+  mUploadAfterThisTimeInTheFuture(99999999999999999LL),
+  mHaveLoggedWarningAboutFutureFileTimes(false)
 {
 }
 

Modified: box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h
===================================================================
--- box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h	2011-01-12 00:11:53 UTC (rev 2847)
+++ box/trunk/bin/bbackupd/BackupClientDirectoryRecord.h	2011-01-12 00:13:11 UTC (rev 2848)
@@ -86,6 +86,7 @@
 		ProgressNotifier &mrProgressNotifier;
 		BackupClientContext &mrContext;
 		bool mReadErrorsOnFilesystemObjects;
+		int64_t mMaxUploadRate;
 		
 		// Member variables modified by syncing process
 		box_time_t mUploadAfterThisTimeInTheFuture;

Modified: box/trunk/bin/bbackupd/BackupDaemon.cpp
===================================================================
--- box/trunk/bin/bbackupd/BackupDaemon.cpp	2011-01-12 00:11:53 UTC (rev 2847)
+++ box/trunk/bin/bbackupd/BackupDaemon.cpp	2011-01-12 00:13:11 UTC (rev 2848)
@@ -830,6 +830,12 @@
 		conf.GetKeyValueInt("DiffingUploadSizeThreshold");
 	params.mMaxFileTimeInFuture = 
 		SecondsToBoxTime(conf.GetKeyValueInt("MaxFileTimeInFuture"));
+
+	if(conf.KeyExists("MaxUploadRate"))
+	{
+		params.mMaxUploadRate = conf.GetKeyValueInt("MaxUploadRate");
+	}
+
 	mDeleteRedundantLocationsAfter =
 		conf.GetKeyValueInt("DeleteRedundantLocationsAfter");
 	mStorageLimitExceeded = false;




More information about the Boxbackup-commit mailing list