changeset 2625:5469dda691cd jobs

new configuration option: SynchronousCMove
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 May 2018 10:54:33 +0200
parents 714dcddeb65f
children e09021ddc00d
files NEWS OrthancServer/OrthancMoveRequestHandler.cpp Resources/Configuration.json
diffstat 3 files changed, 37 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu May 24 21:44:22 2018 +0200
+++ b/NEWS	Fri May 25 10:54:33 2018 +0200
@@ -5,6 +5,10 @@
 -------
 
 * New advanced job engine
+* New configuration options:
+  - "ConcurrentJobs": Max number of jobs that are simultanously running
+  - "SynchronousCMove": Whether to run DICOM C-Move operations synchronously
+  - "JobsHistorySize": Max number of completed jobs that are kept in memory
 
 Orthanc Explorer
 ----------------
--- a/OrthancServer/OrthancMoveRequestHandler.cpp	Thu May 24 21:44:22 2018 +0200
+++ b/OrthancServer/OrthancMoveRequestHandler.cpp	Fri May 25 10:54:33 2018 +0200
@@ -60,7 +60,7 @@
 
     public:
       SynchronousMove(ServerContext& context,
-                      const std::string& aet,
+                      const std::string& targetAet,
                       const std::string& publicId,
                       const std::string& originatorAet,
                       uint16_t originatorId) :
@@ -70,7 +70,7 @@
         originatorAet_(originatorAet),
         originatorId_(originatorId)
       {
-        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\"";
+        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << targetAet << "\"";
 
         std::list<std::string> tmp;
         context_.GetIndex().GetChildInstances(tmp, publicId);
@@ -81,7 +81,7 @@
           instances_.push_back(*it);
         }
 
-        remote_ = Configuration::GetModalityUsingAet(aet);
+        remote_ = Configuration::GetModalityUsingAet(targetAet);
       }
 
       virtual unsigned int GetSubOperationCount() const
@@ -122,7 +122,7 @@
       
     public:
       AsynchronousMove(ServerContext& context,
-                       const std::string& aet,
+                       const std::string& targetAet,
                        const std::string& publicId,
                        const std::string& originatorAet,
                        uint16_t originatorId) :
@@ -130,12 +130,12 @@
         job_(new DicomModalityStoreJob(context)),
         position_(0)
       {
-        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\"";
+        LOG(INFO) << "Sending resource " << publicId << " to modality \"" << targetAet << "\"";
 
         job_->SetDescription("C-MOVE");
         job_->SetPermissive(true);
         job_->SetLocalAet(context.GetDefaultLocalApplicationEntityTitle());
-        job_->SetRemoteModality(Configuration::GetModalityUsingAet(aet));
+        job_->SetRemoteModality(Configuration::GetModalityUsingAet(targetAet));
 
         if (originatorId != 0)
         {
@@ -232,6 +232,25 @@
   }
 
 
+  static IMoveRequestIterator* CreateIterator(ServerContext& context,
+                                              const std::string& targetAet,
+                                              const std::string& publicId,
+                                              const std::string& originatorAet,
+                                              uint16_t originatorId)
+  {
+    bool synchronous = Configuration::GetGlobalBoolParameter("SynchronousCMove", false);
+
+    if (synchronous)
+    {
+      return new SynchronousMove(context, targetAet, publicId, originatorAet, originatorId);
+    }
+    else
+    {
+      return new AsynchronousMove(context, targetAet, publicId, originatorAet, originatorId);
+    }
+  }
+
+
   IMoveRequestIterator* OrthancMoveRequestHandler::Handle(const std::string& targetAet,
                                                           const DicomMap& input,
                                                           const std::string& originatorIp,
@@ -254,7 +273,6 @@
       }
     }
 
-
     /**
      * Retrieve the query level.
      **/
@@ -278,8 +296,7 @@
           LookupIdentifier(publicId, ResourceType_Study, input) ||
           LookupIdentifier(publicId, ResourceType_Patient, input))
       {
-        return new AsynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
-        //return new SynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
+        return CreateIterator(context_, targetAet, publicId, originatorAet, originatorId);
       }
       else
       {
@@ -300,8 +317,7 @@
 
     if (LookupIdentifier(publicId, level, input))
     {
-      return new AsynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
-      //return new SynchronousMove(context_, targetAet, publicId, originatorAet, originatorId);
+      return CreateIterator(context_, targetAet, publicId, originatorAet, originatorId);
     }
     else
     {
--- a/Resources/Configuration.json	Thu May 24 21:44:22 2018 +0200
+++ b/Resources/Configuration.json	Fri May 25 10:54:33 2018 +0200
@@ -379,6 +379,12 @@
     // "2001,5f" : [ "SQ", "StackSequence", 1, 1, "Philips Imaging DD 001" ]
   },
 
+  // Whether to run DICOM C-Move operations synchronously. If set to
+  // "false" (the default), each incoming C-Move request results in
+  // creating a new background job. Until Orthanc 1.3.2, the default
+  // behavior was to use synchronous C-Move.
+  "SynchronousCMove" : false,
+
   // Maximum number of completed jobs that are kept in memory. A
   // processing job is considered as complete once it is tagged as
   // "Success" or "Failure".