comparison OrthancServer/ServerJobs/LuaJobManager.cpp @ 2620:1232922c8793 jobs

speeding up shutdown if Lua script is in trailing phase
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 22 May 2018 14:08:57 +0200
parents 2f3007bf0708
children 714dcddeb65f
comparison
equal deleted inserted replaced
2619:4ecb79c6e81c 2620:1232922c8793
32 32
33 33
34 #include "../PrecompiledHeadersServer.h" 34 #include "../PrecompiledHeadersServer.h"
35 #include "LuaJobManager.h" 35 #include "LuaJobManager.h"
36 36
37 #include "../OrthancInitialization.h"
38 #include "../../Core/Logging.h"
39
37 #include "../../Core/JobsEngine/Operations/LogJobOperation.h" 40 #include "../../Core/JobsEngine/Operations/LogJobOperation.h"
38 #include "DeleteResourceOperation.h" 41 #include "DeleteResourceOperation.h"
39 #include "ModifyInstanceOperation.h" 42 #include "ModifyInstanceOperation.h"
40 #include "StorePeerOperation.h" 43 #include "StorePeerOperation.h"
41 #include "StoreScuOperation.h" 44 #include "StoreScuOperation.h"
63 currentJob_(NULL), 66 currentJob_(NULL),
64 maxOperations_(1000), 67 maxOperations_(1000),
65 priority_(0), 68 priority_(0),
66 trailingTimeout_(5000) 69 trailingTimeout_(5000)
67 { 70 {
71 dicomTimeout_ = Configuration::GetGlobalUnsignedIntegerParameter("DicomAssociationCloseDelay", 5);
72 LOG(INFO) << "Lua: DICOM associations will be closed after "
73 << dicomTimeout_ << " seconds of inactivity";
68 } 74 }
69 75
70 76
71 void LuaJobManager::SetMaxOperationsPerJob(size_t count) 77 void LuaJobManager::SetMaxOperationsPerJob(size_t count)
72 { 78 {
84 90
85 void LuaJobManager::SetTrailingOperationTimeout(unsigned int timeout) 91 void LuaJobManager::SetTrailingOperationTimeout(unsigned int timeout)
86 { 92 {
87 boost::mutex::scoped_lock lock(mutex_); 93 boost::mutex::scoped_lock lock(mutex_);
88 trailingTimeout_ = timeout; 94 trailingTimeout_ = timeout;
95 }
96
97
98 void LuaJobManager::AwakeTrailingSleep()
99 {
100 boost::mutex::scoped_lock lock(mutex_);
101
102 LOG(INFO) << "Awaking trailing sleep";
103
104 if (currentJob_ != NULL)
105 {
106 currentJob_->AwakeTrailingSleep();
107 }
89 } 108 }
90 109
91 110
92 LuaJobManager::Lock::Lock(LuaJobManager& that, 111 LuaJobManager::Lock::Lock(LuaJobManager& that,
93 JobsEngine& engine) : 112 JobsEngine& engine) :
123 that_.currentJob_->SetDescription("Lua"); 142 that_.currentJob_->SetDescription("Lua");
124 143
125 { 144 {
126 jobLock_.reset(new SequenceOfOperationsJob::Lock(*that_.currentJob_)); 145 jobLock_.reset(new SequenceOfOperationsJob::Lock(*that_.currentJob_));
127 jobLock_->SetTrailingOperationTimeout(that_.trailingTimeout_); 146 jobLock_->SetTrailingOperationTimeout(that_.trailingTimeout_);
147 jobLock_->SetDicomAssociationTimeout(that_.dicomTimeout_ * 1000); // Milliseconds expected
128 } 148 }
129 } 149 }
130 150
131 assert(jobLock_.get() != NULL); 151 assert(jobLock_.get() != NULL);
132 } 152 }