Do not use toString() in looging messages
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / TimedReconnectStrategyFactory.java
1 /*
2  * Copyright (c) 2019 Pantheon Technologies, s.r.o. and others. All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.nettyutil;
9
10 import io.netty.util.concurrent.EventExecutor;
11 import java.math.BigDecimal;
12
13 @Deprecated
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;
19
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;
24         } else {
25             connectionAttempts = null;
26         }
27
28         this.sleepFactor = sleepFactor.doubleValue();
29         this.executor = executor;
30         this.minSleep = minSleep;
31     }
32
33     @Override
34     public ReconnectStrategy createReconnectStrategy() {
35         return new TimedReconnectStrategy(executor, minSleep,
36                 minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);
37     }
38 }