Mercurial > hg > orthanc-databases
comparison Framework/Plugins/StorageBackend.h @ 269:567761f0c1ea
fix issue #151: support of retries in the storage area plugins to deal with multiple writers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 21 Apr 2021 17:54:31 +0200 |
parents | d663d9e44f8d |
children | 16aac0287485 |
comparison
equal
deleted
inserted
replaced
268:9b003f265a8f | 269:567761f0c1ea |
---|---|
69 | 69 |
70 virtual void Remove(const std::string& uuid, | 70 virtual void Remove(const std::string& uuid, |
71 OrthancPluginContentType type) = 0; | 71 OrthancPluginContentType type) = 0; |
72 }; | 72 }; |
73 | 73 |
74 /** | |
75 * This class is similar to | |
76 * "Orthanc::StatelessDatabaseOperations": It handles retries of | |
77 * transactions in the case of collision between multiple | |
78 * readers/writers. | |
79 **/ | |
80 class IDatabaseOperation : public boost::noncopyable | |
81 { | |
82 public: | |
83 virtual ~IDatabaseOperation() | |
84 { | |
85 } | |
86 | |
87 virtual void Execute(IAccessor& accessor) = 0; | |
88 }; | |
89 | |
90 class ReadWholeOperation; | |
91 | |
74 private: | 92 private: |
75 class StringVisitor; | 93 class StringVisitor; |
76 | 94 |
77 boost::mutex mutex_; | 95 boost::mutex mutex_; |
78 DatabaseManager manager_; | 96 DatabaseManager manager_; |
97 unsigned int maxRetries_; | |
79 | 98 |
80 protected: | 99 protected: |
81 class AccessorBase : public IAccessor | 100 class AccessorBase : public IAccessor |
82 { | 101 { |
83 private: | 102 private: |
116 }; | 135 }; |
117 | 136 |
118 virtual bool HasReadRange() const = 0; | 137 virtual bool HasReadRange() const = 0; |
119 | 138 |
120 public: | 139 public: |
121 StorageBackend(IDatabaseFactory* factory); // Takes ownership | 140 StorageBackend(IDatabaseFactory* factory /* takes ownership */, |
141 unsigned int maxRetries); | |
122 | 142 |
123 virtual ~StorageBackend() | 143 virtual ~StorageBackend() |
124 { | 144 { |
125 } | 145 } |
126 | 146 |
145 IAccessor& accessor, | 165 IAccessor& accessor, |
146 const std::string& uuid, | 166 const std::string& uuid, |
147 OrthancPluginContentType type, | 167 OrthancPluginContentType type, |
148 uint64_t start, | 168 uint64_t start, |
149 size_t length); | 169 size_t length); |
170 | |
171 unsigned int GetMaxRetries() const | |
172 { | |
173 return maxRetries_; | |
174 } | |
175 | |
176 void Execute(IDatabaseOperation& operation); | |
150 }; | 177 }; |
151 } | 178 } |