summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris+github@qwirx.com>2010-11-17 09:49:39 +0000
committerChris Wilson <chris+github@qwirx.com>2010-11-17 09:49:39 +0000
commit79e0bbb3d773037371ff83563aba8ebdb20190e8 (patch)
tree35696c4aa2a33dd27e883d1a1bdc0c24f55aa9b6
parent55689249c942cd865c6da9ce27cb995cba4d1a7c (diff)
Log the total number of bytes uploaded to the server for each file.
-rw-r--r--bin/bbackupd/BackupClientDirectoryRecord.cpp14
-rw-r--r--bin/bbackupd/BackupDaemon.h6
-rw-r--r--bin/bbackupd/BackupDaemonInterface.h2
-rw-r--r--lib/backupclient/BackupStoreFile.cpp8
-rw-r--r--lib/backupclient/BackupStoreFile.h7
-rw-r--r--lib/backupclient/BackupStoreFileEncodeStream.cpp2
-rw-r--r--lib/backupclient/BackupStoreFileEncodeStream.h2
7 files changed, 31 insertions, 10 deletions
diff --git a/bin/bbackupd/BackupClientDirectoryRecord.cpp b/bin/bbackupd/BackupClientDirectoryRecord.cpp
index 84c17dab..a555085f 100644
--- a/bin/bbackupd/BackupClientDirectoryRecord.cpp
+++ b/bin/bbackupd/BackupClientDirectoryRecord.cpp
@@ -17,9 +17,10 @@
#include <errno.h>
#include <string.h>
-#include "BackupClientDirectoryRecord.h"
#include "autogen_BackupProtocolClient.h"
+#include "BackupClientDirectoryRecord.h"
#include "BackupClientContext.h"
+#include "BackupStoreFileEncodeStream.h"
#include "IOStream.h"
#include "MemBlockStream.h"
#include "CommonException.h"
@@ -1513,6 +1514,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
// Info
int64_t objID = 0;
bool doNormalUpload = true;
+ int64_t uploadedSize = -1;
// Use a try block to catch store full errors
try
@@ -1543,6 +1545,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
rContext.ManageDiffProcess();
bool isCompletelyDifferent = false;
+
std::auto_ptr<IOStream> patchStream(
BackupStoreFile::EncodeFileDiff(
rFilename.c_str(),
@@ -1566,6 +1569,10 @@ int64_t BackupClientDirectoryRecord::UploadFile(
// Don't attempt to upload it again!
doNormalUpload = false;
+
+ // Capture number of bytes sent
+ uploadedSize = ((BackupStoreFileEncodeStream &)
+ *patchStream).GetTotalBytesSent();
}
}
@@ -1591,6 +1598,9 @@ int64_t BackupClientDirectoryRecord::UploadFile(
// Get object ID from the result
objID = stored->GetObjectID();
+
+ uploadedSize = ((BackupStoreFileEncodeStream &)
+ *upload).GetTotalBytesSent();
}
}
catch(BoxException &e)
@@ -1625,7 +1635,7 @@ int64_t BackupClientDirectoryRecord::UploadFile(
throw;
}
- rNotifier.NotifyFileUploaded(this, rFilename, FileSize);
+ rNotifier.NotifyFileUploaded(this, rFilename, FileSize, uploadedSize);
// Return the new object ID of this file
return objID;
diff --git a/bin/bbackupd/BackupDaemon.h b/bin/bbackupd/BackupDaemon.h
index b41c6508..be37cd11 100644
--- a/bin/bbackupd/BackupDaemon.h
+++ b/bin/bbackupd/BackupDaemon.h
@@ -457,11 +457,13 @@ public:
virtual void NotifyFileUploaded(
const BackupClientDirectoryRecord* pDirRecord,
const std::string& rLocalPath,
- int64_t FileSize)
+ int64_t FileSize, int64_t UploadedSize)
{
if (mLogAllFileAccess)
{
- BOX_NOTICE("Uploaded file: " << rLocalPath);
+ BOX_NOTICE("Uploaded file: " << rLocalPath << ", "
+ "total size = " << FileSize << ", "
+ "uploaded size = " << UploadedSize);
}
}
virtual void NotifyFileSynchronised(
diff --git a/bin/bbackupd/BackupDaemonInterface.h b/bin/bbackupd/BackupDaemonInterface.h
index 2a2d8d4b..b603273c 100644
--- a/bin/bbackupd/BackupDaemonInterface.h
+++ b/bin/bbackupd/BackupDaemonInterface.h
@@ -129,7 +129,7 @@ class ProgressNotifier
virtual void NotifyFileUploaded(
const BackupClientDirectoryRecord* pDirRecord,
const std::string& rLocalPath,
- int64_t FileSize) = 0;
+ int64_t FileSize, int64_t UploadedSize) = 0;
virtual void NotifyFileSynchronised(
const BackupClientDirectoryRecord* pDirRecord,
const std::string& rLocalPath,
diff --git a/lib/backupclient/BackupStoreFile.cpp b/lib/backupclient/BackupStoreFile.cpp
index 4bd75f96..44d96d0c 100644
--- a/lib/backupclient/BackupStoreFile.cpp
+++ b/lib/backupclient/BackupStoreFile.cpp
@@ -73,9 +73,11 @@ BackupStoreFileStats BackupStoreFile::msStats = {0,0,0};
// Created: 2003/08/28
//
// --------------------------------------------------------------------------
-std::auto_ptr<IOStream> BackupStoreFile::EncodeFile(const char *Filename,
- int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
- int64_t *pModificationTime, ReadLoggingStream::Logger* pLogger,
+std::auto_ptr<IOStream> BackupStoreFile::EncodeFile(
+ const char *Filename, int64_t ContainerID,
+ const BackupStoreFilename &rStoreFilename,
+ int64_t *pModificationTime,
+ ReadLoggingStream::Logger* pLogger,
RunStatusProvider* pRunStatusProvider)
{
// Create the stream
diff --git a/lib/backupclient/BackupStoreFile.h b/lib/backupclient/BackupStoreFile.h
index f4c60919..f5bc1924 100644
--- a/lib/backupclient/BackupStoreFile.h
+++ b/lib/backupclient/BackupStoreFile.h
@@ -118,11 +118,14 @@ public:
// Main interface
- static std::auto_ptr<IOStream> EncodeFile(const char *Filename,
+ static std::auto_ptr<IOStream> EncodeFile
+ (
+ const char *Filename,
int64_t ContainerID, const BackupStoreFilename &rStoreFilename,
int64_t *pModificationTime = 0,
ReadLoggingStream::Logger* pLogger = NULL,
- RunStatusProvider* pRunStatusProvider = NULL);
+ RunStatusProvider* pRunStatusProvider = NULL
+ );
static std::auto_ptr<IOStream> EncodeFileDiff
(
const char *Filename, int64_t ContainerID,
diff --git a/lib/backupclient/BackupStoreFileEncodeStream.cpp b/lib/backupclient/BackupStoreFileEncodeStream.cpp
index 54c2463d..e9d773f0 100644
--- a/lib/backupclient/BackupStoreFileEncodeStream.cpp
+++ b/lib/backupclient/BackupStoreFileEncodeStream.cpp
@@ -55,6 +55,7 @@ BackupStoreFileEncodeStream::BackupStoreFileEncodeStream()
mPositionInCurrentBlock(0),
mBlockSize(BACKUP_FILE_MIN_BLOCK_SIZE),
mLastBlockSize(0),
+ mTotalBytesSent(0),
mpRawBuffer(0),
mAllocatedBufferSize(0),
mEntryIVBase(0)
@@ -463,6 +464,7 @@ int BackupStoreFileEncodeStream::Read(void *pBuffer, int NBytes, int Timeout)
// Add encoded size to stats
BackupStoreFile::msStats.mTotalFileStreamSize += (NBytes - bytesToRead);
+ mTotalBytesSent += (NBytes - bytesToRead);
// Return size of data to caller
return NBytes - bytesToRead;
diff --git a/lib/backupclient/BackupStoreFileEncodeStream.h b/lib/backupclient/BackupStoreFileEncodeStream.h
index c5fa780a..023994af 100644
--- a/lib/backupclient/BackupStoreFileEncodeStream.h
+++ b/lib/backupclient/BackupStoreFileEncodeStream.h
@@ -85,6 +85,7 @@ public:
virtual void Write(const void *pBuffer, int NBytes);
virtual bool StreamDataLeft();
virtual bool StreamClosed();
+ int64_t GetTotalBytesSent() { return mTotalBytesSent; }
private:
enum
@@ -121,6 +122,7 @@ private:
int32_t mPositionInCurrentBlock; // for reading out
int32_t mBlockSize; // Basic block size of most of the blocks in the file
int32_t mLastBlockSize; // the size (unencoded) of the last block in the file
+ int64_t mTotalBytesSent;
// Buffers
uint8_t *mpRawBuffer; // buffer for raw data
BackupStoreFile::EncodingBuffer mEncodedBuffer;