brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [03/10] brooklyn-server git commit: repeater now respects its timeout more tightly
Date Fri, 28 Apr 2017 13:53:41 GMT
repeater now respects its timeout more tightly


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/f9cb0b24
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/f9cb0b24
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/f9cb0b24

Branch: refs/heads/master
Commit: f9cb0b2447b02d93fe2b39496320cb1c920be3ff
Parents: aae7218
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Apr 25 15:06:19 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Fri Apr 28 14:09:50 2017 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/brooklyn/util/repeat/Repeater.java | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f9cb0b24/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
----------------------------------------------------------------------
diff --git a/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java b/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
index b08050b..a04f58c 100644
--- a/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
+++ b/utils/common/src/main/java/org/apache/brooklyn/util/repeat/Repeater.java
@@ -90,7 +90,7 @@ public class Repeater implements Callable<Boolean> {
     private Predicate<? super Throwable> rethrowImmediatelyCondition = Exceptions.isFatalPredicate();
     private boolean warnOnUnRethrownException = true;
     private boolean shutdown = false;
-    private ExecutorService executor = MoreExecutors.sameThreadExecutor();
+    private ExecutorService executor = MoreExecutors.newDirectExecutorService();
 
     public Repeater() {
         this(null);
@@ -367,6 +367,9 @@ public class Repeater implements Callable<Boolean> {
         try {
             while (true) {
                 Duration delayThisIteration = delayOnIteration.apply(iterations);
+                if (timer.isNotPaused() && delayThisIteration.isLongerThan(timer.getDurationRemaining()))
{
+                    delayThisIteration = timer.getDurationRemaining();
+                }
                 iterations++;
 
                 Future<?> call = executor.submit(body);


Mime
View raw message