Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/LuaJobManager.cpp @ 5663:3765085693e5 large-queries
merge default -> large-queries
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Thu, 04 Jul 2024 07:40:58 +0200 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
2603 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 * Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
6 * Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2603 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
10 * modify it under the terms of the GNU General Public License as | |
11 * published by the Free Software Foundation, either version 3 of the | |
12 * License, or (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, but | |
15 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 * General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
21 **/ | |
22 | |
23 | |
24 #include "../PrecompiledHeadersServer.h" | |
25 #include "LuaJobManager.h" | |
26 | |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2730
diff
changeset
|
27 #include "../OrthancConfiguration.h" |
4045 | 28 #include "../../../OrthancFramework/Sources/Logging.h" |
2620
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
29 |
4045 | 30 #include "../../../OrthancFramework/Sources/JobsEngine/Operations/LogJobOperation.h" |
2641 | 31 #include "Operations/DeleteResourceOperation.h" |
32 #include "Operations/ModifyInstanceOperation.h" | |
33 #include "Operations/StorePeerOperation.h" | |
34 #include "Operations/StoreScuOperation.h" | |
35 #include "Operations/SystemCallOperation.h" | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
36 |
4045 | 37 #include "../../../OrthancFramework/Sources/JobsEngine/Operations/NullOperationValue.h" |
38 #include "../../../OrthancFramework/Sources/JobsEngine/Operations/StringOperationValue.h" | |
2641 | 39 #include "Operations/DicomInstanceOperationValue.h" |
2603 | 40 |
41 namespace Orthanc | |
42 { | |
43 void LuaJobManager::SignalDone(const SequenceOfOperationsJob& job) | |
44 { | |
45 boost::mutex::scoped_lock lock(mutex_); | |
46 | |
47 if (&job == currentJob_) | |
48 { | |
49 currentId_.clear(); | |
50 currentJob_ = NULL; | |
51 } | |
52 } | |
53 | |
54 | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
55 LuaJobManager::LuaJobManager() : |
2603 | 56 currentJob_(NULL), |
57 maxOperations_(1000), | |
2609
f7a84b551ee4
switch Lua to new jobs engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
58 priority_(0), |
f7a84b551ee4
switch Lua to new jobs engine
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2608
diff
changeset
|
59 trailingTimeout_(5000) |
2603 | 60 { |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
61 unsigned int dicomTimeout; |
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
62 |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2730
diff
changeset
|
63 { |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2730
diff
changeset
|
64 OrthancConfiguration::ReaderLock lock; |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
65 dicomTimeout = lock.GetConfiguration().GetUnsignedIntegerParameter("DicomAssociationCloseDelay", 5); |
2940
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2730
diff
changeset
|
66 } |
4767d36679ed
refactoring access to Orthanc configuration
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2730
diff
changeset
|
67 |
3851
6498739a3c3c
refactoring: TimeoutDicomConnectionManager is now only used by Lua
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
68 connectionManager_.SetInactivityTimeout(dicomTimeout * 1000); // Milliseconds expected |
4295 | 69 CLOG(INFO, LUA) << "Lua: DICOM associations will be closed after " |
70 << dicomTimeout << " seconds of inactivity"; | |
2603 | 71 } |
72 | |
73 | |
74 void LuaJobManager::SetMaxOperationsPerJob(size_t count) | |
75 { | |
76 boost::mutex::scoped_lock lock(mutex_); | |
77 maxOperations_ = count; | |
78 } | |
79 | |
80 | |
81 void LuaJobManager::SetPriority(int priority) | |
82 { | |
83 boost::mutex::scoped_lock lock(mutex_); | |
84 priority_ = priority; | |
85 } | |
86 | |
87 | |
88 void LuaJobManager::SetTrailingOperationTimeout(unsigned int timeout) | |
89 { | |
90 boost::mutex::scoped_lock lock(mutex_); | |
91 trailingTimeout_ = timeout; | |
92 } | |
93 | |
94 | |
2620
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
95 void LuaJobManager::AwakeTrailingSleep() |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
96 { |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
97 boost::mutex::scoped_lock lock(mutex_); |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
98 |
4295 | 99 CLOG(INFO, LUA) << "Awaking trailing sleep"; |
2620
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
100 |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
101 if (currentJob_ != NULL) |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
102 { |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
103 currentJob_->AwakeTrailingSleep(); |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
104 } |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
105 } |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
106 |
1232922c8793
speeding up shutdown if Lua script is in trailing phase
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2616
diff
changeset
|
107 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
108 LuaJobManager::Lock::Lock(LuaJobManager& that, |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
109 JobsEngine& engine) : |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
110 that_(that), |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
111 lock_(that.mutex_), |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
112 engine_(engine) |
2603 | 113 { |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
114 if (that_.currentJob_ == NULL) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
115 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
116 isNewJob_ = true; |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
117 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
118 else |
2603 | 119 { |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
120 jobLock_.reset(new SequenceOfOperationsJob::Lock(*that_.currentJob_)); |
2603 | 121 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
122 if (jobLock_->IsDone() || |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
123 jobLock_->GetOperationsCount() >= that_.maxOperations_) |
2603 | 124 { |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
125 jobLock_.reset(NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
126 isNewJob_ = true; |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
127 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
128 else |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
129 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
130 isNewJob_ = false; |
2603 | 131 } |
132 } | |
133 | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
134 if (isNewJob_) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
135 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
136 // Need to create a new job, as the previous one is either |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
137 // finished, or is getting too long |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
138 that_.currentJob_ = new SequenceOfOperationsJob; |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2940
diff
changeset
|
139 that_.currentJob_->Register(that_); |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
140 that_.currentJob_->SetDescription("Lua"); |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
141 |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
142 { |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
143 jobLock_.reset(new SequenceOfOperationsJob::Lock(*that_.currentJob_)); |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
144 jobLock_->SetTrailingOperationTimeout(that_.trailingTimeout_); |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2609
diff
changeset
|
145 } |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
146 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
147 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
148 assert(jobLock_.get() != NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
149 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
150 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
151 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
152 LuaJobManager::Lock::~Lock() |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
153 { |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
154 bool isEmpty; |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
155 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
156 assert(jobLock_.get() != NULL); |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
157 isEmpty = (isNewJob_ && |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
158 jobLock_->GetOperationsCount() == 0); |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
159 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
160 jobLock_.reset(NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
161 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
162 if (isNewJob_) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
163 { |
2624
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
164 if (isEmpty) |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
165 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
166 // No operation was added, discard the newly created job |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
167 isNewJob_ = false; |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
168 delete that_.currentJob_; |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
169 that_.currentJob_ = NULL; |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
170 } |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
171 else |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
172 { |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
173 engine_.GetRegistry().Submit(that_.currentId_, that_.currentJob_, that_.priority_); |
714dcddeb65f
asynchronous c-movoe
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2620
diff
changeset
|
174 } |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
175 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
176 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
177 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
178 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
179 size_t LuaJobManager::Lock::AddDeleteResourceOperation(ServerContext& context) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
180 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
181 assert(jobLock_.get() != NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
182 return jobLock_->AddOperation(new DeleteResourceOperation(context)); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
183 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
184 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
185 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
186 size_t LuaJobManager::Lock::AddLogOperation() |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
187 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
188 assert(jobLock_.get() != NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
189 return jobLock_->AddOperation(new LogJobOperation); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
190 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
191 |
2603 | 192 |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
193 size_t LuaJobManager::Lock::AddStoreScuOperation(ServerContext& context, |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
194 const std::string& localAet, |
2605
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
195 const RemoteModalityParameters& modality) |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
196 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
197 assert(jobLock_.get() != NULL); |
3894
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
198 return jobLock_->AddOperation(new StoreScuOperation( |
8f7ad4989fec
transcoding to uncompressed transfer syntaxes over DICOM protocol is implemented
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3851
diff
changeset
|
199 context, that_.connectionManager_, localAet, modality)); |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
200 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
201 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
202 |
2605
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
203 size_t LuaJobManager::Lock::AddStorePeerOperation(const WebServiceParameters& peer) |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
204 { |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
205 assert(jobLock_.get() != NULL); |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
206 return jobLock_->AddOperation(new StorePeerOperation(peer)); |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
207 } |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
208 |
1e11b0229e04
StorePeerOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2604
diff
changeset
|
209 |
2606
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
210 size_t LuaJobManager::Lock::AddSystemCallOperation(const std::string& command) |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
211 { |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
212 assert(jobLock_.get() != NULL); |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
213 return jobLock_->AddOperation(new SystemCallOperation(command)); |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
214 } |
2607
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
215 |
2606
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
216 |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
217 size_t LuaJobManager::Lock::AddSystemCallOperation |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
218 (const std::string& command, |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
219 const std::vector<std::string>& preArguments, |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
220 const std::vector<std::string>& postArguments) |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
221 { |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
222 assert(jobLock_.get() != NULL); |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
223 return jobLock_->AddOperation |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
224 (new SystemCallOperation(command, preArguments, postArguments)); |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
225 } |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
226 |
f2b9d3256060
SystemCallOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2605
diff
changeset
|
227 |
2607
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
228 size_t LuaJobManager::Lock::AddModifyInstanceOperation(ServerContext& context, |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
229 DicomModification* modification) |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
230 { |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
231 assert(jobLock_.get() != NULL); |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
232 return jobLock_->AddOperation |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
233 (new ModifyInstanceOperation(context, RequestOrigin_Lua, modification)); |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
234 } |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
235 |
44e268605478
ModifyInstanceOperation
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2606
diff
changeset
|
236 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
237 void LuaJobManager::Lock::AddNullInput(size_t operation) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
238 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
239 assert(jobLock_.get() != NULL); |
2730 | 240 NullOperationValue null; |
241 jobLock_->AddInput(operation, null); | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
242 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
243 |
2603 | 244 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
245 void LuaJobManager::Lock::AddStringInput(size_t operation, |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
246 const std::string& content) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
247 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
248 assert(jobLock_.get() != NULL); |
2730 | 249 StringOperationValue value(content); |
250 jobLock_->AddInput(operation, value); | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
251 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
252 |
2603 | 253 |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
254 void LuaJobManager::Lock::AddDicomInstanceInput(size_t operation, |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
255 ServerContext& context, |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
256 const std::string& instanceId) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
257 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
258 assert(jobLock_.get() != NULL); |
2730 | 259 DicomInstanceOperationValue value(context, instanceId); |
260 jobLock_->AddInput(operation, value); | |
2604
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
261 } |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
262 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
263 |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
264 void LuaJobManager::Lock::Connect(size_t operation1, |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
265 size_t operation2) |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
266 { |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
267 assert(jobLock_.get() != NULL); |
76ef12fa136c
fix race conditions if creating Lua jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2603
diff
changeset
|
268 jobLock_->Connect(operation1, operation2); |
2603 | 269 } |
270 } |