comparison OrthancServer/ServerIndex.h @ 511:3b735fdf320b

monitoring of stable patients/studies/series
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 16 Aug 2013 15:39:53 +0200
parents 23e5b35e3c5c
children 2c739f76d0bb
comparison
equal deleted inserted replaced
509:e7841864c97c 511:3b735fdf320b
32 32
33 #pragma once 33 #pragma once
34 34
35 #include <boost/thread.hpp> 35 #include <boost/thread.hpp>
36 #include <boost/noncopyable.hpp> 36 #include <boost/noncopyable.hpp>
37 #include "../Core/Cache/LeastRecentlyUsedIndex.h"
37 #include "../Core/SQLite/Connection.h" 38 #include "../Core/SQLite/Connection.h"
38 #include "../Core/DicomFormat/DicomMap.h" 39 #include "../Core/DicomFormat/DicomMap.h"
39 #include "../Core/DicomFormat/DicomInstanceHasher.h" 40 #include "../Core/DicomFormat/DicomInstanceHasher.h"
40 #include "ServerEnumerations.h" 41 #include "ServerEnumerations.h"
41 42
53 54
54 class ServerIndex : public boost::noncopyable 55 class ServerIndex : public boost::noncopyable
55 { 56 {
56 private: 57 private:
57 class Transaction; 58 class Transaction;
59 struct UnstableResourcePayload;
58 60
61 bool done_;
59 boost::mutex mutex_; 62 boost::mutex mutex_;
60 boost::thread flushThread_; 63 boost::thread flushThread_;
64 boost::thread unstableResourcesMonitorThread_;
61 65
62 std::auto_ptr<Internals::ServerIndexListener> listener_; 66 std::auto_ptr<Internals::ServerIndexListener> listener_;
63 std::auto_ptr<DatabaseWrapper> db_; 67 std::auto_ptr<DatabaseWrapper> db_;
68 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_;
64 69
65 uint64_t currentStorageSize_; 70 uint64_t currentStorageSize_;
66 uint64_t maximumStorageSize_; 71 uint64_t maximumStorageSize_;
67 unsigned int maximumPatients_; 72 unsigned int maximumPatients_;
73
74 static void FlushThread(ServerIndex* that);
75
76 static void UnstableResourcesMonitorThread(ServerIndex* that);
68 77
69 void MainDicomTagsToJson(Json::Value& result, 78 void MainDicomTagsToJson(Json::Value& result,
70 int64_t resourceId); 79 int64_t resourceId);
71 80
72 SeriesStatus GetSeriesStatus(int id); 81 SeriesStatus GetSeriesStatus(int id);
75 84
76 void Recycle(uint64_t instanceSize, 85 void Recycle(uint64_t instanceSize,
77 const std::string& newPatientId); 86 const std::string& newPatientId);
78 87
79 void StandaloneRecycling(); 88 void StandaloneRecycling();
89
90 void MarkAsUnstable(int64_t id,
91 Orthanc::ResourceType type);
80 92
81 public: 93 public:
82 typedef std::list<FileInfo> Attachments; 94 typedef std::list<FileInfo> Attachments;
83 95
84 ServerIndex(ServerContext& context, 96 ServerIndex(ServerContext& context,