Skip to content
Snippets Groups Projects
Commit cb1bb6c2 authored by srsdanny's avatar srsdanny
Browse files

Last commit before deadline :(

parent f509193d
No related branches found
No related tags found
No related merge requests found
......@@ -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 informci";
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
......
......@@ -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
......
......@@ -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) {
......
......@@ -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
......
......@@ -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));
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment