import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
-import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
*
* Initial sleep time is specified as minSleep. Each subsequent unsuccessful attempt multiplies this time by a constant
* factor (sleepFactor) -- this allows for either constant reconnect times (sleepFactor = 1), or various degrees of
- * exponential back-off (sleepFactor > 1). Maximum sleep time between attempts can be capped to a specific value
+ * exponential back-off (sleepFactor > 1). Maximum sleep time between attempts can be capped to a specific value
* (maxSleep).
*
* The strategy can optionally give up based on two criteria:
*
* Both these caps can be combined, with the strategy giving up as soon as the first one is reached.
*/
+@Deprecated
@ThreadSafe
public final class TimedReconnectStrategy implements ReconnectStrategy {
private static final Logger LOG = LoggerFactory.getLogger(TimedReconnectStrategy.class);
this.scheduled = true;
// Schedule a task for the right time. It will also clear the flag.
- return this.executor.schedule(new Callable<Void>() {
- @Override
- public Void call() throws TimeoutException {
- synchronized (lock) {
- Preconditions.checkState(TimedReconnectStrategy.this.scheduled);
- TimedReconnectStrategy.this.scheduled = false;
- }
-
- return null;
+ return this.executor.schedule(() -> {
+ synchronized (lock) {
+ Preconditions.checkState(TimedReconnectStrategy.this.scheduled);
+ TimedReconnectStrategy.this.scheduled = false;
}
+
+ return null;
}, this.lastSleep, TimeUnit.MILLISECONDS);
}