umustafi commented on a change in pull request #3336:
URL: https://github.com/apache/gobblin/pull/3336#discussion_r678705247



##########
File path: 
gobblin-restli/gobblin-flow-config-service/gobblin-flow-config-service-server/src/main/java/org/apache/gobblin/service/FlowExecutionResourceLocalHandler.java
##########
@@ -199,4 +206,20 @@ public static FlowExecution 
convertFlowStatus(org.apache.gobblin.service.monitor
   private static long 
getFlowStartTime(org.apache.gobblin.service.monitoring.FlowStatus flowStatus) {
     return flowStatus.getFlowExecutionId();
   }
+
+  /**
+   * Estimate the time left to complete the copy based on the following 
formula -
+   * timeLeft = (100/completionPercentage) * timeElapsed
+   */
+  public static long estimateCopyTimeLeft(Long currentTime, Long startTime, 
int completionPercentage) {
+    if (completionPercentage == 0) {
+      return 0;
+    }
+
+    Instant current = Instant.ofEpochMilli(currentTime);
+    Instant start = Instant.ofEpochMilli(startTime);
+    Long timeBetween = Duration.between(start, current).toMillis();

Review comment:
       it is however alex had recommended using the Instant/Duration classes 
earlier to make it clear what units the times were in. I agree that this may 
not add much clarity and perhaps a comment can do the same. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to