Make sure HoldTimer is running during BGP negotiation
[bgpcep.git] / framework / src / main / java / org / opendaylight / protocol / framework / Dispatcher.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.channel.ChannelFuture;
11 import io.netty.util.concurrent.Future;
12
13 import java.net.InetSocketAddress;
14
15 /**
16  * Dispatcher class for creating protocol servers and clients.
17  */
18 public interface Dispatcher {
19         /**
20          * Creates server. Each server needs factories to pass their instances to client sessions.
21          * 
22          * @param address address to which the server should be bound
23          * @param listenerFactory factory for creating protocol listeners, passed to the negotiator
24          * @param negotiatorFactory protocol session negotiator factory
25          * @param messageFactory message parser
26          * 
27          * @return ChannelFuture representing the binding process
28          */
29         public <M extends ProtocolMessage, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> ChannelFuture createServer(
30                         InetSocketAddress address,  final SessionListenerFactory<L> listenerFactory,
31                         SessionNegotiatorFactory<M, S, L> negotiatorFactory, ProtocolMessageFactory<M> messageFactory);
32
33         /**
34          * Creates a client.
35          * 
36          * @param address remote address
37          * @param listener session listener
38          * @param negotiatorFactory session negotiator factory
39          * @param messageFactory message parser
40          * @param connectStrategy Reconnection strategy to be used when initial connection fails
41          * 
42          * @return Future representing the connection process. Its result represents
43          *         the combined success of TCP connection as well as session negotiation.
44          */
45         public <M extends ProtocolMessage, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> Future<S> createClient(
46                         InetSocketAddress address, final L listener, SessionNegotiatorFactory<M, S, L> negotiatorFactory,
47                         ProtocolMessageFactory<M> messageFactory, ReconnectStrategy connectStrategy);
48
49         /**
50          * Creates a client.
51          * 
52          * @param address remote address
53          * @param listener session listener
54          * @param negotiatorFactory session negotiator factory
55          * @param messageFactory message parser
56          * @param connectStrategyFactory Factory for creating reconnection strategy to be used when initial connection fails
57          * @param reestablishStrategy Reconnection strategy to be used when the already-established session fails
58          * 
59          * @return Future representing the reconnection task. It will report
60          *         completion based on reestablishStrategy, e.g. success if
61          *         it indicates no further attempts should be made and failure
62          *         if it reports an error
63          */
64         public <M extends ProtocolMessage, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> Future<Void> createReconnectingClient(
65                         final InetSocketAddress address, final L listener, final SessionNegotiatorFactory<M, S, L> negotiatorFactory,
66                         final ProtocolMessageFactory<M> messageFactory,
67                         final ReconnectStrategyFactory connectStrategyFactory, final ReconnectStrategy reestablishStrategy);
68 }