diff options
| author | Stefan Boberg <[email protected]> | 2023-05-23 15:00:55 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-23 15:00:55 +0200 |
| commit | 55844c3f72866711f9a10b987f14da5622cc2d63 (patch) | |
| tree | a872fdb170bf1019cdb4b5cc17c53dcc1585e3cc /src/zenserver/cache/httpstructuredcache.h | |
| parent | use exception when allocations fail rather than asserts (#319) (diff) | |
| download | zen-55844c3f72866711f9a10b987f14da5622cc2d63.tar.xz zen-55844c3f72866711f9a10b987f14da5622cc2d63.zip | |
cache log sessionid (#297)
* implemented structured cache logging to be used as audit trail to help analyse potential cache pollution/corruption
* added common header to all known log targets
* made Oid::operator bool explicit to avoid logging/text format mishaps
* HttpClient::operator bool -> explicit
* changed cache logs to not rotate on start in order to retain more history
* added CacheRequestContext
* properly initialize request context
* log session id and request id on zencacehstore get/put
* changelog
Diffstat (limited to 'src/zenserver/cache/httpstructuredcache.h')
| -rw-r--r-- | src/zenserver/cache/httpstructuredcache.h | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/zenserver/cache/httpstructuredcache.h b/src/zenserver/cache/httpstructuredcache.h index 4f03daae4..60714d6ae 100644 --- a/src/zenserver/cache/httpstructuredcache.h +++ b/src/zenserver/cache/httpstructuredcache.h @@ -6,6 +6,7 @@ #include <zenhttp/httpserver.h> #include <zenhttp/httpstats.h> #include <zenhttp/httpstatus.h> +#include <zenutil/cache/cache.h> #include <memory> #include <vector> @@ -113,17 +114,18 @@ private: void HandleRpcRequest(HttpServerRequest& Request); void HandleDetailsRequest(HttpServerRequest& Request); - CbPackage HandleRpcPutCacheRecords(const CbPackage& BatchRequest); - CbPackage HandleRpcGetCacheRecords(CbObjectView BatchRequest); - CbPackage HandleRpcPutCacheValues(const CbPackage& BatchRequest); - CbPackage HandleRpcGetCacheValues(CbObjectView BatchRequest); - CbPackage HandleRpcGetCacheChunks(CbObjectView BatchRequest); - HttpResponseCode HandleRpcRequest(const ZenContentType ContentType, - IoBuffer&& Body, - uint32_t& OutAcceptMagic, - RpcAcceptOptions& OutAcceptFlags, - int& OutTargetProcessId, - CbPackage& OutPackage); + CbPackage HandleRpcPutCacheRecords(const CacheRequestContext& Context, const CbPackage& BatchRequest); + CbPackage HandleRpcGetCacheRecords(const CacheRequestContext& Context, CbObjectView BatchRequest); + CbPackage HandleRpcPutCacheValues(const CacheRequestContext& Context, const CbPackage& BatchRequest); + CbPackage HandleRpcGetCacheValues(const CacheRequestContext& Context, CbObjectView BatchRequest); + CbPackage HandleRpcGetCacheChunks(const CacheRequestContext& Context, CbObjectView BatchRequest); + HttpResponseCode HandleRpcRequest(const CacheRequestContext& Context, + const ZenContentType ContentType, + IoBuffer&& Body, + uint32_t& OutAcceptMagic, + RpcAcceptOptions& OutAcceptFlags, + int& OutTargetProcessId, + CbPackage& OutPackage); void HandleCacheRequest(HttpServerRequest& Request); void HandleCacheNamespaceRequest(HttpServerRequest& Request, std::string_view Namespace); @@ -142,22 +144,27 @@ private: std::vector<cache::detail::ChunkRequest*>& ValueRequests, CbObjectView RpcRequest); /** HandleRpcGetCacheChunks Helper: Load records to get ContentId for RecordRequests, and load their payloads if they exist locally. */ - void GetLocalCacheRecords(std::string_view Namespace, + void GetLocalCacheRecords(const CacheRequestContext& Context, + std::string_view Namespace, std::vector<CacheKeyRequest>& RecordKeys, std::vector<cache::detail::RecordBody>& Records, std::vector<cache::detail::ChunkRequest*>& RecordRequests, std::vector<CacheChunkRequest*>& OutUpstreamChunks); /** HandleRpcGetCacheChunks Helper: For ValueRequests, load their payloads if they exist locally. */ - void GetLocalCacheValues(std::string_view Namespace, + void GetLocalCacheValues(const CacheRequestContext& Context, + std::string_view Namespace, std::vector<cache::detail::ChunkRequest*>& ValueRequests, std::vector<CacheChunkRequest*>& OutUpstreamChunks); /** HandleRpcGetCacheChunks Helper: Load payloads from upstream that did not exist locally. */ - void GetUpstreamCacheChunks(std::string_view Namespace, + void GetUpstreamCacheChunks(const CacheRequestContext& Context, + std::string_view Namespace, std::vector<CacheChunkRequest*>& UpstreamChunks, std::vector<CacheChunkRequest>& RequestKeys, std::vector<cache::detail::ChunkRequest>& Requests); /** HandleRpcGetCacheChunks Helper: Send response message containing all chunk results. */ - CbPackage WriteGetCacheChunksResponse(std::string_view Namespace, std::vector<cache::detail::ChunkRequest>& Requests); + CbPackage WriteGetCacheChunksResponse(const CacheRequestContext& Context, + std::string_view Namespace, + std::vector<cache::detail::ChunkRequest>& Requests); bool AreDiskWritesAllowed() const; @@ -174,7 +181,7 @@ private: CacheStats m_CacheStats; const DiskWriteBlocker* m_DiskWriteBlocker = nullptr; - void ReplayRequestRecorder(cache::IRpcRequestReplayer& Replayer, uint32_t ThreadCount); + void ReplayRequestRecorder(const CacheRequestContext& Context, cache::IRpcRequestReplayer& Replayer, uint32_t ThreadCount); std::unique_ptr<cache::IRpcRequestRecorder> m_RequestRecorder; }; |