Bump odlparent 2.0.2 to 2.0.4
[controller.git] / opendaylight / commons / protocol-framework / src / main / java / org / opendaylight / protocol / framework / 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.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 org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17
18 import com.google.common.base.Preconditions;
19
20 /**
21  * Utility ReconnectStrategy singleton, which will cause the reconnect process
22  * to immediately schedule a reconnection attempt.
23  */
24 @Deprecated
25 @ThreadSafe
26 public final class ReconnectImmediatelyStrategy implements ReconnectStrategy {
27     private static final Logger LOG = LoggerFactory.getLogger(ReconnectImmediatelyStrategy.class);
28     private final EventExecutor executor;
29     private final int timeout;
30
31     public ReconnectImmediatelyStrategy(final EventExecutor executor, final int timeout) {
32         Preconditions.checkArgument(timeout >= 0);
33         this.executor = Preconditions.checkNotNull(executor);
34         this.timeout = timeout;
35     }
36
37     @Override
38     public Future<Void> scheduleReconnect(final Throwable cause) {
39         LOG.debug("Connection attempt failed", cause);
40         return executor.newSucceededFuture(null);
41     }
42
43     @Override
44     public void reconnectSuccessful() {
45         // Nothing to do
46     }
47
48     @Override
49     public int getConnectTimeout() {
50         return timeout;
51     }
52 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.