annotate OrthancServer/Sources/ServerIndex.h @ 5856:d1dea8ad74a6 find-refactoring

implement StorageAccessOnFind for answers
author Alain Mazy <am@orthanc.team>
date Mon, 04 Nov 2024 21:51:24 +0100
parents 272b0d0eef38
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1898
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
1288
6e7e5ed91c2d upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1286
diff changeset
4 * Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5603
diff changeset
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5603
diff changeset
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5316
diff changeset
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * This program is free software: you can redistribute it and/or
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * modify it under the terms of the GNU General Public License as
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * published by the Free Software Foundation, either version 3 of the
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * License, or (at your option) any later version.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful, but
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * General Public License for more details.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 *
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 **/
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #pragma once
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
4587
888868a5dc4e ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4585
diff changeset
26 #include "Database/StatelessDatabaseOperations.h"
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
27 #include "../../OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h"
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3093
diff changeset
28
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 #include <boost/thread.hpp>
186
f68c039b0571 preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 183
diff changeset
30
62
a70bb32802ae renaming Server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 57
diff changeset
31 namespace Orthanc
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
3094
61da3c9b4121 cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3093
diff changeset
33 class ServerContext;
4587
888868a5dc4e ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4585
diff changeset
34
888868a5dc4e ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4585
diff changeset
35 class ServerIndex : public StatelessDatabaseOperations
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
4590
4a0bf1019335 simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4587
diff changeset
38 class TransactionContext;
4585
f0bdd99f3d81 created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4584
diff changeset
39 class TransactionContextFactory;
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
40 class UnstableResourcePayload;
278
771f12042be9 more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 272
diff changeset
41
511
3b735fdf320b monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
42 bool done_;
4577
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
43 boost::mutex monitoringMutex_;
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
44 boost::thread flushThread_;
5661
71c7d260510d update statistics thread
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
45 boost::thread updateStatisticsThread_;
511
3b735fdf320b monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
46 boost::thread unstableResourcesMonitorThread_;
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
5603
b2a97dfd719f monitoring of stable resources now also considers the resource type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
48 LeastRecentlyUsedIndex<std::pair<ResourceType, int64_t>, UnstableResourcePayload> unstableResources_;
180
626777d01dc4 use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 179
diff changeset
49
5061
e95fadefeb72 new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
50 MaxStorageMode maximumStorageMode_;
e95fadefeb72 new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
51 uint64_t maximumStorageSize_;
e95fadefeb72 new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
52 unsigned int maximumPatients_;
5817
272b0d0eef38 ReadOnly mode continued
Alain Mazy <am@orthanc.team>
parents: 5785
diff changeset
53 bool readOnly_;
269
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
54
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
55 static void FlushThread(ServerIndex* that,
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
56 unsigned int threadSleep);
511
3b735fdf320b monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
57
5661
71c7d260510d update statistics thread
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
58 static void UpdateStatisticsThread(ServerIndex* that,
71c7d260510d update statistics thread
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
59 unsigned int threadSleep);
71c7d260510d update statistics thread
Alain Mazy <am@orthanc.team>
parents: 5640
diff changeset
60
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
61 static void UnstableResourcesMonitorThread(ServerIndex* that,
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
62 unsigned int threadSleep);
511
3b735fdf320b monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
63
5603
b2a97dfd719f monitoring of stable resources now also considers the resource type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
64 void MarkAsUnstable(ResourceType type,
b2a97dfd719f monitoring of stable resources now also considers the resource type
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
65 int64_t id,
1177
5b2d8c280ac2 Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1162
diff changeset
66 const std::string& publicId);
511
3b735fdf320b monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 440
diff changeset
67
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 public:
226
8a26a8e85edf refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 224
diff changeset
69 ServerIndex(ServerContext& context,
2665
389d050a2e66 fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
70 IDatabaseWrapper& database,
5785
b4e7a85cde80 fix readonly init
Alain Mazy <am@orthanc.team>
parents: 5664
diff changeset
71 unsigned int threadSleepGranularityMilliseconds,
b4e7a85cde80 fix readonly init
Alain Mazy <am@orthanc.team>
parents: 5664
diff changeset
72 bool readOnly);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
206
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
74 ~ServerIndex();
4453a010d0db flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 204
diff changeset
75
1453
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
76 void Stop();
c0bdc47165ef code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1432
diff changeset
77
269
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
78 // "size == 0" means no limit on the storage size
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
79 void SetMaximumStorageSize(uint64_t size);
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
80
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
81 // "count == 0" means no limit on the number of patients
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
82 void SetMaximumPatientCount(unsigned int count);
f6fdf5abe751 recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 268
diff changeset
83
5061
e95fadefeb72 new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
84 void SetMaximumStorageMode(MaxStorageMode mode);
e95fadefeb72 new MaximumStorageMode configuration
Alain Mazy <am@osimis.io>
parents: 5044
diff changeset
85
4577
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
86 StoreStatus Store(std::map<MetadataType, std::string>& instanceMetadata,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
87 const DicomMap& dicomSummary,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
88 const Attachments& attachments,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
89 const MetadataMap& metadata,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
90 const DicomInstanceOrigin& origin,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
91 bool overwrite,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
92 bool hasTransferSyntax,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
93 DicomTransferSyntax transferSyntax,
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
94 bool hasPixelDataOffset,
4988
8fba26292a9f Housekeeper plugin: finalizing + integration tests ok
Alain Mazy <am@osimis.io>
parents: 4892
diff changeset
95 uint64_t pixelDataOffset,
5316
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
96 ValueRepresentation pixelDataVR,
03501a258d9e added instance metadata "PixelDataVR"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5185
diff changeset
97 bool isReconstruct);
4577
a114a5db2afe end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4574
diff changeset
98
4627
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4590
diff changeset
99 StoreStatus AddAttachment(int64_t& newRevision /*out*/,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4590
diff changeset
100 const FileInfo& attachment,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4590
diff changeset
101 const std::string& publicId,
f7d5372b59b3 handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4590
diff changeset
102 bool hasOldRevision,
4640
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4627
diff changeset
103 int64_t oldRevision,
66109d24d26e "ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4627
diff changeset
104 const std::string& oldMD5);
5606
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5603
diff changeset
105
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5603
diff changeset
106 bool IsUnstableResource(ResourceType type,
6e2dad336446 added "IsStable" field in expanded resources
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5603
diff changeset
107 int64_t id);
0
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 };
3959d33612cc initial commit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }