Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3720386
D4220.id13868.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D4220.id13868.diff
View Options
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.h b/services/tunnelbroker/src/Database/DatabaseManager.h
--- a/services/tunnelbroker/src/Database/DatabaseManager.h
+++ b/services/tunnelbroker/src/Database/DatabaseManager.h
@@ -47,6 +47,9 @@
std::vector<std::shared_ptr<MessageItem>>
findMessageItemsByReceiver(const std::string &toDeviceID);
void removeMessageItem(const std::string &messageID);
+ void removeMessageItemsOlderThenDeviceCheckpoint(
+ const std::string &toDeviceID,
+ const size_t &checkpointTime);
};
} // namespace database
diff --git a/services/tunnelbroker/src/Database/DatabaseManager.cpp b/services/tunnelbroker/src/Database/DatabaseManager.cpp
--- a/services/tunnelbroker/src/Database/DatabaseManager.cpp
+++ b/services/tunnelbroker/src/Database/DatabaseManager.cpp
@@ -209,6 +209,29 @@
this->innerRemoveItem(*item);
}
+void DatabaseManager::removeMessageItemsOlderThenDeviceCheckpoint(
+ const std::string &toDeviceID,
+ const size_t &checkpointTime) {
+ std::vector<std::shared_ptr<MessageItem>> messageItems =
+ this->findMessageItemsByReceiver(toDeviceID);
+ std::vector<Aws::DynamoDB::Model::WriteRequest> writeRequests;
+
+ for (std::shared_ptr<MessageItem> &messageItem : messageItems) {
+ if (messageItem->getCreatedAt() <= checkpointTime) {
+ Aws::DynamoDB::Model::DeleteRequest deleteRequest;
+ PrimaryKeyDescriptor pk = messageItem->getPrimaryKeyDescriptor();
+ PrimaryKeyValue primaryKeyValue = messageItem->getPrimaryKeyValue();
+ deleteRequest.AddKey(
+ pk.partitionKey,
+ Aws::DynamoDB::Model::AttributeValue(primaryKeyValue.partitionKey));
+ Aws::DynamoDB::Model::WriteRequest curWriteRequest;
+ curWriteRequest.SetDeleteRequest(deleteRequest);
+ writeRequests.push_back(curWriteRequest);
+ }
+ }
+ this->innerBatchWriteItem(MESSAGES_TABLE_NAME, writeRequests);
+}
+
} // namespace database
} // namespace network
} // namespace comm
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 9, 12:10 PM (9 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2834725
Default Alt Text
D4220.id13868.diff (1 KB)
Attached To
Mode
D4220: [services] Tunnelbroker - Add remove MessageItems older than checkpoint database method
Attached
Detach File
Event Timeline
Log In to Comment