2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.protocol.framework;
10 import io.netty.util.concurrent.EventExecutor;
11 import io.netty.util.concurrent.Future;
13 import javax.annotation.concurrent.ThreadSafe;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
18 import com.google.common.base.Preconditions;
21 * Utility ReconnectStrategy singleton, which will cause the reconnect process
22 * to immediately schedule a reconnection attempt.
25 public final class ReconnectImmediatelyStrategy implements ReconnectStrategy {
26 private static final Logger LOG = LoggerFactory.getLogger(ReconnectImmediatelyStrategy.class);
27 private final EventExecutor executor;
28 private final int timeout;
30 public ReconnectImmediatelyStrategy(final EventExecutor executor, final int timeout) {
31 Preconditions.checkArgument(timeout >= 0);
32 this.executor = Preconditions.checkNotNull(executor);
33 this.timeout = timeout;
37 public Future<Void> scheduleReconnect(final Throwable cause) {
38 LOG.debug("Connection attempt failed", cause);
39 return executor.newSucceededFuture(null);
43 public void reconnectSuccessful() {
48 public int getConnectTimeout() {