import io.netty.channel.Channel;
import io.netty.util.concurrent.Promise;
-import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
/**
@NonNull SessionNegotiator getSessionNegotiator(
@NonNull PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
@NonNull Channel channel, @NonNull Promise<PCEPSession> promise);
-
- /**
- * Returns list containing PCEP Capabilities.
- *
- * @return PCEPCapabilities
- */
- @Deprecated(forRemoval = true)
- @NonNull List<PCEPCapability> getCapabilities();
}
import io.netty.util.concurrent.Promise;
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
public final class DefaultPCEPSessionNegotiator extends AbstractPCEPSessionNegotiator {
- private final PcepSessionErrorPolicy errorPolicy;
private final PCEPSessionListener listener;
+ private final int maxUnknownMessages;
public DefaultPCEPSessionNegotiator(final Promise<PCEPSession> promise, final Channel channel,
final PCEPSessionListener listener, final Uint8 sessionId, final Open localPrefs,
- final PcepSessionErrorPolicy errorPolicy, final PcepSessionTls tlsConfiguration) {
+ final Uint16 maxUnknownMessages, final PcepSessionTls tlsConfiguration) {
super(promise, channel, tlsConfiguration);
this.listener = requireNonNull(listener);
- this.errorPolicy = requireNonNull(errorPolicy);
+ this.maxUnknownMessages = maxUnknownMessages.toJava();
myLocalPrefs = new OpenBuilder()
.setKeepalive(localPrefs.getKeepalive())
.setDeadTimer(localPrefs.getDeadTimer())
public DefaultPCEPSessionNegotiator(final Promise<PCEPSession> promise, final Channel channel,
final PCEPSessionListener listener, final Uint8 sessionId, final Open localPrefs,
- final PcepSessionErrorPolicy errorPolicy) {
- this(promise, channel, listener, sessionId, localPrefs, errorPolicy, null);
+ final Uint16 maxUnknownMessages) {
+ this(promise, channel, listener, sessionId, localPrefs, maxUnknownMessages, null);
}
private final Open myLocalPrefs;
@Override
@VisibleForTesting
public PCEPSessionImpl createSession(final Channel channel, final Open localPrefs, final Open remotePrefs) {
- return new PCEPSessionImpl(listener, errorPolicy.requireMaxUnknownMessages().toJava(), channel, localPrefs,
- remotePrefs);
+ return new PCEPSessionImpl(listener, maxUnknownMessages, channel, localPrefs, remotePrefs);
}
@Override
import org.opendaylight.protocol.pcep.PCEPSession;
import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactoryDependencies;
import org.opendaylight.protocol.pcep.PCEPTimerProposal;
-import org.opendaylight.protocol.pcep.impl.spi.Util;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PcepDispatcherConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTimers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTls;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessionNegotiatorFactory {
- private final PCEPTimerProposal timers;
+ private final @NonNull PCEPTimerProposal timers;
private final @NonNull List<PCEPCapability> capabilities;
- private final PcepSessionErrorPolicy errorPolicy;
+ private final @NonNull Uint16 maxUnknownMessages;
private final PcepSessionTls tlsConfiguration;
public DefaultPCEPSessionNegotiatorFactory(final PcepSessionTimers timers, final List<PCEPCapability> capabilities,
- final PcepSessionErrorPolicy errorPolicy) {
- this(timers, capabilities, errorPolicy, errorPolicy instanceof PcepDispatcherConfig dc ? dc.getTls() : null);
+ final Uint16 maxUnknownMessages) {
+ this(timers, capabilities, maxUnknownMessages, null);
}
public DefaultPCEPSessionNegotiatorFactory(final PcepSessionTimers timers, final List<PCEPCapability> capabilities,
- final PcepSessionErrorPolicy errorPolicy, final PcepSessionTls tlsConfiguration) {
- this(new PCEPTimerProposal(timers), capabilities, errorPolicy, tlsConfiguration);
+ final Uint16 maxUnknownMessages, final PcepSessionTls tlsConfiguration) {
+ this(new PCEPTimerProposal(timers), capabilities, maxUnknownMessages, tlsConfiguration);
}
public DefaultPCEPSessionNegotiatorFactory(final PCEPTimerProposal timers, final List<PCEPCapability> capabilities,
- final PcepSessionErrorPolicy errorPolicy, final PcepSessionTls tlsConfiguration) {
+ final Uint16 maxUnknownMessages, final PcepSessionTls tlsConfiguration) {
this.timers = requireNonNull(timers);
this.capabilities = requireNonNull(capabilities);
- this.errorPolicy = requireNonNull(errorPolicy);
+ this.maxUnknownMessages = requireNonNull(maxUnknownMessages);
this.tlsConfiguration = tlsConfiguration;
}
- @Deprecated(forRemoval = true)
- @Override
- public List<PCEPCapability> getCapabilities() {
- return capabilities;
- }
-
@Override
protected AbstractPCEPSessionNegotiator createNegotiator(
final PCEPSessionNegotiatorFactoryDependencies sessionNegotiatorDependencies,
final Promise<PCEPSession> promise,
final Channel channel,
final Uint8 sessionId) {
+ final var address = (InetSocketAddress) channel.remoteAddress();
+ final var peerProposal = sessionNegotiatorDependencies.getPeerProposal();
+
+ final var builder = new TlvsBuilder();
+ for (final var capability : capabilities) {
+ capability.setCapabilityProposal(address, builder);
+ }
- final Open proposal = Util.createOpenObject((InetSocketAddress) channel.remoteAddress(), sessionId, timers,
- capabilities, sessionNegotiatorDependencies.getPeerProposal());
+ if (peerProposal != null) {
+ peerProposal.setPeerSpecificProposal(address, builder);
+ }
- return new DefaultPCEPSessionNegotiator(
- promise,
- channel,
- sessionNegotiatorDependencies.getListenerFactory().getSessionListener(),
- sessionId,
- proposal,
- errorPolicy,
- tlsConfiguration);
+ return new DefaultPCEPSessionNegotiator(promise, channel,
+ sessionNegotiatorDependencies.getListenerFactory().getSessionListener(), sessionId, new OpenBuilder()
+ .setSessionId(sessionId)
+ .setKeepalive(timers.keepAlive())
+ .setDeadTimer(timers.deadTimer())
+ .setTlvs(builder.build())
+ .build(), maxUnknownMessages, tlsConfiguration);
}
}
*/
package org.opendaylight.protocol.pcep.impl.spi;
-import java.net.InetSocketAddress;
import java.util.Collections;
-import java.util.List;
-import org.eclipse.jdt.annotation.Nullable;
-import org.opendaylight.protocol.pcep.PCEPCapability;
-import org.opendaylight.protocol.pcep.PCEPPeerProposal;
-import org.opendaylight.protocol.pcep.PCEPTimerProposal;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.PcerrBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcep.error.object.ErrorObjectBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.PcerrMessageBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.ErrorsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.SessionCaseBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.error.type.session._case.SessionBuilder;
-import org.opendaylight.yangtools.yang.common.Uint8;
/**
* Utilities used in pcep-impl.
.setErrorType(type).build())
.build();
}
-
- public static Open createOpenObject(final InetSocketAddress address, final Uint8 sessionId,
- final PCEPTimerProposal timers, final List<PCEPCapability> capabilities,
- final @Nullable PCEPPeerProposal peerProposal) {
- final var builder = new TlvsBuilder();
- for (final var capability : capabilities) {
- capability.setCapabilityProposal(address, builder);
- }
-
- if (peerProposal != null) {
- peerProposal.setPeerSpecificProposal(address, builder);
- }
-
- return new OpenBuilder()
- .setSessionId(sessionId)
- .setKeepalive(timers.keepAlive())
- .setDeadTimer(timers.deadTimer())
- .setTlvs(builder.build())
- .build();
- }
}
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Copyright (c) 2016 Brocade Communications Systems, Inc. and others. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v1.0 which accompanies this distribution,
- and is available at http://www.eclipse.org/legal/epl-v10.html
--->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
- xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
-
- <!-- Obtains the specific list of PCEPCapability OSGi services announced via
- META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability resources.
- -->
- <odl:specific-reference-list id="pcepCapabilities" interface="org.opendaylight.protocol.pcep.PCEPCapability"/>
-
- <odl:clustered-app-config id="pcepSessionConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PcepSessionConfig"/>
-
- <odl:clustered-app-config id="pcepDispatcherConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.PcepDispatcherConfig"/>
-
- <bean id="pcepSessionNegotiatorFactory" class="org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory">
- <argument ref="pcepSessionConfig"/>
- <argument ref="pcepCapabilities"/>
- <argument ref="pcepDispatcherConfig"/>
- </bean>
-
- <service ref="pcepSessionNegotiatorFactory" interface="org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory"/>
-</blueprint>
\ No newline at end of file
+++ /dev/null
-module pcep-app-config {
- namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:app-config";
- prefix "pcep-app-config";
-
- description
- "Configuration for the PCEP implementation.
-
- Copyright (c) 2016 Brocade Communications Systems, Inc. All rights reserved.
-
- This program and the accompanying materials are made available
- under the terms of the Eclipse Public License v1.0 which
- accompanies this distribution, and is available at
- http://www.eclipse.org/legal/epl-v10.html";
-
- revision "2016-07-07" {
- description
- "Initial revision.";
- }
-
- import pcep-config { prefix pc; }
-
- container pcep-session-config {
- // FIXME: BGPCEP-962: remove this container
- uses pc:pcep-session-timers;
- }
-
- container pcep-dispatcher-config {
- // FIXME: BGPCEP-962: remove this container
-
- uses pc:pcep-session-error-policy;
-
- container tls {
- presence true;
- uses pc:pcep-session-tls;
- }
- }
-}
import com.google.common.base.Ticker;
import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.GlobalEventExecutor;
+import org.eclipse.jdt.annotation.NonNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
-import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
import org.opendaylight.protocol.pcep.PCEPSessionListener;
import org.opendaylight.protocol.pcep.PCEPTerminationReason;
import org.opendaylight.protocol.pcep.impl.spi.Util;
import org.opendaylight.protocol.pcep.spi.PCEPErrors;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.pcep.config.session.config.TlsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Keepalive;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open;
@RunWith(MockitoJUnitRunner.Silent.class)
public class FiniteStateMachineTest extends AbstractPCEPSessionTest {
- @Mock
- private PcepSessionErrorPolicy errorPolicy;
+ private static final @NonNull Uint16 MAX_UNKNOWN_MESSAGES = Uint16.valueOf(20);
private DefaultPCEPSessionNegotiator serverSession;
private DefaultPCEPSessionNegotiator tlsSessionNegotiator;
@Before
public void setup() {
- doReturn(Uint16.valueOf(20)).when(errorPolicy).requireMaxUnknownMessages();
-
final var localPrefs = new OpenBuilder().setKeepalive(Uint8.ONE).build();
serverSession = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
- channel, listener, Uint8.ONE, localPrefs, errorPolicy);
+ channel, listener, Uint8.ONE, localPrefs, MAX_UNKNOWN_MESSAGES);
tlsSessionNegotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
- channel, listener, Uint8.ONE, localPrefs, errorPolicy, new TlsBuilder().build());
+ channel, listener, Uint8.ONE, localPrefs, MAX_UNKNOWN_MESSAGES, new TlsBuilder().build());
}
/**
final DefaultPCEPSessionNegotiator negotiator =
new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
channel, listener, Uint8.ONE, new OpenBuilder().setKeepalive(Uint8.ONE).build(),
- errorPolicy, SslContextFactoryTest.createTlsConfig());
+ MAX_UNKNOWN_MESSAGES, SslContextFactoryTest.createTlsConfig());
negotiator.channelActive(null);
assertEquals(1, msgsSend.size());
assertTrue(msgsSend.get(0) instanceof Starttls);
serverSession.handleMessage(kaMsg);
checkEquals(() -> {
for (final Notification<?> m : msgsSend) {
- if (m instanceof Pcerr) {
- final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0);
+ if (m instanceof Pcerr pcErr) {
+ final Errors obj = pcErr.getPcerrMessage().getErrors().get(0);
assertEquals(Uint8.ONE, obj.getErrorObject().getType());
assertEquals(Uint8.ONE, obj.getErrorObject().getValue());
}
import org.opendaylight.protocol.pcep.PCEPTimerProposal;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
private PCEPSessionNegotiatorFactoryDependencies negotiatorDependencies;
@Mock
private PCEPSessionListenerFactory listenerFactory;
- @Mock
- private PcepSessionErrorPolicy errorPolicy;
private MessageRegistry msgReg;
private PCEPSessionNegotiatorFactory negotiatorFactory;
@Before
public void setUp() {
- doReturn(Uint16.ZERO).when(errorPolicy).requireMaxUnknownMessages();
msgReg = new DefaultPCEPExtensionConsumerContext().getMessageHandlerRegistry();
negotiatorFactory = new DefaultPCEPSessionNegotiatorFactory(new PCEPTimerProposal(KEEP_ALIVE, DEAD_TIMER),
- List.of(), errorPolicy, null);
+ List.of(), Uint16.ZERO, null);
dispatcher = new PCEPDispatcherImpl();
import org.opendaylight.protocol.pcep.PCEPTimerProposal;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager;
-import org.opendaylight.protocol.pcep.pcc.mock.protocol.MockPcepSessionErrorPolicy;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCSessionListener;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.common.Uint8;
private PCEPSessionNegotiatorFactory getSessionNegotiatorFactory() {
return new DefaultPCEPSessionNegotiatorFactory(new PCEPTimerProposal(keepAlive, deadTimer),
- List.of(pcepCapabilities), MockPcepSessionErrorPolicy.ZERO, null);
+ List.of(pcepCapabilities), Uint16.ZERO, null);
}
}
+++ /dev/null
-/*
- * Copyright (c) 2023 PANTHEON.tech, s.r.o. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep.pcc.mock.protocol;
-
-import static java.util.Objects.requireNonNull;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
-import org.opendaylight.yangtools.yang.common.Uint16;
-
-public record MockPcepSessionErrorPolicy(Uint16 maxUnknownMessages) implements PcepSessionErrorPolicy {
- public static final MockPcepSessionErrorPolicy ZERO = new MockPcepSessionErrorPolicy(Uint16.ZERO);
-
- public MockPcepSessionErrorPolicy {
- requireNonNull(maxUnknownMessages);
- }
-
- @Override
- public Uint16 getMaxUnknownMessages() {
- return maxUnknownMessages;
- }
-
- @Override
- public Class<? extends PcepSessionErrorPolicy> implementedInterface() {
- throw new UnsupportedOperationException();
- }
-}
import org.opendaylight.protocol.pcep.PCEPTimerProposal;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
-import org.opendaylight.protocol.pcep.pcc.mock.protocol.MockPcepSessionErrorPolicy;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class PCCDispatcherImplTest {
private final DefaultPCEPSessionNegotiatorFactory nf = new DefaultPCEPSessionNegotiatorFactory(
- new PCEPTimerProposal(Uint8.TEN, Uint8.valueOf(40)), List.of(), MockPcepSessionErrorPolicy.ZERO, null);
+ new PCEPTimerProposal(Uint8.TEN, Uint8.valueOf(40)), List.of(), Uint16.ZERO, null);
private PCCDispatcherImpl dispatcher;
private PCEPDispatcherImpl pcepDispatcher;
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
import org.opendaylight.protocol.pcep.pcc.mock.api.PCCTunnelManager;
-import org.opendaylight.protocol.pcep.pcc.mock.protocol.MockPcepSessionErrorPolicy;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCSessionListener;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.lsp.object.Lsp;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.pcrpt.message.pcrpt.message.Reports;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Message;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint64;
import org.opendaylight.yangtools.yang.common.Uint8;
private PCEPSessionNegotiatorFactory getSessionNegotiatorFactory() {
return new DefaultPCEPSessionNegotiatorFactory(new PCEPTimerProposal(KEEP_ALIVE, DEAD_TIMER),
- getCapabilities(), MockPcepSessionErrorPolicy.ZERO, null);
+ getCapabilities(), Uint16.ZERO, null);
}
TestingSessionListener getListener(final TestingSessionListenerFactory factory) {
import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class Main {
-
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
+ // FIXME: inline as a text block
private static final String USAGE = "DESCRIPTION:\n"
+ "\tCreates a server with given parameters. As long as it runs, it accepts connections "
+ "from PCCs.\n" + "USAGE:\n"
+ "With no parameters, this help is printed.";
private static final int KA_TO_DEADTIMER_RATIO = 4;
- private static final Uint8 KA_DEFAULT = Uint8.valueOf(30);
- private static final PcepSessionErrorPolicy ERROR_POLICY = new PcepSessionErrorPolicy() {
- @Override
- public Uint16 getMaxUnknownMessages() {
- return Uint16.valueOf(5);
- }
-
- @Override
- public Class<? extends PcepSessionErrorPolicy> implementedInterface() {
- throw new UnsupportedOperationException();
- }
- };
private Main() {
}
InetSocketAddress address = null;
- Uint8 keepAliveValue = KA_DEFAULT;
+ Uint8 keepAliveValue = Uint8.valueOf(30);
Uint8 deadTimerValue = Uint8.ZERO;
+ // FIXME: add a command-line option for this
+ Uint16 maxUnknownMessages = Uint16.valueOf(5);
boolean stateful = false;
boolean active = false;
boolean instant = false;
dispatcher.createServer(address, KeyMapping.of(), handlerRegistry,
new DefaultPCEPSessionNegotiatorFactory(new PCEPTimerProposal(keepAliveValue, deadTimerValue),
List.of(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false)),
- ERROR_POLICY, null), new TestToolPCEPNegotiatorDependencies()).get();
+ maxUnknownMessages, null), new TestToolPCEPNegotiatorDependencies()).get();
}
}
import org.opendaylight.protocol.pcep.pcc.mock.protocol.PCCDispatcherImpl;
import org.opendaylight.protocol.pcep.spi.pojo.DefaultPCEPExtensionConsumerContext;
import org.opendaylight.protocol.util.InetSocketAddressUtil;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
public final class PCCMock {
- private static final PcepSessionErrorPolicy ERROR_POLICY = new PcepSessionErrorPolicy() {
- @Override
- public Uint16 getMaxUnknownMessages() {
- return Uint16.ZERO;
- }
-
- @Override
- public Class<? extends PcepSessionErrorPolicy> implementedInterface() {
- throw new UnsupportedOperationException();
- }
- };
-
private PCCMock() {
// Hidden on purpose
}
public static void main(final String[] args) throws InterruptedException, ExecutionException {
checkArgument(args.length > 0, "Host and port of server must be provided.");
final var snf = new DefaultPCEPSessionNegotiatorFactory(
- new PCEPTimerProposal(Uint8.valueOf(30), Uint8.valueOf(120)), List.of(), ERROR_POLICY, null);
+ new PCEPTimerProposal(Uint8.valueOf(30), Uint8.valueOf(120)), List.of(), Uint16.ZERO, null);
final var serverHostAndPort = HostAndPort.fromString(args[0]);
final var serverAddr = new InetSocketAddress(serverHostAndPort.getHost(),
serverHostAndPort.getPortOrDefault(12345));
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.protocol.concepts.KeyMapping;
+import org.opendaylight.protocol.pcep.PCEPTimerProposal;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IetfInetUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev220720.graph.topology.GraphKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.pcep.stats.provider.config.rev220730.TopologyPcep1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionTls;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.Node1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TopologyTypes1;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.common.Uint16;
final class PCEPTopologyConfiguration implements Immutable {
private static final long DEFAULT_UPDATE_INTERVAL = TimeUnit.SECONDS.toNanos(5);
private final @NonNull InetSocketAddress address;
private final @NonNull GraphKey graphKey;
private final @NonNull KeyMapping keys;
+ private final @NonNull PCEPTimerProposal timerProposal;
+ private final @NonNull Uint16 maxUnknownMessages;
+ private final @Nullable PcepSessionTls tls;
private final long updateIntervalNanos;
private final short rpcTimeout;
- PCEPTopologyConfiguration(final @NonNull InetSocketAddress address, final @NonNull KeyMapping keys,
- final @NonNull GraphKey graphKey, final short rpcTimeout, final long updateIntervalNanos) {
+ PCEPTopologyConfiguration(final InetSocketAddress address, final KeyMapping keys, final GraphKey graphKey,
+ final short rpcTimeout, final long updateIntervalNanos, final PCEPTimerProposal timerProposal,
+ final Uint16 maxUnknownMessages, final @Nullable PcepSessionTls tls) {
this.address = requireNonNull(address);
this.keys = requireNonNull(keys);
this.graphKey = requireNonNull(graphKey);
this.rpcTimeout = rpcTimeout;
this.updateIntervalNanos = updateIntervalNanos;
+ this.timerProposal = requireNonNull(timerProposal);
+ this.maxUnknownMessages = requireNonNull(maxUnknownMessages);
+ this.tls = tls;
}
static @Nullable PCEPTopologyConfiguration of(final @NonNull Topology topology) {
return new PCEPTopologyConfiguration(
getInetSocketAddress(sessionConfig.getListenAddress(), sessionConfig.getListenPort()),
constructKeys(topology.getNode()), constructGraphKey(sessionConfig.getTedName()),
- sessionConfig.getRpcTimeout(), updateInterval);
+ sessionConfig.getRpcTimeout(), updateInterval, new PCEPTimerProposal(sessionConfig),
+ sessionConfig.requireMaxUnknownMessages(), sessionConfig.getTls());
}
short getRpcTimeout() {
return graphKey;
}
+ @NonNull PCEPTimerProposal getTimerProposal() {
+ return timerProposal;
+ }
+
+ @NonNull Uint16 getMaxUnknownMessages() {
+ return maxUnknownMessages;
+ }
+
+ @Nullable PcepSessionTls getTls() {
+ return tls;
+ }
+
private static @NonNull KeyMapping constructKeys(final @Nullable Map<NodeKey, Node> nodes) {
if (nodes == null) {
return KeyMapping.of();
import io.netty.channel.ChannelFuture;
import io.netty.channel.epoll.EpollChannelOption;
import java.util.Arrays;
+import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.protocol.pcep.PCEPCapability;
+import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev181109.NetworkTopologyPcepProgrammingService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.NetworkTopologyPcepService;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
synchronized void updateConfiguration(final @Nullable PCEPTopologyConfiguration newConfiguration) {
// FIXME: BGPCEP-960: this check should be a one-time thing in PCEPTopologyTracker startup once we have OSGi DS
- final var effectiveConfig = dependencies.getPCEPSessionNegotiatorFactory().getCapabilities().stream()
- .anyMatch(PCEPCapability::isStateful) ? newConfiguration : null;
+ final var effectiveConfig = dependencies.getCapabilities().stream().anyMatch(PCEPCapability::isStateful)
+ ? newConfiguration : null;
applyConfiguration(effectiveConfig);
}
return;
}
+ // FIXME: can we apply this less aggressively to just routing it through manager to the negotiator factory?
+ final var currentTimerProposal = currentConfig.getTimerProposal();
+ final var newTimerProposal = newConfiguration.getTimerProposal();
+ if (!currentTimerProposal.equals(newTimerProposal)) {
+ LOG.info("Topology Provider {} timer proposal changed from {} to {}, restarting", topologyId(),
+ currentTimerProposal, newTimerProposal);
+ applyConfiguration(null);
+ applyConfiguration(newConfiguration);
+ return;
+ }
+
+ // FIXME: can we apply this less aggressively to just routing it through manager to the negotiator factory?
+ final var currentMaxUnkownMessages = currentConfig.getMaxUnknownMessages();
+ final var newMaxUnknownMessages = newConfiguration.getMaxUnknownMessages();
+ if (!currentMaxUnkownMessages.equals(newMaxUnknownMessages)) {
+ LOG.info("Topology Provider {} max-unknown-messages changed from {} to {}, restarting", topologyId(),
+ currentMaxUnkownMessages, newMaxUnknownMessages);
+ applyConfiguration(null);
+ applyConfiguration(newConfiguration);
+ return;
+ }
+
+ // FIXME: can we apply this less aggressively to just routing it through manager to the negotiator factory?
+ final var currentTls = currentConfig.getTls();
+ final var newTls = newConfiguration.getTls();
+ if (!Objects.equals(currentTls, newTls)) {
+ LOG.info("Topology Provider {} TLS changed from {} to {}, restarting", topologyId(), currentTls, newTls);
+ applyConfiguration(null);
+ applyConfiguration(newConfiguration);
+ return;
+ }
+
// TCP-MD5 configuration is propagated from the server channel to individual channels. For any node that has
// changed this configuration we need to tear down any existing session.
final var currentKeys = currentConfig.getKeys().asMap();
LOG.info("PCEP Topology Provider {} starting server channel", topologyId());
final var channelFuture = dependencies.getPCEPDispatcher().createServer(currentConfig.getAddress(),
currentConfig.getKeys(), dependencies.getMessageRegistry(),
- dependencies.getPCEPSessionNegotiatorFactory(),
+ new DefaultPCEPSessionNegotiatorFactory(currentConfig.getTimerProposal(), dependencies.getCapabilities(),
+ currentConfig.getMaxUnknownMessages(), currentConfig.getTls()),
new PCEPSessionNegotiatorFactoryDependenciesImpl(manager, proposal));
channelFuture.addListener(ignored -> enableRPCs(future, channelFuture));
}
package org.opendaylight.bgpcep.pcep.topology.provider;
import io.netty.util.Timer;
+import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.opendaylight.bgpcep.pcep.server.PceServerProvider;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
import org.opendaylight.protocol.pcep.MessageRegistry;
+import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
/**
* Provides required dependencies for PCEPTopologyProviderProvider instantiation.
MessageRegistry getMessageRegistry();
/**
- * PCEP Session Negotiator Factory.
+ * Returns list containing PCEP Capabilities.
*
- * @return Negotiator factory
+ * @return PCEPCapabilities
*/
- PCEPSessionNegotiatorFactory getPCEPSessionNegotiatorFactory();
+ List<PCEPCapability> getCapabilities();
/**
* PCEP Dispatcher.
import static java.util.Objects.requireNonNull;
import static org.opendaylight.bgpcep.pcep.topology.provider.TopologyUtils.friendlyId;
+import com.google.common.collect.ImmutableList;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timeout;
import io.netty.util.Timer;
import io.netty.util.TimerTask;
import java.util.Collection;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.protocol.pcep.MessageRegistry;
+import org.opendaylight.protocol.pcep.PCEPCapability;
import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory;
import org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.topology.stats.rpc.rev190321.PcepTopologyStatsRpcService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev220730.TopologyTypes1;
// Services we are using
final @NonNull InstructionSchedulerFactory instructionSchedulerFactory;
final @NonNull ClusterSingletonServiceProvider singletonService;
- private final @NonNull PCEPSessionNegotiatorFactory sessionNegotiatorFactory;
private final @NonNull RpcProviderService rpcProviderRegistry;
private final @NonNull PceServerProvider pceServerProvider;
private final @NonNull MessageRegistry messageRegistry;
// Statistics RPCs
private final @NonNull TopologyStatsRpcServiceImpl statsRpcs;
+ // FIXME: route to org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory
+ private final @NonNull ImmutableList<PCEPCapability> capabilities;
+
// We are reusing our monitor as the universal lock. We have to account for three distinct threads competing for
// our state:
// 1) the typical DTCL callback thread invoking onDataTreeChanged()
public PCEPTopologyTracker(final DataBroker dataBroker, final ClusterSingletonServiceProvider singletonService,
final RpcProviderService rpcProviderRegistry, final PCEPExtensionConsumerContext extensions,
- final PCEPSessionNegotiatorFactory sessionNegotiatorFactory,
- final PCEPDispatcher pcepDispatcher, final InstructionSchedulerFactory instructionSchedulerFactory,
- final PceServerProvider pceServerProvider) {
+ final List<PCEPCapability> capabilities, final PCEPDispatcher pcepDispatcher,
+ final InstructionSchedulerFactory instructionSchedulerFactory, final PceServerProvider pceServerProvider) {
this.dataBroker = requireNonNull(dataBroker);
this.singletonService = requireNonNull(singletonService);
this.rpcProviderRegistry = requireNonNull(rpcProviderRegistry);
messageRegistry = extensions.getMessageHandlerRegistry();
- this.sessionNegotiatorFactory = requireNonNull(sessionNegotiatorFactory);
this.pcepDispatcher = requireNonNull(pcepDispatcher);
this.instructionSchedulerFactory = requireNonNull(instructionSchedulerFactory);
this.pceServerProvider = requireNonNull(pceServerProvider);
+ this.capabilities = ImmutableList.copyOf(capabilities);
statsProvider = new TopologyStatsProvider(timer);
statsRpcs = new TopologyStatsRpcServiceImpl(dataBroker);
statsReg = rpcProviderRegistry.registerRpcImplementation(PcepTopologyStatsRpcService.class, statsRpcs);
}
@Override
- public PCEPSessionNegotiatorFactory getPCEPSessionNegotiatorFactory() {
- return sessionNegotiatorFactory;
+ public List<PCEPCapability> getCapabilities() {
+ return capabilities;
}
@Override
terms of the Eclipse Public License v1.0 which accompanies this distribution,
and is available at http://www.eclipse.org/legal/epl-v10.html
-->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+ xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
+ <!--
+ Obtains the specific list of PCEPCapability OSGi services announced via
+ META-INF/services/org.opendaylight.protocol.pcep.PCEPCapability resources.
+ -->
+ <odl:specific-reference-list id="pcepCapabilities" interface="org.opendaylight.protocol.pcep.PCEPCapability"/>
+
<reference id="dataBroker" interface="org.opendaylight.mdsal.binding.api.DataBroker"/>
<reference id="rpcProviderService" interface="org.opendaylight.mdsal.binding.api.RpcProviderService"/>
<reference id="pcepExtensionContext" interface="org.opendaylight.protocol.pcep.spi.PCEPExtensionConsumerContext"/>
- <reference id="sessionNegotiatorFactory" interface="org.opendaylight.protocol.pcep.PCEPSessionNegotiatorFactory"/>
<reference id="pcepDispatcher" interface="org.opendaylight.protocol.pcep.PCEPDispatcher"/>
<reference id="clusterSingletonServiceProvider"
interface="org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider"/>
<argument ref="clusterSingletonServiceProvider"/>
<argument ref="rpcProviderService"/>
<argument ref="pcepExtensionContext"/>
- <argument ref="sessionNegotiatorFactory"/>
+ <argument ref="pcepCapabilities"/>
<argument ref="pcepDispatcher"/>
<argument ref="intructionFactory"/>
<argument ref="pceServerProvider"/>
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.graph.rev220720.graph.topology.GraphKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.config.rev230112.PcepSessionErrorPolicy;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.Ero;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.EroBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route.object.ero.Subobject;
private PCEPTopologyProviderDependencies topologyDependencies;
@Mock
private Promise<PCEPSession> promise;
- @Mock
- private PcepSessionErrorPolicy errorPolicy;
private final Timer timer = new HashedWheelTimer();
private DefaultPCEPSessionNegotiator neg;
doReturn(timer).when(topologyDependencies).getTimer();
doReturn(null).when(topologyDependencies).getPceServerProvider();
- doReturn(Uint16.valueOf(5)).when(errorPolicy).requireMaxUnknownMessages();
-
manager = customizeSessionManager(new ServerSessionManager(TOPO_IID, topologyDependencies,
new GraphKey("graph-test"), RPC_TIMEOUT, TimeUnit.SECONDS.toNanos(5)));
startSessionManager();
neg = new DefaultPCEPSessionNegotiator(promise, clientListener, manager.getSessionListener(), Uint8.ONE,
- localPrefs, errorPolicy);
+ localPrefs, Uint16.valueOf(5));
topologyRpcs = new TopologyRPCs(manager);
}