* Stores usability for available capabilities.
*/
public interface PCEPCapability {
-
/**
* Sets stateful capabilities tlv in incoming builder.
*
* @param builder for TLVs included in PCEPOpenObject
*/
void setCapabilityProposal(InetSocketAddress address, TlvsBuilder builder);
-
- /**
- * Returs stateful capability state.
- *
- * @return true if capability is present
- */
- boolean isStateful();
}
.build());
}
- @Override
- public boolean isStateful() {
- return false;
- }
-
@Override
public String toString() {
return MoreObjects.toStringHelper(this).toString();
@MetaInfServices
public final class PCEPStatefulCapability implements PCEPCapability {
- private final boolean stateful;
private final boolean active;
private final boolean initiated;
private final boolean triggeredSync;
private final boolean includeDbVersion;
public PCEPStatefulCapability() {
- this(true, true, true, true, true, true, true);
+ this(true, true, true, true, true, true);
}
- public PCEPStatefulCapability(final boolean stateful, final boolean active, final boolean initiated,
- final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync,
- final boolean includeDbVersion) {
- this.stateful = stateful || active || triggeredSync || triggeredResync || deltaLspSync || includeDbVersion;
+ public PCEPStatefulCapability(final boolean active, final boolean initiated, final boolean triggeredSync,
+ final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion) {
this.active = active;
this.initiated = initiated;
this.triggeredSync = triggeredSync;
}
public PCEPStatefulCapability(final StatefulCapabilities config) {
- this(config.getStateful(), config.getActive(), config.getInitiated(), config.getTriggeredInitialSync(),
+ this(config.getActive(), config.getInitiated(), config.getTriggeredInitialSync(),
config.getTriggeredResync(), config.getDeltaLspSyncCapability(), config.getIncludeDbVersion());
}
@Override
public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
- if (stateful) {
- builder.addAugmentation(new Tlvs1Builder()
- .setStateful(new StatefulBuilder().setLspUpdateCapability(active)
- .addAugmentation(new Stateful1Builder().setInitiation(initiated).build())
- .addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller
- .pcep.sync.optimizations.rev200720.Stateful1Builder()
- .setTriggeredInitialSync(triggeredSync)
- .setTriggeredResync(triggeredResync)
- .setDeltaLspSyncCapability(deltaLspSync)
- .setIncludeDbVersion(includeDbVersion)
- .build())
- .build())
- .build());
- }
- }
-
- @Override
- public boolean isStateful() {
- return stateful;
+ builder.addAugmentation(new Tlvs1Builder()
+ .setStateful(new StatefulBuilder().setLspUpdateCapability(active)
+ .addAugmentation(new Stateful1Builder().setInitiation(initiated).build())
+ .addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller
+ .pcep.sync.optimizations.rev200720.Stateful1Builder()
+ .setTriggeredInitialSync(triggeredSync)
+ .setTriggeredResync(triggeredResync)
+ .setDeltaLspSyncCapability(deltaLspSync)
+ .setIncludeDbVersion(includeDbVersion)
+ .build())
+ .build())
+ .build());
}
public boolean isActive() {
default true;
}
- leaf stateful {
- type boolean;
- default true;
- }
-
leaf active {
type boolean;
default true;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.initiated.rev200720.Stateful1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.Tlvs1Builder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.stateful.capability.tlv.StatefulBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
public class PCEPStatefulCapabilityTest {
-
- private static final Tlvs EXPECTED_TLVS = new TlvsBuilder()
+ @Test
+ public void testPCEPStatefulCapability() {
+ final PCEPStatefulCapability sspf = new PCEPStatefulCapability(true, true, true, false, true, false);
+ assertTrue(sspf.isActive());
+ assertTrue(sspf.isInstant());
+ assertFalse(sspf.isTriggeredResync());
+ assertTrue(sspf.isTriggeredSync());
+ assertTrue(sspf.isDeltaLspSync());
+ assertTrue(sspf.isIncludeDbVersion());
+ final TlvsBuilder builder = new TlvsBuilder();
+ sspf.setCapabilityProposal(null, builder);
+ assertEquals(new TlvsBuilder()
.addAugmentation(new Tlvs1Builder()
.setStateful(new StatefulBuilder().setLspUpdateCapability(true)
.addAugmentation(new Stateful1Builder().setInitiation(true).build())
.build())
.build())
.build())
- .build();
-
- @Test
- public void testPCEPStatefulCapability() {
- final PCEPStatefulCapability sspf = new PCEPStatefulCapability(true, true, true, true, false, true, false);
- assertTrue(sspf.isActive());
- assertTrue(sspf.isInstant());
- assertTrue(sspf.isStateful());
- assertFalse(sspf.isTriggeredResync());
- assertTrue(sspf.isTriggeredSync());
- assertTrue(sspf.isDeltaLspSync());
- assertTrue(sspf.isIncludeDbVersion());
- final TlvsBuilder builder = new TlvsBuilder();
- sspf.setCapabilityProposal(null, builder);
- assertEquals(EXPECTED_TLVS, builder.build());
+ .build(), builder.build());
}
}
if (triggeredInitSync) {
Preconditions.checkArgument(includeDbv);
}
- return new PCEPStatefulCapability(true, true, true, triggeredInitSync, triggeredResync,
- incrementalSync, includeDbv);
+ return new PCEPStatefulCapability(true, true, triggeredInitSync, triggeredResync, incrementalSync, includeDbv);
}
private static ch.qos.logback.classic.Logger getRootLogger(final LoggerContext lc) {
package org.opendaylight.protocol.pcep.pcc.mock;
import io.netty.channel.Channel;
-import java.math.BigInteger;
-import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
import org.opendaylight.yangtools.yang.common.Uint64;
public class PCCIncrementalSyncTest extends PCCMockCommon {
-
- private final BigInteger lsp = BigInteger.valueOf(8);
/**
* Test Incremental Synchronization
* Create 8 lsp, then it disconnects after 5 sec and then after 5 sec reconnects with Pcc DBVersion 10
* After reconnection PCE has DBVersion 10, therefore there is 9 changes missed. 9 Pcrt + 1 Pcrt-Sync
*/
- private final String[] mainInputIncrementalSync = new String[]{"--local-address", this.localAddress.getHostString(),
- "--remote-address", InetSocketAddressUtil.toHostAndPort(this.remoteAddress).toString(), "--pcc", "1", "--lsp",
- this.lsp.toString(), "--log-level", "DEBUG", "-ka", "30", "-d", "120", "--reconnect", "-1",
+ private final String[] mainInputIncrementalSync = new String[]{"--local-address", localAddress.getHostString(),
+ "--remote-address", InetSocketAddressUtil.toHostAndPort(remoteAddress).toString(), "--pcc", "1", "--lsp",
+ "8", "--log-level", "DEBUG", "-ka", "30", "-d", "120", "--reconnect", "-1",
"--redelegation-timeout", "0", "--state-timeout", "-1", "--incremental-sync-procedure", "10", "5", "5"};
@Test
public void testSessionIncrementalSyncEstablishment() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final Uint64 numberOflspAndDBv = Uint64.valueOf(8);
- final Channel channel = createServer(factory, this.remoteAddress, new PCCServerPeerProposal(numberOflspAndDBv));
- Main.main(this.mainInputIncrementalSync);
+ final Channel channel = createServer(factory, remoteAddress, new PCCServerPeerProposal(numberOflspAndDBv));
+ Main.main(mainInputIncrementalSync);
final TestingSessionListener pceSessionListener = getListener(factory);
checkSynchronizedSession(8, pceSessionListener, numberOflspAndDBv);
Thread.sleep(6000);
@Override
protected List<PCEPCapability> getCapabilities() {
- final List<PCEPCapability> caps = new ArrayList<>();
- caps.add(new PCEPStatefulCapability(true, true, true, false, false, true, true));
- return caps;
+ return List.of(new PCEPStatefulCapability(true, true, false, false, true, true));
}
}
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
public void testSessionAvoidanceDesynchronizedEstablishment() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
- final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
+ final Channel channel = createServer(factory, remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(Uint64.TEN).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
@Override
protected List<PCEPCapability> getCapabilities() {
- final List<PCEPCapability> caps = new ArrayList<>();
- caps.add(new PCEPStatefulCapability(true, true, true, false,
- false, false, true));
- return caps;
+ return List.of(new PCEPStatefulCapability(true, true, false, false, false, true));
}
}
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
final int lspQuantity = 3;
final Uint64 numberOflspAndDBv = Uint64.valueOf(lspQuantity);
- final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
+ final Channel channel = createServer(factory, remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
checkSynchronizedSession(lspQuantity, pceSessionListener, numberOflspAndDBv);
- this.pccSessionListener.onMessage(session, createTriggerLspResync());
+ pccSessionListener.onMessage(session, createTriggerLspResync());
final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
checkResyncSession(Optional.of(lspQuantity), 4,8, null, numberOflspAndDBv, sessionListenerAfterReconnect);
channel.close().get();
.setLsp(lsp)
.setPath(new PathBuilder().build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder();
- ub.setUpdates(Collections.singletonList(rb.build()));
+ ub.setUpdates(List.of(rb.build()));
return new PcupdBuilder().setPcupdMessage(ub.build()).build();
}
@Override
protected List<PCEPCapability> getCapabilities() {
- final List<PCEPCapability> caps = new ArrayList<>();
- caps.add(new PCEPStatefulCapability(true, true, true, false, true, false, true));
- return caps;
+ return List.of(new PCEPStatefulCapability(true, true, false, true, false, true));
}
}
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.junit.Test;
final int lspQuantity = 3;
final Uint64 numberOflspAndDBv = Uint64.valueOf(lspQuantity);
- final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
+ final Channel channel = createServer(factory, remoteAddress, new PCCPeerProposal());
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
checkSynchronizedSession(lspQuantity, pceSessionListener, numberOflspAndDBv);
- this.pccSessionListener.onMessage(session, createTriggerLspResync());
+ pccSessionListener.onMessage(session, createTriggerLspResync());
final TestingSessionListener sessionListenerAfterReconnect = getListener(factory);
checkResyncSession(Optional.of(lspQuantity), 2, 6, null, numberOflspAndDBv, sessionListenerAfterReconnect);
channel.close().get();
final PathBuilder pb = new PathBuilder();
rb.setPath(pb.build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder();
- ub.setUpdates(Collections.singletonList(rb.build()));
+ ub.setUpdates(List.of(rb.build()));
return new PcupdBuilder().setPcupdMessage(ub.build()).build();
}
@Override
protected List<PCEPCapability> getCapabilities() {
- final List<PCEPCapability> caps = new ArrayList<>();
- caps.add(new PCEPStatefulCapability(true, true, true, false, true, false, true));
- return caps;
+ return List.of(new PCEPStatefulCapability(true, true, false, true, false, true));
}
}
import static org.junit.Assert.assertNotNull;
import io.netty.channel.Channel;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.pcep.PCEPCapability;
@Test
public void testSessionTriggeredSync() throws Exception {
final TestingSessionListenerFactory factory = new TestingSessionListenerFactory();
- final Channel channel = createServer(factory, this.remoteAddress, new PCCPeerProposal());
+ final Channel channel = createServer(factory, remoteAddress, new PCCPeerProposal());
final Uint64 numberOflspAndDBv = Uint64.valueOf(3);
final PCEPSession session = createPCCSession(numberOflspAndDBv).get();
assertNotNull(session);
final TestingSessionListener pceSessionListener = getListener(factory);
assertNotNull(pceSessionListener);
checkSynchronizedSession(0, pceSessionListener, Uint64.ZERO);
- this.pccSessionListener.onMessage(session, createTriggerMsg());
+ pccSessionListener.onMessage(session, createTriggerMsg());
checkSynchronizedSession(3, pceSessionListener, numberOflspAndDBv);
channel.close().get();
}
.setLsp(new LspBuilder().setPlspId(new PlspId(Uint32.ZERO)).setSync(Boolean.TRUE).build())
.setPath(new PathBuilder().build());
final PcupdMessageBuilder ub = new PcupdMessageBuilder();
- ub.setUpdates(Collections.singletonList(rb.build()));
+ ub.setUpdates(List.of(rb.build()));
return new PcupdBuilder().setPcupdMessage(ub.build()).build();
}
@Override
protected List<PCEPCapability> getCapabilities() {
- final List<PCEPCapability> caps = new ArrayList<>();
- caps.add(new PCEPStatefulCapability(true, true, true, true, false, false, true));
- return caps;
+ return List.of(new PCEPStatefulCapability(true, true, true, false, false, true));
}
}
.build());
}
- @Override
- public boolean isStateful() {
- return false;
- }
-
@Override
public String toString() {
return MoreObjects.toStringHelper(this).toString();
dispatcher.createServer(address, KeyMapping.of(), handlerRegistry, new DefaultPCEPSessionNegotiatorFactory(
new TestingSessionListenerFactory(),
new PCEPTimerProposal(keepAliveValue, deadTimerValue),
- List.of(new PCEPStatefulCapability(stateful, active, instant, false, false, false, false)),
+ stateful ? List.of(new PCEPStatefulCapability(active, instant, false, false, false, false)) : List.of(),
maxUnknownMessages, null)).get();
}
}
}
final var capabilityAug = topologyPcep.augmentation(TopologyPcep1.class);
final var capabilities = capabilityAug != null ? capabilityAug.getCapabilities() : null;
- if (capabilities != null && !capabilities.nonnullStateful().requireStateful()) {
+ if (capabilities != null && !capabilities.nonnullStateful().requireEnabled()) {
return null;
}
augment "/nt:network-topology/nt:topology/nt:topology-types/pn:topology-pcep" {
container capabilities {
container stateful {
+ leaf enabled {
+ type boolean;
+ default true;
+ }
+
uses opisc:stateful-capabilities;
}
leaf p2mp {