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.pcep.impl;
10 import io.netty.channel.Channel;
11 import io.netty.util.concurrent.Promise;
12 import org.opendaylight.protocol.pcep.PCEPSession;
13 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
14 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
15 import org.opendaylight.protocol.pcep.SessionNegotiator;
16 import org.opendaylight.yangtools.yang.common.Uint8;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * SessionNegotiator which takes care of making sure sessions between PCEP peers are kept unique. This needs to be
22 * further subclassed to provide either a client or server factory.
24 public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessionNegotiatorFactory {
25 private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
27 private final PCEPPeerRegistry sessionRegistry = new PCEPPeerRegistry();
30 * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
32 * @param snd PCEP Session Negotiator dependencies
33 * @param promise Session promise to be completed by the negotiator
34 * @param channel Associated channel
35 * @param sessionId Session ID assigned to the resulting session
36 * @return a PCEP session negotiator
38 protected abstract AbstractPCEPSessionNegotiator createNegotiator(
39 PCEPSessionNegotiatorFactoryDependencies snd,
40 Promise<PCEPSession> promise,
41 Channel channel, Uint8 sessionId);
44 public final SessionNegotiator getSessionNegotiator(final PCEPSessionNegotiatorFactoryDependencies dependencies,
45 final Channel channel, final Promise<PCEPSession> promise) {
47 LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
48 return new PCEPSessionNegotiator(channel, promise, dependencies, this);
51 public PCEPPeerRegistry getSessionRegistry() {
52 return sessionRegistry;