changeset 3658:2d90dd30858c storage-commitment

providing job ID to the IJob::Step() methods
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 10 Feb 2020 16:44:26 +0100
parents 115f82775c46
children 08eb0f93c491
files Core/JobsEngine/IJob.h Core/JobsEngine/JobsEngine.cpp Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp Core/JobsEngine/Operations/SequenceOfOperationsJob.h Core/JobsEngine/SetOfCommandsJob.cpp Core/JobsEngine/SetOfCommandsJob.h Core/JobsEngine/SetOfInstancesJob.cpp OrthancServer/ServerJobs/ArchiveJob.cpp OrthancServer/ServerJobs/ArchiveJob.h OrthancServer/ServerJobs/DicomMoveScuJob.cpp OrthancServer/ServerJobs/StorageCommitmentScpJob.cpp Plugins/Engine/PluginsJob.cpp Plugins/Engine/PluginsJob.h UnitTestsSources/MultiThreadingTests.cpp
diffstat 14 files changed, 37 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/Core/JobsEngine/IJob.h	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/IJob.h	Mon Feb 10 16:44:26 2020 +0100
@@ -50,7 +50,7 @@
     // Method called once the job enters the jobs engine
     virtual void Start() = 0;
     
-    virtual JobStepResult Step() = 0;
+    virtual JobStepResult Step(const std::string& jobId) = 0;
 
     // Method called once the job is resubmitted after a failure
     virtual void Reset() = 0;
--- a/Core/JobsEngine/JobsEngine.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/JobsEngine.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -71,7 +71,7 @@
 
     try
     {
-      result = running.GetJob().Step();
+      result = running.GetJob().Step(running.GetId());
     }
     catch (OrthancException& e)
     {
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -319,7 +319,7 @@
   }
 
 
-  JobStepResult SequenceOfOperationsJob::Step()
+  JobStepResult SequenceOfOperationsJob::Step(const std::string& jobId)
   {
     boost::mutex::scoped_lock lock(mutex_);
 
--- a/Core/JobsEngine/Operations/SequenceOfOperationsJob.h	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/Operations/SequenceOfOperationsJob.h	Mon Feb 10 16:44:26 2020 +0100
@@ -130,7 +130,7 @@
     {
     }
 
-    virtual JobStepResult Step();
+    virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE;
 
     virtual void Reset();
 
--- a/Core/JobsEngine/SetOfCommandsJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/SetOfCommandsJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -145,7 +145,7 @@
   }
       
 
-  JobStepResult SetOfCommandsJob::Step()
+  JobStepResult SetOfCommandsJob::Step(const std::string& jobId)
   {
     if (!started_)
     {
@@ -169,7 +169,7 @@
     try
     {
       // Not at the trailing step: Handle the current command
-      if (!commands_[position_]->Execute())
+      if (!commands_[position_]->Execute(jobId))
       {
         // Error
         if (!permissive_)
--- a/Core/JobsEngine/SetOfCommandsJob.h	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/SetOfCommandsJob.h	Mon Feb 10 16:44:26 2020 +0100
@@ -49,7 +49,7 @@
       {
       }
 
-      virtual bool Execute() = 0;
+      virtual bool Execute(const std::string& jobId) = 0;
 
       virtual void Serialize(Json::Value& target) const = 0;
     };
@@ -126,7 +126,7 @@
 
     const ICommand& GetCommand(size_t index) const;
       
-    virtual JobStepResult Step();
+    virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE;
     
     virtual void GetPublicContent(Json::Value& value);
     
--- a/Core/JobsEngine/SetOfInstancesJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/Core/JobsEngine/SetOfInstancesJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -60,7 +60,7 @@
       return instance_;
     }
       
-    virtual bool Execute()
+    virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
     {
       if (!that_.HandleInstance(instance_))
       {
@@ -91,12 +91,12 @@
     {
     }       
       
-    virtual bool Execute()
+    virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
     {
       return that_.HandleTrailingStep();
     }
 
-    virtual void Serialize(Json::Value& target) const
+    virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE
     {
       target = Json::nullValue;
     }
--- a/OrthancServer/ServerJobs/ArchiveJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/OrthancServer/ServerJobs/ArchiveJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -935,7 +935,7 @@
   }
     
 
-  JobStepResult ArchiveJob::Step()
+  JobStepResult ArchiveJob::Step(const std::string& jobId)
   {
     assert(writer_.get() != NULL);
 
--- a/OrthancServer/ServerJobs/ArchiveJob.h	Mon Feb 10 14:53:36 2020 +0100
+++ b/OrthancServer/ServerJobs/ArchiveJob.h	Mon Feb 10 16:44:26 2020 +0100
@@ -92,7 +92,7 @@
 
     virtual void Start();
 
-    virtual JobStepResult Step();
+    virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE;
 
     virtual void Stop(JobStopReason reason)
     {
--- a/OrthancServer/ServerJobs/DicomMoveScuJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/OrthancServer/ServerJobs/DicomMoveScuJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -57,7 +57,7 @@
     {
     }
 
-    virtual bool Execute()
+    virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
     {
       that_.Retrieve(*findAnswer_);
       return true;
--- a/OrthancServer/ServerJobs/StorageCommitmentScpJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/OrthancServer/ServerJobs/StorageCommitmentScpJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -87,7 +87,7 @@
       return false;
     }
     
-    virtual bool Execute()
+    virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
     {
       if (hasFailureReason_)
       {
@@ -189,7 +189,7 @@
       return true;
     }
     
-    virtual bool Execute()
+    virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE
     {
       that_.Answer();
       return true;
--- a/Plugins/Engine/PluginsJob.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/Plugins/Engine/PluginsJob.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -78,7 +78,7 @@
     parameters_.finalize(parameters_.job);
   }
 
-  JobStepResult PluginsJob::Step()
+  JobStepResult PluginsJob::Step(const std::string& jobId)
   {
     OrthancPluginJobStepStatus status = parameters_.step(parameters_.job);
 
--- a/Plugins/Engine/PluginsJob.h	Mon Feb 10 14:53:36 2020 +0100
+++ b/Plugins/Engine/PluginsJob.h	Mon Feb 10 16:44:26 2020 +0100
@@ -55,7 +55,7 @@
     {
     }
     
-    virtual JobStepResult Step();
+    virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE;
 
     virtual void Reset();
 
--- a/UnitTestsSources/MultiThreadingTests.cpp	Mon Feb 10 14:53:36 2020 +0100
+++ b/UnitTestsSources/MultiThreadingTests.cpp	Mon Feb 10 16:44:26 2020 +0100
@@ -101,7 +101,7 @@
     {
     }
     
-    virtual JobStepResult Step() ORTHANC_OVERRIDE
+    virtual JobStepResult Step(const std::string& jobId) ORTHANC_OVERRIDE
     {
       if (fails_)
       {
@@ -1045,12 +1045,12 @@
     job.AddInstance("nope");
     job.AddInstance("world");
     job.SetPermissive(true);
-    ASSERT_THROW(job.Step(), OrthancException);  // Not started yet
+    ASSERT_THROW(job.Step("jobId"), OrthancException);  // Not started yet
     ASSERT_FALSE(job.HasTrailingStep());
     ASSERT_FALSE(job.IsTrailingStepDone());
     job.Start();
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
 
     {
       DummyUnserializer unserializer;
@@ -1101,7 +1101,7 @@
       lock.SetTrailingOperationTimeout(300);
     }
 
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
 
     {
       GenericJobUnserializer unserializer;
@@ -1618,8 +1618,8 @@
 
       job.AddTrailingStep();
       job.Start();
-      ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
-      ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+      ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
+      ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
 
       study2 = job.GetTargetStudy();
       ASSERT_FALSE(study2.empty());
@@ -1677,8 +1677,8 @@
 
     job.AddTrailingStep();
     job.Start();
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
-    ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
+    ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
 
     ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     ASSERT_TRUE(job.Serialize(s));
@@ -1746,7 +1746,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
     
-    ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
     ASSERT_EQ(1u, job.GetPosition());
     ASSERT_FALSE(job.IsTrailingStepDone());
     
@@ -1755,7 +1755,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_THROW(job.Step(), OrthancException);
+    ASSERT_THROW(job.Step("jobId"), OrthancException);
   }
 
   {
@@ -1777,7 +1777,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
     
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
     ASSERT_EQ(1u, job.GetPosition());
     ASSERT_FALSE(job.IsTrailingStepDone());
     
@@ -1786,7 +1786,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
     ASSERT_EQ(2u, job.GetPosition());
     ASSERT_FALSE(job.IsTrailingStepDone());
     
@@ -1795,7 +1795,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_THROW(job.Step(), OrthancException);
+    ASSERT_THROW(job.Step("jobId"), OrthancException);
   }
 
   {
@@ -1818,7 +1818,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
     
-    ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
     ASSERT_EQ(1u, job.GetPosition());
     ASSERT_TRUE(job.IsTrailingStepDone());
     
@@ -1827,7 +1827,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_THROW(job.Step(), OrthancException);
+    ASSERT_THROW(job.Step("jobId"), OrthancException);
   }
 
   {
@@ -1852,7 +1852,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
     
-    ASSERT_EQ(JobStepCode_Continue, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Continue, job.Step("jobId").GetCode());
     ASSERT_EQ(1u, job.GetPosition());
     ASSERT_FALSE(job.IsTrailingStepDone());
     
@@ -1861,7 +1861,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_EQ(JobStepCode_Success, job.Step().GetCode());
+    ASSERT_EQ(JobStepCode_Success, job.Step("jobId").GetCode());
     ASSERT_EQ(2u, job.GetPosition());
     ASSERT_TRUE(job.IsTrailingStepDone());
     
@@ -1870,7 +1870,7 @@
       ASSERT_TRUE(CheckIdempotentSetOfInstances(unserializer, job));
     }
 
-    ASSERT_THROW(job.Step(), OrthancException);
+    ASSERT_THROW(job.Step("jobId"), OrthancException);
   }
 }