Author: pauls
Date: Fri Aug  4 12:54:08 2017
New Revision: 1804116

URL: http://svn.apache.org/viewvc?rev=1804116&view=rev
Log:
SLING-7027: Fix eta calculation for jobs and make sure we use the new eta on an 
updated.

Modified:
    
sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java

Modified: 
sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java?rev=1804116&r1=1804115&r2=1804116&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java
 (original)
+++ 
sling/trunk/bundles/extensions/event/resource/src/main/java/org/apache/sling/event/impl/jobs/JobImpl.java
 Fri Aug  4 12:54:08 2017
@@ -278,7 +278,7 @@ public class JobImpl implements Job, Com
             final Calendar now = Calendar.getInstance();
             final long elapsed = now.getTimeInMillis() - 
this.getProcessingStarted().getTimeInMillis();
 
-            final long eta = elapsed * steps / step;
+            final long eta = System.currentTimeMillis() + (elapsed / current) 
* (steps - current);
             now.setTimeInMillis(eta);
             this.setProperty(Job.PROPERTY_JOB_PROGRESS_ETA, now);
             return new String[] {Job.PROPERTY_JOB_PROGRESS_STEP, 
Job.PROPERTY_JOB_PROGRESS_ETA};
@@ -291,7 +291,7 @@ public class JobImpl implements Job, Com
             final Date finishDate = new Date(System.currentTimeMillis() + eta 
* 1000);
             final Calendar finishCal = Calendar.getInstance();
             finishCal.setTime(finishDate);
-            this.setProperty(Job.PROPERTY_JOB_PROGRESS_ETA, eta);
+            this.setProperty(Job.PROPERTY_JOB_PROGRESS_ETA, finishCal);
         } else {
             this.properties.remove(Job.PROPERTY_JOB_PROGRESS_ETA);
         }


Reply via email to