public class HazelcastTimeoutUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
protected static <T> T |
execute(org.mule.runtime.core.api.util.func.CheckedFunction<Long,T> closure,
long timeout) |
static <T> T |
executeWithTimeoutIntervals(long timeoutMillis,
org.mule.runtime.core.api.util.func.CheckedFunction<Long,T> closure,
Predicate<T> breakCondition)
Hazelcast may take a while to actually throw the Interrupted exception, so we must do the operation in shorter consecutive
intervals so in the case of interruption we can be notified as soon as possible and proceed with the shutdown normally.
|
public static <T> T executeWithTimeoutIntervals(long timeoutMillis,
org.mule.runtime.core.api.util.func.CheckedFunction<Long,T> closure,
Predicate<T> breakCondition)
throws InterruptedException
timeoutMillis - The total timeout in milliseconds. The partial timeouts of the intervals will add up to this value.closure - the actual call to make, receiving the calculated partial timeout as a parameter.breakCondition - The condition under which the returned value will be considered valid and returned by this method. When
false is returned, another interval with a partial timeout will take place.closure when breakCondition becomes true or the
timeoutMillis is completed.InterruptedException - if the thread is interrupted during this method. As per the Hazelcast behavior,
InterruptedException may not be thrown until the partial interval is complete.protected static <T> T execute(org.mule.runtime.core.api.util.func.CheckedFunction<Long,T> closure, long timeout) throws InterruptedException
InterruptedExceptionCopyright © 2006–2022 MuleSoft, Inc.. All rights reserved.