diff options
| author | Dan Engelbrecht <[email protected]> | 2022-05-25 14:08:11 +0200 |
|---|---|---|
| committer | Dan Engelbrecht <[email protected]> | 2022-05-25 14:08:11 +0200 |
| commit | 5feb2725a3c6461e913a95ea271046855c773ac5 (patch) | |
| tree | bfb9dd48545abadfbae13302a17b6e8d5a068375 /zenserver/cache | |
| parent | Make sure ZenCacheMemoryLayer handles dropped buckets correctly (just like Ze... (diff) | |
| download | zen-5feb2725a3c6461e913a95ea271046855c773ac5.tar.xz zen-5feb2725a3c6461e913a95ea271046855c773ac5.zip | |
namespace drop
Diffstat (limited to 'zenserver/cache')
| -rw-r--r-- | zenserver/cache/structuredcache.cpp | 18 | ||||
| -rw-r--r-- | zenserver/cache/structuredcachestore.cpp | 25 | ||||
| -rw-r--r-- | zenserver/cache/structuredcachestore.h | 7 |
3 files changed, 38 insertions, 12 deletions
diff --git a/zenserver/cache/structuredcache.cpp b/zenserver/cache/structuredcache.cpp index e11499289..79d15a204 100644 --- a/zenserver/cache/structuredcache.cpp +++ b/zenserver/cache/structuredcache.cpp @@ -398,7 +398,7 @@ HttpStructuredCacheService::HandleRequest(HttpServerRequest& Request) } void -HttpStructuredCacheService::HandleCacheNamespaceRequest(zen::HttpServerRequest& Request, std::string_view) +HttpStructuredCacheService::HandleCacheNamespaceRequest(zen::HttpServerRequest& Request, std::string_view Namespace) { switch (Request.RequestVerb()) { @@ -412,14 +412,14 @@ HttpStructuredCacheService::HandleCacheNamespaceRequest(zen::HttpServerRequest& case HttpVerb::kDelete: // Drop namespace { - // if (m_CacheStore.DropNamespace(Namespace)) - // { - // return Request.WriteResponse(HttpResponseCode::OK); - // } - // else - // { - // return Request.WriteResponse(HttpResponseCode::NotFound); - // } + if (m_CacheStore.DropNamespace(Namespace)) + { + return Request.WriteResponse(HttpResponseCode::OK); + } + else + { + return Request.WriteResponse(HttpResponseCode::NotFound); + } } break; diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index d4b8bff39..6af673ebc 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -342,6 +342,14 @@ ZenCacheNamespace::DropBucket(std::string_view Bucket) return AnyDropped; } +bool +ZenCacheNamespace::Drop() +{ + m_MemLayer.Drop(); + const bool DiskDropped = m_DiskLayer.Drop(); + return DiskDropped; +} + void ZenCacheNamespace::Flush() { @@ -2300,7 +2308,22 @@ ZenCacheStore::DropBucket(std::string_view Namespace, std::string_view Bucket) { return Store->DropBucket(Bucket); } - ZEN_WARN("request for unknown namespace '{}' in ZenCacheStore::Put, bucket '{}'", Namespace, Bucket); + ZEN_WARN("request for unknown namespace '{}' in ZenCacheStore::DropBucket, bucket '{}'", Namespace, Bucket); + return false; +} + +bool +ZenCacheStore::DropNamespace(std::string_view InNamespace) +{ + RwLock::SharedLockScope _(m_NamespacesLock); + if (auto It = m_Namespaces.find(std::string(InNamespace)); It != m_Namespaces.end()) + { + ZenCacheNamespace& Namespace = *It->second; + m_DroppedNamespaces.push_back(std::move(It->second)); + m_Namespaces.erase(It); + return Namespace.Drop(); + } + ZEN_WARN("request for unknown namespace '{}' in ZenCacheStore::DropNamespace", InNamespace); return false; } diff --git a/zenserver/cache/structuredcachestore.h b/zenserver/cache/structuredcachestore.h index 4da48d3d9..c07c3e382 100644 --- a/zenserver/cache/structuredcachestore.h +++ b/zenserver/cache/structuredcachestore.h @@ -333,6 +333,7 @@ public: bool Get(std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue); void Put(std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value); + bool Drop(); bool DropBucket(std::string_view Bucket); void Flush(); void Scrub(ScrubContext& Ctx); @@ -375,6 +376,7 @@ public: bool Get(std::string_view Namespace, std::string_view Bucket, const IoHash& HashKey, ZenCacheValue& OutValue); void Put(std::string_view Namespace, std::string_view Bucket, const IoHash& HashKey, const ZenCacheValue& Value); bool DropBucket(std::string_view Namespace, std::string_view Bucket); + bool DropNamespace(std::string_view Namespace); void Flush(); void Scrub(ScrubContext& Ctx); @@ -388,8 +390,9 @@ private: typedef std::unordered_map<std::string, std::unique_ptr<ZenCacheNamespace>> NameSpaceMap; - mutable RwLock m_NamespacesLock; - NameSpaceMap m_Namespaces; + mutable RwLock m_NamespacesLock; + NameSpaceMap m_Namespaces; + std::vector<std::unique_ptr<ZenCacheNamespace>> m_DroppedNamespaces; CasGc& m_Gc; Configuration m_Configuration; |