comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.h @ 4613:2684544ff03c db-changes

maximum number of database retries for writer collisions is now set by the plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Apr 2021 10:46:12 +0200
parents f75c63aa9de0
children 95ffe3b6ef7c
comparison
equal deleted inserted replaced
4612:4982733a4e39 4613:2684544ff03c
37 37
38 #include "IDatabaseWrapper.h" 38 #include "IDatabaseWrapper.h"
39 #include "../DicomInstanceOrigin.h" 39 #include "../DicomInstanceOrigin.h"
40 40
41 #include <boost/shared_ptr.hpp> 41 #include <boost/shared_ptr.hpp>
42 #include <boost/thread/shared_mutex.hpp>
42 43
43 44
44 namespace Orthanc 45 namespace Orthanc
45 { 46 {
46 class DatabaseLookup; 47 class DatabaseLookup;
406 private: 407 private:
407 class MainDicomTagsRegistry; 408 class MainDicomTagsRegistry;
408 class Transaction; 409 class Transaction;
409 410
410 IDatabaseWrapper& db_; 411 IDatabaseWrapper& db_;
412 boost::shared_ptr<MainDicomTagsRegistry> mainDicomTagsRegistry_; // "shared_ptr" because of PImpl
413 bool hasFlushToDisk_;
414
415 // Mutex to protect the configuration options
416 boost::shared_mutex mutex_;
411 std::unique_ptr<ITransactionContextFactory> factory_; 417 std::unique_ptr<ITransactionContextFactory> factory_;
412 unsigned int maxRetries_; 418 unsigned int maxRetries_;
413 boost::shared_ptr<MainDicomTagsRegistry> mainDicomTagsRegistry_; // "shared_ptr" because of PImpl
414 bool hasFlushToDisk_;
415 419
416 void NormalizeLookup(std::vector<DatabaseConstraint>& target, 420 void NormalizeLookup(std::vector<DatabaseConstraint>& target,
417 const DatabaseLookup& source, 421 const DatabaseLookup& source,
418 ResourceType level) const; 422 ResourceType level) const;
419 423
426 430
427 public: 431 public:
428 explicit StatelessDatabaseOperations(IDatabaseWrapper& database); 432 explicit StatelessDatabaseOperations(IDatabaseWrapper& database);
429 433
430 void SetTransactionContextFactory(ITransactionContextFactory* factory /* takes ownership */); 434 void SetTransactionContextFactory(ITransactionContextFactory* factory /* takes ownership */);
435
436 // Only used to handle "ErrorCode_DatabaseCannotSerialize" in the
437 // case of collision between multiple writers
438 void SetMaxDatabaseRetries(unsigned int maxRetries);
431 439
432 // It is assumed that "GetDatabaseVersion()" can run out of a 440 // It is assumed that "GetDatabaseVersion()" can run out of a
433 // database transaction 441 // database transaction
434 unsigned int GetDatabaseVersion() 442 unsigned int GetDatabaseVersion()
435 { 443 {