changeset 4793:fc2ba1ce6538

new configuration 'DicomThreadsCount'
author Alain Mazy <am@osimis.io>
date Thu, 30 Sep 2021 15:03:35 +0200
parents 9754d5f2f38a
children 034346bca698
files NEWS OrthancFramework/Sources/DicomNetworking/DicomServer.cpp OrthancFramework/Sources/DicomNetworking/DicomServer.h OrthancServer/Resources/Configuration.json OrthancServer/Sources/main.cpp
diffstat 5 files changed, 31 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Tue Sep 14 14:51:12 2021 +0200
+++ b/NEWS	Thu Sep 30 15:03:35 2021 +0200
@@ -3,6 +3,9 @@
 
 * Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
 
+* New configuration options:
+  - "DicomThreadsCount" to set the number of threads in the embedded DICOM server
+
 
 Version 1.9.7 (2021-08-31)
 ==========================
--- a/OrthancFramework/Sources/DicomNetworking/DicomServer.cpp	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomServer.cpp	Thu Sep 30 15:03:35 2021 +0200
@@ -424,7 +424,10 @@
 #endif
 
     continue_ = true;
-    pimpl_->workers_.reset(new RunnableWorkersPool(4));   // Use 4 workers - TODO as a parameter?
+
+    CLOG(INFO, DICOM) << "The embedded DICOM server will use " << threadsCount_ << " threads";
+
+    pimpl_->workers_.reset(new RunnableWorkersPool(threadsCount_));
     pimpl_->thread_ = boost::thread(ServerThread, this, maximumPduLength_, useDicomTls_);
   }
 
@@ -588,4 +591,16 @@
   {
     return remoteCertificateRequired_;
   }
+
+  void DicomServer::SetThreadsCount(unsigned int threads)
+  {
+    if (threads == 0)
+    {
+      throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+    
+    Stop();
+    threadsCount_ = threads;
+  }
+
 }
--- a/OrthancFramework/Sources/DicomNetworking/DicomServer.h	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancFramework/Sources/DicomNetworking/DicomServer.h	Thu Sep 30 15:03:35 2021 +0200
@@ -72,6 +72,7 @@
     uint16_t port_;
     bool continue_;
     uint32_t associationTimeout_;
+    unsigned int threadsCount_;
     IRemoteModalities* modalities_;
     IFindRequestHandlerFactory* findRequestHandlerFactory_;
     IMoveRequestHandlerFactory* moveRequestHandlerFactory_;
@@ -89,6 +90,7 @@
     unsigned int maximumPduLength_;
     bool         remoteCertificateRequired_;  // New in 1.9.3
 
+
     static void ServerThread(DicomServer* server,
                              unsigned int maximumPduLength,
                              bool useDicomTls);
@@ -163,5 +165,8 @@
 
     void SetRemoteCertificateRequired(bool required);
     bool IsRemoteCertificateRequired() const;
+
+    void SetThreadsCount(unsigned int threadsCount);
+
   };
 }
--- a/OrthancServer/Resources/Configuration.json	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancServer/Resources/Configuration.json	Thu Sep 30 15:03:35 2021 +0200
@@ -418,7 +418,12 @@
   // (1.2.840.10008.1.2.1). This parameter can possibly correspond to
   // a compressed transfer syntax. (new in Orthanc 1.9.0)
   "DicomScuPreferredTransferSyntax" : "1.2.840.10008.1.2.1",
-  
+
+  // Number of threads that are used by the embedded DICOM server.
+  // This defines the number of concurrent DICOM operations that can
+  // be run. (new in Orthanc 1.9.8)
+  "DicomThreadsCount" : 4,
+
   // The list of the known Orthanc peers. This option is ignored if
   // "OrthancPeersInDatabase" is set to "true", in which case you must
   // use the REST API to define Orthanc peers.
--- a/OrthancServer/Sources/main.cpp	Tue Sep 14 14:51:12 2021 +0200
+++ b/OrthancServer/Sources/main.cpp	Thu Sep 30 15:03:35 2021 +0200
@@ -1210,6 +1210,7 @@
       dicomServer.SetCalledApplicationEntityTitleCheck(lock.GetConfiguration().GetBooleanParameter("DicomCheckCalledAet", false));
       dicomServer.SetAssociationTimeout(lock.GetConfiguration().GetUnsignedIntegerParameter("DicomScpTimeout", 30));
       dicomServer.SetPortNumber(lock.GetConfiguration().GetUnsignedIntegerParameter("DicomPort", 4242));
+      dicomServer.SetThreadsCount(lock.GetConfiguration().GetUnsignedIntegerParameter("DicomThreadsCount", 4));
       dicomServer.SetApplicationEntityTitle(lock.GetConfiguration().GetOrthancAET());
 
       // Configuration of DICOM TLS for Orthanc SCP (since Orthanc 1.9.0)