From c74440ff12daa03cc4b7792d0c3baad46a11a465 Mon Sep 17 00:00:00 2001 From: vnugent Date: Mon, 18 Mar 2024 21:57:57 -0400 Subject: feat: message checksum support & dynamic serializers --- plugins/ObjectCacheServer/server/container/Dockerfile | 1 + .../config-templates/ObjectCacheServer-template.json | 3 ++- .../ObjectCacheServer/server/container/docker-compose.yaml | 3 ++- .../src/Cache/CacheMemoryConfiguration.cs | 3 +++ plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs | 14 ++++++++++---- 5 files changed, 18 insertions(+), 6 deletions(-) (limited to 'plugins/ObjectCacheServer') diff --git a/plugins/ObjectCacheServer/server/container/Dockerfile b/plugins/ObjectCacheServer/server/container/Dockerfile index 6c466d4..725b9d1 100644 --- a/plugins/ObjectCacheServer/server/container/Dockerfile +++ b/plugins/ObjectCacheServer/server/container/Dockerfile @@ -55,6 +55,7 @@ ENV MAX_ENTRIES=10000 ENV CACHE_BUCKETS=100 ENV CACHE_MAX_MESSAGE=20480 ENV MAX_CONCURRENT_CONNECTIONS=1000 +ENV ENABLE_CHECKSUMS=true ENV VERIFY_IP=true ENV MAX_PEER_NODES=10 diff --git a/plugins/ObjectCacheServer/server/container/config-templates/ObjectCacheServer-template.json b/plugins/ObjectCacheServer/server/container/config-templates/ObjectCacheServer-template.json index 765c3d7..564039a 100644 --- a/plugins/ObjectCacheServer/server/container/config-templates/ObjectCacheServer-template.json +++ b/plugins/ObjectCacheServer/server/container/config-templates/ObjectCacheServer-template.json @@ -45,7 +45,8 @@ "buffer_recv_min": 8192, //min of 8k transfer buffer "buffer_header_max": 2048, //2k max header buffer size "buffer_header_min": 128, //128 byte min request header buffer size - "max_message_size": ${CACHE_MAX_MESSAGE} //Absolute maxium message size allowed, also the maxium size of cache entires + "max_message_size": ${CACHE_MAX_MESSAGE}, //Absolute maxium message size allowed, also the maxium size of cache entires + "enable_checksums": ${ENABLE_CHECKSUMS} //Enable checksums for cache entries }, //Known peers array, must point to well-known endpoint for discovery diff --git a/plugins/ObjectCacheServer/server/container/docker-compose.yaml b/plugins/ObjectCacheServer/server/container/docker-compose.yaml index c1b61fa..647c8c2 100644 --- a/plugins/ObjectCacheServer/server/container/docker-compose.yaml +++ b/plugins/ObjectCacheServer/server/container/docker-compose.yaml @@ -25,7 +25,8 @@ services: VERIFY_IP: "true" #verfies the IP address of clients during negotiation (recommended) MAX_PEER_NODES: "10" #max number of other peer nodes this node shoud connect to DISCOVERY_INTERVAL: "360" #time (in seconds) between peer node discovery - KNOWN_PEERS: '[]' #array of known peer nodes in the cluster + KNOWN_PEERS: '[]' #array of known peer nodes in the cluster + 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 diff --git a/plugins/ObjectCacheServer/src/Cache/CacheMemoryConfiguration.cs b/plugins/ObjectCacheServer/src/Cache/CacheMemoryConfiguration.cs index c404cc5..0b81447 100644 --- a/plugins/ObjectCacheServer/src/Cache/CacheMemoryConfiguration.cs +++ b/plugins/ObjectCacheServer/src/Cache/CacheMemoryConfiguration.cs @@ -54,5 +54,8 @@ namespace VNLib.Data.Caching.ObjectCache.Server.Cache [JsonPropertyName("memory_lib_path")] public string? ExternLibPath { get; set; } + + [JsonPropertyName("enable_checksums")] + public bool EnableChecksums { get; set; } = true; } } diff --git a/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs b/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs index cd5bf1b..f8ce8a9 100644 --- a/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs +++ b/plugins/ObjectCacheServer/src/ObjectCacheSystemState.cs @@ -187,15 +187,21 @@ namespace VNLib.Data.Caching.ObjectCache.Server CacheListenerPubQueue queue = new(plugin, PeerEventQueue); - //Must register background worker to listen for changes + //Must register the queue background worker to listen for changes _ = plugin.ObserveWork(queue, 150); + BlobCacheListenerConfig conf = new() + { + Log = plugin.Log.CreateScope(CacheConstants.LogScopes.BlobCacheListener), + MemoryManager = new SharedHeapFBMMemoryManager(SharedCacheHeap), + EnableMessageChecksums = MemoryConfiguration.EnableChecksums, + }; + //Endpoint only allows for a single reader Listener = new( plugin.LoadMemoryCacheSystem(config, manager, MemoryConfiguration), - queue, - plugin.Log.CreateScope(CacheConstants.LogScopes.BlobCacheListener), - new SharedHeapFBMMemoryManager(SharedCacheHeap) + conf, + queue ); InternalStore = new CacheStore(Listener.Cache); -- cgit