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.channel.ChannelFuture;
11 import io.netty.util.concurrent.Future;
13 import java.net.InetSocketAddress;
16 * Dispatcher class for creating protocol servers and clients.
18 public interface Dispatcher {
20 * Creates server. Each server needs factories to pass their instances to client sessions.
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
27 * @return ChannelFuture representing the binding process
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);
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
42 * @return Future representing the connection process. Its result represents
43 * the combined success of TCP connection as well as session negotiation.
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);
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
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
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);