Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32361132
D3777.1765321153.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
D3777.1765321153.diff
View Options
diff --git a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h
--- a/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h
+++ b/services/backup/docker-server/contents/server/src/Reactors/server/CreateNewBackupReactor.h
@@ -34,12 +34,19 @@
std::string holder;
std::string backupID;
std::shared_ptr<reactor::BlobPutClientReactor> putReactor;
+ std::shared_ptr<reactor::BlobAppendHolderClientReactor> holderReactor;
+
ServiceBlobClient blobClient;
std::mutex reactorStateMutex;
- std::condition_variable blobDoneCV;
- std::mutex blobDoneCVMutex;
+
+ std::condition_variable blobPutDoneCV;
+ std::mutex blobPutDoneCVMutex;
+
+ std::condition_variable blobAppendHolderDoneCV;
+ std::mutex blobAppendHolderDoneCVMutex;
std::string generateBackupID();
+ void initializeHolderReactor();
public:
std::unique_ptr<ServerBidiReactorStatus> handleRequest(
@@ -53,6 +60,23 @@
return generateRandomString();
}
+void CreateNewBackupReactor::initializeHolderReactor() {
+ if (this->holder.empty()) {
+ throw std::runtime_error(
+ "holder reactor cannot be initialized with empty holder");
+ }
+ if (this->dataHash.empty()) {
+ throw std::runtime_error(
+ "holder reactor cannot be initialized with empty hash");
+ }
+ if (this->holderReactor == nullptr) {
+ this->holderReactor =
+ std::make_shared<reactor::BlobAppendHolderClientReactor>(
+ this->holder, this->dataHash, &this->blobAppendHolderDoneCV);
+ this->blobClient.appendHolder(this->holderReactor);
+ }
+}
+
std::unique_ptr<ServerBidiReactorStatus> CreateNewBackupReactor::handleRequest(
backup::CreateNewBackupRequest request,
backup::CreateNewBackupResponse *response) {
@@ -89,7 +113,7 @@
response->set_backupid(this->backupID);
this->holder = this->backupID;
this->putReactor = std::make_shared<reactor::BlobPutClientReactor>(
- this->holder, this->dataHash, &this->blobDoneCV);
+ this->holder, this->dataHash, &this->blobPutDoneCV);
this->blobClient.put(this->putReactor);
return nullptr;
}
@@ -108,13 +132,24 @@
return;
}
this->putReactor->scheduleSendingDataChunk(std::make_unique<std::string>(""));
- std::unique_lock<std::mutex> lock2(this->blobDoneCVMutex);
- if (this->putReactor->isDone()) {
- if (!this->putReactor->getStatus().ok()) {
- throw std::runtime_error(this->putReactor->getStatus().error_message());
+ std::unique_lock<std::mutex> lock2(this->blobPutDoneCVMutex);
+ if (this->putReactor->isDone() && !this->putReactor->getStatus().ok()) {
+ throw std::runtime_error(this->putReactor->getStatus().error_message());
+ }
+ if (!this->putReactor->isDone()) {
+ this->blobPutDoneCV.wait(lock2);
+ }
+ if (this->putReactor->getDataExists()) {
+ this->initializeHolderReactor();
+ std::unique_lock<std::mutex> lockHolder(this->blobAppendHolderDoneCVMutex);
+ if (this->holderReactor->isDone() &&
+ !this->holderReactor->getStatus().ok()) {
+ throw std::runtime_error(
+ this->holderReactor->getStatus().error_message());
+ }
+ if (!this->holderReactor->isDone()) {
+ this->blobAppendHolderDoneCV.wait(lockHolder);
}
- } else {
- this->blobDoneCV.wait(lock2);
}
try {
// TODO add recovery data
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 10:59 PM (8 h, 3 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5858532
Default Alt Text
D3777.1765321153.diff (3 KB)
Attached To
Mode
D3777: [services] Backup - Improve code style in create new backup reactor
Attached
Detach File
Event Timeline
Log In to Comment