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 javax.annotation.Nonnull;
13 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
14 import org.opendaylight.protocol.pcep.PCEPSessionListener;
15 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
16 import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
17 import org.opendaylight.protocol.pcep.SessionNegotiator;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * SessionNegotiator which takes care of making sure sessions between PCEP peers are kept unique. This needs to be
23 * further subclassed to provide either a client or server factory.
25 public abstract class AbstractPCEPSessionNegotiatorFactory implements PCEPSessionNegotiatorFactory<PCEPSessionImpl> {
27 private static final Logger LOG = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
29 private final PCEPPeerRegistry sessionRegistry = new PCEPPeerRegistry();
32 * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
34 * @param promise Session promise to be completed by the negotiator
35 * @param channel Associated channel
36 * @param sessionId Session ID assigned to the resulting session
37 * @return a PCEP session negotiator
39 protected abstract AbstractPCEPSessionNegotiator createNegotiator(
40 @Nonnull PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
41 Promise<PCEPSessionImpl> promise,
42 Channel channel, short sessionId);
45 public final SessionNegotiator getSessionNegotiator(final PCEPSessionNegotiatorFactoryDependencies dependencies,
46 final Channel channel, final Promise<PCEPSessionImpl> promise) {
48 LOG.debug("Instantiating bootstrap negotiator for channel {}", channel);
49 return new PCEPSessionNegotiator(channel, promise, dependencies, this);
52 public PCEPPeerRegistry getSessionRegistry() {
53 return this.sessionRegistry;