Mercurial > hg > orthanc
annotate OrthancFramework/Sources/JobsEngine/JobsRegistry.h @ 5853:4d932683049d get-scu tip
very first implementation of C-Get SCU
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Tue, 29 Oct 2024 17:25:49 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
2569 | 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:
5364
diff
changeset
|
7 * Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
2569 | 8 * |
9 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
12 * the License, or (at your option) any later version. |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
13 * |
2569 | 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 | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
17 * Lesser General Public License for more details. |
2569 | 18 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
21 * <http://www.gnu.org/licenses/>. |
2569 | 22 **/ |
23 | |
24 | |
25 #pragma once | |
26 | |
27 #if !defined(ORTHANC_SANDBOXED) | |
28 # error The macro ORTHANC_SANDBOXED must be defined | |
29 #endif | |
30 | |
31 #if ORTHANC_SANDBOXED == 1 | |
32 # error The job engine cannot be used in sandboxed environments | |
33 #endif | |
34 | |
35 #include "JobInfo.h" | |
2648
e1893d31652a
serialization of JobHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2581
diff
changeset
|
36 #include "IJobUnserializer.h" |
2569 | 37 |
38 #include <list> | |
39 #include <set> | |
40 #include <queue> | |
41 #include <boost/thread/mutex.hpp> | |
42 #include <boost/thread/condition_variable.hpp> | |
43 | |
44 namespace Orthanc | |
45 { | |
46 // This class handles the state machine of the jobs engine | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
47 class ORTHANC_PUBLIC JobsRegistry : public boost::noncopyable |
2569 | 48 { |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
49 public: |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
50 class ORTHANC_PUBLIC IObserver : public boost::noncopyable |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
51 { |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
52 public: |
4303
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
53 virtual ~IObserver() |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
54 { |
44b53a2c0a13
improving detection of ABI compatibility
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4300
diff
changeset
|
55 } |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
56 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
57 virtual void SignalJobSubmitted(const std::string& jobId) = 0; |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
58 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
59 virtual void SignalJobSuccess(const std::string& jobId) = 0; |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
60 |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
61 virtual void SignalJobFailure(const std::string& jobId) = 0; |
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
62 }; |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
63 |
2569 | 64 private: |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
65 enum CompletedReason |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
66 { |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
67 CompletedReason_Success, |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
68 CompletedReason_Failure, |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
69 CompletedReason_Canceled |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
70 }; |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
71 |
2569 | 72 class JobHandler; |
73 | |
74 struct PriorityComparator | |
75 { | |
4203
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
76 bool operator() (JobHandler* const& a, |
4d42408da117
improving const-correctness in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4202
diff
changeset
|
77 JobHandler* const& b) const; |
2569 | 78 }; |
79 | |
80 typedef std::map<std::string, JobHandler*> JobsIndex; | |
81 typedef std::list<JobHandler*> CompletedJobs; | |
82 typedef std::set<JobHandler*> RetryJobs; | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
83 typedef std::priority_queue<JobHandler*, |
2569 | 84 std::vector<JobHandler*>, // Could be a "std::deque" |
85 PriorityComparator> PendingJobs; | |
86 | |
87 boost::mutex mutex_; | |
88 JobsIndex jobsIndex_; | |
89 PendingJobs pendingJobs_; | |
90 CompletedJobs completedJobs_; | |
91 RetryJobs retryJobs_; | |
92 | |
93 boost::condition_variable pendingJobAvailable_; | |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
94 boost::condition_variable someJobComplete_; |
2569 | 95 size_t maxCompletedJobs_; |
96 | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
97 IObserver* observer_; |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
98 |
2569 | 99 |
100 #ifndef NDEBUG | |
101 bool IsPendingJob(const JobHandler& job) const; | |
102 | |
103 bool IsCompletedJob(JobHandler& job) const; | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
104 |
2569 | 105 bool IsRetryJob(JobHandler& job) const; |
106 #endif | |
107 | |
108 void CheckInvariants() const; | |
109 | |
110 void ForgetOldCompletedJobs(); | |
111 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
112 void SetCompletedJob(JobHandler& job, |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
113 bool success); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
114 |
2569 | 115 void MarkRunningAsCompleted(JobHandler& job, |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
116 CompletedReason reason); |
2569 | 117 |
118 void MarkRunningAsRetry(JobHandler& job, | |
119 unsigned int timeout); | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
120 |
2569 | 121 void MarkRunningAsPaused(JobHandler& job); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
122 |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
123 bool GetStateInternal(JobState& state, |
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
124 const std::string& id); |
2569 | 125 |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
126 void RemovePendingJob(const std::string& id); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
127 |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
128 void RemoveRetryJob(JobHandler* handler); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
129 |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
130 void SubmitInternal(std::string& id, |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
131 JobHandler* handler); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
132 |
2569 | 133 public: |
4300 | 134 explicit JobsRegistry(size_t maxCompletedJobs); |
2569 | 135 |
2667
5fa2f2ce74f0
serialization of JobsRegistry
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2648
diff
changeset
|
136 JobsRegistry(IJobUnserializer& unserializer, |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
137 const Json::Value& s, |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
138 size_t maxCompletedJobs); |
2569 | 139 |
140 ~JobsRegistry(); | |
141 | |
142 void SetMaxCompletedJobs(size_t i); | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
143 |
2950
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
144 size_t GetMaxCompletedJobs(); |
dc18d5804746
support of JobsHistorySize set to zero
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2867
diff
changeset
|
145 |
2569 | 146 void ListJobs(std::set<std::string>& target); |
147 | |
148 bool GetJobInfo(JobInfo& target, | |
149 const std::string& id); | |
2648
e1893d31652a
serialization of JobHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2581
diff
changeset
|
150 |
5364
b5f2122a1334
Added a route to delete completed jobs from history: DELETE /jobs/{id}
Alain Mazy <am@osimis.io>
parents:
5310
diff
changeset
|
151 bool DeleteJobInfo(const std::string& id); |
b5f2122a1334
Added a route to delete completed jobs from history: DELETE /jobs/{id}
Alain Mazy <am@osimis.io>
parents:
5310
diff
changeset
|
152 |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2950
diff
changeset
|
153 bool GetJobOutput(std::string& output, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2950
diff
changeset
|
154 MimeType& mime, |
4805
0a38000b086d
Archive jobs response now contains a header Content-Disposition:filename='archive.zip'
Alain Mazy <am@osimis.io>
parents:
4437
diff
changeset
|
155 std::string& filename, |
2976
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2950
diff
changeset
|
156 const std::string& job, |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2950
diff
changeset
|
157 const std::string& key); |
cb5d75143da0
Asynchronous generation of ZIP archives and DICOM medias
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2950
diff
changeset
|
158 |
5310
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
159 bool DeleteJobOutput(const std::string& job, |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
160 const std::string& key); |
b5c502bcaf99
added a route to DELETE /jobs/../archive
Alain Mazy <am@osimis.io>
parents:
5185
diff
changeset
|
161 |
2648
e1893d31652a
serialization of JobHandler
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2581
diff
changeset
|
162 void Serialize(Json::Value& target); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
163 |
2569 | 164 void Submit(std::string& id, |
165 IJob* job, // Takes ownership | |
166 int priority); | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
167 |
2569 | 168 void Submit(IJob* job, // Takes ownership |
169 int priority); | |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
170 |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
171 void SubmitAndWait(Json::Value& successContent, |
2867 | 172 IJob* job, // Takes ownership |
2570
2e879c796ec7
JobsRegistry::SubmitAndWait(), StoreScuJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2569
diff
changeset
|
173 int priority); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
174 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2570
diff
changeset
|
175 bool SetPriority(const std::string& id, |
2569 | 176 int priority); |
177 | |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2570
diff
changeset
|
178 bool Pause(const std::string& id); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
179 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2570
diff
changeset
|
180 bool Resume(const std::string& id); |
2569 | 181 |
2573
3372c5255333
StoreScuJob, Orthanc Explorer for jobs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2570
diff
changeset
|
182 bool Resubmit(const std::string& id); |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
183 |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
184 bool Cancel(const std::string& id); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
185 |
2569 | 186 void ScheduleRetries(); |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
187 |
2569 | 188 bool GetState(JobState& state, |
189 const std::string& id); | |
190 | |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
191 void SetObserver(IObserver& observer); |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
192 |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
193 void ResetObserver(); |
2673
8e0bc055d18c
JobsRegistry::IObserver
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2669
diff
changeset
|
194 |
3177
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
195 void GetStatistics(unsigned int& pending, |
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
196 unsigned int& running, |
3179
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
197 unsigned int& success, |
fca730c267d7
New primitives to set and refresh metrics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3177
diff
changeset
|
198 unsigned int& errors); |
3177
053e72ff9fc5
new metrics: orthanc_jobs_[pending|running|completed]
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
199 |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
200 class ORTHANC_PUBLIC RunningJob : public boost::noncopyable |
2569 | 201 { |
202 private: | |
203 JobsRegistry& registry_; | |
204 JobHandler* handler_; // Can only be accessed if the | |
205 // registry mutex is locked! | |
206 IJob* job_; // Will by design be in mutual exclusion, | |
207 // because only one RunningJob can be | |
208 // executed at a time on a JobHandler | |
209 | |
210 std::string id_; | |
211 int priority_; | |
212 JobState targetState_; | |
213 unsigned int targetRetryTimeout_; | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
214 bool canceled_; |
4024
1d2b31fc782f
new 'changes': JobSubmitted, JobSuccess, JobFailure
Alain Mazy <alain@mazy.be>
parents:
4022
diff
changeset
|
215 |
2569 | 216 public: |
217 RunningJob(JobsRegistry& registry, | |
218 unsigned int timeout); | |
219 | |
220 ~RunningJob(); | |
221 | |
222 bool IsValid() const; | |
223 | |
224 const std::string& GetId() const; | |
225 | |
226 int GetPriority() const; | |
227 | |
228 IJob& GetJob(); | |
229 | |
230 bool IsPauseScheduled(); | |
231 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
232 bool IsCancelScheduled(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
233 |
2569 | 234 void MarkSuccess(); |
235 | |
236 void MarkFailure(); | |
237 | |
238 void MarkPause(); | |
239 | |
2581
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
240 void MarkCanceled(); |
8da2cffc2378
JobsRegistry::Cancel()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2573
diff
changeset
|
241 |
2569 | 242 void MarkRetry(unsigned int timeout); |
243 | |
3240
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
244 void UpdateStatus(ErrorCode code, |
e44e0127e553
Fix issue #134 (/patient/modify gives 500, should really be 400)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3179
diff
changeset
|
245 const std::string& details); |
2569 | 246 }; |
247 }; | |
248 } |