You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2023/12/18 17:02:25 UTC

(camel) branch main updated (2ac4e9677ab -> 5f3c86019c1)

This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


    from 2ac4e9677ab Fix website doc build
     new c3bc84b1cc1 CAMEL-20225: use the clock API when possible for exchange duration calculations
     new 935ed455c71 CAMEL-20225: deprecate ad-hoc elapsed time calculations
     new 5f3c86019c1 CAMEL-20225: use a monotonic source for computing duration

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/camel/management/mbean/ManagedBacklogDebugger.java    | 2 +-
 .../src/main/java/org/apache/camel/support/MonotonicClock.java   | 6 +++++-
 .../src/main/java/org/apache/camel/support/ResetableClock.java   | 9 ++++++++-
 .../src/main/java/org/apache/camel/util/TimeUtils.java           | 6 ++++--
 4 files changed, 18 insertions(+), 5 deletions(-)


(camel) 03/03: CAMEL-20225: use a monotonic source for computing duration

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 5f3c86019c15ef9f883cd3c19bd0084cdb5a6e91
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Dec 15 12:11:58 2023 -0300

    CAMEL-20225: use a monotonic source for computing duration
---
 .../src/main/java/org/apache/camel/support/MonotonicClock.java   | 6 +++++-
 .../src/main/java/org/apache/camel/support/ResetableClock.java   | 9 ++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/core/camel-support/src/main/java/org/apache/camel/support/MonotonicClock.java b/core/camel-support/src/main/java/org/apache/camel/support/MonotonicClock.java
index 3a3ca3f482b..1642f57dfae 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/MonotonicClock.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/MonotonicClock.java
@@ -17,18 +17,22 @@
 
 package org.apache.camel.support;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.Clock;
 
 public class MonotonicClock implements Clock {
     private final long created;
+    private final long createdNano;
 
     MonotonicClock() {
         this.created = System.currentTimeMillis();
+        this.createdNano = System.nanoTime();
     }
 
     @Override
     public long elapsed() {
-        return System.currentTimeMillis() - created;
+        return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - createdNano);
     }
 
     @Override
diff --git a/core/camel-support/src/main/java/org/apache/camel/support/ResetableClock.java b/core/camel-support/src/main/java/org/apache/camel/support/ResetableClock.java
index cabf9c776fc..130deaecfd4 100644
--- a/core/camel-support/src/main/java/org/apache/camel/support/ResetableClock.java
+++ b/core/camel-support/src/main/java/org/apache/camel/support/ResetableClock.java
@@ -17,22 +17,27 @@
 
 package org.apache.camel.support;
 
+import java.util.concurrent.TimeUnit;
+
 import org.apache.camel.Clock;
 
 public final class ResetableClock implements Clock {
     private long created;
+    private long createdNano;
 
     ResetableClock(Clock clock) {
         this.created = clock.getCreated();
+        this.createdNano = System.nanoTime();
     }
 
     ResetableClock() {
         this.created = System.currentTimeMillis();
+        this.createdNano = System.nanoTime();
     }
 
     @Override
     public long elapsed() {
-        return System.currentTimeMillis() - created;
+        return TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - createdNano);
     }
 
     @Override
@@ -45,6 +50,7 @@ public final class ResetableClock implements Clock {
      */
     public void reset() {
         this.created = System.currentTimeMillis();
+        this.createdNano = System.nanoTime();
     }
 
     /**
@@ -53,5 +59,6 @@ public final class ResetableClock implements Clock {
      */
     void unset() {
         this.created = 0;
+        this.createdNano = 0;
     }
 }


(camel) 02/03: CAMEL-20225: deprecate ad-hoc elapsed time calculations

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 935ed455c71766d0ff0b623249f41f66d82afdf4
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Dec 15 12:07:21 2023 -0300

    CAMEL-20225: deprecate ad-hoc elapsed time calculations
---
 core/camel-util/src/main/java/org/apache/camel/util/TimeUtils.java | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/core/camel-util/src/main/java/org/apache/camel/util/TimeUtils.java b/core/camel-util/src/main/java/org/apache/camel/util/TimeUtils.java
index 835c1b9c446..d689b8c5434 100644
--- a/core/camel-util/src/main/java/org/apache/camel/util/TimeUtils.java
+++ b/core/camel-util/src/main/java/org/apache/camel/util/TimeUtils.java
@@ -254,9 +254,11 @@ public final class TimeUtils {
     /**
      * Elapsed time using milliseconds since epoch.
      *
-     * @param  start the timestamp in milliseconds since epoch
-     * @return       the elapsed time in milliseconds
+     * @param      start the timestamp in milliseconds since epoch
+     * @return           the elapsed time in milliseconds
+     * @deprecated       Use the Clock API when possible
      */
+    @Deprecated(since = "4.4.0")
     public static long elapsedMillisSince(long start) {
         return System.currentTimeMillis() - start;
     }


(camel) 01/03: CAMEL-20225: use the clock API when possible for exchange duration calculations

Posted by or...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit c3bc84b1cc149f2c6aa50095c5f6df72ebb9e3c7
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Fri Dec 15 12:05:28 2023 -0300

    CAMEL-20225: use the clock API when possible for exchange duration calculations
---
 .../java/org/apache/camel/management/mbean/ManagedBacklogDebugger.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogDebugger.java b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogDebugger.java
index b07f6ee39ee..206efa9a67e 100644
--- a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogDebugger.java
+++ b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedBacklogDebugger.java
@@ -394,7 +394,7 @@ public class ManagedBacklogDebugger implements ManagedBacklogDebuggerMBean {
                             + "]";
                 }
 
-                long elapsed = TimeUtils.elapsedMillisSince(suspendedExchange.getClock().getCreated());
+                long elapsed = suspendedExchange.getClock().elapsed();
 
                 messageHistoryBuilder
                         .append("    <messageHistoryEntry")