Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32902682
D3558.1768192011.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D3558.1768192011.diff
View Options
diff --git a/services/backup/docker-server/contents/server/src/Constants.h b/services/backup/docker-server/contents/server/src/Constants.h
--- a/services/backup/docker-server/contents/server/src/Constants.h
+++ b/services/backup/docker-server/contents/server/src/Constants.h
@@ -30,5 +30,12 @@
const std::string BACKUP_TABLE_NAME = "backup-service-backup";
#endif
+// this has to be smaller than GRPC_CHUNK_SIZE_LIMIT because we need to
+// recognize if we may receive multiple chunks or just one
+// if it was larger than the chunk limit, once we get the amount of data of size
+// equal to the limit, we wouldn't know if we should put this in the database
+// right away or wait for more data
+const size_t LOG_DATA_SIZE_DATABASE_LIMIT = 1 * 1024 * 1024;
+
} // namespace network
} // namespace comm
diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h
--- a/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h
+++ b/services/backup/docker-server/contents/server/src/Reactors/server/SendLogReactor.h
@@ -1,5 +1,6 @@
#pragma once
+#include "Constants.h"
#include "ServerReadReactorBase.h"
#include "../_generated/backup.grpc.pb.h"
@@ -21,9 +22,22 @@
LOG_CHUNK = 2,
};
+ enum class PersistenceMethod {
+ UNKNOWN = 0,
+ DB = 1,
+ BLOB = 2,
+ };
+
State state = State::USER_ID;
+ PersistenceMethod persistenceMethod = PersistenceMethod::UNKNOWN;
std::string userID;
+ void storeInDatabase(const std::string &data) {
+ }
+
+ void storeInBlob(const std::string &data) {
+ }
+
public:
using ServerReadReactorBase<backup::SendLogRequest, google::protobuf::Empty>::
ServerReadReactorBase;
@@ -49,8 +63,28 @@
if (!request.has_logdata()) {
throw std::runtime_error("log data expected but not received");
}
- std::string chunk = request.logdata();
- std::cout << "log data received " << chunk << std::endl;
+ std::string *chunk = request.mutable_logdata();
+ // decide if keep in DB or upload to blob
+ if (chunk->size() <= LOG_DATA_SIZE_DATABASE_LIMIT) {
+ if (this->persistenceMethod != PersistenceMethod::UNKNOWN) {
+ throw std::runtime_error(
+ "error - invalid persistence state, storing in the database is "
+ "allowed only once per session");
+ }
+ this->persistenceMethod = PersistenceMethod::DB;
+ this->storeInDatabase(*chunk);
+ } else {
+ if (this->persistenceMethod != PersistenceMethod::UNKNOWN &&
+ this->persistenceMethod != PersistenceMethod::BLOB) {
+ throw std::runtime_error(
+ "error - invalid persistence state, uploading to blob should be "
+ "continued but it is not");
+ }
+ this->persistenceMethod = PersistenceMethod::BLOB;
+ this->storeInBlob(*chunk);
+ }
+ std::cout << "log data received " << chunk->size() << std::endl;
+ return nullptr;
};
}
throw std::runtime_error("send log - invalid state");
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 12, 4:26 AM (8 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5921671
Default Alt Text
D3558.1768192011.diff (3 KB)
Attached To
Mode
D3558: [services] Backup - Send log - Add basic logic
Attached
Detach File
Event Timeline
Log In to Comment