comparison OrthancServer/Sources/ServerIndex.cpp @ 5783:56352ae88120 find-refactoring

wip: new ReadOnly configuration
author Alain Mazy <am@orthanc.team>
date Mon, 16 Sep 2024 18:31:37 +0200
parents 71c7d260510d
children b4e7a85cde80
comparison
equal deleted inserted replaced
5782:f1ccb67fce31 5783:56352ae88120
345 345
346 346
347 ServerIndex::ServerIndex(ServerContext& context, 347 ServerIndex::ServerIndex(ServerContext& context,
348 IDatabaseWrapper& db, 348 IDatabaseWrapper& db,
349 unsigned int threadSleepGranularityMilliseconds) : 349 unsigned int threadSleepGranularityMilliseconds) :
350 StatelessDatabaseOperations(db), 350 StatelessDatabaseOperations(db, context.IsReadOnly()),
351 done_(false), 351 done_(false),
352 maximumStorageMode_(MaxStorageMode_Recycle), 352 maximumStorageMode_(MaxStorageMode_Recycle),
353 maximumStorageSize_(0), 353 maximumStorageSize_(0),
354 maximumPatients_(0) 354 maximumPatients_(0)
355 { 355 {
356 SetTransactionContextFactory(new TransactionContextFactory(context)); 356 SetTransactionContextFactory(new TransactionContextFactory(context));
357 357
358 // Initial recycling if the parameters have changed since the last 358 // Initial recycling if the parameters have changed since the last
359 // execution of Orthanc 359 // execution of Orthanc
360 StandaloneRecycling(maximumStorageMode_, maximumStorageSize_, maximumPatients_); 360 if (!context.IsReadOnly())
361 {
362 StandaloneRecycling(maximumStorageMode_, maximumStorageSize_, maximumPatients_);
363 }
361 364
362 // For some DB engines (like SQLite), make sure we flush the DB to disk at regular interval 365 // For some DB engines (like SQLite), make sure we flush the DB to disk at regular interval
363 if (GetDatabaseCapabilities().HasFlushToDisk()) 366 if (GetDatabaseCapabilities().HasFlushToDisk())
364 { 367 {
365 flushThread_ = boost::thread(FlushThread, this, threadSleepGranularityMilliseconds); 368 if (context.IsReadOnly())
369 {
370 LOG(WARNING) << "READ-ONLY SYSTEM: not starting the flush disk thread";
371 }
372 else
373 {
374 flushThread_ = boost::thread(FlushThread, this, threadSleepGranularityMilliseconds);
375 }
366 } 376 }
367 377
368 // For some DB plugins that implements the UpdateAndGetStatistics function, updating 378 // For some DB plugins that implements the UpdateAndGetStatistics function, updating
369 // the statistics can take quite some time if you have not done it for a long time 379 // the statistics can take quite some time if you have not done it for a long time
370 // -> make sure they are updated at regular interval 380 // -> make sure they are updated at regular interval
371 if (GetDatabaseCapabilities().HasUpdateAndGetStatistics()) 381 if (GetDatabaseCapabilities().HasUpdateAndGetStatistics())
372 { 382 {
373 updateStatisticsThread_ = boost::thread(UpdateStatisticsThread, this, threadSleepGranularityMilliseconds); 383 if (context.IsReadOnly())
374 } 384 {
375 385 LOG(WARNING) << "READ-ONLY SYSTEM: not starting the UpdateStatisticsThread";
376 unstableResourcesMonitorThread_ = boost::thread 386 }
377 (UnstableResourcesMonitorThread, this, threadSleepGranularityMilliseconds); 387 else
388 {
389 updateStatisticsThread_ = boost::thread(UpdateStatisticsThread, this, threadSleepGranularityMilliseconds);
390 }
391 }
392
393 if (context.IsReadOnly())
394 {
395 LOG(WARNING) << "READ-ONLY SYSTEM: not starting the unstable resources monitor thread";
396 }
397 else
398 {
399 unstableResourcesMonitorThread_ = boost::thread
400 (UnstableResourcesMonitorThread, this, threadSleepGranularityMilliseconds);
401 }
378 } 402 }
379 403
380 404
381 ServerIndex::~ServerIndex() 405 ServerIndex::~ServerIndex()
382 { 406 {