comparison OrthancServer/ServerContext.cpp @ 2671:06c0a6b8a871 jobs

new command-line argument: --no-jobs
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 11 Jun 2018 09:20:04 +0200
parents d26dd081df97
children 3efc44fac209
comparison
equal deleted inserted replaced
2670:c5646f766b3e 2671:06c0a6b8a871
106 } 106 }
107 } 107 }
108 } 108 }
109 109
110 110
111 void ServerContext::SetupJobsEngine(bool unitTesting) 111 void ServerContext::SetupJobsEngine(bool unitTesting,
112 bool loadJobsFromDatabase)
112 { 113 {
113 jobsEngine_.SetWorkersCount(Configuration::GetGlobalUnsignedIntegerParameter("ConcurrentJobs", 2)); 114 jobsEngine_.SetWorkersCount(Configuration::GetGlobalUnsignedIntegerParameter("ConcurrentJobs", 2));
114 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200); 115 jobsEngine_.SetThreadSleep(unitTesting ? 20 : 200);
115 116
116 std::string serialized; 117 if (loadJobsFromDatabase)
117 if (index_.LookupGlobalProperty(serialized, GlobalProperty_JobsRegistry)) 118 {
118 { 119 std::string serialized;
119 LOG(WARNING) << "Reloading the jobs from the last execution of Orthanc"; 120 if (index_.LookupGlobalProperty(serialized, GlobalProperty_JobsRegistry))
120 OrthancJobUnserializer unserializer(*this); 121 {
121 122 LOG(WARNING) << "Reloading the jobs from the last execution of Orthanc";
122 try 123 OrthancJobUnserializer unserializer(*this);
123 { 124
124 jobsEngine_.LoadRegistryFromString(unserializer, serialized); 125 try
125 } 126 {
126 catch (OrthancException& e) 127 jobsEngine_.LoadRegistryFromString(unserializer, serialized);
127 { 128 }
128 LOG(ERROR) << "Cannot unserialize the jobs engine: " << e.What(); 129 catch (OrthancException& e)
129 throw; 130 {
130 } 131 LOG(ERROR) << "Cannot unserialize the jobs engine: " << e.What();
131 } 132 throw;
132 else 133 }
133 { 134 }
134 LOG(INFO) << "The last execution of Orthanc has archived no job"; 135 else
135 //jobsEngine_.GetRegistry().SetMaxCompleted // TODO 136 {
136 } 137 LOG(INFO) << "The last execution of Orthanc has archived no job";
138 }
139 }
140 else
141 {
142 LOG(WARNING) << "Not reloading the jobs from the last execution of Orthanc";
143 }
144
145 //jobsEngine_.GetRegistry().SetMaxCompleted // TODO
137 146
138 jobsEngine_.Start(); 147 jobsEngine_.Start();
139 } 148 }
140 149
141 150
160 } 169 }
161 170
162 171
163 ServerContext::ServerContext(IDatabaseWrapper& database, 172 ServerContext::ServerContext(IDatabaseWrapper& database,
164 IStorageArea& area, 173 IStorageArea& area,
165 bool unitTesting) : 174 bool unitTesting,
175 bool loadJobsFromDatabase) :
166 index_(*this, database, (unitTesting ? 20 : 500)), 176 index_(*this, database, (unitTesting ? 20 : 500)),
167 area_(area), 177 area_(area),
168 compressionEnabled_(false), 178 compressionEnabled_(false),
169 storeMD5_(true), 179 storeMD5_(true),
170 provider_(*this), 180 provider_(*this),
177 queryRetrieveArchive_(Configuration::GetGlobalUnsignedIntegerParameter("QueryRetrieveSize", 10)), 187 queryRetrieveArchive_(Configuration::GetGlobalUnsignedIntegerParameter("QueryRetrieveSize", 10)),
178 defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC")) 188 defaultLocalAet_(Configuration::GetGlobalStringParameter("DicomAet", "ORTHANC"))
179 { 189 {
180 listeners_.push_back(ServerListener(lua_, "Lua")); 190 listeners_.push_back(ServerListener(lua_, "Lua"));
181 191
182 SetupJobsEngine(unitTesting); 192 SetupJobsEngine(unitTesting, loadJobsFromDatabase);
183 193
184 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100)); 194 changeThread_ = boost::thread(ChangeThread, this, (unitTesting ? 20 : 100));
185 } 195 }
186 196
187 197