Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerIndex.h @ 4604:2c702cfae274 db-changes
New option "DatabaseServerIdentifier" to identify the server among a pool of Orthanc servers
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 30 Mar 2021 10:39:59 +0200 |
parents | 4a0bf1019335 |
children | f7d5372b59b3 |
rev | line source |
---|---|
0 | 1 /** |
62 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 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 |
4437
d9473bd5ed43
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4205
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
0 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU General Public License as | |
9 * published by the Free Software Foundation, either version 3 of the | |
10 * License, or (at your option) any later version. | |
136 | 11 * |
12 * In addition, as a special exception, the copyright holders of this | |
13 * program give permission to link the code of its release with the | |
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
15 * that use the same license as the "OpenSSL" library), and distribute | |
16 * the linked executables. You must obey the GNU General Public License | |
17 * in all respects for all of the code used other than "OpenSSL". If you | |
18 * modify file(s) with this exception, you may extend this exception to | |
19 * your version of the file(s), but you are not obligated to do so. If | |
20 * you do not wish to do so, delete this exception statement from your | |
21 * version. If you delete this exception statement from all source files | |
22 * in the program, then also delete it here. | |
0 | 23 * |
24 * This program is distributed in the hope that it will be useful, but | |
25 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
27 * General Public License for more details. | |
28 * | |
29 * You should have received a copy of the GNU General Public License | |
30 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
31 **/ | |
32 | |
33 | |
34 #pragma once | |
35 | |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4585
diff
changeset
|
36 #include "Database/StatelessDatabaseOperations.h" |
4045 | 37 #include "../../OrthancFramework/Sources/Cache/LeastRecentlyUsedIndex.h" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
38 |
0 | 39 #include <boost/thread.hpp> |
186
f68c039b0571
preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
183
diff
changeset
|
40 |
62 | 41 namespace Orthanc |
0 | 42 { |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
43 class ServerContext; |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4585
diff
changeset
|
44 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4585
diff
changeset
|
45 class ServerIndex : public StatelessDatabaseOperations |
0 | 46 { |
47 private: | |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4587
diff
changeset
|
48 class TransactionContext; |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
49 class TransactionContextFactory; |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
50 class UnstableResourcePayload; |
278
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
272
diff
changeset
|
51 |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
52 bool done_; |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
53 boost::mutex monitoringMutex_; |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
54 boost::thread flushThread_; |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
55 boost::thread unstableResourcesMonitorThread_; |
0 | 56 |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
57 LeastRecentlyUsedIndex<int64_t, UnstableResourcePayload> unstableResources_; |
180
626777d01dc4
use of hashes to index dicom objects
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
179
diff
changeset
|
58 |
2825
8aa6aef11b70
New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2668
diff
changeset
|
59 uint64_t maximumStorageSize_; |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
60 unsigned int maximumPatients_; |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
61 |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
62 static void FlushThread(ServerIndex* that, |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
63 unsigned int threadSleep); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
64 |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
65 static void UnstableResourcesMonitorThread(ServerIndex* that, |
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
66 unsigned int threadSleep); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
67 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
68 void MarkAsUnstable(int64_t id, |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
69 Orthanc::ResourceType type, |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
70 const std::string& publicId); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
71 |
4554 | 72 bool IsUnstableResource(int64_t id); |
3090
31244604f617
starting optimization of SeriesIndex::GetSeriesStatus()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3086
diff
changeset
|
73 |
0 | 74 public: |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
75 ServerIndex(ServerContext& context, |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
76 IDatabaseWrapper& database, |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
77 unsigned int threadSleepGranularityMilliseconds); |
0 | 78 |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
79 ~ServerIndex(); |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
204
diff
changeset
|
80 |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
81 void Stop(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
82 |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
83 // "size == 0" means no limit on the storage size |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
84 void SetMaximumStorageSize(uint64_t size); |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
85 |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
86 // "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
|
87 void SetMaximumPatientCount(unsigned int count); |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
88 |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
89 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
|
90 const DicomMap& dicomSummary, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
91 const Attachments& attachments, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
92 const MetadataMap& metadata, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
93 const DicomInstanceOrigin& origin, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
94 bool overwrite, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
95 bool hasTransferSyntax, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
96 DicomTransferSyntax transferSyntax, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
97 bool hasPixelDataOffset, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
98 uint64_t pixelDataOffset); |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
99 |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
100 StoreStatus AddAttachment(const FileInfo& attachment, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
101 const std::string& publicId); |
0 | 102 }; |
103 } |