2 * Copyright (c) 2019 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.nettyutil;
10 import io.netty.util.concurrent.EventExecutor;
11 import java.math.BigDecimal;
14 public final class TimedReconnectStrategyFactory implements ReconnectStrategyFactory {
15 private final Long connectionAttempts;
16 private final EventExecutor executor;
17 private final double sleepFactor;
18 private final int minSleep;
20 public TimedReconnectStrategyFactory(final EventExecutor executor, final Long maxConnectionAttempts,
21 final int minSleep, final BigDecimal sleepFactor) {
22 if (maxConnectionAttempts != null && maxConnectionAttempts > 0) {
23 connectionAttempts = maxConnectionAttempts;
25 connectionAttempts = null;
28 this.sleepFactor = sleepFactor.doubleValue();
29 this.executor = executor;
30 this.minSleep = minSleep;
34 public ReconnectStrategy createReconnectStrategy() {
35 return new TimedReconnectStrategy(executor, minSleep,
36 minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);