You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ge...@apache.org on 2017/04/28 13:53:41 UTC

[03/10] brooklyn-server git commit: repeater now respects its timeout more tightly

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 <al...@cloudsoftcorp.com>
Authored: Tue Apr 25 15:06:19 2017 +0100
Committer: Alex Heneveld <al...@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);