Add custom EXI buffer management
[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 import javax.annotation.concurrent.ThreadSafe;
14
15 /**
16  * Utility ReconnectStrategy singleton, which will cause the reconnect process
17  * to always fail.
18  */
19 @Deprecated
20 @ThreadSafe
21 public final class NeverReconnectStrategy implements ReconnectStrategy {
22     private final EventExecutor executor;
23     private final int timeout;
24
25     public NeverReconnectStrategy(final EventExecutor executor, final int timeout) {
26         Preconditions.checkArgument(timeout >= 0);
27         this.executor = Preconditions.checkNotNull(executor);
28         this.timeout = timeout;
29     }
30
31     @Override
32     public Future<Void> scheduleReconnect(final Throwable cause) {
33         return executor.newFailedFuture(new Throwable("Reconnect failed", cause));
34     }
35
36     @Override
37     public void reconnectSuccessful() {
38         // Nothing to do
39     }
40
41     @Override
42     public int getConnectTimeout() {
43         return timeout;
44     }
45 }