import io.netty.util.concurrent.Future;
-import java.io.IOException;
-
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPConnection;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
import org.opendaylight.protocol.framework.Dispatcher;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
/**
* Implementation of BGPDispatcher.
private final Dispatcher dispatcher;
- public BGPDispatcherImpl(final Dispatcher dispatcher) throws IOException {
+ public BGPDispatcherImpl(final Dispatcher dispatcher) {
this.dispatcher = dispatcher;
}
@Override
- public Future<? extends BGPSession> createClient(final BGPConnection connection, final ProtocolMessageFactory parser) throws IOException {
- return this.dispatcher.createClient(connection, new BGPSessionFactory(parser));
+ public Future<? extends BGPSession> createClient(final BGPConnection connection, final ProtocolMessageFactory parser,
+ final ReconnectStrategy strategy) {
+ return this.dispatcher.createClient(connection, new BGPSessionFactory(parser), strategy);
}
public Dispatcher getDispatcher() {
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposalChecker;
import org.opendaylight.protocol.concepts.ListenerRegistration;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
import com.google.common.base.Preconditions;
*/
@Override
public BGPListenerRegistration registerUpdateListener(final BGPSessionListener listener) throws IOException {
+ // FIXME: BUG-58: fix this
+ final ReconnectStrategy strategy = null;
+
final BGPSession session;
try {
session = this.dispatcher.createClient(
- new BGPConnectionImpl(this.address, listener, this.proposal.getProposal(), this.checker), this.parser).get();
+ new BGPConnectionImpl(this.address, listener, this.proposal.getProposal(), this.checker), this.parser, strategy).get();
} catch (InterruptedException | ExecutionException e) {
throw new IOException("Failed to connect to peer", e);
}
import org.opendaylight.protocol.bgp.parser.BGPSession;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
/**
* Dispatcher class for creating BGP clients.
* @return client session
* @throws IOException
*/
- Future<? extends BGPSession> createClient(BGPConnection connection, ProtocolMessageFactory parser) throws IOException;
+ Future<? extends BGPSession> createClient(BGPConnection connection, ProtocolMessageFactory parser, final ReconnectStrategy strategy);
}
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionProposal;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
public class BGPImplTest {
doReturn("").when(this.parser).toString();
doReturn(null).when(this.future).get();
- doReturn(future).when(this.disp).createClient(any(BGPConnection.class), any(ProtocolMessageFactory.class));
+ doReturn(future).when(this.disp).createClient(any(BGPConnection.class), any(ProtocolMessageFactory.class), any(ReconnectStrategy.class));
}
@Test
*/
package org.opendaylight.protocol.bgp.testtool;
+import io.netty.util.concurrent.GlobalEventExecutor;
+
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import org.opendaylight.protocol.concepts.ASNumber;
import org.opendaylight.protocol.concepts.IPv4Address;
import org.opendaylight.protocol.framework.DispatcherImpl;
+import org.opendaylight.protocol.framework.NeverReconnectStrategy;
import org.opendaylight.protocol.framework.ProtocolMessageFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
logger.debug(address + " " + sessionListener + " " + proposal + " " + checker);
final InetSocketAddress addr = address;
- m.dispatcher.createClient(new BGPConnectionImpl(addr, sessionListener, proposal, checker), parser);
+ m.dispatcher.createClient(new BGPConnectionImpl(addr, sessionListener, proposal, checker), parser,
+ new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000));
}
}
import io.netty.util.concurrent.Future;
-import java.io.IOException;
import java.net.InetSocketAddress;
/**
* @return instance of ProtocolServer
*/
public Future<ProtocolServer> createServer(final InetSocketAddress address, final ProtocolConnectionFactory connectionFactory,
- final ProtocolSessionFactory<?> sfactory) throws IOException;
+ final ProtocolSessionFactory<?> sfactory);
/**
* Creates a client.
*
* @param connection connection specific attributes
* @param sfactory protocol session factory to create a specific session
- * @param handlerFactory protocol-specific channel handlers factory
+ * @param strategy Reconnection strategy to be used when initial connection fails
*
* @return session associated with this client
*/
- public <T extends ProtocolSession> Future<T> createClient(final ProtocolConnection connection, final ProtocolSessionFactory<T> sfactory) throws IOException;
+ public <T extends ProtocolSession> Future<T> createClient(final ProtocolConnection connection,
+ final ProtocolSessionFactory<T> sfactory, final ReconnectStrategy strategy);
}
}
@Override
- public <T extends ProtocolSession> Future<T> createClient(final ProtocolConnection connection, final ProtocolSessionFactory<T> sfactory) {
+ public <T extends ProtocolSession> Future<T> createClient(final ProtocolConnection connection, final ProtocolSessionFactory<T> sfactory, final ReconnectStrategy strategy) {
final Bootstrap b = new Bootstrap();
b.group(this.workerGroup);
b.channel(NioSocketChannel.class);
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import io.netty.util.concurrent.GlobalEventExecutor;
import java.io.IOException;
import java.net.ConnectException;
public SessionListener getListener() {
return ServerTest.this.pce;
}
- }, new SimpleSessionFactory(MAX_MSGSIZE)).get();
+ }, new SimpleSessionFactory(MAX_MSGSIZE), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000)).get();
final int maxAttempts = 1000;
int attempts = 0;
public SessionListener getListener() {
return listener;
}
- }, new SimpleSessionFactory(MAX_MSGSIZE)).get();
+ }, new SimpleSessionFactory(MAX_MSGSIZE), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000)).get();
fail("Connection succeeded unexpectedly");
} catch (ExecutionException e) {
import org.opendaylight.protocol.framework.Dispatcher;
import org.opendaylight.protocol.framework.ProtocolServer;
+import org.opendaylight.protocol.framework.ReconnectStrategy;
import org.opendaylight.protocol.pcep.PCEPConnection;
import org.opendaylight.protocol.pcep.PCEPConnectionFactory;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
*/
@Override
public Future<? extends PCEPSession> createClient(final PCEPConnection connection) throws IOException {
- return this.dispatcher.createClient(connection, new PCEPSessionFactoryImpl(this.maxUnknownMessages));
+ // FIXME: BUG-58: fix this
+ final ReconnectStrategy strategy = null;
+
+ return this.dispatcher.createClient(connection, new PCEPSessionFactoryImpl(this.maxUnknownMessages), strategy);
}
@Override