comparison Core/FileStorage/StorageAccessor.h @ 3175:574890d14c92

new metrics: orthanc_store_dicom_duration_ms, orthanc_storage_[create|read|remove]_duration_ms
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Jan 2019 17:34:09 +0100
parents 4e43e67f8ecf
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3174:8ea7c4546c3a 3175:574890d14c92
59 59
60 #include <vector> 60 #include <vector>
61 #include <string> 61 #include <string>
62 #include <boost/noncopyable.hpp> 62 #include <boost/noncopyable.hpp>
63 #include <stdint.h> 63 #include <stdint.h>
64 #include <json/value.h>
65 64
66 namespace Orthanc 65 namespace Orthanc
67 { 66 {
67 class MetricsRegistry;
68
69 /**
70 * This class handles the compression/decompression of the raw files
71 * contained in the storage area, and monitors timing metrics (if
72 * enabled).
73 **/
68 class StorageAccessor : boost::noncopyable 74 class StorageAccessor : boost::noncopyable
69 { 75 {
70 private: 76 private:
71 IStorageArea& area_; 77 class MetricsTimer;
78
79 IStorageArea& area_;
80 MetricsRegistry* metrics_;
72 81
73 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 82 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
74 void SetupSender(BufferHttpSender& sender, 83 void SetupSender(BufferHttpSender& sender,
75 const FileInfo& info, 84 const FileInfo& info,
76 const std::string& mime); 85 const std::string& mime);
77 #endif 86 #endif
78 87
79 public: 88 public:
80 StorageAccessor(IStorageArea& area) : area_(area) 89 StorageAccessor(IStorageArea& area) :
90 area_(area),
91 metrics_(NULL)
92 {
93 }
94
95 StorageAccessor(IStorageArea& area,
96 MetricsRegistry& metrics) :
97 area_(area),
98 metrics_(&metrics)
81 { 99 {
82 } 100 }
83 101
84 FileInfo Write(const void* data, 102 FileInfo Write(const void* data,
85 size_t size, 103 size_t size,
97 } 115 }
98 116
99 void Read(std::string& content, 117 void Read(std::string& content,
100 const FileInfo& info); 118 const FileInfo& info);
101 119
102 void Read(Json::Value& content, 120 void ReadRaw(std::string& content,
103 const FileInfo& info); 121 const FileInfo& info);
122
123 void Remove(const std::string& fileUuid,
124 FileContentType type);
104 125
105 void Remove(const FileInfo& info) 126 void Remove(const FileInfo& info)
106 { 127 {
107 area_.Remove(info.GetUuid(), info.GetContentType()); 128 Remove(info.GetUuid(), info.GetContentType());
108 } 129 }
109 130
110 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1 131 #if ORTHANC_ENABLE_CIVETWEB == 1 || ORTHANC_ENABLE_MONGOOSE == 1
111 void AnswerFile(HttpOutput& output, 132 void AnswerFile(HttpOutput& output,
112 const FileInfo& info, 133 const FileInfo& info,