diff --git a/program/Source/cloud/CloudManager.cpp b/program/Source/cloud/CloudManager.cpp index 7360f0040f723e58f3cd14c223b28486f42d0b34..0384c3a1d2ada0430ab6155613dab81d2de3a939 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 154f18b6c6143c001daaf9e85b40ce70f3f2f23b..e631768c8823a0a1136f90980a17eb26c7a2ea90 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 c9caaa5ddb6e02624d497239639c4e20a190b5f4..cc1318cbd37932c212261c33596c34549fa20417 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 cada50de3a1caeef276a9a3d5f0a34efe7b7aab0..0d3c35650b108afd03a8d91c56e26e7bc61ffa4f 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 fc9f4891e04a759bdfe7a69f62d056ab050bd997..39a7d0ece2c90e611be9f8394d74441a9760f3b6 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 37b887833948ba117f4d9049fbe382e87261b6e5..0a15f297cf900e613f73d49297be434b237f8b1b 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