Repository: curator Updated Branches: refs/heads/CURATOR-2.0 448259ac8 -> ec66c493b
brought in master version of Timing Project: http://git-wip-us.apache.org/repos/asf/curator/repo Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/ec66c493 Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/ec66c493 Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/ec66c493 Branch: refs/heads/CURATOR-2.0 Commit: ec66c493b2acaa455ebfb4b5a86f603120349407 Parents: 448259a Author: randgalt <[email protected]> Authored: Wed Jul 19 12:38:40 2017 -0500 Committer: randgalt <[email protected]> Committed: Wed Jul 19 12:38:40 2017 -0500 ---------------------------------------------------------------------- .../java/org/apache/curator/test/Timing.java | 47 +++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/curator/blob/ec66c493/curator-test/src/main/java/org/apache/curator/test/Timing.java ---------------------------------------------------------------------- diff --git a/curator-test/src/main/java/org/apache/curator/test/Timing.java b/curator-test/src/main/java/org/apache/curator/test/Timing.java index 0f013db..242aa50 100644 --- a/curator-test/src/main/java/org/apache/curator/test/Timing.java +++ b/curator-test/src/main/java/org/apache/curator/test/Timing.java @@ -36,7 +36,8 @@ public class Timing private static final int DEFAULT_SECONDS = 10; private static final int DEFAULT_WAITING_MULTIPLE = 5; - private static final double SESSION_MULTIPLE = .25; + private static final double SESSION_MULTIPLE = 1.5; + private static final double SESSION_SLEEP_MULTIPLE = SESSION_MULTIPLE * 1.75; // has to be at least session + 2/3 of a session to account for missed heartbeat then session expiration /** * Use the default base time @@ -207,6 +208,18 @@ public class Timing } /** + * Return a new timing that is a multiple of the this timing + * + * @param n the multiple + * @param waitingMultiple new waitingMultiple + * @return this timing times the multiple + */ + public Timing multiple(double n, int waitingMultiple) + { + return new Timing((int)(value * n), unit, waitingMultiple); + } + + /** * Return a new timing with the standard multiple for waiting on latches, etc. * * @return this timing multiplied @@ -218,13 +231,43 @@ public class Timing } /** + * Return a new timing with a multiple that ensures a ZK session timeout + * + * @return this timing multiplied + */ + public Timing forSessionSleep() + { + return multiple(SESSION_SLEEP_MULTIPLE, 1); + } + + /** + * Return a new timing with a multiple for sleeping a smaller amount of time + * + * @return this timing multiplied + */ + public Timing forSleepingABit() + { + return multiple(.25); + } + + /** * Sleep for a small amount of time * * @throws InterruptedException if interrupted */ public void sleepABit() throws InterruptedException { - unit.sleep(value / 4); + forSleepingABit().sleep(); + } + + /** + * Sleep for a the full amount of time + * + * @throws InterruptedException if interrupted + */ + public void sleep() throws InterruptedException + { + unit.sleep(value); } /**
