Convert yanglib to OSGi DS
[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 static com.google.common.base.Preconditions.checkArgument;
11 import static java.util.Objects.requireNonNull;
12
13 import io.netty.util.concurrent.EventExecutor;
14 import io.netty.util.concurrent.Future;
15
16 /**
17  * Utility ReconnectStrategy singleton, which will cause the reconnect process to always fail. This class is thred-safe.
18  */
19 @Deprecated
20 public final class NeverReconnectStrategy implements ReconnectStrategy {
21     private final EventExecutor executor;
22     private final int timeout;
23
24     public NeverReconnectStrategy(final EventExecutor executor, final int timeout) {
25         checkArgument(timeout >= 0);
26         this.executor = requireNonNull(executor);
27         this.timeout = timeout;
28     }
29
30     @Override
31     public Future<Void> scheduleReconnect(final Throwable cause) {
32         return executor.newFailedFuture(new Throwable("Reconnect failed", cause));
33     }
34
35     @Override
36     public void reconnectSuccessful() {
37         // Nothing to do
38     }
39
40     @Override
41     public int getConnectTimeout() {
42         return timeout;
43     }
44 }