Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerIndex.cpp @ 4831:7053502fbf97
added copyright UCLouvain
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Nov 2021 19:01:11 +0100 |
parents | 66109d24d26e |
children | 2e71a08eea15 43e613a7756b |
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:
4371
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
4831
7053502fbf97
added copyright UCLouvain
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4640
diff
changeset
|
6 * Copyright (C) 2021-2021 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
0 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
9 * modify it under the terms of the GNU General Public License as | |
10 * published by the Free Software Foundation, either version 3 of the | |
11 * License, or (at your option) any later version. | |
136 | 12 * |
13 * In addition, as a special exception, the copyright holders of this | |
14 * program give permission to link the code of its release with the | |
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
16 * that use the same license as the "OpenSSL" library), and distribute | |
17 * the linked executables. You must obey the GNU General Public License | |
18 * in all respects for all of the code used other than "OpenSSL". If you | |
19 * modify file(s) with this exception, you may extend this exception to | |
20 * your version of the file(s), but you are not obligated to do so. If | |
21 * you do not wish to do so, delete this exception statement from your | |
22 * version. If you delete this exception statement from all source files | |
23 * in the program, then also delete it here. | |
0 | 24 * |
25 * This program is distributed in the hope that it will be useful, but | |
26 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
28 * General Public License for more details. | |
29 * | |
30 * You should have received a copy of the GNU General Public License | |
31 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
32 **/ | |
33 | |
34 | |
831
84513f2ee1f3
pch for unit tests and server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
35 #include "PrecompiledHeadersServer.h" |
0 | 36 #include "ServerIndex.h" |
37 | |
6 | 38 #ifndef NOMINMAX |
2 | 39 #define NOMINMAX |
6 | 40 #endif |
41 | |
4045 | 42 #include "../../OrthancFramework/Sources/Logging.h" |
43 #include "../../OrthancFramework/Sources/Toolbox.h" | |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
44 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
45 #include "OrthancConfiguration.h" |
3094
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
46 #include "ServerContext.h" |
61da3c9b4121
cont reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3093
diff
changeset
|
47 #include "ServerIndexChange.h" |
1668
de1413733c97
reconstructing main dicom tags
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1555
diff
changeset
|
48 #include "ServerToolbox.h" |
0 | 49 |
50 | |
440
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
51 static const uint64_t MEGA_BYTES = 1024 * 1024; |
23e5b35e3c5c
statistics for patient/studies/series/instances
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
438
diff
changeset
|
52 |
62 | 53 namespace Orthanc |
0 | 54 { |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
55 class ServerIndex::TransactionContext : public StatelessDatabaseOperations::ITransactionContext |
0 | 56 { |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
57 private: |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
58 struct FileToRemove |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
59 { |
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
60 private: |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
61 std::string uuid_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
62 FileContentType type_; |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
63 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
64 public: |
4205 | 65 explicit FileToRemove(const FileInfo& info) : |
66 uuid_(info.GetUuid()), | |
67 type_(info.GetContentType()) | |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1189
diff
changeset
|
68 { |
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1189
diff
changeset
|
69 } |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
70 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
71 const std::string& GetUuid() const |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
72 { |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
73 return uuid_; |
278
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
74 } |
771f12042be9
more efficient determination of storage size for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
273
diff
changeset
|
75 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
76 FileContentType GetContentType() const |
264
5b8e8b74bc8b
remove files only after the sqlite transaction has succeeded
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
77 { |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
78 return type_; |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
79 } |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
80 }; |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
81 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
82 ServerContext& context_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
83 bool hasRemainingLevel_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
84 ResourceType remainingType_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
85 std::string remainingPublicId_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
86 std::list<FileToRemove> pendingFilesToRemove_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
87 std::list<ServerIndexChange> pendingChanges_; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
88 uint64_t sizeOfFilesToRemove_; |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
89 uint64_t sizeOfAddedAttachments_; |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
90 |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
91 void Reset() |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
92 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
93 sizeOfFilesToRemove_ = 0; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
94 hasRemainingLevel_ = false; |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4590
diff
changeset
|
95 remainingType_ = ResourceType_Instance; // dummy initialization |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
96 pendingFilesToRemove_.clear(); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
97 pendingChanges_.clear(); |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
98 sizeOfAddedAttachments_ = 0; |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
99 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
100 |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
101 void CommitFilesToRemove() |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
102 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
103 for (std::list<FileToRemove>::const_iterator |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
104 it = pendingFilesToRemove_.begin(); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
105 it != pendingFilesToRemove_.end(); ++it) |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1177
diff
changeset
|
106 { |
3702
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
107 try |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
108 { |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
109 context_.RemoveFile(it->GetUuid(), it->GetContentType()); |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
110 } |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
111 catch (OrthancException& e) |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
112 { |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
113 LOG(ERROR) << "Unable to remove an attachment from the storage area: " |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
114 << it->GetUuid() << " (type: " << EnumerationToString(it->GetContentType()) << ")"; |
643b5ee86f92
fix handling of errors of OrthancPluginStorageRemove()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3699
diff
changeset
|
115 } |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
116 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
117 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
118 |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
119 void CommitChanges() |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
120 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
121 for (std::list<ServerIndexChange>::const_iterator |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
122 it = pendingChanges_.begin(); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
123 it != pendingChanges_.end(); ++it) |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
124 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
125 context_.SignalChange(*it); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
126 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
127 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
128 |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
129 public: |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
130 explicit TransactionContext(ServerContext& context) : |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
131 context_(context) |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
132 { |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
133 Reset(); |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
134 assert(ResourceType_Patient < ResourceType_Study && |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
135 ResourceType_Study < ResourceType_Series && |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
136 ResourceType_Series < ResourceType_Instance); |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
137 } |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
138 |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
139 virtual void SignalRemainingAncestor(ResourceType parentType, |
4571
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
140 const std::string& publicId) ORTHANC_OVERRIDE |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
141 { |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4263
diff
changeset
|
142 LOG(TRACE) << "Remaining ancestor \"" << publicId << "\" (" << parentType << ")"; |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
143 |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
144 if (hasRemainingLevel_) |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
145 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
146 if (parentType < remainingType_) |
1189
6b9b02a16e99
NewChildInstance change type
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1177
diff
changeset
|
147 { |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
148 remainingType_ = parentType; |
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
149 remainingPublicId_ = publicId; |
1191
d49505e377e3
demo of OnChangeCallback in plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1189
diff
changeset
|
150 } |
1158 | 151 } |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
152 else |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
153 { |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
154 hasRemainingLevel_ = true; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
155 remainingType_ = parentType; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
156 remainingPublicId_ = publicId; |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
157 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
158 } |
201
bee20e978835
refactoring of delete
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
200
diff
changeset
|
159 |
4571
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
160 virtual void SignalAttachmentDeleted(const FileInfo& info) ORTHANC_OVERRIDE |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
161 { |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
162 assert(Toolbox::IsUuid(info.GetUuid())); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
163 pendingFilesToRemove_.push_back(FileToRemove(info)); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
164 sizeOfFilesToRemove_ += info.GetCompressedSize(); |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
165 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
166 |
4571
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
167 virtual void SignalResourceDeleted(ResourceType type, |
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
168 const std::string& publicId) ORTHANC_OVERRIDE |
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
169 { |
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
170 SignalChange(ServerIndexChange(ChangeType_Deleted, type, publicId)); |
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
171 } |
9224e107d613
simplifying IDatabaseListener::SignalChange() as IDatabaseListener::SignalResourceDeleted()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4570
diff
changeset
|
172 |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
173 virtual void SignalChange(const ServerIndexChange& change) ORTHANC_OVERRIDE |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
174 { |
4268
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4263
diff
changeset
|
175 LOG(TRACE) << "Change related to resource " << change.GetPublicId() << " of type " |
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4263
diff
changeset
|
176 << EnumerationToString(change.GetResourceType()) << ": " |
0ae2ca210077
new macro TLOG() to replace VLOG() for trace logs with a category
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4263
diff
changeset
|
177 << EnumerationToString(change.GetChangeType()); |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
178 |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
179 pendingChanges_.push_back(change); |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
180 } |
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
181 |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
182 virtual void SignalAttachmentsAdded(uint64_t compressedSize) ORTHANC_OVERRIDE |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
183 { |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
184 sizeOfAddedAttachments_ += compressedSize; |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
185 } |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
186 |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
187 virtual bool LookupRemainingLevel(std::string& remainingPublicId /* out */, |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
188 ResourceType& remainingLevel /* out */) ORTHANC_OVERRIDE |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
189 { |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
190 if (hasRemainingLevel_) |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
191 { |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
192 remainingPublicId = remainingPublicId_; |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
193 remainingLevel = remainingType_; |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
194 return true; |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
195 } |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
196 else |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
197 { |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
198 return false; |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
199 } |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
200 }; |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
201 |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
202 virtual void MarkAsUnstable(int64_t id, |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
203 Orthanc::ResourceType type, |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
204 const std::string& publicId) ORTHANC_OVERRIDE |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
205 { |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
206 context_.GetIndex().MarkAsUnstable(id, type, publicId); |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
207 } |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
208 |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
209 virtual bool IsUnstableResource(int64_t id) ORTHANC_OVERRIDE |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
210 { |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
211 return context_.GetIndex().IsUnstableResource(id); |
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
212 } |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
213 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
214 virtual void Commit() ORTHANC_OVERRIDE |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
215 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
216 // We can remove the files once the SQLite transaction has |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
217 // been successfully committed. Some files might have to be |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
218 // deleted because of recycling. |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
219 CommitFilesToRemove(); |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
220 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
221 // Send all the pending changes to the Orthanc plugins |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
222 CommitChanges(); |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
223 } |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
224 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
225 virtual int64_t GetCompressedSizeDelta() ORTHANC_OVERRIDE |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
226 { |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
227 return (static_cast<int64_t>(sizeOfAddedAttachments_) - |
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
228 static_cast<int64_t>(sizeOfFilesToRemove_)); |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
229 } |
1432
0ac74fa21db8
rename IServerIndexListener as IDatabaseListener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1368
diff
changeset
|
230 }; |
0 | 231 |
232 | |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
233 class ServerIndex::TransactionContextFactory : public ITransactionContextFactory |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
234 { |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
235 private: |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
236 ServerContext& context_; |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
237 |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
238 public: |
4591
ff8170d17d90
moving all accesses to databases from IDatabaseWrapper to ITransaction
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4590
diff
changeset
|
239 explicit TransactionContextFactory(ServerContext& context) : |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
240 context_(context) |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
241 { |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
242 } |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
243 |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
244 virtual ITransactionContext* Create() |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
245 { |
4594
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4591
diff
changeset
|
246 // There can be concurrent calls to this method, which is not an |
d494b4f1103e
removed the global database mutex from ServerIndex and StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4591
diff
changeset
|
247 // issue because we simply create an object |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
248 return new TransactionContext(context_); |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
249 } |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
250 }; |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
251 |
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
252 |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
253 class ServerIndex::UnstableResourcePayload |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
254 { |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
255 private: |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
256 ResourceType type_; |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
257 std::string publicId_; |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
258 boost::posix_time::ptime time_; |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
259 |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
260 public: |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
261 UnstableResourcePayload() : type_(ResourceType_Instance) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
262 { |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
263 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
264 |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
265 UnstableResourcePayload(Orthanc::ResourceType type, |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
266 const std::string& publicId) : |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
267 type_(type), |
4205 | 268 publicId_(publicId), |
269 time_(boost::posix_time::second_clock::local_time()) | |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
270 { |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
271 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
272 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
273 unsigned int GetAge() const |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
274 { |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
275 return (boost::posix_time::second_clock::local_time() - time_).total_seconds(); |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
276 } |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
277 |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
278 ResourceType GetResourceType() const |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
279 { |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
280 return type_; |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
281 } |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
282 |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
283 const std::string& GetPublicId() const |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
284 { |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
285 return publicId_; |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
286 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
287 }; |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
288 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
289 |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
290 void ServerIndex::FlushThread(ServerIndex* that, |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
291 unsigned int threadSleepGranularityMilliseconds) |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
292 { |
1102
ce6386b37afd
avoid unnecessary exceptions on Orthanc startup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1006
diff
changeset
|
293 // By default, wait for 10 seconds before flushing |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
294 static const unsigned int SLEEP_SECONDS = 10; |
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
295 |
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
296 if (threadSleepGranularityMilliseconds > 1000) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
297 { |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
298 throw OrthancException(ErrorCode_ParameterOutOfRange); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
299 } |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
300 |
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
301 LOG(INFO) << "Starting the database flushing thread (sleep = " << SLEEP_SECONDS << " seconds)"; |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
302 |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
303 unsigned int count = 0; |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
304 unsigned int countThreshold = (1000 * SLEEP_SECONDS) / threadSleepGranularityMilliseconds; |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
305 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
306 while (!that->done_) |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
307 { |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
308 boost::this_thread::sleep(boost::posix_time::milliseconds(threadSleepGranularityMilliseconds)); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
309 count++; |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
310 |
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
311 if (count >= countThreshold) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
312 { |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
313 Logging::Flush(); |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
314 that->FlushToDisk(); |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
315 |
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
316 count = 0; |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
317 } |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
318 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
319 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
320 LOG(INFO) << "Stopping the database flushing thread"; |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
321 } |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
322 |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
323 |
4554 | 324 bool ServerIndex::IsUnstableResource(int64_t id) |
325 { | |
4584
b25941dcdbbe
ITransactionContext to uncouple ServerIndex from database wrapper
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4583
diff
changeset
|
326 boost::mutex::scoped_lock lock(monitoringMutex_); |
4554 | 327 return unstableResources_.Contains(id); |
328 } | |
329 | |
1237 | 330 |
226
8a26a8e85edf
refactoring to read files
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
224
diff
changeset
|
331 ServerIndex::ServerIndex(ServerContext& context, |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
332 IDatabaseWrapper& db, |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
333 unsigned int threadSleepGranularityMilliseconds) : |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
334 StatelessDatabaseOperations(db), |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
335 done_(false), |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
336 maximumStorageSize_(0), |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
337 maximumPatients_(0) |
186
f68c039b0571
preparing refactoring of ServerIndex
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
180
diff
changeset
|
338 { |
4590
4a0bf1019335
simplification of ServerIndex::Listener as ServerIndex::TransactionContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4589
diff
changeset
|
339 SetTransactionContextFactory(new TransactionContextFactory(context)); |
4585
f0bdd99f3d81
created a ITransactionContextFactory around ServerIndex::Listener
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4584
diff
changeset
|
340 |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
341 // Initial recycling if the parameters have changed since the last |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
342 // execution of Orthanc |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
343 StandaloneRecycling(maximumStorageSize_, maximumPatients_); |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
344 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
345 if (HasFlushToDisk()) |
1306
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1305
diff
changeset
|
346 { |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
347 flushThread_ = boost::thread(FlushThread, this, threadSleepGranularityMilliseconds); |
1306
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1305
diff
changeset
|
348 } |
8cd5784a6d80
IDatabaseWrapper::HasFlushToDisk()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1305
diff
changeset
|
349 |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
350 unstableResourcesMonitorThread_ = boost::thread |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
351 (UnstableResourcesMonitorThread, this, threadSleepGranularityMilliseconds); |
206
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
352 } |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
353 |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
354 |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
355 ServerIndex::~ServerIndex() |
4453a010d0db
flush to disk thread
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
205
diff
changeset
|
356 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
357 if (!done_) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
358 { |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
359 LOG(ERROR) << "INTERNAL ERROR: ServerIndex::Stop() should be invoked manually to avoid mess in the destruction order!"; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
360 Stop(); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
361 } |
0 | 362 } |
363 | |
364 | |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
365 void ServerIndex::Stop() |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
366 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
367 if (!done_) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
368 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
369 done_ = true; |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
370 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
371 if (flushThread_.joinable()) |
1453
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
372 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
373 flushThread_.join(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
374 } |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
375 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
376 if (unstableResourcesMonitorThread_.joinable()) |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
377 { |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
378 unstableResourcesMonitorThread_.join(); |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
379 } |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
380 } |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
381 } |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
382 |
c0bdc47165ef
code to warn about possible threading problems
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1432
diff
changeset
|
383 |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
384 void ServerIndex::SetMaximumPatientCount(unsigned int count) |
268
4bc02e2254ec
preparing ServerIndex for recycling
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
264
diff
changeset
|
385 { |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
386 { |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
387 boost::mutex::scoped_lock lock(monitoringMutex_); |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
388 maximumPatients_ = count; |
3020
d207f6ac1f86
tracking disk size by the database engine to ensure consistency across transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3019
diff
changeset
|
389 |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
390 if (count == 0) |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
391 { |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
392 LOG(WARNING) << "No limit on the number of stored patients"; |
4575
e23bacd4fffc
clarifications in ServerIndex::Recycle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
393 } |
e23bacd4fffc
clarifications in ServerIndex::Recycle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
394 else |
e23bacd4fffc
clarifications in ServerIndex::Recycle()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4574
diff
changeset
|
395 { |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
396 LOG(WARNING) << "At most " << count << " patients will be stored"; |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
397 } |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
398 } |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
399 |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
400 StandaloneRecycling(maximumStorageSize_, maximumPatients_); |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
401 } |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
402 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
403 |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
404 void ServerIndex::SetMaximumStorageSize(uint64_t size) |
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
405 { |
270
e6a4c4329481
parameters for storage capacity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
406 { |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
407 boost::mutex::scoped_lock lock(monitoringMutex_); |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
408 maximumStorageSize_ = size; |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
409 |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
410 if (size == 0) |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
411 { |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
412 LOG(WARNING) << "No limit on the size of the storage area"; |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
413 } |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
414 else |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
415 { |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
416 LOG(WARNING) << "At most " << (size / MEGA_BYTES) << "MB will be used for the storage area"; |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
417 } |
270
e6a4c4329481
parameters for storage capacity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
418 } |
e6a4c4329481
parameters for storage capacity
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
269
diff
changeset
|
419 |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
420 StandaloneRecycling(maximumStorageSize_, maximumPatients_); |
269
f6fdf5abe751
recycling up and running
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
268
diff
changeset
|
421 } |
272
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
270
diff
changeset
|
422 |
337c506461d2
protection from rest api
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
270
diff
changeset
|
423 |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
424 void ServerIndex::UnstableResourcesMonitorThread(ServerIndex* that, |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
425 unsigned int threadSleepGranularityMilliseconds) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
426 { |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
427 int stableAge; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
428 |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
429 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
430 OrthancConfiguration::ReaderLock lock; |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
431 stableAge = lock.GetConfiguration().GetUnsignedIntegerParameter("StableAge", 60); |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
432 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2898
diff
changeset
|
433 |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
434 if (stableAge <= 0) |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
435 { |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
436 stableAge = 60; |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
437 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
438 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
439 LOG(INFO) << "Starting the monitor for stable resources (stable age = " << stableAge << ")"; |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
440 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
441 while (!that->done_) |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
442 { |
2665
389d050a2e66
fix deadlock, speed up unit tests
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2664
diff
changeset
|
443 // Check for stable resources each few seconds |
4580
49f6b9a2b9f5
remove the only use of GlobalProperty_FlushSleep
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4579
diff
changeset
|
444 boost::this_thread::sleep(boost::posix_time::milliseconds(threadSleepGranularityMilliseconds)); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
445 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
446 for (;;) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
447 { |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
448 UnstableResourcePayload stableResource; |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
449 int64_t stableId; |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
450 |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
451 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
452 boost::mutex::scoped_lock lock(that->monitoringMutex_); |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
453 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
454 if (!that->unstableResources_.IsEmpty() && |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
455 that->unstableResources_.GetOldestPayload().GetAge() > static_cast<unsigned int>(stableAge)) |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
456 { |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
457 // This DICOM resource has not received any new instance for |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
458 // some time. It can be considered as stable. |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
459 stableId = that->unstableResources_.RemoveOldest(stableResource); |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
460 //LOG(TRACE) << "Stable resource: " << EnumerationToString(stableResource.GetResourceType()) << " " << stableId; |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
461 } |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
462 else |
513 | 463 { |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
464 // No more stable DICOM resource, leave the internal loop |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
465 break; |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
466 } |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
467 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
468 |
4614
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
469 try |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
470 { |
4614
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
471 /** |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
472 * WARNING: Don't protect the calls to "LogChange()" using |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
473 * "monitoringMutex_", as this could lead to deadlocks in |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
474 * other threads (typically, if "Store()" is being running in |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
475 * another thread, which leads to calls to "MarkAsUnstable()", |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
476 * which leads to two lockings of "monitoringMutex_"). |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
477 **/ |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
478 switch (stableResource.GetResourceType()) |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
479 { |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
480 case ResourceType_Patient: |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
481 that->LogChange(stableId, ChangeType_StablePatient, stableResource.GetPublicId(), ResourceType_Patient); |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
482 break; |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
483 |
4614
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
484 case ResourceType_Study: |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
485 that->LogChange(stableId, ChangeType_StableStudy, stableResource.GetPublicId(), ResourceType_Study); |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
486 break; |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
487 |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
488 case ResourceType_Series: |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
489 that->LogChange(stableId, ChangeType_StableSeries, stableResource.GetPublicId(), ResourceType_Series); |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
490 break; |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
491 |
4614
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
492 default: |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
493 throw OrthancException(ErrorCode_InternalError); |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
494 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
495 } |
4614
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
496 catch (OrthancException& e) |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
497 { |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
498 LOG(ERROR) << "Cannot log a change about a stable resource into the database"; |
67d112ef680f
added missing try/catch
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4594
diff
changeset
|
499 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
500 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
501 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
502 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
503 LOG(INFO) << "Closing the monitor thread for stable resources"; |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
504 } |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
505 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
506 |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
507 void ServerIndex::MarkAsUnstable(int64_t id, |
1177
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
508 Orthanc::ResourceType type, |
5b2d8c280ac2
Plugins can monitor changes through callbacks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1162
diff
changeset
|
509 const std::string& publicId) |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
510 { |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
511 assert(type == Orthanc::ResourceType_Patient || |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
512 type == Orthanc::ResourceType_Study || |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
513 type == Orthanc::ResourceType_Series); |
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
514 |
4581
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
515 { |
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
516 boost::mutex::scoped_lock lock(monitoringMutex_); |
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
517 UnstableResourcePayload payload(type, publicId); |
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
518 unstableResources_.AddOrMakeMostRecent(id, payload); |
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
519 //LOG(INFO) << "Unstable resource: " << EnumerationToString(type) << " " << id; |
bb3c82b8f373
transient introduction of ServerIndex::databaseMutex_
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4580
diff
changeset
|
520 } |
511
3b735fdf320b
monitoring of stable patients/studies/series
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
440
diff
changeset
|
521 } |
521 | 522 |
523 | |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
524 StoreStatus ServerIndex::Store(std::map<MetadataType, std::string>& instanceMetadata, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
525 const DicomMap& dicomSummary, |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
526 const ServerIndex::Attachments& attachments, |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
527 const ServerIndex::MetadataMap& metadata, |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
528 const DicomInstanceOrigin& origin, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
529 bool overwrite, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
530 bool hasTransferSyntax, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
531 DicomTransferSyntax transferSyntax, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
532 bool hasPixelDataOffset, |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
533 uint64_t pixelDataOffset) |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
534 { |
4579 | 535 uint64_t maximumStorageSize; |
536 unsigned int maximumPatients; | |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
537 |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
538 { |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
539 boost::mutex::scoped_lock lock(monitoringMutex_); |
4579 | 540 maximumStorageSize = maximumStorageSize_; |
541 maximumPatients = maximumPatients_; | |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
542 } |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
543 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
544 return StatelessDatabaseOperations::Store( |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
545 instanceMetadata, dicomSummary, attachments, metadata, origin, overwrite, hasTransferSyntax, |
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
546 transferSyntax, hasPixelDataOffset, pixelDataOffset, maximumStorageSize, maximumPatients); |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
547 } |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
548 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
549 |
4627
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4614
diff
changeset
|
550 StoreStatus ServerIndex::AddAttachment(int64_t& newRevision, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4614
diff
changeset
|
551 const FileInfo& attachment, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4614
diff
changeset
|
552 const std::string& publicId, |
f7d5372b59b3
handling revisions of attachments
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4614
diff
changeset
|
553 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
|
554 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
|
555 const std::string& oldMD5) |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
556 { |
4579 | 557 uint64_t maximumStorageSize; |
558 unsigned int maximumPatients; | |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
559 |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
560 { |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
561 boost::mutex::scoped_lock lock(monitoringMutex_); |
4579 | 562 maximumStorageSize = maximumStorageSize_; |
563 maximumPatients = maximumPatients_; | |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
564 } |
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
565 |
4587
888868a5dc4e
ServerIndex now uses StatelessDatabaseOperations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4586
diff
changeset
|
566 return StatelessDatabaseOperations::AddAttachment( |
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
|
567 newRevision, attachment, publicId, maximumStorageSize, maximumPatients, |
66109d24d26e
"ETag" headers for metadata and attachments now allow strong comparison (MD5 is included)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4627
diff
changeset
|
568 hasOldRevision, oldRevision, oldMD5); |
4577
a114a5db2afe
end of refactoring read-write transactions
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4576
diff
changeset
|
569 } |
0 | 570 } |