Mercurial > hg > orthanc
comparison OrthancServer/Sources/ServerContext.h @ 4457:789676a8c96a
Refactoring and improvements to the cache of DICOM files in ServerContext
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 19 Jan 2021 19:05:04 +0100 |
parents | d9473bd5ed43 |
children | 6831de40acd9 |
comparison
equal
deleted
inserted
replaced
4456:3e4f7b7840f0 | 4457:789676a8c96a |
---|---|
37 #include "LuaScripting.h" | 37 #include "LuaScripting.h" |
38 #include "OrthancHttpHandler.h" | 38 #include "OrthancHttpHandler.h" |
39 #include "ServerIndex.h" | 39 #include "ServerIndex.h" |
40 #include "ServerJobs/IStorageCommitmentFactory.h" | 40 #include "ServerJobs/IStorageCommitmentFactory.h" |
41 | 41 |
42 #include "../../OrthancFramework/Sources/Cache/MemoryCache.h" | |
43 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h" | 42 #include "../../OrthancFramework/Sources/DicomFormat/DicomElement.h" |
44 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h" | 43 #include "../../OrthancFramework/Sources/DicomParsing/DicomModification.h" |
45 #include "../../OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h" | 44 #include "../../OrthancFramework/Sources/DicomParsing/IDicomTranscoder.h" |
45 #include "../../OrthancFramework/Sources/DicomParsing/ParsedDicomCache.h" | |
46 #include "../../OrthancFramework/Sources/MultiThreading/Semaphore.h" | |
46 | 47 |
47 | 48 |
48 namespace Orthanc | 49 namespace Orthanc |
49 { | 50 { |
50 class DicomInstanceToStore; | 51 class DicomInstanceToStore; |
120 { | 121 { |
121 return context_.filterLua_.FilterIncomingInstance(instance, simplified); | 122 return context_.filterLua_.FilterIncomingInstance(instance, simplified); |
122 } | 123 } |
123 }; | 124 }; |
124 | 125 |
125 class DicomCacheProvider : public Deprecated::ICachePageProvider // TODO | |
126 { | |
127 private: | |
128 ServerContext& context_; | |
129 | |
130 public: | |
131 explicit DicomCacheProvider(ServerContext& context) : context_(context) | |
132 { | |
133 } | |
134 | |
135 virtual IDynamicObject* Provide(const std::string& id) ORTHANC_OVERRIDE; | |
136 }; | |
137 | |
138 class ServerListener | 126 class ServerListener |
139 { | 127 { |
140 private: | 128 private: |
141 IServerListener *listener_; | 129 IServerListener *listener_; |
142 std::string description_; | 130 std::string description_; |
183 ServerIndex index_; | 171 ServerIndex index_; |
184 IStorageArea& area_; | 172 IStorageArea& area_; |
185 | 173 |
186 bool compressionEnabled_; | 174 bool compressionEnabled_; |
187 bool storeMD5_; | 175 bool storeMD5_; |
188 | 176 |
189 DicomCacheProvider provider_; | 177 Semaphore largeDicomThrottler_; // New in Orthanc 1.9.0 (notably for very large DICOM files in WSI) |
190 boost::mutex dicomCacheMutex_; | 178 ParsedDicomCache dicomCache_; |
191 Deprecated::MemoryCache dicomCache_; // TODO | |
192 | 179 |
193 LuaScripting mainLua_; | 180 LuaScripting mainLua_; |
194 LuaScripting filterLua_; | 181 LuaScripting filterLua_; |
195 LuaServerListener luaListener_; | 182 LuaServerListener luaListener_; |
196 std::unique_ptr<SharedArchive> mediaArchive_; | 183 std::unique_ptr<SharedArchive> mediaArchive_; |
247 const DatabaseLookup& lookup, | 234 const DatabaseLookup& lookup, |
248 ResourceType queryLevel, | 235 ResourceType queryLevel, |
249 size_t since, | 236 size_t since, |
250 size_t limit); | 237 size_t limit); |
251 | 238 |
239 void PublishDicomCacheMetrics(); | |
240 | |
252 // This DicomModification object is intended to be used as a | 241 // This DicomModification object is intended to be used as a |
253 // "rules engine" when de-identifying logs for C-Find, C-Get, and | 242 // "rules engine" when de-identifying logs for C-Find, C-Get, and |
254 // C-Move queries (new in Orthanc 1.8.2) | 243 // C-Move queries (new in Orthanc 1.8.2) |
255 DicomModification logsDeidentifierRules_; | 244 DicomModification logsDeidentifierRules_; |
256 bool deidentifyLogs_; | 245 bool deidentifyLogs_; |
257 | 246 |
258 public: | 247 public: |
259 class DicomCacheLocker : public boost::noncopyable | 248 class DicomCacheLocker : public boost::noncopyable |
260 { | 249 { |
261 private: | 250 private: |
262 ServerContext& that_; | 251 ServerContext& context_; |
263 ParsedDicomFile *dicom_; | 252 std::string instancePublicId_; |
264 boost::mutex::scoped_lock lock_; | 253 std::unique_ptr<ParsedDicomCache::Accessor> accessor_; |
254 std::unique_ptr<ParsedDicomFile> dicom_; | |
255 size_t dicomSize_; | |
256 std::unique_ptr<Semaphore::Locker> largeDicomLocker_; | |
265 | 257 |
266 public: | 258 public: |
267 DicomCacheLocker(ServerContext& that, | 259 DicomCacheLocker(ServerContext& context, |
268 const std::string& instancePublicId); | 260 const std::string& instancePublicId); |
269 | 261 |
270 ~DicomCacheLocker(); | 262 ~DicomCacheLocker(); |
271 | 263 |
272 ParsedDicomFile& GetDicom() | 264 ParsedDicomFile& GetDicom() const; |
273 { | |
274 return *dicom_; | |
275 } | |
276 }; | 265 }; |
277 | 266 |
278 ServerContext(IDatabaseWrapper& database, | 267 ServerContext(IDatabaseWrapper& database, |
279 IStorageArea& area, | 268 IStorageArea& area, |
280 bool unitTesting, | 269 bool unitTesting, |