Bump odlparent to 5.0.0
[netconf.git] / netconf / netconf-netty-util / src / main / java / org / opendaylight / netconf / nettyutil / NeverReconnectStrategy.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
14 /**
15  * Utility ReconnectStrategy singleton, which will cause the reconnect process to always fail. This class is thred-safe.
16  */
17 @Deprecated
18 public final class NeverReconnectStrategy implements ReconnectStrategy {
19     private final EventExecutor executor;
20     private final int timeout;
21
22     public NeverReconnectStrategy(final EventExecutor executor, final int timeout) {
23         Preconditions.checkArgument(timeout >= 0);
24         this.executor = Preconditions.checkNotNull(executor);
25         this.timeout = timeout;
26     }
27
28     @Override
29     public Future<Void> scheduleReconnect(final Throwable cause) {
30         return executor.newFailedFuture(new Throwable("Reconnect failed", cause));
31     }
32
33     @Override
34     public void reconnectSuccessful() {
35         // Nothing to do
36     }
37
38     @Override
39     public int getConnectTimeout() {
40         return timeout;
41     }
42 }