@InterfaceAudience.Private public final class Waiter extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Waiter.ExplainingPredicate<E extends Exception>
A mixin interface, can be used with
Waiter to explain failed state. |
static interface |
Waiter.Predicate<E extends Exception>
A predicate 'closure' used by the
waitFor(Configuration, long, Predicate) and
waitFor(Configuration, long, Predicate) and
{@link Waiter#waitFor(Configuration, long, long, boolean, Predicate) methods. |
Modifier and Type | Field and Description |
---|---|
static String |
HBASE_TEST_WAIT_FOR_RATIO
System property name whose value is a scale factor to increase time out values dynamically used
in
sleep(Configuration, long) , waitFor(Configuration, long, Predicate) ,
waitFor(Configuration, long, long, Predicate) , and
waitFor(Configuration, long, long, boolean, Predicate) method
The actual time out value will equal to hbase.test.wait.for.ratio * passed-in timeout |
Modifier and Type | Method and Description |
---|---|
static String |
getExplanation(Waiter.Predicate explain) |
static float |
getWaitForRatio(Configuration conf)
Returns the 'wait for ratio' used in the
sleep(Configuration, long) ,
waitFor(Configuration, long, Predicate) ,
waitFor(Configuration, long, long, Predicate) and
waitFor(Configuration, long, long, boolean, Predicate) methods of the class
This is useful to dynamically adjust max time out values when same test cases run in different
test machine settings without recompiling & re-deploying code. |
static void |
sleep(Configuration conf,
long time)
Makes the current thread sleep for the duration equal to the specified time in milliseconds
multiplied by the
getWaitForRatio(Configuration) . |
static <E extends Exception> |
waitFor(Configuration conf,
long timeout,
long interval,
boolean failIfTimeout,
Waiter.Predicate<E> predicate)
Waits up to the duration equal to the specified timeout multiplied by the
getWaitForRatio(Configuration) for the given Waiter.Predicate to become
true , failing the test if the timeout is reached, the Predicate is still
false and failIfTimeout is set as true . |
static <E extends Exception> |
waitFor(Configuration conf,
long timeout,
long interval,
Waiter.Predicate<E> predicate)
Waits up to the duration equal to the specified timeout multiplied by the
getWaitForRatio(Configuration) for the given Waiter.Predicate to become
true , failing the test if the timeout is reached and the Predicate is still
false . |
static <E extends Exception> |
waitFor(Configuration conf,
long timeout,
Waiter.Predicate<E> predicate)
Waits up to the duration equal to the specified timeout multiplied by the
getWaitForRatio(Configuration) for the given Waiter.Predicate to become
true , failing the test if the timeout is reached and the Predicate is still
false . |
public static final String HBASE_TEST_WAIT_FOR_RATIO
sleep(Configuration, long)
, waitFor(Configuration, long, Predicate)
,
waitFor(Configuration, long, long, Predicate)
, and
waitFor(Configuration, long, long, boolean, Predicate)
method
The actual time out value will equal to hbase.test.wait.for.ratio * passed-in timeoutpublic static float getWaitForRatio(Configuration conf)
sleep(Configuration, long)
,
waitFor(Configuration, long, Predicate)
,
waitFor(Configuration, long, long, Predicate)
and
waitFor(Configuration, long, long, boolean, Predicate)
methods of the class
This is useful to dynamically adjust max time out values when same test cases run in different
test machine settings without recompiling & re-deploying code.
The value is obtained from the Java System property or configuration setting
hbase.test.wait.for.ratio
which defaults to 1
.conf
- the configurationpublic static void sleep(Configuration conf, long time)
getWaitForRatio(Configuration)
.conf
- the configurationtime
- the number of milliseconds to sleep.public static <E extends Exception> long waitFor(Configuration conf, long timeout, Waiter.Predicate<E> predicate) throws E extends Exception
getWaitForRatio(Configuration)
for the given Waiter.Predicate
to become
true
, failing the test if the timeout is reached and the Predicate is still
false
.
conf
- the configurationtimeout
- the timeout in milliseconds to wait for the predicate.predicate
- the predicate to evaluate.true
or
wait is interrupted otherwise -1
when times outE extends Exception
public static <E extends Exception> long waitFor(Configuration conf, long timeout, long interval, Waiter.Predicate<E> predicate) throws E extends Exception
getWaitForRatio(Configuration)
for the given Waiter.Predicate
to become
true
, failing the test if the timeout is reached and the Predicate is still
false
.
conf
- the configurationtimeout
- the max timeout in milliseconds to wait for the predicate.interval
- the interval in milliseconds to evaluate predicate.predicate
- the predicate to evaluate.true
or
wait is interrupted otherwise -1
when times outE extends Exception
public static <E extends Exception> long waitFor(Configuration conf, long timeout, long interval, boolean failIfTimeout, Waiter.Predicate<E> predicate) throws E extends Exception
getWaitForRatio(Configuration)
for the given Waiter.Predicate
to become
true
, failing the test if the timeout is reached, the Predicate is still
false
and failIfTimeout is set as true
.
conf
- the configurationtimeout
- the timeout in milliseconds to wait for the predicate.interval
- the interval in milliseconds to evaluate predicate.failIfTimeout
- indicates if should fail current test case when times out.predicate
- the predicate to evaluate.true
or
wait is interrupted otherwise -1
when times outE extends Exception
public static String getExplanation(Waiter.Predicate explain)