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.bgp.rib.impl;
10 import io.netty.util.HashedWheelTimer;
11 import io.netty.util.Timer;
12 import io.netty.util.concurrent.Future;
14 import java.net.InetSocketAddress;
16 import org.opendaylight.protocol.bgp.parser.BGPMessage;
17 import org.opendaylight.protocol.bgp.parser.BGPSession;
18 import org.opendaylight.protocol.bgp.parser.BGPSessionListener;
19 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPDispatcher;
20 import org.opendaylight.protocol.bgp.rib.impl.spi.BGPSessionPreferences;
21 import org.opendaylight.protocol.framework.Dispatcher;
22 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
23 import org.opendaylight.protocol.framework.ReconnectStrategy;
25 import com.google.common.base.Preconditions;
28 * Implementation of BGPDispatcher.
30 public final class BGPDispatcherImpl implements BGPDispatcher {
31 private final Timer timer = new HashedWheelTimer();
32 private final ProtocolMessageFactory<BGPMessage> parser;
33 private final Dispatcher dispatcher;
35 public BGPDispatcherImpl(final Dispatcher dispatcher, final ProtocolMessageFactory<BGPMessage> parser) {
36 this.dispatcher = Preconditions.checkNotNull(dispatcher);
37 this.parser = Preconditions.checkNotNull(parser);
41 public Future<? extends BGPSession> createClient(final InetSocketAddress address, final BGPSessionPreferences preferences,
42 final BGPSessionListener listener, final ReconnectStrategy strategy) {
43 return this.dispatcher.createClient(address, listener, new BGPSessionNegotiatorFactory(timer, preferences), parser, strategy);
46 public Dispatcher getDispatcher() {
47 return this.dispatcher;