Bump odlparent to 5.0.0
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / ReconnectImmediatelyStrategy.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 com.google.common.base.Preconditions;
11 import io.netty.util.concurrent.EventExecutor;
12 import io.netty.util.concurrent.Future;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16 /**
17  * Utility ReconnectStrategy singleton, which will cause the reconnect process to immediately schedule a reconnection
18  * attempt. This class is thread-safe.
19  */
20 @Deprecated
21 public final class ReconnectImmediatelyStrategy implements ReconnectStrategy {
22     private static final Logger LOG = LoggerFactory.getLogger(ReconnectImmediatelyStrategy.class);
23     private final EventExecutor executor;
24     private final int timeout;
25
26     public ReconnectImmediatelyStrategy(final EventExecutor executor, final int timeout) {
27         Preconditions.checkArgument(timeout >= 0);
28         this.executor = Preconditions.checkNotNull(executor);
29         this.timeout = timeout;
30     }
31
32     @Override
33     public Future<Void> scheduleReconnect(final Throwable cause) {
34         LOG.debug("Connection attempt failed", cause);
35         return executor.newSucceededFuture(null);
36     }
37
38     @Override
39     public void reconnectSuccessful() {
40         // Nothing to do
41     }
42
43     @Override
44     public int getConnectTimeout() {
45         return timeout;
46     }
47 }