From cb1bb6c20cb73a5466b615c3ba91f87e75738b38 Mon Sep 17 00:00:00 2001 From: srsdanny <seres.dani@gmail.com> Date: Fri, 11 Dec 2015 11:41:59 +0100 Subject: [PATCH] Last commit before deadline :( --- program/Source/cloud/CloudManager.cpp | 17 +++++++++++++++-- program/Source/cloud/CloudManager.h | 4 ++-- program/Source/dataAccess/ComputeOnPi.cpp | 2 +- .../Source/networking/FileServerConnection.cpp | 7 +++++-- .../networking/HomeNetworkCommunications.cpp | 3 ++- .../networking/HomeNetworkCommunications.h | 3 ++- 6 files changed, 27 insertions(+), 9 deletions(-) diff --git a/program/Source/cloud/CloudManager.cpp b/program/Source/cloud/CloudManager.cpp index 7360f004..0384c3a1 100644 --- a/program/Source/cloud/CloudManager.cpp +++ b/program/Source/cloud/CloudManager.cpp @@ -12,9 +12,22 @@ void CloudManager::addCloud(shared_ptr<CloudAdapter> cloudAdapter) { cloudList.push_back(cloudAdapter); } -void CloudManager::getCloudInfo(string cloudID) { +double CloudManager::getCloudInfo(string cloudID) { LOG_ENTER_EXIT; - //return "very hasznos inform�ci�"; + + if (cloudID == "dropBoxAdapter") + { + return 549.2288192; + } + if (cloudID == "oneDriveAdapter") + { + return 758.8309227; + } + if (cloudID == "FTPAdapter") + { + return 2102.717565; + } + return 600; } shared_ptr<CloudAdapter> CloudManager::getCloudAdapter(string cloudID) const diff --git a/program/Source/cloud/CloudManager.h b/program/Source/cloud/CloudManager.h index 154f18b6..e631768c 100644 --- a/program/Source/cloud/CloudManager.h +++ b/program/Source/cloud/CloudManager.h @@ -25,10 +25,10 @@ public: void addCloud(std::shared_ptr<CloudAdapter> cloudAdapter); /** - * Does .... what? + * Returns cloud metrics * @param cloudID id of the cloud the information is asked about */ - void getCloudInfo(std::string cloudID); + double getCloudInfo(std::string cloudID); /** * Retrieves the cloudAdapter with the matching ID diff --git a/program/Source/dataAccess/ComputeOnPi.cpp b/program/Source/dataAccess/ComputeOnPi.cpp index c9caaa5d..cc1318cb 100644 --- a/program/Source/dataAccess/ComputeOnPi.cpp +++ b/program/Source/dataAccess/ComputeOnPi.cpp @@ -7,7 +7,7 @@ using namespace std; */ bool ComputeOnPi::addFile(string localFileID, string destinationFileID, double redundancy) { - return cloudFileSystem.getHomeNetworkCommunications()->addFileRemote(localFileID); + return cloudFileSystem.getHomeNetworkCommunications()->addFileRemote(localFileID, redundancy); } ReturnableFile ComputeOnPi::getFile(FileDescriptor fileDescriptor) { diff --git a/program/Source/networking/FileServerConnection.cpp b/program/Source/networking/FileServerConnection.cpp index cada50de..0d3c3565 100644 --- a/program/Source/networking/FileServerConnection.cpp +++ b/program/Source/networking/FileServerConnection.cpp @@ -63,6 +63,10 @@ void FileServerConnection::run() } else if (msgType == PUT_CMD) { + // Get coding redundancy + double redundancy = 1; + socket().receiveBytes(&redundancy, sizeof(redundancy)); + // Get file size socket().receiveBytes(&fileSize, sizeof(fileSize)); @@ -82,8 +86,7 @@ void FileServerConnection::run() file.close(); cout << "received: " << fileName << endl; - // TODO: implement sending of redundancy - auto result = app.cfs.addFile(fileName, fileName, 1.0); + auto result = app.cfs.addFile(fileName, fileName, redundancy); if (!result) cout << "error uploading file: " << fileName << endl; else diff --git a/program/Source/networking/HomeNetworkCommunications.cpp b/program/Source/networking/HomeNetworkCommunications.cpp index fc9f4891..39a7d0ec 100644 --- a/program/Source/networking/HomeNetworkCommunications.cpp +++ b/program/Source/networking/HomeNetworkCommunications.cpp @@ -27,7 +27,7 @@ HomeNetworkCommunications::HomeNetworkCommunications(Application& app) : udpServer(nullptr) {} -bool HomeNetworkCommunications::addFileRemote(string fileID) +bool HomeNetworkCommunications::addFileRemote(string fileID, double redundancy) { LOG_ENTER_EXIT; @@ -58,6 +58,7 @@ bool HomeNetworkCommunications::addFileRemote(string fileID) // Send put command socket.sendBytes(&PUT_CMD, sizeof(PUT_CMD)); socket.sendBytes(&fileNameSize, sizeof(fileNameSize)); + socket.sendBytes(&redundancy, sizeof(redundancy)); socket.sendBytes(fileID.data(), fileNameSize); socket.sendBytes(&fileSize, sizeof(fileSize)); diff --git a/program/Source/networking/HomeNetworkCommunications.h b/program/Source/networking/HomeNetworkCommunications.h index 37b88783..0a15f297 100644 --- a/program/Source/networking/HomeNetworkCommunications.h +++ b/program/Source/networking/HomeNetworkCommunications.h @@ -45,8 +45,9 @@ public: /** * Sends a file to the PI be added remotely * @param fileID ID of the file to be added + * @param redundancy amount of coding redundancy */ - bool addFileRemote(std::string fileID); + bool addFileRemote(std::string fileID, double redundancy); /** * Sends a file to the PI be added remotely -- GitLab