aboutsummaryrefslogtreecommitdiff
path: root/src/zenserver/cache/structuredcachestore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/zenserver/cache/structuredcachestore.cpp')
-rw-r--r--src/zenserver/cache/structuredcachestore.cpp70
1 files changed, 40 insertions, 30 deletions
diff --git a/src/zenserver/cache/structuredcachestore.cpp b/src/zenserver/cache/structuredcachestore.cpp
index 2ba1f61bd..c8384d330 100644
--- a/src/zenserver/cache/structuredcachestore.cpp
+++ b/src/zenserver/cache/structuredcachestore.cpp
@@ -224,8 +224,9 @@ ZEN_DEFINE_LOG_CATEGORY_STATIC(LogCacheActivity, "z$");
static constinit std::string_view UE4DDCNamespaceName = "ue4.ddc";
-ZenCacheStore::ZenCacheStore(GcManager& Gc, const Configuration& Configuration)
+ZenCacheStore::ZenCacheStore(GcManager& Gc, const Configuration& Configuration, const DiskWriteBlocker* InDiskWriteBlocker)
: m_Log(logging::Get("z$"))
+, m_DiskWriteBlocker(InDiskWriteBlocker)
, m_Gc(Gc)
, m_Configuration(Configuration)
, m_ExitLogging(false)
@@ -293,44 +294,53 @@ ZenCacheStore::LogWorker()
try
{
m_LogQueueLock.WithExclusiveLock([this, &Items]() { Items.swap(m_LogQueue); });
- for (const auto& Item : Items)
+ if (m_DiskWriteBlocker == nullptr || m_DiskWriteBlocker->AreDiskWritesAllowed())
{
- if (Item.Value.Value)
+ for (const auto& Item : Items)
{
- const bool IsCbObject = Item.Value.Value.GetContentType() == ZenContentType::kCbObject;
-
- try
+ if (Item.Value.Value)
{
- const IoHash ObjectHash = IsCbObject ? IoHash::HashBuffer(Item.Value.Value.GetView()) : Item.Value.RawHash;
- const size_t ObjectSize = IsCbObject ? Item.Value.Value.GetSize() : Item.Value.RawSize;
+ const bool IsCbObject = Item.Value.Value.GetContentType() == ZenContentType::kCbObject;
- ZEN_LOG_INFO(LogCacheActivity,
- "{} [{}] {}/{}/{} -> {} {} {}",
- Item.Op,
- Item.Context,
- Item.Namespace,
- Item.Bucket,
- Item.HashKey,
- ObjectHash,
- ObjectSize,
- ToString(Item.Value.Value.GetContentType()))
+ try
+ {
+ const IoHash ObjectHash = IsCbObject ? IoHash::HashBuffer(Item.Value.Value.GetView()) : Item.Value.RawHash;
+ const size_t ObjectSize = IsCbObject ? Item.Value.Value.GetSize() : Item.Value.RawSize;
+
+ ZEN_LOG_INFO(LogCacheActivity,
+ "{} [{}] {}/{}/{} -> {} {} {}",
+ Item.Op,
+ Item.Context,
+ Item.Namespace,
+ Item.Bucket,
+ Item.HashKey,
+ ObjectHash,
+ ObjectSize,
+ ToString(Item.Value.Value.GetContentType()))
+ }
+ catch (std::exception& Ex)
+ {
+ ZEN_LOG_INFO(LogCacheActivity,
+ "{} [{}] {}/{}/{} failed: Reason: '{}'",
+ Item.Op,
+ Item.Context,
+ Item.Namespace,
+ Item.Bucket,
+ Item.HashKey,
+ Ex.what())
+ }
}
- catch (std::exception& Ex)
+ else
{
ZEN_LOG_INFO(LogCacheActivity,
- "{} [{}] {}/{}/{} failed: Reason: '{}'",
+ "{} [{}] {}/{}/{}",
Item.Op,
Item.Context,
Item.Namespace,
Item.Bucket,
- Item.HashKey,
- Ex.what())
+ Item.HashKey);
}
}
- else
- {
- ZEN_LOG_INFO(LogCacheActivity, "{} [{}] {}/{}/{}", Item.Op, Item.Context, Item.Namespace, Item.Bucket, Item.HashKey);
- }
}
if (!Items.empty())
{
@@ -1227,7 +1237,7 @@ TEST_CASE("z$.namespaces")
IoHash Key2;
{
GcManager Gc;
- ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = false});
+ ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = false}, nullptr);
const auto Bucket = "teardrinker"sv;
const auto CustomNamespace = "mynamespace"sv;
@@ -1252,7 +1262,7 @@ TEST_CASE("z$.namespaces")
{
GcManager Gc;
- ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true});
+ ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true}, nullptr);
const auto Bucket = "teardrinker"sv;
const auto CustomNamespace = "mynamespace"sv;
@@ -1313,7 +1323,7 @@ TEST_CASE("z$.drop.bucket")
WorkerThreadPool Workers(1);
{
GcManager Gc;
- ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true});
+ ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true}, nullptr);
const auto Bucket = "teardrinker"sv;
const auto Namespace = "mynamespace"sv;
@@ -1384,7 +1394,7 @@ TEST_CASE("z$.drop.namespace")
WorkerThreadPool Workers(1);
{
GcManager Gc;
- ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true});
+ ZenCacheStore Zcs(Gc, {.BasePath = TempDir.Path() / "cache", .AllowAutomaticCreationOfNamespaces = true}, nullptr);
const auto Bucket1 = "teardrinker1"sv;
const auto Bucket2 = "teardrinker2"sv;
const auto Namespace1 = "mynamespace1"sv;