aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar vnugent <public@vaughnnugent.com>2024-03-24 20:55:01 -0400
committerLibravatar vnugent <public@vaughnnugent.com>2024-03-24 20:55:01 -0400
commita504435151efbe1d19404fa44859b15c629f6d5d (patch)
tree4eb1bd863074e64922e35ff730f354ac40528698
parentc74440ff12daa03cc4b7792d0c3baad46a11a465 (diff)
chore: Updated compose and added some more logging
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs30
-rw-r--r--lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs5
-rw-r--r--plugins/ObjectCacheServer/server/container/docker-compose.yaml7
-rw-r--r--plugins/ObjectCacheServer/server/taskfile.yaml12
-rw-r--r--plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs4
-rw-r--r--plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs6
6 files changed, 54 insertions, 10 deletions
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
index 3584344..7908313 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheLIstener.cs
@@ -83,6 +83,9 @@ namespace VNLib.Data.Caching.ObjectCache
/// </summary>
public IBlobCacheTable Cache { get; } = cache ?? throw new ArgumentNullException(nameof(cache));
+
+ private readonly ILogProvider _tLog = config.LogTransactions ? config.Log : new NullLogger();
+
///<inheritdoc/>
protected override async Task ProcessAsync(FBMContext context, T? userState, CancellationToken exitToken)
{
@@ -250,6 +253,8 @@ namespace VNLib.Data.Caching.ObjectCache
if (found)
{
EnqueEvent(change);
+
+ _tLog.Debug("Deleted cache entry {id}", change.CurrentId);
}
}
@@ -260,6 +265,8 @@ namespace VNLib.Data.Caching.ObjectCache
EnqueEvent(change);
+ _tLog.Debug("Cache entry {id} added or updated. New ID {nid}", change.CurrentId, change.AlternateId);
+
context.CloseResponse(ResponseCodes.Okay);
}
@@ -286,5 +293,28 @@ namespace VNLib.Data.Caching.ObjectCache
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
+
+ sealed class NullLogger : ILogProvider
+ {
+ public void Flush()
+ { }
+
+ public object GetLogProvider() => null!;
+
+
+ public bool IsEnabled(LogLevel level) => false;
+
+ public void Write(LogLevel level, string value)
+ { }
+
+ public void Write(LogLevel level, Exception exception, string value = "")
+ { }
+
+ public void Write(LogLevel level, string value, params object?[] args)
+ { }
+
+ public void Write(LogLevel level, string value, params ValueType[] args)
+ { }
+ }
}
}
diff --git a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
index 1098be4..492dfb8 100644
--- a/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
+++ b/lib/VNLib.Data.Caching.ObjectCache/src/BlobCacheListenerConfig.cs
@@ -47,5 +47,10 @@ namespace VNLib.Data.Caching.ObjectCache
/// data in FBM header fields
/// </summary>
public bool EnableMessageChecksums { get; init; } = true;
+
+ /// <summary>
+ /// A flag that enables logging of transactions (events) to the log
+ /// </summary>
+ public bool LogTransactions { get; init; }
}
}
diff --git a/plugins/ObjectCacheServer/server/container/docker-compose.yaml b/plugins/ObjectCacheServer/server/container/docker-compose.yaml
index 647c8c2..5aa494e 100644
--- a/plugins/ObjectCacheServer/server/container/docker-compose.yaml
+++ b/plugins/ObjectCacheServer/server/container/docker-compose.yaml
@@ -10,6 +10,7 @@ services:
restart: unless-stopped
hostname: vncache-server
volumes:
+ - ./data/:/app/data:rw #optional writes log files to the host (may be required in the future)
- ./assets:/app/usr/assets:ro #optional if assets are required
- ./ssl:/app/ssl:ro #optional only if SSL is enabled (currently not a feature)
ports:
@@ -18,7 +19,7 @@ services:
#System memory consumption is calculated as follows:
# MAX_ENTIRES x CACHE_BUCKETS x CACHE_MAX_MESSAGE = max memory consumption
- MAX_CONCURRENT_CONNECTIONS: "1000" #max number of concurrent connections
+ MAX_CONCURRENT_CONNECTIONS: "1000" #max number of concurrent client connections
MAX_ENTRIES: "10000" #max number of cache entries per bucket
CACHE_BUCKETS: "100" #number of cache buckets for load balancing
CACHE_MAX_MESSAGE: "20480" #20KB
@@ -29,8 +30,8 @@ services:
ENABLE_CHECKSUMS: "true" #enables checksums for messages
#SECRETS (must be JWK formatted keys)
- CACHE_PRIV_KEY: "" #REQUIRED local private key used to identify and sign messages to clients and other nodes
- CLIENT_PUB_KEY: "" #REQUIRED used to verify client messages
+ CACHE_PRIV_KEY: '' #REQUIRED local private key used to identify and sign messages to clients and other nodes
+ CLIENT_PUB_KEY: '' #REQUIRED used to verify client messages
#HC vault
#HC_VAULT_ADDR: ""
diff --git a/plugins/ObjectCacheServer/server/taskfile.yaml b/plugins/ObjectCacheServer/server/taskfile.yaml
index 38eae79..9455451 100644
--- a/plugins/ObjectCacheServer/server/taskfile.yaml
+++ b/plugins/ObjectCacheServer/server/taskfile.yaml
@@ -38,12 +38,12 @@ tasks:
VNLIB_SHARED_HEAP_FILE_PATH: lib/libvn_rpmalloc
cmds:
- - cmd: dotnet webserver/VNLib.WebServer.dll --config config/config.json --input-off --inline-scheduler {{.ARGS}}
+ - cmd: dotnet webserver/VNLib.WebServer.dll --config config/config.json --input-off --inline-scheduler {{.CLI_ARGS}}
#setup sever environment
- setup-debian:
- desc: "Performs initial setup on Debian x64 based machines"
+ setup-apt:
+ desc: "Performs initial setup on Debian/APT x64 based machines"
silent: true
cmds:
- apt update
@@ -51,8 +51,8 @@ tasks:
- task: setup
- echo "Setup complete"
- setup-fedora:
- desc: "Performs initial setup on Fedora/Redhat x64 (dnf) based machines"
+ setup-dnf:
+ desc: "Performs initial setup on Fedora using DNF x64 (dnf) based machines"
silent: true
cmds:
- dnf update
@@ -61,7 +61,7 @@ tasks:
- echo "Setup complete"
setup-alpine:
- desc: "Performs initial setup on Alpine x64 based machines"
+ desc: "Performs initial setup on Alpine using APK x64 based machines"
silent: true
cmds:
- apk update
diff --git a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
index 8368d3a..42f406a 100644
--- a/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
+++ b/plugins/ObjectCacheServer/src/Endpoints/ConnectEndpoint.cs
@@ -244,6 +244,8 @@ namespace VNLib.Data.Caching.ObjectCache.Server.Endpoints
{
WsUserState state = wss.UserState!;
+ Log.Debug("Client established websocket connection {sid}", wss.SocketID);
+
//Notify peers of new connection
Peers.OnPeerConnected(state);
@@ -307,7 +309,7 @@ namespace VNLib.Data.Caching.ObjectCache.Server.Endpoints
//Notify monitor of disconnect
Peers.OnPeerDisconnected(state);
- Log.Debug("Server websocket exited");
+ Log.Debug("Client websocket disconnected {sid}", wss.SocketID);
}
diff --git a/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs b/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs
index f8ce8a9..3b3e2c0 100644
--- a/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs
+++ b/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs
@@ -195,8 +195,14 @@ namespace VNLib.Data.Caching.ObjectCache.Server
Log = plugin.Log.CreateScope(CacheConstants.LogScopes.BlobCacheListener),
MemoryManager = new SharedHeapFBMMemoryManager(SharedCacheHeap),
EnableMessageChecksums = MemoryConfiguration.EnableChecksums,
+ LogTransactions = plugin.IsDebug() || plugin.HostArgs.HasArgument("--log-cache-events")
};
+ if (conf.LogTransactions)
+ {
+ plugin.Log.Information("Verbose cache event logging enabled");
+ }
+
//Endpoint only allows for a single reader
Listener = new(
plugin.LoadMemoryCacheSystem(config, manager, MemoryConfiguration),