Merge "Bug 2682 - Switch sal-binding-dom-it to sal-test-model"
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / protocol / framework / 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.protocol.framework;
9
10 import io.netty.util.concurrent.EventExecutor;
11 import io.netty.util.concurrent.Future;
12
13 import javax.annotation.concurrent.ThreadSafe;
14
15 import com.google.common.base.Preconditions;
16
17 /**
18  * Utility ReconnectStrategy singleton, which will cause the reconnect process
19  * to always fail.
20  */
21 @Deprecated
22 @ThreadSafe
23 public final class NeverReconnectStrategy implements ReconnectStrategy {
24     private final EventExecutor executor;
25     private final int timeout;
26
27     public NeverReconnectStrategy(final EventExecutor executor, final int timeout) {
28         Preconditions.checkArgument(timeout >= 0);
29         this.executor = Preconditions.checkNotNull(executor);
30         this.timeout = timeout;
31     }
32
33     @Override
34     public Future<Void> scheduleReconnect(final Throwable cause) {
35         return executor.newFailedFuture(new Throwable());
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 }