<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
</project>
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev220310.GetConstrainedPathOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.path.computation.rev220310.PathComputationService;
import org.opendaylight.yangtools.concepts.Registration;
-import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.osgi.service.component.annotations.Activate;
if (cgraph == null) {
output.setStatus(ComputationStatus.Failed);
return RpcResultBuilder.<GetConstrainedPathOutput>failed()
- .withError(RpcError.ErrorType.RPC, "Unknown Graph Name").buildFuture();
+ .withError(ErrorType.RPC, "Unknown Graph Name").buildFuture();
}
/* get a new Path Computation Algorithm according to Input choice */
if (algo == null) {
output.setStatus(ComputationStatus.Failed);
return RpcResultBuilder.<GetConstrainedPathOutput>failed()
- .withError(RpcError.ErrorType.RPC, "Unknown Path Computation Algorithm").buildFuture();
+ .withError(ErrorType.RPC, "Unknown Path Computation Algorithm").buildFuture();
}
/*
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class AppPeerBenchmark implements OdlBgpAppPeerBenchmarkService, TransactionChainListener, AutoCloseable {
+public final class AppPeerBenchmark implements OdlBgpAppPeerBenchmarkService, TransactionChainListener, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(AppPeerBenchmark.class);
public AppPeerBenchmark(final DataBroker bindingDataBroker, final RpcProviderService rpcProviderRegistry,
final String appRibId) {
this.appRibId = requireNonNull(appRibId);
- this.txChain = bindingDataBroker.createMergingTransactionChain(this);
+ txChain = bindingDataBroker.createMergingTransactionChain(this);
- this.appIID = InstanceIdentifier.builder(ApplicationRib.class,
+ appIID = InstanceIdentifier.builder(ApplicationRib.class,
new ApplicationRibKey(new ApplicationRibId(appRibId))).build();
- this.routesIId = this.appIID
+ routesIId = appIID
.child(Tables.class, new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class))
.child(Ipv4RoutesCase.class, Ipv4Routes.class);
- this.rpcRegistration = rpcProviderRegistry.registerRpcImplementation(OdlBgpAppPeerBenchmarkService.class, this);
+ rpcRegistration = rpcProviderRegistry.registerRpcImplementation(OdlBgpAppPeerBenchmarkService.class, this);
LOG.info("BGP Application Peer Benchmark Application started.");
}
public void start() {
- LOG.debug("Instantiating App Peer Benchmark : {}", this.appRibId);
+ LOG.debug("Instantiating App Peer Benchmark : {}", appRibId);
final ApplicationRib appRib = new ApplicationRibBuilder().setId(new ApplicationRibId(
- new ApplicationRibId(this.appRibId))).setTables(EMPTY_TABLES).build();
+ new ApplicationRibId(appRibId))).setTables(EMPTY_TABLES).build();
- final WriteTransaction wTx = this.txChain.newWriteOnlyTransaction();
- wTx.put(LogicalDatastoreType.CONFIGURATION, this.appIID, appRib);
+ final WriteTransaction wTx = txChain.newWriteOnlyTransaction();
+ wTx.put(LogicalDatastoreType.CONFIGURATION, appIID, appRib);
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
- LOG.info("Empty Structure created for Application Peer Benchmark {}", AppPeerBenchmark.this.appRibId);
+ LOG.info("Empty Structure created for Application Peer Benchmark {}", appRibId);
}
@Override
public void onFailure(final Throwable throwable) {
- LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}",
- AppPeerBenchmark.this.appRibId, throwable);
+ LOG.error("Failed to create Empty Structure for Application Peer Benchmark {}", appRibId, throwable);
}
}, MoreExecutors.directExecutor());
}
final long duration = addRoute(input.getPrefix(), input.getNexthop(), input.getCount(), input.getBatchsize());
final long rate = countRate(duration, input.getCount());
- final AddPrefixOutputBuilder outputbuilder = new AddPrefixOutputBuilder();
- outputbuilder.setResult(createResult(input.getCount(), duration, rate));
- final AddPrefixOutput output = outputbuilder.build();
- return RpcResultBuilder.success(output).buildFuture();
+ return RpcResultBuilder.success(
+ new AddPrefixOutputBuilder().setResult(createResult(input.getCount(), duration, rate)).build())
+ .buildFuture();
}
@Override
final long duration = deleteRoute(input.getPrefix(), input.getCount(), input.getBatchsize());
final long rate = countRate(duration, input.getCount());
- final DeletePrefixOutputBuilder outputbuilder = new DeletePrefixOutputBuilder();
- outputbuilder.setResult(createResult(input.getCount(), duration, rate));
- final DeletePrefixOutput output = outputbuilder.build();
- return RpcResultBuilder.success(output).buildFuture();
+ return RpcResultBuilder.success(
+ new DeletePrefixOutputBuilder().setResult(createResult(input.getCount(), duration, rate)).build())
+ .buildFuture();
}
@Override
public void close() {
- this.rpcRegistration.close();
- final WriteTransaction dTx = this.txChain.newWriteOnlyTransaction();
- dTx.delete(LogicalDatastoreType.CONFIGURATION, this.appIID);
+ rpcRegistration.close();
+ final WriteTransaction dTx = txChain.newWriteOnlyTransaction();
+ dTx.delete(LogicalDatastoreType.CONFIGURATION, appIID);
try {
dTx.commit().get();
} catch (final InterruptedException | ExecutionException e) {
LOG.warn("Failed to clean-up BGP Application RIB.", e);
}
- this.txChain.close();
+ txChain.close();
LOG.info("BGP Application Peer Benchmark Application closed.");
}
@VisibleForTesting
InstanceIdentifier<Ipv4Routes> getIpv4RoutesIID() {
- return this.routesIId;
+ return routesIId;
}
private long addRoute(final Ipv4Prefix ipv4Prefix, final Ipv4AddressNoZone nextHop, final Uint32 count,
private long processRoutes(final Ipv4Prefix ipv4Prefix, final Uint32 count, final Uint32 batch,
final Attributes attributes) {
- WriteTransaction wt = this.txChain.newWriteOnlyTransaction();
+ WriteTransaction wt = txChain.newWriteOnlyTransaction();
String address = getAdddressFromPrefix(ipv4Prefix);
final long countLong = count.longValue();
final long batchLong = batch.longValue();
for (int i = 1; i <= countLong; i++) {
final Ipv4RouteKey routeKey = new Ipv4RouteKey(NON_PATH_ID, createKey(address));
final KeyedInstanceIdentifier<Ipv4Route, Ipv4RouteKey> routeIId =
- this.routesIId.child(Ipv4Route.class, routeKey);
+ routesIId.child(Ipv4Route.class, routeKey);
if (attributes != null) {
- final Ipv4RouteBuilder ipv4RouteBuilder = new Ipv4RouteBuilder();
- ipv4RouteBuilder.setRouteKey(routeKey.getRouteKey());
- ipv4RouteBuilder.setPrefix(new Ipv4Prefix(routeKey.getRouteKey()));
- ipv4RouteBuilder.withKey(routeKey);
- ipv4RouteBuilder.setAttributes(attributes);
- final Ipv4Route ipv4Route = ipv4RouteBuilder.build();
- wt.put(LogicalDatastoreType.CONFIGURATION, routeIId,
- ipv4Route);
+ wt.put(LogicalDatastoreType.CONFIGURATION, routeIId, new Ipv4RouteBuilder()
+ .setRouteKey(routeKey.getRouteKey())
+ .setPrefix(new Ipv4Prefix(routeKey.getRouteKey()))
+ .withKey(routeKey)
+ .setAttributes(attributes)
+ .build());
} else {
wt.delete(LogicalDatastoreType.CONFIGURATION, routeIId);
}
LOG.error("Failed commit", trw);
}
}, MoreExecutors.directExecutor());
- wt = this.txChain.newWriteOnlyTransaction();
+ wt = txChain.newWriteOnlyTransaction();
}
address = increasePrefix(address);
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
*/
package org.opendaylight.protocol.bgp.cli.utils;
-import static org.opendaylight.protocol.bgp.cli.utils.GlobalStateCliUtils.displayRibOperationalState;
-import static org.opendaylight.protocol.bgp.cli.utils.NeighborStateCliUtils.displayNeighborOperationalState;
-import static org.opendaylight.protocol.bgp.cli.utils.PeerGroupStateCliUtils.displayPeerOperationalState;
-
import java.io.PrintStream;
import java.util.concurrent.ExecutionException;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
*/
public final class BGPOperationalStateUtils {
private static final Logger LOG = LoggerFactory.getLogger(BGPOperationalStateUtils.class);
- static final InstanceIdentifier<Protocols> PROTOCOLS_IID = InstanceIdentifier.create(NetworkInstances.class)
- .child(NetworkInstance.class, new NetworkInstanceKey("global-bgp")).child(Protocols.class);
+ static final InstanceIdentifier<Protocols> PROTOCOLS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
+ .child(NetworkInstance.class, new NetworkInstanceKey("global-bgp"))
+ .child(Protocols.class);
private BGPOperationalStateUtils() {
// Hidden on purpose
return;
}
if (neighbor == null && group == null) {
- displayRibOperationalState(ribId, globalBgp.getGlobal(), stream);
+ GlobalStateCliUtils.displayRibOperationalState(ribId, globalBgp.getGlobal(), stream);
} else {
if (neighbor != null) {
globalBgp.getNeighbors().nonnullNeighbor().values().stream()
- .filter(neig -> toString(neig.key().getNeighborAddress()).matches(neighbor))
- .findFirst()
- .ifPresent(neighbor1 -> displayNeighborOperationalState(neighbor, neighbor1, stream));
+ .filter(neig -> toString(neig.key().getNeighborAddress()).matches(neighbor))
+ .findFirst()
+ .ifPresent(neighbor1 -> NeighborStateCliUtils.displayNeighborOperationalState(neighbor,
+ neighbor1, stream));
} else {
- displayPeerOperationalState(globalBgp.getPeerGroups().nonnullPeerGroup().values(), stream);
+ PeerGroupStateCliUtils.displayPeerOperationalState(
+ globalBgp.getPeerGroups().nonnullPeerGroup().values(), stream);
}
}
}
import java.io.PrintStream;
import java.util.Collection;
-import java.util.List;
+import java.util.Set;
import org.apache.karaf.shell.support.table.ShellTable;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
table.print(stream);
}
- private static void printCapabilitiesState(final List<Class<? extends BgpCapability>> supportedCapabilities,
+ private static void printCapabilitiesState(final Set<Class<? extends BgpCapability>> supportedCapabilities,
final ShellTable table) {
if (supportedCapabilities == null) {
return;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintStream;
-import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
-import java.util.Collections;
import java.util.Map;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafi;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi.list.AfiSafiBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.operational.rev151009.bgp.neighbor.prefix.counters_state.PrefixesBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.AfiSafisBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.StateBuilder;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Timers;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TimersBuilder;
-import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.TransportBuilder;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.Neighbor;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbors.NeighborBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborTimersStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborTransportStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.MessagesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Received;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.ReceivedBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.SentBuilder;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
private static final IpAddress NEIGHBOR_IP_ADDRESS = new IpAddress(new Ipv4Address(NEIGHBOR_ADDRESS));
private static final String NO_SESSION_FOUND = "No BgpSessionState found for [" + NEIGHBOR_ADDRESS + "]\n";
private final ByteArrayOutputStream output = new ByteArrayOutputStream();
- private final PrintStream stream = new PrintStream(this.output);
+ private final PrintStream stream = new PrintStream(output);
static Neighbor createBasicNeighbor() {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp.common.afi.safi
@Test
public void testNeighborStateWO_StateCli() {
NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS,
- new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4"))).build(),
- this.stream);
- assertEquals(NO_SESSION_FOUND, this.output.toString());
+ new NeighborBuilder().setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4"))).build(), stream);
+ assertEquals(NO_SESSION_FOUND, output.toString());
}
@Test
public void testEmptyNeighborStateCli() throws IOException {
- final Neighbor neighbor = createBasicNeighbor();
- NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, neighbor, this.stream);
+ NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, createBasicNeighbor(), stream);
final String expected = Resources.toString(getClass().getClassLoader().getResource("empty-neighbor.txt"),
StandardCharsets.UTF_8);
- assertEquals(expected, this.output.toString());
+ assertEquals(expected, output.toString());
}
@Test
public void testFullNeighborStateCli() throws IOException {
- final AfiSafi afiSafi = new AfiSafiBuilder()
- .setAfiSafiName(IPV4UNICAST.class)
- .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp
- .common.afi.safi.list.afi.safi.StateBuilder()
+ NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS, new NeighborBuilder()
+ .setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4")))
+ .setState(new StateBuilder()
+ .addAugmentation(new NeighborStateAugmentationBuilder()
+ .setSupportedCapabilities(Set.of(ADDPATHS.class))
+ .setSessionState(BgpNeighborState.SessionState.ACTIVE)
+ .build())
+ .addAugmentation(new BgpNeighborStateAugmentationBuilder()
+ .setMessages(new MessagesBuilder()
+ .setReceived(new ReceivedBuilder().setNOTIFICATION(Uint64.ONE).setUPDATE(Uint64.TEN).build())
+ .setSent(new SentBuilder().setNOTIFICATION(Uint64.TEN).setUPDATE(Uint64.ONE).build())
+ .build())
+ .build())
+ .build())
+ .setAfiSafis(new AfiSafisBuilder()
+ .setAfiSafi(BindingMap.of(new AfiSafiBuilder()
+ .setAfiSafiName(IPV4UNICAST.class)
+ .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.multiprotocol.rev151009.bgp
+ .common.afi.safi.list.afi.safi.StateBuilder()
.addAugmentation(new NeighborAfiSafiStateAugmentationBuilder()
.setActive(Boolean.TRUE)
.setPrefixes(new PrefixesBuilder()
.setReceived(Uint32.ONE)
.setSent(Uint32.TWO).build())
.build())
- .build())
- .build();
-
-
- final StateBuilder stateBuilder = new StateBuilder()
- .addAugmentation(new NeighborStateAugmentationBuilder()
- .setSupportedCapabilities(Collections.singletonList(ADDPATHS.class))
- .setSessionState(BgpNeighborState.SessionState.ACTIVE)
- .build());
-
- final Received received = new ReceivedBuilder()
- .setNOTIFICATION(Uint64.ONE)
- .setUPDATE(Uint64.TEN)
- .build();
-
- final Sent sent = new SentBuilder()
- .setNOTIFICATION(Uint64.TEN)
- .setUPDATE(Uint64.ONE)
- .build();
-
- stateBuilder.addAugmentation(new BgpNeighborStateAugmentationBuilder()
- .setMessages(new MessagesBuilder()
- .setReceived(received)
- .setSent(sent)
+ .build())
+ .build()))
.build())
- .build());
-
- final Transport transport = new TransportBuilder()
+ .setTransport(new TransportBuilder()
.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
.transport.StateBuilder()
- .addAugmentation(new NeighborTransportStateAugmentationBuilder()
- .setRemoteAddress(NEIGHBOR_IP_ADDRESS)
- .setLocalPort(new PortNumber(Uint16.valueOf(1234)))
- .setRemotePort(new PortNumber(Uint16.valueOf(4321)))
- .build())
+ .addAugmentation(new NeighborTransportStateAugmentationBuilder()
+ .setRemoteAddress(NEIGHBOR_IP_ADDRESS)
+ .setLocalPort(new PortNumber(Uint16.valueOf(1234)))
+ .setRemotePort(new PortNumber(Uint16.valueOf(4321)))
.build())
- .build();
- final Timers timers = new TimersBuilder()
+ .build())
+ .build())
+ .setTimers(new TimersBuilder()
.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
.timers.StateBuilder()
- .addAugmentation(new NeighborTimersStateAugmentationBuilder()
- .setNegotiatedHoldTime(BigDecimal.TEN)
- .setUptime(new Timeticks(Uint32.valueOf(600)))
- .build())
+ .addAugmentation(new NeighborTimersStateAugmentationBuilder()
+ .setNegotiatedHoldTime(Decimal64.valueOf(2, 10))
+ .setUptime(new Timeticks(Uint32.valueOf(600)))
.build())
- .build();
- final Neighbor neighbor = new NeighborBuilder()
- .setNeighborAddress(new IpAddress(new Ipv4Address("1.2.3.4")))
- .setState(stateBuilder.build())
- .setAfiSafis(new AfiSafisBuilder().setAfiSafi(Map.of(afiSafi.key(), afiSafi)).build())
- .setTransport(transport)
- .setTimers(timers)
- .build();
- NeighborStateCliUtils.displayNeighborOperationalState(NEIGHBOR_ADDRESS,
- neighbor, this.stream);
+ .build())
+ .build())
+ .build(), stream);
final String expected = Resources.toString(getClass().getClassLoader().getResource("neighbor.txt"),
StandardCharsets.UTF_8);
- assertEquals(expected, this.output.toString());
+ assertEquals(expected, output.toString());
}
-}
\ No newline at end of file
+}
│
Timer state │
====================== │
-Negotiated Hold Time │ 10
+Negotiated Hold Time │ 10.0
Uptime │ 600
│
Transport state │
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
package org.opendaylight.protocol.bgp.evpn.impl;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.opendaylight.protocol.bgp.evpn.impl.EvpnTestUtil.RD;
import static org.opendaylight.protocol.bgp.evpn.impl.nlri.EthADRParserTest.ETHERNET_AD_ROUTE_CASE;
import static org.opendaylight.protocol.bgp.evpn.impl.nlri.EthADRParserTest.ETHERNET_AD_ROUTE_CASE_KEY;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-import org.junit.Assert;
+import java.util.List;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.evpn.impl.nlri.EvpnNlriParser;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public final class EvpnRibSupportTest extends AbstractRIBSupportTest<EvpnRoutesCase, EvpnRoutes, EvpnRoute> {
- private EvpnRibSupport ribSupport;
private static final EvpnRoute ROUTE;
private static final EvpnRouteKey ROUTE_KEY;
private static final EvpnDestination EVPN_DESTINATION = new EvpnDestinationBuilder()
.build();
private static final DestinationEvpnCase REACH_NLRI = new DestinationEvpnCaseBuilder()
.setDestinationEvpn(new DestinationEvpnBuilder()
- .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION)).build()).build();
+ .setEvpnDestination(List.of(EVPN_DESTINATION)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationEvpnCase UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev200120.update.attributes
.setDestinationEvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.evpn.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.evpn._case.DestinationEvpnBuilder()
- .setEvpnDestination(Collections.singletonList(EVPN_DESTINATION))
+ .setEvpnDestination(List.of(EVPN_DESTINATION))
.build())
.build();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
final ByteBuf buffer = Unpooled.buffer();
- EvpnNlriParser.serializeNlri(Collections.singletonList(new EvpnDestinationBuilder()
+ EvpnNlriParser.serializeNlri(List.of(new EvpnDestinationBuilder()
.setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE_KEY).build()), buffer);
ROUTE_KEY = new EvpnRouteKey(new PathId(Uint32.ZERO), ByteArray.encodeBase64(buffer));
ROUTE = new EvpnRouteBuilder().setRouteKey(ROUTE_KEY.getRouteKey())
.setPathId(ROUTE_KEY.getPathId())
.setAttributes(ATTRIBUTES).setRouteDistinguisher(RD).setEvpnChoice(ETHERNET_AD_ROUTE_CASE).build();
- EVPN_ROUTES = new EvpnRoutesBuilder().setEvpnRoute(Map.of(ROUTE.key(), ROUTE)).build();
+ EVPN_ROUTES = new EvpnRoutesBuilder().setEvpnRoute(BindingMap.of(ROUTE)).build();
}
+ private EvpnRibSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new EvpnRibSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new EvpnRibSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<EvpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<EvpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(EvpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final EvpnRoute route = (EvpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final EvpnRoute route = (EvpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(),
+ final Update update = ribSupport.buildUpdate(List.of(),
createRoutes(EVPN_ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(
- createRoutes(EVPN_ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(
+ createRoutes(EVPN_ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(EVPN_ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(EvpnRoutes.QNAME,
- Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(EvpnRoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(EvpnRoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(EvpnRoutes.class, this.ribSupport.routesContainerClass());
+ assertEquals(EvpnRoutes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(EvpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(EvpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new EvpnRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new EvpnRoutesCaseBuilder().setEvpnRoutes(new EvpnRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new EvpnRoutesCaseBuilder().setEvpnRoutes(EVPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
package org.opendaylight.protocol.bgp.flowspec;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistries.SAFI;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class FlowspecIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecRoutesCase, FlowspecRoutes,
FlowspecRoute> {
private static final DestinationPrefixCase DEST_PREFIX = new DestinationPrefixCaseBuilder()
.setDestinationPrefix(new Ipv4Prefix("10.0.1.0/32")).build();
- private static final List<Flowspec> FLOW_LIST
- = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final List<Flowspec> FLOW_LIST = List.of(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
private static final DestinationFlowspecIpv4 DEST_FLOW = new DestinationFlowspecIpv4Builder()
.setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
private static final DestinationFlowspecCase REACH_NLRI = new DestinationFlowspecCaseBuilder()
final BGPActivator act = new BGPActivator();
final BGPExtensionProviderContext context = new SimpleBGPExtensionProviderContext();
act.start(context);
- this.ribSupport = new FlowspecIpv4RIBSupport(this.adapter.currentSerializer());
+ ribSupport = new FlowspecIpv4RIBSupport(adapter.currentSerializer());
final SimpleFlowspecIpv4NlriParser parser = new SimpleFlowspecIpv4NlriParser(SAFI.FLOWSPEC);
- this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
- this.route = new FlowspecRouteBuilder().withKey(this.routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
+ routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
+ route = new FlowspecRouteBuilder().withKey(routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
.setAttributes(new AttributesBuilder().build()).build();
- this.routes = new FlowspecRoutesBuilder().setFlowspecRoute(Map.of(this.route.key(), this.route)).build();
- setUpTestCustomizer(this.ribSupport);
+ routes = new FlowspecRoutesBuilder().setFlowspecRoute(Map.of(route.key(), route)).build();
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecRoute> instanceIdentifier = this.deletedRoutes.get(0);
- assertEquals(this.routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecRoute> instanceIdentifier = deletedRoutes.get(0);
+ assertEquals(routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- assertEquals(this.route, this.insertedRoutes.get(0).getValue());
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ assertEquals(route, insertedRoutes.get(0).getValue());
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(routes), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(routes), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(routes), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(routes), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
- final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(this.routes);
- assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(routes);
+ assertEquals(getRoutePath().node(prefixNii), ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new NodeIdentifier(QName.create(FlowspecRoutes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(FlowspecRoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(FlowspecRoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(FlowspecRoutes.class, this.ribSupport.routesContainerClass());
+ assertEquals(FlowspecRoutes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(FlowspecRoute.class, this.ribSupport.routesListClass());
+ assertEquals(FlowspecRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new FlowspecRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes
= new FlowspecRoutesCaseBuilder().setFlowspecRoutes(new FlowspecRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(new FlowspecRoutesCaseBuilder()
- .setFlowspecRoutes(new FlowspecRoutesBuilder().setFlowspecRoute(Map.of(this.route.key(), this.route))
+ .setFlowspecRoutes(new FlowspecRoutesBuilder().setFlowspecRoute(Map.of(route.key(), route))
.build()).build())).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
package org.opendaylight.protocol.bgp.flowspec;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.flowspec.FlowspecTypeRegistries.SAFI;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class FlowspecIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecIpv6RoutesCase, FlowspecIpv6Routes,
FlowspecRoute> {
private static final PathId PATH_ID = new PathId(Uint32.ONE);
private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
.setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
- private static final List<Flowspec> FLOW_LIST = Collections.singletonList(new FlowspecBuilder()
- .setFlowspecType(DEST_PREFIX).build());
+ private static final List<Flowspec> FLOW_LIST = List.of(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
private static final DestinationFlowspecIpv6 DEST_FLOW = new DestinationFlowspecIpv6Builder()
.setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
private static final DestinationFlowspecIpv6Case REACH_NLRI = new DestinationFlowspecIpv6CaseBuilder()
act.start(context);
final SimpleFlowspecIpv6NlriParser parser = new SimpleFlowspecIpv6NlriParser(SAFI.FLOWSPEC);
- this.routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
- this.route = new FlowspecRouteBuilder().withKey(this.routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
+ routeKey = new FlowspecRouteKey(PATH_ID, parser.stringNlri(FLOW_LIST));
+ route = new FlowspecRouteBuilder().withKey(routeKey).setPathId(PATH_ID).setFlowspec(FLOW_LIST)
.setAttributes(new AttributesBuilder().build()).build();
- this.routes = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Map.of(this.route.key(), this.route)).build();
- this.ribSupport = new FlowspecIpv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ routes = new FlowspecIpv6RoutesBuilder().setFlowspecRoute(Map.of(route.key(), route)).build();
+ ribSupport = new FlowspecIpv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecRoute> instanceIdentifier = this.deletedRoutes.get(0);
- assertEquals(this.routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecRoute> instanceIdentifier = deletedRoutes.get(0);
+ assertEquals(routeKey, instanceIdentifier.firstKeyOf(FlowspecRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- assertEquals(this.route, this.insertedRoutes.get(0).getValue());
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ assertEquals(route, insertedRoutes.get(0).getValue());
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(),
- createRoutes(this.routes), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(routes), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(this.routes),
- Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(routes), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
- final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(this.routes);
+ final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(routes);
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new NodeIdentifier(QName.create(FlowspecIpv6Routes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes
.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(FlowspecIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(FlowspecIpv6RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(FlowspecIpv6Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(FlowspecIpv6Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(FlowspecRoute.class, this.ribSupport.routesListClass());
+ assertEquals(FlowspecRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new FlowspecIpv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new FlowspecIpv6RoutesCaseBuilder()
.setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(new FlowspecIpv6RoutesCaseBuilder()
.setFlowspecIpv6Routes(new FlowspecIpv6RoutesBuilder()
- .setFlowspecRoute(Map.of(this.route.key(), this.route)).build()).build())).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ .setFlowspecRoute(Map.of(route.key(), route)).build()).build())).getRootNode();
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
import static org.mockito.Mockito.doReturn;
import static org.opendaylight.bgp.concepts.RouteDistinguisherUtil.extractRouteDistinguisher;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Before
public void setUp() {
- doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(any());
- doReturn(true).when(this.muliPathSupport).isTableTypeSupported(any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
+ "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
+ "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static void testFlows(
}
private static FlowspecType createSps() {
- final List<SourcePorts> sports = Lists.newArrayList(new SourcePortsBuilder().setOp(
+ final List<SourcePorts> sports = List.of(new SourcePortsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint16.valueOf(8080)).build());
return new SourcePortCaseBuilder().setSourcePorts(sports).build();
}
private static FlowspecType createProts() {
- final List<ProtocolIps> protocols = Lists.newArrayList(new ProtocolIpsBuilder().setOp(
+ final List<ProtocolIps> protocols = List.of(new ProtocolIpsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
return new ProtocolIpCaseBuilder().setProtocolIps(protocols).build();
}
private static FlowspecType createDps() {
- final List<DestinationPorts> destports = Lists.newArrayList(
+ final List<DestinationPorts> destports = List.of(
new DestinationPortsBuilder().setOp(new NumericOperand(false, false, false, true, false))
.setValue(Uint16.valueOf(4089)).build(),
new DestinationPortsBuilder().setOp(new NumericOperand(false, true, true, false, false))
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
+ "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
+ "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static PortCase createPorts() {
- final List<Ports> ports = Lists.newArrayList(
+ final List<Ports> ports = List.of(
new PortsBuilder().setOp(new NumericOperand(false, false, true, true, false)).setValue(Uint16.valueOf(137))
.build(),
new PortsBuilder().setOp(new NumericOperand(true, false, true, false, true)).setValue(Uint16.valueOf(139))
assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
+ "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
+ "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static FlowspecType createFragment() {
- final List<Fragments> fragments = Lists.newArrayList(new FragmentsBuilder().setOp(
+ final List<Fragments> fragments = List.of(new FragmentsBuilder().setOp(
new BitmaskOperand(false, true, true, false)).setValue(new Fragment(false, true, true, true)).build());
return new FragmentCaseBuilder().setFragments(fragments).build();
}
private static FlowspecType createDscp() {
- final List<Dscps> dscps = Lists.newArrayList(new DscpsBuilder().setOp(
+ final List<Dscps> dscps = List.of(new DscpsBuilder().setOp(
new NumericOperand(false, true, false, true, false)).setValue(new Dscp(Uint8.valueOf(42))).build());
return new DscpCaseBuilder().setDscps(dscps).build();
}
private static PacketLengthCase createPackets() {
- final List<PacketLengths> packets = Lists.newArrayList(new PacketLengthsBuilder().setOp(
+ final List<PacketLengths> packets = List.of(new PacketLengthsBuilder().setOp(
new NumericOperand(false, true, false, false, true)).setValue(Uint16.valueOf(57005)).build());
return new PacketLengthCaseBuilder().setPacketLengths(packets).build();
}
private static TcpFlagsCase createTcp() {
- final List<TcpFlags> flags = Lists.newArrayList(
+ final List<TcpFlags> flags = List.of(
new TcpFlagsBuilder().setOp(new BitmaskOperand(false, false, false, true)).setValue(Uint16.valueOf(1025))
.build(),
new TcpFlagsBuilder().setOp(new BitmaskOperand(false, true, true, false)).setValue(Uint16.valueOf(22193))
}
private static FlowspecType createIcmpCode() {
- final List<Codes> codes = Lists.newArrayList(
+ final List<Codes> codes = List.of(
new CodesBuilder().setOp(new NumericOperand(false, false, false, false, true)).setValue(Uint8.valueOf(4))
.build(),
new CodesBuilder().setOp(new NumericOperand(false, true, false, false, false)).setValue(Uint8.valueOf(5))
}
private static FlowspecType createIcmpType() {
- final List<Types> types = Lists.newArrayList(
+ final List<Types> types = List.of(
new TypesBuilder().setOp(new NumericOperand(false, false, false, false, true)).setValue(Uint8.TWO)
.build(),
new TypesBuilder().setOp(new NumericOperand(false, true, false, false, true)).setValue(Uint8.valueOf(3))
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
DestinationFlowspecL3vpnIpv4 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
+ "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
+ "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(
new Ipv4Prefix("127.0.0.5/32")).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new ProtocolIpCaseBuilder()
- .setProtocolIps(Lists.newArrayList(new ProtocolIpsBuilder()
+ .setProtocolIps(List.of(new ProtocolIpsBuilder()
.setValue(Uint8.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false))
.build(), new ProtocolIpsBuilder()
.setOp(new NumericOperand(true, true, true, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new PortCaseBuilder()
- .setPorts(Lists.newArrayList(new PortsBuilder()
+ .setPorts(List.of(new PortsBuilder()
.setValue(Uint16.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.EQUALS_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint16.valueOf(1024)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPortCaseBuilder()
- .setDestinationPorts(Lists.newArrayList(new DestinationPortsBuilder()
+ .setDestinationPorts(List.of(new DestinationPortsBuilder()
.setValue(Uint16.valueOf(1024))
.setOp(new NumericOperand(false, true, true, false, false))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourcePortCaseBuilder()
- .setSourcePorts(Lists.newArrayList(new SourcePortsBuilder()
+ .setSourcePorts(List.of(new SourcePortsBuilder()
.setValue(Uint16.valueOf(8080))
.setOp(new NumericOperand(true, true, true, true, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new IcmpTypeCaseBuilder()
- .setTypes(Lists.newArrayList(new TypesBuilder()
+ .setTypes(List.of(new TypesBuilder()
.setValue(Uint8.valueOf(22))
.setOp(new NumericOperand(true, true, true, true, true))
.build()))
.build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Collections.emptySet()).build())
+ .withValue(Set.of()).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(23)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new IcmpCodeCaseBuilder()
- .setCodes(Lists.newArrayList(new CodesBuilder()
+ .setCodes(List.of(new CodesBuilder()
.setValue(Uint8.valueOf(23))
.setOp(new NumericOperand(false, false, false, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint16.valueOf(99)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(Lists.newArrayList(new TcpFlagsBuilder()
+ expectedFS.setFlowspecType(new TcpFlagsCaseBuilder().setTcpFlags(List.of(new TcpFlagsBuilder()
.setValue(Uint16.valueOf(99)).setOp(new BitmaskOperand(true, true, false, false)).build())).build());
final List<Flowspec> expected = new ArrayList<>();
expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(expected, fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint16.valueOf(101)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(Lists.newArrayList(
+ expectedFS.setFlowspecType(new PacketLengthCaseBuilder().setPacketLengths(List.of(
new PacketLengthsBuilder().setValue(Uint16.valueOf(101)).setOp(
new NumericOperand(true, false, false, true, false)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(15)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(Lists.newArrayList(new DscpsBuilder().setValue(
+ expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(List.of(new DscpsBuilder().setValue(
new Dscp(Uint8.valueOf(15))).setOp(new NumericOperand(true, true, false, true, false)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE,
BitmaskOperandParser.NOT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv4NlriParser.VALUE_NID)
- .withValue(Sets.newHashSet(AbstractFlowspecNlriParser.DO_NOT_VALUE,
+ .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE,
AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE,
AbstractFlowspecNlriParser.LAST_VALUE)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(Lists.newArrayList(new FragmentsBuilder()
+ expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder()
.setValue(new Fragment(true, true, true, true)).setOp(new BitmaskOperand(true, true, true, true)).build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
package org.opendaylight.protocol.bgp.flowspec;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv4.FlowspecL3vpnIpv4RIBSupport;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class FlowspecL3vpnIpv4RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnIpv4RoutesCase,
FlowspecL3vpnIpv4Routes, FlowspecL3vpnRoute> {
private static final RouteDistinguisher RD = new RouteDistinguisher(new RdTwoOctetAs("0:5:3"));
private static final DestinationPrefixCase DEST_PREFIX = new DestinationPrefixCaseBuilder()
.setDestinationPrefix(new Ipv4Prefix("172.17.1.0/24")).build();
- private static final List<Flowspec> FLOW_LIST
- = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final List<Flowspec> FLOW_LIST = List.of(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
private static final DestinationFlowspecL3vpnIpv4 DEST_FLOW
= new DestinationFlowspecL3vpnIpv4Builder().setRouteDistinguisher(RD)
.setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new FlowspecL3vpnIpv4RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new FlowspecL3vpnIpv4RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecL3vpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(
new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()),
ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(
+ final Update update = ribSupport.buildUpdate(createRoutes(
new FlowspecL3vpnIpv4RoutesBuilder().setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()),
- Collections.emptyList(), ATTRIBUTES);
+ List.of(), ATTRIBUTES);
final AdvertizedRoutes advertised = update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes();
assertEquals(REACH_NLRI, advertised.getDestinationType());
@Test
public void testCacheableNlriObjects() {
- assertEquals(Set.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(Set.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
= createRouteNIWP(new FlowspecL3vpnIpv4RoutesBuilder()
.setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build());
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new NodeIdentifier(QName.create(FlowspecL3vpnIpv4Routes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(FlowspecL3vpnIpv4RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(FlowspecL3vpnIpv4RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(FlowspecL3vpnIpv4Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(FlowspecL3vpnIpv4Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(FlowspecL3vpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(FlowspecL3vpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new FlowspecL3vpnIpv4RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new FlowspecL3vpnIpv4RoutesCaseBuilder()
.setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new FlowspecL3vpnIpv4RoutesCaseBuilder()
.setFlowspecL3vpnIpv4Routes(new FlowspecL3vpnIpv4RoutesBuilder()
.setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
import static org.junit.Assert.assertEquals;
import static org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecIpv4NlriParserTest.PATH_ID;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Before
public void setUp() {
- Mockito.doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(Mockito.any());
- Mockito.doReturn(true).when(this.muliPathSupport).isTableTypeSupported(Mockito.any());
+ Mockito.doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(Mockito.any());
+ Mockito.doReturn(true).when(muliPathSupport).isTableTypeSupported(Mockito.any());
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder()
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder()
.setOp(new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
);
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
.setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
.build())
assertArrayEquals(REACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder()
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder()
.setOp(new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
);
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
.setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
.build())
assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
);
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
private static FragmentCase createFragment() {
- final List<Fragments> fragments = Lists.newArrayList(new FragmentsBuilder().setOp(
+ final List<Fragments> fragments = List.of(new FragmentsBuilder().setOp(
new BitmaskOperand(false, true, true, false)).setValue(new Fragment(false, true, true, true)).build());
return new FragmentCaseBuilder().setFragments(fragments).build();
}
private static FlowspecType createLabel() {
- final List<FlowLabel> labels = new ArrayList<>(2);
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
- .setValue(Uint32.valueOf(16777222)).build());
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
- .setValue(Uint32.valueOf(258)).build());
+ final List<FlowLabel> labels = List.of(
+ new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
+ .setValue(Uint32.valueOf(16777222)).build(),
+ new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
+ .setValue(Uint32.valueOf(258)).build());
return new FlowLabelCaseBuilder().setFlowLabel(labels).build();
}
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecL3vpnSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
final DestinationFlowspecL3vpnIpv6 flowspecDst = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
);
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE,
BitmaskOperandParser.NOT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
- .withValue(Sets.newHashSet(AbstractFlowspecNlriParser.DO_NOT_VALUE,
+ .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE,
AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE,
AbstractFlowspecNlriParser.LAST_VALUE)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(Lists.newArrayList(
+ expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(
new FragmentsBuilder().setValue(new Fragment(true, true, true, true)).setOp(
new BitmaskOperand(true, true, true, true)).build())).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
.withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new NextHeaderCaseBuilder()
- .setNextHeaders(Lists.newArrayList(
+ .setNextHeaders(List.of(
new NextHeadersBuilder().setValue(Uint8.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false)).build(),
new NextHeadersBuilder().setValue(Uint8.valueOf(200))
new NextHeadersBuilder().setValue(Uint8.valueOf(210))
.setOp(new NumericOperand(true, true, true, false, false)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
.withValue(Uint32.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(FlowspecL3vpnIpv6NlriParser.VALUE_NID)
.withValue(Uint32.valueOf(200)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(Lists.newArrayList(
+ expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(List.of(
new FlowLabelBuilder().setValue(Uint32.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false)).build(),
new FlowLabelBuilder().setValue(Uint32.valueOf(200))
.setOp(new NumericOperand(true, false, false, false, false)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(
new Ipv6Prefix("102:304:500::/40")).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix(new Ipv6Prefix("102:304:600::/40"))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
}
import static org.junit.Assert.assertTrue;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6.FlowspecL3vpnIpv6RIBSupport;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdTwoOctetAs;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class FlowspecL3vpnIpv6RIBSupportTest extends AbstractRIBSupportTest<FlowspecL3vpnIpv6RoutesCase,
FlowspecL3vpnIpv6Routes, FlowspecL3vpnRoute> {
private static final RouteDistinguisher RD = new RouteDistinguisher(new RdTwoOctetAs("0:5:3"));
private static final DestinationIpv6PrefixCase DEST_PREFIX = new DestinationIpv6PrefixCaseBuilder()
.setDestinationPrefix(new Ipv6Prefix("2001:db8:1:2::/64")).build();
- private static final List<Flowspec> FLOW_LIST
- = Collections.singletonList(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
+ private static final List<Flowspec> FLOW_LIST = List.of(new FlowspecBuilder().setFlowspecType(DEST_PREFIX).build());
private static final DestinationFlowspecL3vpnIpv6 DEST_FLOW
= new DestinationFlowspecL3vpnIpv6Builder().setRouteDistinguisher(RD)
.setFlowspec(FLOW_LIST).setPathId(PATH_ID).build();
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new FlowspecL3vpnIpv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new FlowspecL3vpnIpv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<FlowspecL3vpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(FlowspecL3vpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final FlowspecL3vpnRoute route = (FlowspecL3vpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(
new FlowspecL3vpnIpv6RoutesBuilder()
- .setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()), ATTRIBUTES);
+ .setFlowspecL3vpnRoute(BindingMap.of(ROUTE)).build()), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(
- new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()),
- Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(
+ new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(BindingMap.of(ROUTE)).build()),
+ List.of(), ATTRIBUTES);
final AdvertizedRoutes advertised
= update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri().getAdvertizedRoutes();
assertEquals(REACH_NLRI, advertised.getDestinationType());
@Test
public void testCacheableNlriObjects() {
- assertEquals(Set.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(Set.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final YangInstanceIdentifier.NodeIdentifierWithPredicates prefixNii = createRouteNIWP(
- new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build());
+ new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(BindingMap.of(ROUTE)).build());
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new YangInstanceIdentifier.NodeIdentifier(QName.create(FlowspecL3vpnIpv6Routes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(FlowspecL3vpnIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(FlowspecL3vpnIpv6RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(FlowspecL3vpnIpv6Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(FlowspecL3vpnIpv6Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(FlowspecL3vpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(FlowspecL3vpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new FlowspecL3vpnIpv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new FlowspecL3vpnIpv6RoutesCaseBuilder()
.setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new FlowspecL3vpnIpv6RoutesCaseBuilder()
.setFlowspecL3vpnIpv6Routes(new FlowspecL3vpnIpv6RoutesBuilder()
- .setFlowspecL3vpnRoute(Map.of(ROUTE.key(), ROUTE)).build()).build();
+ .setFlowspecL3vpnRoute(BindingMap.of(ROUTE)).build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Before
public void setUp() {
- doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(any());
- doReturn(true).when(this.muliPathSupport).isTableTypeSupported(any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
+ "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
+ "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static void testFlows(final List<Flowspec> flows, final DestinationPrefixCase destinationPrefix,
}
private static FlowspecType createSps() {
- final List<SourcePorts> sports = Lists.newArrayList(new SourcePortsBuilder().setOp(
+ final List<SourcePorts> sports = List.of(new SourcePortsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint16.valueOf(8080)).build());
return new SourcePortCaseBuilder().setSourcePorts(sports).build();
}
private static FlowspecType createProts() {
- final List<ProtocolIps> protocols = Lists.newArrayList(new ProtocolIpsBuilder().setOp(
+ final List<ProtocolIps> protocols = List.of(new ProtocolIpsBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
return new ProtocolIpCaseBuilder().setProtocolIps(protocols).build();
}
private static FlowspecType createDps() {
- final List<DestinationPorts> destports = Lists.newArrayList(new DestinationPortsBuilder().setOp(
+ final List<DestinationPorts> destports = List.of(new DestinationPortsBuilder().setOp(
new NumericOperand(false, false, false, true, false)).setValue(Uint16.valueOf(4089)).build(),
new DestinationPortsBuilder().setOp(new NumericOperand(false, true, true, false, false))
.setValue(Uint16.valueOf(179)).build());
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ parser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
assertEquals("all packets to 10.0.1.0/32 AND from 1.2.3.4/32 AND where IP protocol equals to 6 AND where port "
+ "is greater than or equals to 137 and is less than or equals to 139 or equals to 8080 AND where "
+ "destination port is greater than 4089 or equals to 179 AND where source port equals to 8080 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static PortCase createPorts() {
- final List<Ports> ports = Lists.newArrayList(
+ final List<Ports> ports = List.of(
new PortsBuilder().setOp(new NumericOperand(false, false, true, true, false)).setValue(Uint16.valueOf(137))
.build(),
new PortsBuilder().setOp(new NumericOperand(true, false, true, false, true)).setValue(Uint16.valueOf(139))
assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
+ "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
+ "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
private static FlowspecType createFragment() {
- final List<Fragments> fragments = Lists.newArrayList(new FragmentsBuilder()
+ final List<Fragments> fragments = List.of(new FragmentsBuilder()
.setOp(new BitmaskOperand(false, true, true, false))
.setValue(new Fragment(false, true, true, true)).build());
return new FragmentCaseBuilder().setFragments(fragments).build();
}
private static FlowspecType createDscp() {
- final List<Dscps> dscps = Lists.newArrayList(new DscpsBuilder()
+ final List<Dscps> dscps = List.of(new DscpsBuilder()
.setOp(new NumericOperand(false, true, false, true, false))
.setValue(new Dscp(Uint8.valueOf(42))).build());
return new DscpCaseBuilder().setDscps(dscps).build();
}
private static PacketLengthCase createPackets() {
- final List<PacketLengths> packets = Lists.newArrayList(new PacketLengthsBuilder()
+ final List<PacketLengths> packets = List.of(new PacketLengthsBuilder()
.setOp(new NumericOperand(false, true, false, false, true))
.setValue(Uint16.valueOf(57005)).build());
return new PacketLengthCaseBuilder().setPacketLengths(packets).build();
}
private static TcpFlagsCase createTcp() {
- final List<TcpFlags> flags = Lists.newArrayList(new TcpFlagsBuilder()
+ final List<TcpFlags> flags = List.of(new TcpFlagsBuilder()
.setOp(new BitmaskOperand(false, false, false, true)).setValue(Uint16.valueOf(1025))
.build(), new TcpFlagsBuilder()
.setOp(new BitmaskOperand(false, true, true, false))
}
private static FlowspecType createIcmpCode() {
- final List<Codes> codes = Lists.newArrayList(new CodesBuilder()
+ final List<Codes> codes = List.of(new CodesBuilder()
.setOp(new NumericOperand(false, false, false, false, true))
.setValue(Uint8.valueOf(4))
.build(), new CodesBuilder()
}
private static FlowspecType createIcmpType() {
- final List<Types> types = Lists.newArrayList(
+ final List<Types> types = List.of(
new TypesBuilder().setOp(new NumericOperand(false, false, false, false, true)).setValue(Uint8.TWO)
.build(),
new TypesBuilder().setOp(new NumericOperand(false, true, false, false, true)).setValue(Uint8.valueOf(3))
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv4AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ parser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
assertEquals("all packets where ICMP type is less than 2 or is less than 3 AND where ICMP code is less than 4 "
+ "or 5 AND where TCP flags is not 1025 or does match 22193 AND where packet length is less than 57005 "
+ "AND where DSCP is greater than 42 AND where fragment does match 'IS FIRST' 'IS LAST' 'IS A' ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPrefixCaseBuilder().setDestinationPrefix(
new Ipv4Prefix("127.0.0.5/32")).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourcePrefixCaseBuilder().setSourcePrefix(new Ipv4Prefix("127.0.0.6/32"))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new ProtocolIpCaseBuilder().setProtocolIps(
- Lists.newArrayList(
+ List.of(
new ProtocolIpsBuilder().setValue(Uint8.valueOf(100)).setOp(
new NumericOperand(true, true, false, false, false)).build(),
new ProtocolIpsBuilder().setValue(Uint8.valueOf(200)).setOp(
new NumericOperand(true, false, false, false, false)).build(),
new ProtocolIpsBuilder().setValue(Uint8.valueOf(240)).setOp(
new NumericOperand(true, true, true, false, false)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.PORTS_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(PROTOCOL_IP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.LESS_THAN_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
final FlowspecBuilder expectedFS = new FlowspecBuilder()
.setFlowspecType(new PortCaseBuilder()
- .setPorts(Lists.newArrayList(new PortsBuilder()
+ .setPorts(List.of(new PortsBuilder()
.setValue(Uint16.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, true))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.EQUALS_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint16.valueOf(1024)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationPortCaseBuilder()
- .setDestinationPorts(Lists.newArrayList(new DestinationPortsBuilder()
+ .setDestinationPorts(List.of(new DestinationPortsBuilder()
.setValue(Uint16.valueOf(1024))
.setOp(new NumericOperand(false, true, true, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourcePortCaseBuilder()
- .setSourcePorts(Lists.newArrayList(new SourcePortsBuilder()
+ .setSourcePorts(List.of(new SourcePortsBuilder()
.setValue(Uint16.valueOf(8080))
.setOp(new NumericOperand(true, true, true, true, true))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, AbstractNumericOperandParser.EQUALS_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE,
AbstractNumericOperandParser.LESS_THAN_VALUE)).build())
.withValue(Uint8.valueOf(22)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(Lists.newArrayList(new TypesBuilder()
+ expectedFS.setFlowspecType(new IcmpTypeCaseBuilder().setTypes(List.of(new TypesBuilder()
.setValue(Uint8.valueOf(22)).setOp(new NumericOperand(true, true, true, true, true)).build())).build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Collections.emptySet()).build())
+ .withValue(Set.of()).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(23)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(Lists.newArrayList(new CodesBuilder()
+ expectedFS.setFlowspecType(new IcmpCodeCaseBuilder().setCodes(List.of(new CodesBuilder()
.setValue(Uint8.valueOf(23)).setOp(new NumericOperand(false, false, false, false, false)).build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint16.valueOf(99)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new TcpFlagsCaseBuilder()
- .setTcpFlags(Lists.newArrayList(new TcpFlagsBuilder()
+ .setTcpFlags(List.of(new TcpFlagsBuilder()
.setValue(Uint16.valueOf(99))
.setOp(new BitmaskOperand(true, true, false, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint16.valueOf(101)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new PacketLengthCaseBuilder()
- .setPacketLengths(Lists.newArrayList(new PacketLengthsBuilder()
+ .setPacketLengths(List.of(new PacketLengthsBuilder()
.setValue(Uint16.valueOf(101))
.setOp(new NumericOperand(true, false, false, true, false))
.build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE,
AbstractNumericOperandParser.GREATER_THAN_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(15)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(Lists.newArrayList(new DscpsBuilder()
+ expectedFS.setFlowspecType(new DscpCaseBuilder().setDscps(List.of(new DscpsBuilder()
.setValue(new Dscp(Uint8.valueOf(15))).setOp(new NumericOperand(true, true, false, true, false)).build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE,
BitmaskOperandParser.NOT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue(Sets.newHashSet(AbstractFlowspecNlriParser.DO_NOT_VALUE,
+ .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE,
AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE,
AbstractFlowspecNlriParser.LAST_VALUE)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(Lists.newArrayList(new FragmentsBuilder()
+ expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder()
.setValue(new Fragment(true, true, true, true)).setOp(new BitmaskOperand(true, true, true, true)).build()))
.build());
- final List<Flowspec> expected = new ArrayList<>();
- expected.add(expectedFS.build());
- assertEquals(expected, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
import static org.mockito.Mockito.doReturn;
import static org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecIpv4NlriParserTest.PATH_ID;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Before
public void setUp() {
- doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(any());
- doReturn(true).when(this.muliPathSupport).isTableTypeSupported(any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder().setOp(
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
assertEquals(headersCase, flows.get(2).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
.setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
.build())
assertArrayEquals(REACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
builder.setFlowspecType(sourcePrefix);
fs.add(builder.build());
- final List<NextHeaders> nextheaders = Lists.newArrayList(new NextHeadersBuilder().setOp(
+ final List<NextHeaders> nextheaders = List.of(new NextHeadersBuilder().setOp(
new NumericOperand(false, true, true, false, false)).setValue(Uint8.valueOf(6)).build());
final NextHeaderCase headersCase = new NextHeaderCaseBuilder().setNextHeaders(nextheaders).build();
builder.setFlowspecType(headersCase);
final MpReachNlriBuilder result = new MpReachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(REACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.reach.nlri.advertized.routes.destination.type
assertEquals(headersCase, flows.get(2).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesReachBuilder()
.setMpReachNlri(mp.setAfi(Ipv6AddressFamily.class).build())
.build())
assertArrayEquals(REACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets to 102:304:500::/40 AND from 102:304:600::/40 AND where next header equals to 6 ",
- this.fsParser.stringNlri(flows));
+ fsParser.stringNlri(flows));
}
@Test
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI), result, null);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
assertEquals(label, flows.get(1).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
private static FragmentCase createFragment() {
- final List<Fragments> fragments = Lists.newArrayList(new FragmentsBuilder().setOp(
+ final List<Fragments> fragments = List.of(new FragmentsBuilder().setOp(
new BitmaskOperand(false, true, true, false)).setValue(new Fragment(false, true, true, true)).build());
return new FragmentCaseBuilder().setFragments(fragments).build();
}
private static FlowspecType createLabel() {
- final List<FlowLabel> labels = new ArrayList<>(2);
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
- .setValue(Uint32.valueOf(16777222)).build());
- labels.add(new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
- .setValue(Uint32.valueOf(258)).build());
+ final List<FlowLabel> labels = List.of(
+ new FlowLabelBuilder().setOp(new NumericOperand(false, false, true, false, false))
+ .setValue(Uint32.valueOf(16777222)).build(),
+ new FlowLabelBuilder().setOp(new NumericOperand(false, true, true, false, false))
+ .setValue(Uint32.valueOf(258)).build());
return new FlowLabelCaseBuilder().setFlowLabel(labels).build();
}
final MpUnreachNlriBuilder result = new MpUnreachNlriBuilder();
result.setAfi(Ipv6AddressFamily.class);
result.setSafi(FlowspecSubsequentAddressFamily.class);
- this.fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, this.constraint);
+ fsParser.parseNlri(Unpooled.wrappedBuffer(UNREACHED_NLRI_ADD_PATH), result, constraint);
final List<Flowspec> flows = ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.flowspec.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
assertEquals(label, flows.get(1).getFlowspecType());
final ByteBuf buffer = Unpooled.buffer();
- this.fsParser.serializeAttribute(new AttributesBuilder()
+ fsParser.serializeAttribute(new AttributesBuilder()
.addAugmentation(new AttributesUnreachBuilder().setMpUnreachNlri(mp.build()).build())
.build(), buffer);
assertArrayEquals(UNREACHED_NLRI_ADD_PATH, ByteArray.readAllBytes(buffer));
assertEquals("all packets where fragment does match 'IS FIRST' 'IS LAST' 'IS A' AND where flow label equals to "
- + "16777222 or equals to 258 ", this.fsParser.stringNlri(flows));
+ + "16777222 or equals to 258 ", fsParser.stringNlri(flows));
}
@Test
.withChild(Builders.unkeyedListEntryBuilder()
.withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE,
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE,
AbstractOperandParser.END_OF_LIST_VALUE, BitmaskOperandParser.MATCH_VALUE,
BitmaskOperandParser.NOT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
- .withValue(Sets.newHashSet(AbstractFlowspecNlriParser.DO_NOT_VALUE,
+ .withValue(Set.of(AbstractFlowspecNlriParser.DO_NOT_VALUE,
AbstractFlowspecNlriParser.FIRST_VALUE, AbstractFlowspecNlriParser.IS_A_VALUE,
AbstractFlowspecNlriParser.LAST_VALUE)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(Lists.newArrayList(new FragmentsBuilder()
+ expectedFS.setFlowspecType(new FragmentCaseBuilder().setFragments(List.of(new FragmentsBuilder()
.setValue(new Fragment(true, true, true, true)).setOp(new BitmaskOperand(true, true, true, true)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint8.valueOf(200)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(NEXT_HEADER_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE, AbstractNumericOperandParser.EQUALS_VALUE))
.build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new NextHeaderCaseBuilder().setNextHeaders(Lists.newArrayList(
+ expectedFS.setFlowspecType(new NextHeaderCaseBuilder().setNextHeaders(List.of(
new NextHeadersBuilder().setValue(Uint8.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false)).build(),
new NextHeadersBuilder().setValue(Uint8.valueOf(200))
new NextHeadersBuilder().setValue(Uint8.valueOf(210))
.setOp(new NumericOperand(true, true, true, false, false)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
.withChild(Builders.unkeyedListBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.END_OF_LIST_VALUE,
+ .withValue(Set.of(AbstractOperandParser.END_OF_LIST_VALUE,
AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint32.valueOf(100)).build()).build())
.withChild(Builders.unkeyedListEntryBuilder().withNodeIdentifier(FLOW_LABEL_NID)
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.OP_NID)
- .withValue(Sets.newHashSet(AbstractOperandParser.AND_BIT_VALUE)).build())
+ .withValue(Set.of(AbstractOperandParser.AND_BIT_VALUE)).build())
.withChild(Builders.leafBuilder().withNodeIdentifier(AbstractFlowspecNlriParser.VALUE_NID)
.withValue(Uint32.valueOf(200)).build()).build())
.build()).build()).build()).build());
final FlowspecBuilder expectedFS = new FlowspecBuilder();
- expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(Lists.newArrayList(
+ expectedFS.setFlowspecType(new FlowLabelCaseBuilder().setFlowLabel(List.of(
new FlowLabelBuilder().setValue(Uint32.valueOf(100))
.setOp(new NumericOperand(true, true, false, false, false)).build(),
new FlowLabelBuilder().setValue(Uint32.valueOf(200))
.setOp(new NumericOperand(true, false, false, false, false)).build()))
.build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new DestinationIpv6PrefixCaseBuilder().setDestinationPrefix(
new Ipv6Prefix("102:304:500::/40")).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
@Test
final FlowspecBuilder expectedFS = new FlowspecBuilder();
expectedFS.setFlowspecType(new SourceIpv6PrefixCaseBuilder().setSourcePrefix(
new Ipv6Prefix("102:304:600::/40")).build());
- final List<Flowspec> expectedValue = new ArrayList<>();
- expectedValue.add(expectedFS.build());
- assertEquals(expectedValue, this.fsParser.extractFlowspec(entry.build()));
+ assertEquals(List.of(expectedFS.build()), fsParser.extractFlowspec(entry.build()));
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
package org.opendaylight.protocol.bgp.inet;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public final class IPv4RIBSupportTest extends AbstractRIBSupportTest<Ipv4RoutesCase, Ipv4Routes, Ipv4Route> {
private IPv4RIBSupport ribSupport;
.setPrefix(PREFIX).build();
private static final DestinationIpv4Case REACH_NLRI = new DestinationIpv4CaseBuilder()
.setDestinationIpv4(new DestinationIpv4Builder()
- .setIpv4Prefixes(Lists.newArrayList(IPV4_PREFIXES)).build()).build();
+ .setIpv4Prefixes(List.of(IPV4_PREFIXES)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4Case UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv4CaseBuilder()
.setDestinationIpv4(new DestinationIpv4Builder()
- .setIpv4Prefixes(Collections.singletonList(IPV4_PREFIXES)).build()).build();
+ .setIpv4Prefixes(List.of(IPV4_PREFIXES)).build()).build();
private static final Ipv4Route ROUTE = new Ipv4RouteBuilder()
.setRouteKey(PREFIX.getValue())
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new IPv4RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new IPv4RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<Ipv4Route> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<Ipv4Route> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv4Route.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final Ipv4Route route = (Ipv4Route) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final Ipv4Route route = (Ipv4Route) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(
+ assertEquals(Set.of(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.Ipv4PrefixAndPathId
- .class), this.ribSupport.cacheableNlriObjects());
+ .class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- assertEquals(getRoutePath().node(prefixNii), this.ribSupport.routePath(getTablePath(), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii), ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(Ipv4RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(Ipv4RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(Ipv4Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(Ipv4Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(Ipv4Route.class, this.ribSupport.routesListClass());
+ assertEquals(Ipv4Route.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new Ipv4RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new Ipv4RoutesCaseBuilder().setIpv4Routes(new Ipv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new Ipv4RoutesCaseBuilder().setIpv4Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public final class IPv6RIBSupportTest extends AbstractRIBSupportTest<Ipv6RoutesCase, Ipv6Routes, Ipv6Route> {
private IPv6RIBSupport ribSupport;
.setPrefix(PREFIX).build();
private static final DestinationIpv6Case REACH_NLRI = new DestinationIpv6CaseBuilder()
.setDestinationIpv6(new DestinationIpv6Builder()
- .setIpv6Prefixes(Lists.newArrayList(IPV6_PREFIXES)).build()).build();
+ .setIpv6Prefixes(List.of(IPV6_PREFIXES)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6Case UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder()
.setDestinationIpv6(new DestinationIpv6Builder()
- .setIpv6Prefixes(Collections.singletonList(IPV6_PREFIXES)).build()).build();
+ .setIpv6Prefixes(List.of(IPV6_PREFIXES)).build()).build();
private static final Ipv6Route ROUTE = new Ipv6RouteBuilder()
.setRouteKey(PREFIX.getValue())
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new IPv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new IPv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
final InstanceIdentifier<Ipv6Route> instanceIdentifier =
- this.deletedRoutes.get(0);
+ deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(Ipv6Route.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final Ipv6Route route = (Ipv6Route) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final Ipv6Route route = (Ipv6Route) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
-
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class)
.getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
- .rev180329.Ipv6Prefix.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet
+ .rev180329.Ipv6Prefix.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii), ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv6Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(Ipv6RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(Ipv6RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(Ipv6Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(Ipv6Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(Ipv6Route.class, this.ribSupport.routesListClass());
+ assertEquals(Ipv6Route.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new Ipv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new Ipv6RoutesCaseBuilder().setIpv6Routes(new Ipv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ Assert.assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new Ipv6RoutesCaseBuilder().setIpv6Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
Assert.assertFalse(result.isEmpty());
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class L3vpnMcastIpv4RIBSupportTest extends AbstractRIBSupportTest<L3vpnMcastRoutesIpv4Case ,L3vpnMcastRoutesIpv4,
L3vpnMcastRoute> {
private static final DestinationL3vpnMcastIpv4AdvertizedCase REACH_NLRI
= new DestinationL3vpnMcastIpv4AdvertizedCaseBuilder()
.setDestinationIpv4L3vpnMcast(new DestinationIpv4L3vpnMcastBuilder()
- .setL3vpnMcastDestination(Collections.singletonList(MCAST_L3VPN_DESTINATION)).build()).build();
+ .setL3vpnMcastDestination(List.of(MCAST_L3VPN_DESTINATION)).build()).build();
private static final DestinationL3vpnMcastIpv4WithdrawnCase UNREACH_NLRI
= new DestinationL3vpnMcastIpv4WithdrawnCaseBuilder()
.setDestinationIpv4L3vpnMcast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.l3vpn.mcast.ipv4.withdrawn._case.DestinationIpv4L3vpnMcastBuilder()
- .setL3vpnMcastDestination(Collections.singletonList(MCAST_L3VPN_DESTINATION)).build()).build();
+ .setL3vpnMcastDestination(List.of(MCAST_L3VPN_DESTINATION)).build()).build();
private L3VpnMcastIpv4RIBSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- ribSupport = new L3VpnMcastIpv4RIBSupport(this.adapter.currentSerializer());
+ ribSupport = new L3VpnMcastIpv4RIBSupport(adapter.currentSerializer());
setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
final ContainerNode withdraw = createNlriWithDrawnRoute(UNREACH_NLRI);
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), withdraw);
- final InstanceIdentifier<L3vpnMcastRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), withdraw);
+ final InstanceIdentifier<L3vpnMcastRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(L3vpnMcastRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final L3vpnMcastRoute route = (L3vpnMcastRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final L3vpnMcastRoute route = (L3vpnMcastRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MCAST_L3VPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), routes, ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), routes, ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MCAST_L3VPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(routes, List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(L3vpnMcastRoutesIpv4Case.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(L3vpnMcastRoutesIpv4Case.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(MCAST_L3VPN_ROUTES);
final YangInstanceIdentifier expected = getRoutePath().node(prefixNii);
- final YangInstanceIdentifier actual = this.ribSupport.routePath(getTablePath(), prefixNii);
+ final YangInstanceIdentifier actual = ribSupport.routePath(getTablePath(), prefixNii);
assertEquals(expected, actual);
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(Attributes.QNAME.bindTo(L3vpnMcastRoutesIpv4Case.QNAME.getModule())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(L3vpnMcastRoutesIpv4Case.class, this.ribSupport.routesCaseClass());
+ assertEquals(L3vpnMcastRoutesIpv4Case.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(L3vpnMcastRoutesIpv4.class, this.ribSupport.routesContainerClass());
+ assertEquals(L3vpnMcastRoutesIpv4.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(L3vpnMcastRoute.class, this.ribSupport.routesListClass());
+ assertEquals(L3vpnMcastRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new L3vpnMcastRoutesIpv4CaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes
= new L3vpnMcastRoutesIpv4CaseBuilder()
.setL3vpnMcastRoutesIpv4(new L3vpnMcastRoutesIpv4Builder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new L3vpnMcastRoutesIpv4CaseBuilder().setL3vpnMcastRoutesIpv4(MCAST_L3VPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class L3vpnMcastIpv6RIBSupportTest extends AbstractRIBSupportTest<L3vpnMcastRoutesIpv6Case, L3vpnMcastRoutesIpv6,
L3vpnMcastRoute> {
private static final DestinationL3vpnMcastIpv6AdvertizedCase REACH_NLRI
= new DestinationL3vpnMcastIpv6AdvertizedCaseBuilder()
.setDestinationIpv6L3vpnMcast(new DestinationIpv6L3vpnMcastBuilder()
- .setL3vpnMcastDestination(Collections.singletonList(MCAST_L3VPN_DESTINATION)).build()).build();
+ .setL3vpnMcastDestination(List.of(MCAST_L3VPN_DESTINATION)).build()).build();
private static final DestinationL3vpnMcastIpv6WithdrawnCase UNREACH_NLRI
= new DestinationL3vpnMcastIpv6WithdrawnCaseBuilder()
.setDestinationIpv6L3vpnMcast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.l3vpn.mcast.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.l3vpn.mcast.ipv6.withdrawn._case.DestinationIpv6L3vpnMcastBuilder()
- .setL3vpnMcastDestination(Collections.singletonList(MCAST_L3VPN_DESTINATION)).build()).build();
+ .setL3vpnMcastDestination(List.of(MCAST_L3VPN_DESTINATION)).build()).build();
private L3VpnMcastIpv6RIBSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- ribSupport = new L3VpnMcastIpv6RIBSupport(this.adapter.currentSerializer());
+ ribSupport = new L3VpnMcastIpv6RIBSupport(adapter.currentSerializer());
setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
final ContainerNode withdraw = createNlriWithDrawnRoute(UNREACH_NLRI);
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), withdraw);
- final InstanceIdentifier<L3vpnMcastRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), withdraw);
+ final InstanceIdentifier<L3vpnMcastRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(L3vpnMcastRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final L3vpnMcastRoute route = (L3vpnMcastRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final L3vpnMcastRoute route = (L3vpnMcastRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MCAST_L3VPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), routes, ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), routes, ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MCAST_L3VPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(routes, List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(L3vpnMcastRoutesIpv6Case.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(L3vpnMcastRoutesIpv6Case.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(MCAST_L3VPN_ROUTES);
final YangInstanceIdentifier expected = getRoutePath().node(prefixNii);
- final YangInstanceIdentifier actual = this.ribSupport.routePath(getTablePath(), prefixNii);
+ final YangInstanceIdentifier actual = ribSupport.routePath(getTablePath(), prefixNii);
assertEquals(expected, actual);
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(Attributes.QNAME.bindTo(L3vpnMcastRoutesIpv6Case.QNAME.getModule())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(L3vpnMcastRoutesIpv6Case.class, this.ribSupport.routesCaseClass());
+ assertEquals(L3vpnMcastRoutesIpv6Case.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(L3vpnMcastRoutesIpv6.class, this.ribSupport.routesContainerClass());
+ assertEquals(L3vpnMcastRoutesIpv6.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(L3vpnMcastRoute.class, this.ribSupport.routesListClass());
+ assertEquals(L3vpnMcastRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new L3vpnMcastRoutesIpv6CaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes
= new L3vpnMcastRoutesIpv6CaseBuilder()
.setL3vpnMcastRoutesIpv6(new L3vpnMcastRoutesIpv6Builder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new L3vpnMcastRoutesIpv6CaseBuilder().setL3vpnMcastRoutesIpv6(MCAST_L3VPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.Arrays;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
@Parameterized.Parameters
public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][]{
- {IPV4_EXPECTED, Collections.singletonList(MCAST_IPV4_L3VPN_DESTINATION)},
- {IPV6_EXPECTED, Collections.singletonList(MCAST_IPV6_L3VPN_DESTINATION)},
+ return List.of(new Object[][] {
+ { IPV4_EXPECTED, List.of(MCAST_IPV4_L3VPN_DESTINATION) },
+ { IPV6_EXPECTED, List.of(MCAST_IPV6_L3VPN_DESTINATION) },
});
}
@Test
public void testL3vpnMcastNlriSerializer() {
ByteBuf actual = Unpooled.buffer();
- L3vpnMcastNlriSerializer.serializeNlri(this.destination, actual);
- assertArrayEquals(this.expectedArray, ByteArray.getAllBytes(actual));
- assertEquals(this.destination,
- L3vpnMcastNlriSerializer.extractDest(Unpooled.copiedBuffer(this.expectedArray), false));
+ L3vpnMcastNlriSerializer.serializeNlri(destination, actual);
+ assertArrayEquals(expectedArray, ByteArray.getAllBytes(actual));
+ assertEquals(destination,
+ L3vpnMcastNlriSerializer.extractDest(Unpooled.copiedBuffer(expectedArray), false));
}
}
\ No newline at end of file
import static org.junit.Assert.assertEquals;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
};
static final IpPrefix IPV4_PREFIX = new IpPrefix(new Ipv4Prefix("34.1.22.0/24"));
- static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
+ static final List<LabelStack> LABEL_STACK = List.of(
new LabelStackBuilder().setLabelValue(new MplsLabel(Uint32.valueOf(355))).build());
static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder
.getDefaultInstance("1.2.3.4:258");
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder()
.setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
- Collections.singletonList(new VpnDestinationBuilder(IPV4_VPN).setPathId(null)
+ List.of(new VpnDestinationBuilder(IPV4_VPN).setPathId(null)
.build())).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
.setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
- Collections.singletonList(IPV4_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
+ List.of(IPV4_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
.setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(
- Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
+ List.of(IPV4_VPN)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
package org.opendaylight.protocol.bgp.l3vpn.unicast.ipv4;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv4.VpnIpv4NlriParserTest.DISTINGUISHER;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv4.VpnIpv4NlriParserTest.LABEL_STACK;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class VpnIpv4RIBSupportTest extends AbstractRIBSupportTest<VpnIpv4RoutesCase, VpnIpv4Routes, VpnRoute> {
private VpnIpv4RIBSupport ribSupport;
private static final DestinationVpnIpv4Case REACH_NLRI = new DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(
- new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build();
+ new VpnIpv4DestinationBuilder().setVpnDestination(List.of(IPV4_VPN)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4Case UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv4CaseBuilder()
.setVpnIpv4Destination(new VpnIpv4DestinationBuilder()
- .setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build();
+ .setVpnDestination(List.of(IPV4_VPN)).build()).build();
private static final VpnRouteKey ROUTE_KEY = new VpnRouteKey(new PathId(Uint32.ZERO), "WAABAQIDBAECIgEW");
private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(NON_PATH_ID)
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new VpnIpv4RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new VpnIpv4RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<VpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<VpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final VpnRoute route = (VpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final VpnRoute route = (VpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(VpnIpv4Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(VpnIpv4RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(VpnIpv4RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(VpnIpv4Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(VpnIpv4Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(VpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(VpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new VpnIpv4RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(
new VpnIpv4RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new VpnIpv4RoutesCaseBuilder().setVpnIpv4Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
import static org.junit.Assert.assertEquals;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.Collections;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.BGPParsingException;
};
static final IpPrefix IPV6PREFIX = new IpPrefix(new Ipv6Prefix("2001:2345:5689::/48"));
- static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
+ static final List<LabelStack> LABEL_STACK = List.of(
new LabelStackBuilder().setLabelValue(new MplsLabel(Uint32.valueOf(355))).build());
static final RouteDistinguisher DISTINGUISHER = RouteDistinguisherBuilder
.getDefaultInstance("1.2.3.4:258");
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
- Collections.singletonList(new VpnDestinationBuilder(IPV6_VPN).setPathId(null).build()))
+ List.of(new VpnDestinationBuilder(IPV6_VPN).setPathId(null).build()))
.build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
- Collections.singletonList(IPV6_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
+ List.of(IPV6_VPN_WITHOUT_LABELS)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
mpBuilder.setWithdrawnRoutes(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(
- Collections.singletonList(IPV6_VPN)).build()).build()).build()).build();
+ List.of(IPV6_VPN)).build()).build()).build()).build();
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
package org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6.VpnIpv6NlriParserTest.DISTINGUISHER;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6.VpnIpv6NlriParserTest.IPV6PREFIX;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6.VpnIpv6NlriParserTest.IPV6_VPN;
import static org.opendaylight.protocol.bgp.l3vpn.unicast.ipv6.VpnIpv6NlriParserTest.LABEL_STACK;
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.PathId;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class VpnIpv6RIBSupportTest extends AbstractRIBSupportTest<VpnIpv6RoutesCase, VpnIpv6Routes, VpnRoute> {
private VpnIpv6RIBSupport ribSupport;
private static final DestinationVpnIpv6Case REACH_NLRI = new DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
- .setVpnDestination(Lists.newArrayList(IPV6_VPN)).build()).build();
+ .setVpnDestination(List.of(IPV6_VPN)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6Case UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
.setVpnIpv6Destination(new VpnIpv6DestinationBuilder()
- .setVpnDestination(Collections.singletonList(IPV6_VPN)).build()).build();
+ .setVpnDestination(List.of(IPV6_VPN)).build()).build();
private static final VpnRouteKey ROUTE_KEY = new VpnRouteKey(new PathId(Uint32.ZERO), "cAABAQIDBAECIAEjRVaJ");
private static final VpnRoute ROUTE = new VpnRouteBuilder().setPathId(NON_PATH_ID)
.setAttributes(ATTRIBUTES).setPrefix(IPV6PREFIX)
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new VpnIpv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new VpnIpv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<VpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<VpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(VpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final VpnRoute route = (VpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final VpnRoute route = (VpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(VpnIpv6Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())), ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(VpnIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(VpnIpv6RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(VpnIpv6Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(VpnIpv6Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(VpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(VpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new VpnIpv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new VpnIpv6RoutesCaseBuilder()
.setVpnIpv6Routes(new VpnIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new VpnIpv6RoutesCaseBuilder().setVpnIpv6Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doReturn;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.List;
(byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00,
};
- private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(
+ private static final List<LabelStack> LABEL_STACK = List.of(
new LabelStackBuilder().setLabelValue(new MplsLabel(Uint32.valueOf(355))).build(),
new LabelStackBuilder().setLabelValue(new MplsLabel(Uint32.valueOf(356))).build(),
new LabelStackBuilder().setLabelValue(new MplsLabel(Uint32.valueOf(357))).build());
@Before
public void setUp() {
- doReturn(Optional.of(this.muliPathSupport)).when(this.constraint).getPeerConstraint(any());
- doReturn(true).when(this.muliPathSupport).isTableTypeSupported(any());
+ doReturn(Optional.of(muliPathSupport)).when(constraint).getPeerConstraint(any());
+ doReturn(true).when(muliPathSupport).isTableTypeSupported(any());
}
@Test
.setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
+ new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(List.of(lu)).build())
.build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
.setPrefix(IPV4_PREFIX).setLabelStack(LABEL_STACK).build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationLabeledUnicastCaseBuilder().setDestinationLabeledUnicast(
- new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(Lists.newArrayList(lu))
+ new DestinationLabeledUnicastBuilder().setCLabeledUnicastDestination(List.of(lu))
.build()).build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV4_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV4_ADD_PATH), testBuilder, constraint);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
.setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
+ .setCLabeledUnicastDestination(List.of(lu1)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
.setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
+ .setCLabeledUnicastDestination(List.of(lu2)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
.setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build())
+ .setCLabeledUnicastDestination(List.of(lu1)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
.setDestinationLabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.labeled.unicast._case.DestinationLabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build())
+ .setCLabeledUnicastDestination(List.of(lu2)).build())
.build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV4_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV4_ADD_PATH), testBuilder, constraint);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv6LabeledUnicastCaseBuilder()
.setDestinationIpv6LabeledUnicast(new DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu)).build())
+ .setCLabeledUnicastDestination(List.of(lu)).build())
.build()).build());
final MpReachNlri mpReachExpected = mpBuilder.build();
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(
new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
new DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu)).build()).build())
+ .setCLabeledUnicastDestination(List.of(lu)).build()).build())
.build());
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV6_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_REACH_NLRI_IPV6_ADD_PATH), testBuilder, constraint);
assertEquals(mpReachExpected, testBuilder.build());
//test serializer
.setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build()).build()).build());
+ .setCLabeledUnicastDestination(List.of(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPrefix(IPV6_PREFIX)
.setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
+ .setCLabeledUnicastDestination(List.of(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
//test parser
.setDestinationIpv6LabeledUnicast(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.labeled.unicast.rev180329.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.ipv6.labeled.unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu1)).build()).build()).build());
+ .setCLabeledUnicastDestination(List.of(lu1)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected1 = mpBuilder.build();
final CLabeledUnicastDestination lu2 = new CLabeledUnicastDestinationBuilder().setPathId(PATH_ID)
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev180329
.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.ipv6.labeled
.unicast._case.DestinationIpv6LabeledUnicastBuilder()
- .setCLabeledUnicastDestination(Lists.newArrayList(lu2)).build()).build()).build());
+ .setCLabeledUnicastDestination(List.of(lu2)).build()).build()).build());
final MpUnreachNlri mpUnreachExpected2 = mpBuilder.build();
//test parser
final MpUnreachNlriBuilder testBuilder = new MpUnreachNlriBuilder();
testBuilder.setAfi(Ipv6AddressFamily.class);
testBuilder.setSafi(LabeledUnicastSubsequentAddressFamily.class);
- parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV6_ADD_PATH), testBuilder, this.constraint);
+ parser.parseNlri(Unpooled.copiedBuffer(LU_UNREACH_NLRI_IPV6_ADD_PATH), testBuilder, constraint);
assertEquals(mpUnreachExpected1, testBuilder.build());
//test serializer
package org.opendaylight.protocol.bgp.labeled.unicast;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class LabeledUnicastIpv4RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastRoutesCase,
LabeledUnicastRoutes, LabeledUnicastRoute> {
private static final LabeledUnicastRouteKey ROUTE_KEY;
private static final String LABEL_KEY;
private static final PathId PATH_ID = new PathId(Uint32.ONE);
- private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(new LabelStackBuilder()
+ private static final List<LabelStack> LABEL_STACK = List.of(new LabelStackBuilder()
.setLabelValue(new MplsLabel(Uint32.valueOf(355))).build());
- private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST
- = Collections.singletonList(new CLabeledUnicastDestinationBuilder()
+ private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST =
+ List.of(new CLabeledUnicastDestinationBuilder()
.setPathId(PATH_ID).setLabelStack(LABEL_STACK).setPrefix(IPV4_PREFIX).build());
private static final DestinationLabeledUnicastCase REACH_NLRI = new DestinationLabeledUnicastCaseBuilder()
.setDestinationLabeledUnicast(new DestinationLabeledUnicastBuilder()
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new LabeledUnicastIpv4RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new LabeledUnicastIpv4RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(LabeledUnicastRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final LabeledUnicastRoute route = (LabeledUnicastRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final LabeledUnicastRoute route = (LabeledUnicastRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(ImmutableSet.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(ImmutableSet.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new NodeIdentifier(QName.create(LabeledUnicastRoutes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(LabeledUnicastRoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(LabeledUnicastRoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(LabeledUnicastRoutes.class, this.ribSupport.routesContainerClass());
+ assertEquals(LabeledUnicastRoutes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(LabeledUnicastRoute.class, this.ribSupport.routesListClass());
+ assertEquals(LabeledUnicastRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new LabeledUnicastRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new LabeledUnicastRoutesCaseBuilder()
.setLabeledUnicastRoutes(new LabeledUnicastRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new LabeledUnicastRoutesCaseBuilder().setLabeledUnicastRoutes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
package org.opendaylight.protocol.bgp.labeled.unicast;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.parser.spi.BGPExtensionProviderContext;
import org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class LabeledUnicastIpv6RIBSupportTest extends AbstractRIBSupportTest<LabeledUnicastIpv6RoutesCase,
LabeledUnicastIpv6Routes, LabeledUnicastRoute> {
private static final LabeledUnicastRouteKey ROUTE_KEY;
private static final String LABEL_KEY;
private static final PathId PATH_ID = new PathId(Uint32.ONE);
- private static final List<LabelStack> LABEL_STACK = Lists.newArrayList(new LabelStackBuilder()
+ private static final List<LabelStack> LABEL_STACK = List.of(new LabelStackBuilder()
.setLabelValue(new MplsLabel(Uint32.valueOf(355))).build());
- private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST
- = Collections.singletonList(new CLabeledUnicastDestinationBuilder()
+ private static final List<CLabeledUnicastDestination> LABELED_DESTINATION_LIST =
+ List.of(new CLabeledUnicastDestinationBuilder()
.setPathId(PATH_ID).setLabelStack(LABEL_STACK).setPrefix(IPV6_PREFIX).build());
private static final DestinationIpv6LabeledUnicastCase REACH_NLRI
= new DestinationIpv6LabeledUnicastCaseBuilder().setDestinationIpv6LabeledUnicast(
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new LabeledUnicastIpv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new LabeledUnicastIpv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<LabeledUnicastRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(LabeledUnicastRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final LabeledUnicastRoute route = (LabeledUnicastRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final LabeledUnicastRoute route = (LabeledUnicastRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
assertEquals(getRoutePath().node(prefixNii),
- this.ribSupport.routePath(getTablePath(), prefixNii));
+ ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
assertEquals(new NodeIdentifier(QName.create(LabeledUnicastIpv6Routes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables
.Attributes.QNAME.getLocalName().intern())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(LabeledUnicastIpv6RoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(LabeledUnicastIpv6RoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(LabeledUnicastIpv6Routes.class, this.ribSupport.routesContainerClass());
+ assertEquals(LabeledUnicastIpv6Routes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(LabeledUnicastRoute.class, this.ribSupport.routesListClass());
+ assertEquals(LabeledUnicastRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new LabeledUnicastIpv6RoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new LabeledUnicastIpv6RoutesCaseBuilder()
.setLabeledUnicastIpv6Routes(new LabeledUnicastIpv6RoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new LabeledUnicastIpv6RoutesCaseBuilder().setLabeledUnicastIpv6Routes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint32;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Set;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrLinkAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
import org.opendaylight.protocol.util.BitArray;
}
private static void parseSrlg(final ByteBuf value, final LinkAttributesBuilder builder) {
- final List<SrlgId> sharedRiskLinkGroups = new ArrayList<>();
+ final var sharedRiskLinkGroups = ImmutableSet.<SrlgId>builder();
while (value.isReadable()) {
sharedRiskLinkGroups.add(new SrlgId(readUint32(value)));
}
- builder.setSharedRiskLinkGroups(sharedRiskLinkGroups);
+ builder.setSharedRiskLinkGroups(sharedRiskLinkGroups.build());
LOG.debug("Parsed Shared Risk Link Groups {}", builder.getSharedRiskLinkGroups());
}
}
}
-
static void serializeLinkAttributes(final LinkAttributesCase linkAttributesCase, final ByteBuf output) {
final LinkAttributes linkAttributes = linkAttributesCase.getLinkAttributes();
LOG.trace("Started serializing Link Attributes");
}
}
- private static void serializeSrlg(final List<SrlgId> srlgList, final ByteBuf byteAggregator) {
+ private static void serializeSrlg(final Set<SrlgId> srlgList, final ByteBuf byteAggregator) {
if (srlgList != null) {
final ByteBuf sharedRLGBuf = Unpooled.buffer();
for (final SrlgId srlgId : srlgList) {
import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.writeUint16;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.buffer.Unpooled;
import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Map.Entry;
+import java.util.Set;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.SrNodeAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
import org.opendaylight.protocol.util.BitArray;
*/
static LinkStateAttribute parseNodeAttributes(final Multimap<Integer, ByteBuf> attributes,
final ProtocolId protocolId) {
- final List<TopologyIdentifier> topologyMembership = new ArrayList<>();
- final List<IsisAreaIdentifier> areaMembership = new ArrayList<>();
+ final var topologyMembership = ImmutableSet.<TopologyIdentifier>builder();
+ final var areaMembership = ImmutableSet.<IsisAreaIdentifier>builder();
final NodeAttributesBuilder builder = new NodeAttributesBuilder();
for (final Entry<Integer, ByteBuf> entry : attributes.entries()) {
final int key = entry.getKey();
}
}
LOG.trace("Finished parsing Node Attributes.");
- builder.setTopologyIdentifier(topologyMembership);
- builder.setIsisAreaId(areaMembership);
+ builder.setTopologyIdentifier(topologyMembership.build());
+ builder.setIsisAreaId(areaMembership.build());
return new NodeAttributesCaseBuilder().setNodeAttributes(builder.build()).build();
}
flags.get(OVERLOAD_BIT), flags.get(ATTACHED_BIT), flags.get(EXTERNAL_BIT), flags.get(ABBR_BIT));
}
- private static void parseTopologyId(final List<TopologyIdentifier> topologyMembership, final ByteBuf value) {
+ private static void parseTopologyId(final ImmutableSet.Builder<TopologyIdentifier> topologyMembership,
+ final ByteBuf value) {
while (value.isReadable()) {
final TopologyIdentifier topId = new TopologyIdentifier(
Uint16.valueOf(value.readUnsignedShort() & TlvUtil.TOPOLOGY_ID_OFFSET));
TlvUtil.writeTLV(DYNAMIC_HOSTNAME, Unpooled.wrappedBuffer(StandardCharsets.UTF_8.encode(
nodeAttributes.getDynamicHostname())), byteAggregator);
}
- final List<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
+ final Set<IsisAreaIdentifier> isisList = nodeAttributes.getIsisAreaId();
if (isisList != null) {
for (final IsisAreaIdentifier isisAreaIdentifier : isisList) {
TlvUtil.writeTLV(ISIS_AREA_IDENTIFIER, Unpooled.wrappedBuffer(isisAreaIdentifier.getValue()),
LOG.trace("Finished serializing Node Attributes");
}
- private static void serializeTopologyId(final List<TopologyIdentifier> topList, final ByteBuf byteAggregator) {
+ private static void serializeTopologyId(final Set<TopologyIdentifier> topList, final ByteBuf byteAggregator) {
if (topList != null) {
final ByteBuf mpIdBuf = Unpooled.buffer();
for (final TopologyIdentifier topologyIdentifier : topList) {
import static org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.sid.sub.tlvs.Ipv6PrefixSidParser.IPV6_PREFIX_SID;
import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.Map.Entry;
+import java.util.Set;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.BindingSidLabelParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.Ipv6SrPrefixAttributesParser;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.RangeTlvParser;
parseAttribute(key, value, protocolId, builder, routeTags, exRouteTags);
}
LOG.trace("Finished parsing Prefix Attributes.");
- builder.setRouteTags(routeTags);
- builder.setExtendedTags(exRouteTags);
+ builder.setRouteTags(ImmutableSet.copyOf(routeTags));
+ builder.setExtendedTags(ImmutableSet.copyOf(exRouteTags));
return new PrefixAttributesCaseBuilder().setPrefixAttributes(builder.build()).build();
}
}
}
- private static void serializeRouteTags(final List<RouteTag> routeTags, final ByteBuf byteAggregator) {
+ private static void serializeRouteTags(final Set<RouteTag> routeTags, final ByteBuf byteAggregator) {
if (routeTags != null) {
final ByteBuf routeTagsBuf = Unpooled.buffer();
for (final RouteTag routeTag : routeTags) {
}
}
- private static void serializeExtendedRouteTags(final List<ExtendedRouteTag> exRouteTags,
+ private static void serializeExtendedRouteTags(final Set<ExtendedRouteTag> exRouteTags,
final ByteBuf byteAggregator) {
if (exRouteTags != null) {
final ByteBuf extendedBuf = Unpooled.buffer();
import static org.opendaylight.protocol.bgp.linkstate.impl.attribute.sr.binding.sid.sub.tlvs.SIDParser.SID_TYPE;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
-import java.util.ArrayList;
-import java.util.List;
import org.opendaylight.mdsal.rfc8294.netty.RFC8294ByteBufUtils;
import org.opendaylight.protocol.bgp.linkstate.spi.TlvUtil;
import org.opendaylight.protocol.util.BitArray;
public static SrAlgorithm parseSrAlgorithms(final ByteBuf buffer) {
final SrAlgorithmBuilder builder = new SrAlgorithmBuilder();
- final List<Algorithm> algs = new ArrayList<>();
+ final var algs = ImmutableSet.<Algorithm>builder();
while (buffer.isReadable()) {
algs.add(Algorithm.forValue(buffer.readUnsignedByte()));
}
- builder.setAlgorithms(algs);
+ builder.setAlgorithms(algs.build());
return builder.build();
}
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Arrays;
+import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.attribute.LinkstateAttributeParser;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.AssociationType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.association.object.AssociationObject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.tspec.object.TspecObject;
+import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
@Before
public final void setUp() {
- this.context = new SimpleRSVPExtensionProviderContext();
- this.rsvpActivator = new RSVPActivator();
- this.rsvpActivator.start(this.context);
- this.parser = new LinkstateAttributeParser(false,this.context.getRsvpRegistry());
+ context = new SimpleRSVPExtensionProviderContext();
+ rsvpActivator = new RSVPActivator();
+ rsvpActivator.start(context);
+ parser = new LinkstateAttributeParser(false,context.getRsvpRegistry());
}
private static AttributesBuilder createBuilder(final ObjectType type) {
.setAdvertizedRoutes(new AdvertizedRoutesBuilder()
.setDestinationType(new DestinationLinkstateCaseBuilder()
.setDestinationLinkstate(new DestinationLinkstateBuilder()
- .setCLinkstateDestination(Lists.newArrayList(new CLinkstateDestinationBuilder()
+ .setCLinkstateDestination(List.of(new CLinkstateDestinationBuilder()
.setObjectType(type)
.setProtocolId(ProtocolId.IsisLevel1)
.build()))
.setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.bgp.linkstate.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes
.destination.type.destination.linkstate._case.DestinationLinkstateBuilder()
- .setCLinkstateDestination(Lists.newArrayList(new CLinkstateDestinationBuilder()
+ .setCLinkstateDestination(List.of(new CLinkstateDestinationBuilder()
.setObjectType(type)
.setProtocolId(ProtocolId.IsisLevel1)
.build()))
public void testGetNlriType() throws BGPParsingException, BGPDocumentedException {
final ByteBuf b = Unpooled.buffer();
AttributesBuilder builder = new AttributesBuilder();
- this.parser.parseAttribute(b, builder, null);
+ parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final AttributesReachBuilder builder1 = new AttributesReachBuilder();
builder.addAugmentation(builder1.build());
- this.parser.parseAttribute(b, builder, null);
+ parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
.build())
.build())
.build());
- this.parser.parseAttribute(b, builder, null);
+ parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final AttributesUnreachBuilder builder2 = new AttributesUnreachBuilder();
builder.addAugmentation(builder2.build());
- this.parser.parseAttribute(b, builder, null);
+ parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
.build())
.build())
.build());
- this.parser.parseAttribute(b, builder, null);
+ parser.parseAttribute(b, builder, null);
assertEquals(0, b.readableBytes());
}
@Test
public void testPositiveLinks() throws BGPParsingException, BGPDocumentedException {
final AttributesBuilder builder = createBuilder(new LinkCaseBuilder().build());
- this.parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder, null);
+ parser.parseAttribute(Unpooled.copiedBuffer(LINK_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final LinkAttributes ls = ((LinkAttributesCase) attrs.getLinkStateAttribute()).getLinkAttributes();
assertNotNull(ls);
assertTrue(ls.getMplsProtocol().getRsvpte());
assertEquals(Uint32.TEN, ls.getMetric().getValue());
assertEquals(2, ls.getSharedRiskLinkGroups().size());
- assertEquals(305419896, ls.getSharedRiskLinkGroups().get(0).getValue().intValue());
+ assertEquals(305419896, ls.getSharedRiskLinkGroups().iterator().next().getValue().intValue());
assertEquals("12K-2", ls.getLinkName());
final IsisAdjFlagsCase flags = new IsisAdjFlagsCaseBuilder()
.setIsisAdjFlags(new IsisAdjFlagsBuilder()
//serialization
final ByteBuf buff = Unpooled.buffer();
- this.parser.serializeAttribute(builder.build(), buff);
+ parser.serializeAttribute(builder.build(), buff);
// The LINK_ATTR buffer is now greater than 255 bytes. Need to skip one more byte
buff.skipBytes(4);
// there is unresolved TLV at the end, that needs to be cut off
@Test
public void testPositiveNodes() throws BGPParsingException, BGPDocumentedException {
final AttributesBuilder builder = createBuilder(new NodeCaseBuilder().build());
- this.parser.parseAttribute(Unpooled.copiedBuffer(NODE_ATTR), builder, null);
+ parser.parseAttribute(Unpooled.copiedBuffer(NODE_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final NodeAttributes ls = ((NodeAttributesCase) attrs.getLinkStateAttribute()).getNodeAttributes();
assertNotNull(ls);
assertEquals(2, ls.getTopologyIdentifier().size());
- assertEquals(42, ls.getTopologyIdentifier().get(0).getValue().intValue());
+ assertEquals(Uint16.valueOf(42), ls.getTopologyIdentifier().iterator().next().getValue());
assertTrue(ls.getNodeFlags().getOverload());
assertFalse(ls.getNodeFlags().getAttached());
assertTrue(ls.getNodeFlags().getExternal());
//serialization
final ByteBuf buff = Unpooled.buffer();
- this.parser.serializeAttribute(builder.build(), buff);
+ parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
assertArrayEquals(NODE_ATTR_S, ByteArray.getAllBytes(buff));
}
final AttributesBuilder builder = createUnreachBuilder(new PrefixCaseBuilder().setPrefixDescriptors(
new PrefixDescriptorsBuilder().setIpReachabilityInformation(new IpPrefix(new Ipv4Prefix("127.0.0.1/32")))
.build()).build());
- this.parser.parseAttribute(Unpooled.copiedBuffer(P4_ATTR), builder, null);
+ parser.parseAttribute(Unpooled.copiedBuffer(P4_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final PrefixAttributes ls = ((PrefixAttributesCase) attrs.getLinkStateAttribute()).getPrefixAttributes();
assertTrue(ispBits.getOspfLocalAddress());
assertTrue(ispBits.getOspfPropagateNssa());
assertEquals(2, ls.getRouteTags().size());
- assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 }, ls.getRouteTags().get(0)
- .getValue());
+ assertArrayEquals(new byte[] { (byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78 },
+ ls.getRouteTags().iterator().next().getValue());
assertEquals(1, ls.getExtendedTags().size());
assertArrayEquals(new byte[] {
(byte) 0x12, (byte) 0x34, (byte) 0x56, (byte) 0x78, (byte) 0x10, (byte) 0x30, (byte) 0x50, (byte) 0x70
- }, ls.getExtendedTags().get(0).getValue());
+ }, ls.getExtendedTags().iterator().next().getValue());
assertEquals(10, ls.getPrefixMetric().getValue().intValue());
assertEquals("10.25.2.27", ls.getOspfForwardingAddress().getIpv4AddressNoZone().getValue());
//serialization
final ByteBuf buff = Unpooled.buffer();
- this.parser.serializeAttribute(builder.build(), buff);
+ parser.serializeAttribute(builder.build(), buff);
buff.skipBytes(3);
// there is unresolved TLV at the end, that needs to be cut off
assertArrayEquals(P4_ATTR, ByteArray.getAllBytes(buff));
@Test
public void testPositiveTELspAttribute() throws BGPParsingException, BGPDocumentedException {
final AttributesBuilder builder = createBuilder(new TeLspCaseBuilder().build());
- this.parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder, null);
+ parser.parseAttribute(Unpooled.copiedBuffer(TE_LSP_ATTR), builder, null);
final Attributes1 attrs = builder.augmentation(Attributes1.class);
final TeLspAttributes teLspAttributes = ((TeLspAttributesCase) attrs.getLinkStateAttribute())
//serialization
final ByteBuf buff = Unpooled.buffer();
- this.parser.serializeAttribute(builder.build(), buff);
+ parser.serializeAttribute(builder.build(), buff);
assertArrayEquals(TE_LSP_ATTR, ByteArray.getAllBytes(buff));
assertTrue(Arrays.equals(TE_LSP_ATTR, ByteArray.getAllBytes(buff)));
}
package org.opendaylight.protocol.bgp.linkstate;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
-import org.junit.Assert;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator;
import org.opendaylight.protocol.bgp.linkstate.impl.LinkstateRIBSupport;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public final class LinkstateRIBSupportTest extends AbstractRIBSupportTest<LinkstateRoutesCase, LinkstateRoutes,
LinkstateRoute> {
private static final DestinationLinkstateCase REACH_NLRI = new DestinationLinkstateCaseBuilder()
.setDestinationLinkstate(new DestinationLinkstateBuilder()
- .setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
+ .setCLinkstateDestination(List.of(LINKSTATE_DESTINATION)).build()).build();
private static final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.update
.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationLinkstateCase UNREACH_NLRI =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.update.attributes
.setDestinationLinkstate(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.bgp.linkstate.rev200120.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type
.destination.linkstate._case.DestinationLinkstateBuilder()
- .setCLinkstateDestination(Collections.singletonList(LINKSTATE_DESTINATION)).build()).build();
+ .setCLinkstateDestination(List.of(LINKSTATE_DESTINATION)).build()).build();
static {
final BGPActivator act = new BGPActivator();
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new LinkstateRIBSupport(this.adapter.currentSerializer());
+ ribSupport = new LinkstateRIBSupport(adapter.currentSerializer());
setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
- final InstanceIdentifier<LinkstateRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), createNlriWithDrawnRoute(UNREACH_NLRI));
+ final InstanceIdentifier<LinkstateRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(LinkstateRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final LinkstateRoute route = (LinkstateRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final LinkstateRoute route = (LinkstateRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), createRoutes(ROUTES), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), createRoutes(ROUTES), ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class)
.getMpUnreachNlri().getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
- final Update update = this.ribSupport.buildUpdate(createRoutes(ROUTES), Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(createRoutes(ROUTES), List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class)
.getMpReachNlri().getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- Assert.assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(ROUTES);
- Assert.assertEquals(getRoutePath().node(prefixNii), this.ribSupport.routePath(getTablePath(), prefixNii));
+ assertEquals(getRoutePath().node(prefixNii), ribSupport.routePath(getTablePath(), prefixNii));
}
@Test
public void testRouteAttributesIdentifier() {
- Assert.assertEquals(new NodeIdentifier(QName.create(LinkstateRoutes.QNAME,
+ assertEquals(new NodeIdentifier(QName.create(LinkstateRoutes.QNAME,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Attributes
- .QNAME.getLocalName().intern())), this.ribSupport.routeAttributesIdentifier());
+ .QNAME.getLocalName().intern())), ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- Assert.assertEquals(LinkstateRoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(LinkstateRoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- Assert.assertEquals(LinkstateRoutes.class, this.ribSupport.routesContainerClass());
+ assertEquals(LinkstateRoutes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- Assert.assertEquals(LinkstateRoute.class, this.ribSupport.routesListClass());
+ assertEquals(LinkstateRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new LinkstateRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new LinkstateRoutesCaseBuilder()
.setLinkstateRoutes(new LinkstateRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- Assert.assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new LinkstateRoutesCaseBuilder().setLinkstateRoutes(ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
- Assert.assertFalse(result.isEmpty());
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
+ assertFalse(result.isEmpty());
}
}
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;
import org.junit.Before;
paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
assertEquals(paBuilder.getOrigin(), attrs.getOrigin());
- paBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
+ paBuilder.setAsPath(new AsPathBuilder().setSegments(List.of()).build());
assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
paBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
new LinkAttributesCaseBuilder().setLinkAttributes(new LinkAttributesBuilder()
.setMetric(new Metric(Uint32.ONE)).build()).build());
paBuilder.addAugmentation(lsAttrBuilder.build());
- paBuilder.setUnrecognizedAttributes(Collections.emptyMap());
+ paBuilder.setUnrecognizedAttributes(Map.of());
assertEquals(
lsAttrBuilder.build(),
paBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
assertEquals(paBuilder.getOrigin(), attrs.getOrigin());
- paBuilder.setAsPath(new AsPathBuilder().setSegments(Collections.emptyList()).build());
+ paBuilder.setAsPath(new AsPathBuilder().setSegments(List.of()).build());
assertEquals(paBuilder.getAsPath(), attrs.getAsPath());
paBuilder.setLocalPref(new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build());
assertEquals(paBuilder.getLocalPref(), attrs.getLocalPref());
paBuilder.addAugmentation(lsBuilder.build());
- paBuilder.setUnrecognizedAttributes(Collections.emptyMap());
+ paBuilder.setUnrecognizedAttributes(Map.of());
final MpReachNlri mp = attrs.augmentation(AttributesReach.class).getMpReachNlri();
assertEquals(mpBuilder.getAfi(), mp.getAfi());
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import com.google.common.collect.Lists;
import com.google.common.primitives.Bytes;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.bgp.linkstate.impl.BGPActivator;
@Test
public void testSrAlgorithm() {
final byte[] bytes = { 0 };
- final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Lists.newArrayList(Algorithm.ShortestPathFirst))
- .build();
- final SrAlgorithm empty = new SrAlgorithmBuilder().setAlgorithms(Collections.emptyList()).build();
+ final SrAlgorithm alg = new SrAlgorithmBuilder().setAlgorithms(Set.of(Algorithm.ShortestPathFirst)).build();
+ final SrAlgorithm empty = new SrAlgorithmBuilder().setAlgorithms(Set.of()).build();
assertEquals(alg, SrNodeAttributesParser.parseSrAlgorithms(Unpooled.wrappedBuffer(bytes)));
final ByteBuf b = Unpooled.buffer();
assertEquals(empty, SrNodeAttributesParser.parseSrAlgorithms(b));
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class MvpnIpv4RIBSupportTest extends AbstractRIBSupportTest<MvpnRoutesIpv4Case, MvpnRoutesIpv4, MvpnRoute> {
private static final PathId PATH_ID = new PathId(Uint32.ZERO);
.build();
private static final DestinationMvpnIpv4AdvertizedCase REACH_NLRI = new DestinationMvpnIpv4AdvertizedCaseBuilder()
.setDestinationMvpn(new DestinationMvpnBuilder()
- .setMvpnDestination(Collections.singletonList(MVPN_DESTINATION)).build()).build();
+ .setMvpnDestination(List.of(MVPN_DESTINATION)).build()).build();
private static final DestinationMvpnIpv4WithdrawnCase UNREACH_NLRI = new DestinationMvpnIpv4WithdrawnCaseBuilder()
.setDestinationMvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv4
.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.mvpn
.ipv4.withdrawn._case.DestinationMvpnBuilder()
- .setMvpnDestination(Collections.singletonList(MVPN_DESTINATION)).build()).build();
+ .setMvpnDestination(List.of(MVPN_DESTINATION)).build()).build();
private MvpnIpv4RIBSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new MvpnIpv4RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new MvpnIpv4RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
final ContainerNode withdraw = createNlriWithDrawnRoute(UNREACH_NLRI);
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), withdraw);
- final InstanceIdentifier<MvpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), withdraw);
+ final InstanceIdentifier<MvpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(MvpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final MvpnRoute route = (MvpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final MvpnRoute route = (MvpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MVPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), routes, ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), routes, ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MVPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(routes, List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(MvpnRoutesIpv4Case.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(MvpnRoutesIpv4Case.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(MVPN_ROUTES);
final YangInstanceIdentifier expected = getRoutePath().node(prefixNii);
- final YangInstanceIdentifier actual = this.ribSupport.routePath(getTablePath(), prefixNii);
+ final YangInstanceIdentifier actual = ribSupport.routePath(getTablePath(), prefixNii);
assertEquals(expected, actual);
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(Attributes.QNAME.bindTo(MvpnRoutesIpv4Case.QNAME.getModule())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(MvpnRoutesIpv4Case.class, this.ribSupport.routesCaseClass());
+ assertEquals(MvpnRoutesIpv4Case.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(MvpnRoutesIpv4.class, this.ribSupport.routesContainerClass());
+ assertEquals(MvpnRoutesIpv4.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(MvpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(MvpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new MvpnRoutesIpv4CaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes
= new MvpnRoutesIpv4CaseBuilder().setMvpnRoutesIpv4(new MvpnRoutesIpv4Builder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new MvpnRoutesIpv4CaseBuilder().setMvpnRoutesIpv4(MVPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
+import java.util.List;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RdIpv4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.RouteDistinguisher;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public final class MvpnIpv6RIBSupportTest
extends AbstractRIBSupportTest<MvpnRoutesIpv6Case, MvpnRoutesIpv6, MvpnRoute> {
.setMvpnChoice(MVPN)
.build();
private static final MvpnRoutesIpv6 MVPN_ROUTES
- = new MvpnRoutesIpv6Builder().setMvpnRoute(Map.of(ROUTE.key(), ROUTE)).build();
+ = new MvpnRoutesIpv6Builder().setMvpnRoute(BindingMap.of(ROUTE)).build();
private static final MvpnDestination MVPN_DESTINATION = new MvpnDestinationBuilder()
.setMvpnChoice(MVPN)
.setPathId(PATH_ID)
.build();
private static final DestinationMvpnIpv6AdvertizedCase REACH_NLRI = new DestinationMvpnIpv6AdvertizedCaseBuilder()
.setDestinationMvpn(new DestinationMvpnBuilder()
- .setMvpnDestination(Collections.singletonList(MVPN_DESTINATION)).build()).build();
+ .setMvpnDestination(List.of(MVPN_DESTINATION)).build()).build();
private static final DestinationMvpnIpv6WithdrawnCase UNREACH_NLRI = new DestinationMvpnIpv6WithdrawnCaseBuilder()
.setDestinationMvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv6
.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.mvpn
.ipv6.withdrawn._case.DestinationMvpnBuilder()
- .setMvpnDestination(Collections.singletonList(MVPN_DESTINATION)).build()).build();
+ .setMvpnDestination(List.of(MVPN_DESTINATION)).build()).build();
private MvpnIpv6RIBSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new MvpnIpv6RIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new MvpnIpv6RIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
final ContainerNode withdraw = createNlriWithDrawnRoute(UNREACH_NLRI);
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), withdraw);
- final InstanceIdentifier<MvpnRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), withdraw);
+ final InstanceIdentifier<MvpnRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(MvpnRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final MvpnRoute route = (MvpnRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final MvpnRoute route = (MvpnRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MVPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), routes, ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), routes, ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(MVPN_ROUTES);
- final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(routes, List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(MvpnRoutesIpv6Case.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(MvpnRoutesIpv6Case.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final NodeIdentifierWithPredicates prefixNii = createRouteNIWP(MVPN_ROUTES);
final YangInstanceIdentifier expected = getRoutePath().node(prefixNii);
- final YangInstanceIdentifier actual = this.ribSupport.routePath(getTablePath(), prefixNii);
+ final YangInstanceIdentifier actual = ribSupport.routePath(getTablePath(), prefixNii);
assertEquals(expected, actual);
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(Attributes.QNAME.bindTo(MvpnRoutesIpv6Case.QNAME.getModule())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(MvpnRoutesIpv6Case.class, this.ribSupport.routesCaseClass());
+ assertEquals(MvpnRoutesIpv6Case.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(MvpnRoutesIpv6.class, this.ribSupport.routesContainerClass());
+ assertEquals(MvpnRoutesIpv6.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(MvpnRoute.class, this.ribSupport.routesListClass());
+ assertEquals(MvpnRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new MvpnRoutesIpv6CaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes
= new MvpnRoutesIpv6CaseBuilder().setMvpnRoutesIpv6(new MvpnRoutesIpv6Builder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new MvpnRoutesIpv6CaseBuilder().setMvpnRoutesIpv6(MVPN_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.bgp.rib.route.PeDistinguisherLabelsAttributeAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.PeDistinguisherLabelsAttributeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttribute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev200120.pe.distinguisher.labels.attribute.pe.distinguisher.labels.attribute.PeDistinguisherLabelAttributeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel;
import org.opendaylight.yangtools.yang.common.Uint32;
inetActivator.start(ctx);
final BGPActivator bgpActivator = new BGPActivator();
bgpActivator.start(ctx);
- this.handler = ctx.getAttributeRegistry();
+ handler = ctx.getAttributeRegistry();
}
@Test
public void testPEDistinguisherLabelsHandler() throws Exception {
final Attributes expected = buildPEDistinguisherLabelsAttributAttribute();
final ByteBuf actual = Unpooled.buffer();
- this.handler.serializeAttribute(expected, actual);
+ handler.serializeAttribute(expected, actual);
assertArrayEquals(PE_DISTINGUISHER_LABELS, ByteArray.readAllBytes(actual));
- final Attributes actualAttr = this.handler.parseAttributes(
+ final Attributes actualAttr = handler.parseAttributes(
Unpooled.wrappedBuffer(PE_DISTINGUISHER_LABELS), null).getAttributes();
assertEquals(expected, actualAttr);
}
private static Attributes buildPEDistinguisherLabelsAttributAttribute() {
- final List<PeDistinguisherLabelAttribute> peAtt = new ArrayList<>(2);
-
- peAtt.add(new PeDistinguisherLabelAttributeBuilder()
- .setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1")))
- .setMplsLabel(new MplsLabel(Uint32.ONE))
- .build());
- peAtt.add(new PeDistinguisherLabelAttributeBuilder()
- .setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2")))
- .setMplsLabel(new MplsLabel(Uint32.TWO))
- .build());
return new AttributesBuilder()
.addAugmentation(new PeDistinguisherLabelsAttributeAugmentationBuilder()
.setPeDistinguisherLabelsAttribute(new PeDistinguisherLabelsAttributeBuilder()
- .setPeDistinguisherLabelAttribute(peAtt).build()).build()).build();
+ .setPeDistinguisherLabelAttribute(List.of(
+ new PeDistinguisherLabelAttributeBuilder()
+ .setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1")))
+ .setMplsLabel(new MplsLabel(Uint32.ONE))
+ .build(),
+ new PeDistinguisherLabelAttributeBuilder()
+ .setPeAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2")))
+ .setMplsLabel(new MplsLabel(Uint32.TWO))
+ .build()))
+ .build())
+ .build())
+ .build();
}
}
\ No newline at end of file
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.Arrays;
import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.bgp.mvpn.impl.attributes.OpaqueUtil;
private static final Opaque OPAQUE_EXTENDED = new OpaqueValueBuilder().setOpaque(OPAQUE_TEST2)
.setOpaqueType(Uint8.TWO).setOpaqueType(Uint8.MAX_VALUE).setOpaqueExtendedType(Uint16.valueOf(4))
.build();
- private static final List<OpaqueValue> OPAQUE_VALUE_LIST = Arrays.asList((OpaqueValue) OPAQUE,
+ private static final List<OpaqueValue> OPAQUE_VALUE_LIST = List.of((OpaqueValue) OPAQUE,
(OpaqueValue) OPAQUE_EXTENDED);
@Test
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-import com.google.common.collect.ImmutableSet;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.junit.Test;
import org.opendaylight.protocol.bgp.rib.spi.AbstractRIBSupportTest;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidates;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.spi.DataTreeCandidates;
public class RouteTargetConstrainRIBSupportTest extends AbstractRIBSupportTest<RouteTargetConstrainRoutesCase,
RouteTargetConstrainRoutes, RouteTargetConstrainRoute> {
private static final DestinationRouteTargetConstrainAdvertizedCase REACH_NLRI
= new DestinationRouteTargetConstrainAdvertizedCaseBuilder()
.setDestinationRouteTargetConstrain(new DestinationRouteTargetConstrainBuilder()
- .setRouteTargetConstrainDestination(Collections.singletonList(RT_DESTINATION)).build()).build();
+ .setRouteTargetConstrainDestination(List.of(RT_DESTINATION)).build()).build();
private static final DestinationRouteTargetConstrainWithdrawnCase UNREACH_NLRI
= new DestinationRouteTargetConstrainWithdrawnCaseBuilder()
.setDestinationRouteTargetConstrain(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp
.route.target.constrain.rev180618.update.attributes.mp.unreach.nlri.withdrawn.routes.destination
.type.destination.route.target.constrain.withdrawn._case.DestinationRouteTargetConstrainBuilder()
- .setRouteTargetConstrainDestination(Collections.singletonList(RT_DESTINATION)).build()).build();
+ .setRouteTargetConstrainDestination(List.of(RT_DESTINATION)).build()).build();
private RouteTargetConstrainRIBSupport ribSupport;
@Override
public void setUp() throws Exception {
super.setUp();
- this.ribSupport = new RouteTargetConstrainRIBSupport(this.adapter.currentSerializer());
- setUpTestCustomizer(this.ribSupport);
+ ribSupport = new RouteTargetConstrainRIBSupport(adapter.currentSerializer());
+ setUpTestCustomizer(ribSupport);
}
@Test
public void testDeleteRoutes() {
final ContainerNode withdraw = createNlriWithDrawnRoute(UNREACH_NLRI);
- this.ribSupport.deleteRoutes(this.tx, getTablePath(), withdraw);
- final InstanceIdentifier<RouteTargetConstrainRoute> instanceIdentifier = this.deletedRoutes.get(0);
+ ribSupport.deleteRoutes(tx, getTablePath(), withdraw);
+ final InstanceIdentifier<RouteTargetConstrainRoute> instanceIdentifier = deletedRoutes.get(0);
assertEquals(ROUTE_KEY, instanceIdentifier.firstKeyOf(RouteTargetConstrainRoute.class));
}
@Test
public void testPutRoutes() {
- this.ribSupport.putRoutes(this.tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
- final RouteTargetConstrainRoute route = (RouteTargetConstrainRoute) this.insertedRoutes.get(0).getValue();
+ ribSupport.putRoutes(tx, getTablePath(), createNlriAdvertiseRoute(REACH_NLRI), createAttributes());
+ final RouteTargetConstrainRoute route = (RouteTargetConstrainRoute) insertedRoutes.get(0).getValue();
assertEquals(ROUTE, route);
}
@Test
public void testEmptyRoute() {
- assertEquals(createEmptyTable(), this.ribSupport.emptyTable());
+ assertEquals(createEmptyTable(), ribSupport.emptyTable());
}
@Test
public void testBuildMpUnreachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(RT_ROUTES);
- final Update update = this.ribSupport.buildUpdate(Collections.emptyList(), routes, ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(List.of(), routes, ATTRIBUTES);
assertEquals(UNREACH_NLRI, update.getAttributes().augmentation(AttributesUnreach.class).getMpUnreachNlri()
.getWithdrawnRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesReach.class));
@Test
public void testBuildMpReachNlriUpdate() {
final Collection<MapEntryNode> routes = createRoutes(RT_ROUTES);
- final Update update = this.ribSupport.buildUpdate(routes, Collections.emptyList(), ATTRIBUTES);
+ final Update update = ribSupport.buildUpdate(routes, List.of(), ATTRIBUTES);
assertEquals(REACH_NLRI, update.getAttributes().augmentation(AttributesReach.class).getMpReachNlri()
.getAdvertizedRoutes().getDestinationType());
assertNull(update.getAttributes().augmentation(AttributesUnreach.class));
@Test
public void testCacheableNlriObjects() {
- assertEquals(ImmutableSet.of(RouteTargetConstrainRoutesCase.class), this.ribSupport.cacheableNlriObjects());
+ assertEquals(Set.of(RouteTargetConstrainRoutesCase.class), ribSupport.cacheableNlriObjects());
}
@Test
public void testCacheableAttributeObjects() {
- assertEquals(ImmutableSet.of(), this.ribSupport.cacheableAttributeObjects());
+ assertEquals(Set.of(), ribSupport.cacheableAttributeObjects());
}
@Test
public void testRoutePath() {
final YangInstanceIdentifier.NodeIdentifierWithPredicates prefixNii = createRouteNIWP(RT_ROUTES);
final YangInstanceIdentifier expected = getRoutePath().node(prefixNii);
- final YangInstanceIdentifier actual = this.ribSupport.routePath(getTablePath(), prefixNii);
+ final YangInstanceIdentifier actual = ribSupport.routePath(getTablePath(), prefixNii);
assertEquals(expected, actual);
}
@Test
public void testRouteAttributesIdentifier() {
assertEquals(new NodeIdentifier(Attributes.QNAME.bindTo(RouteTargetConstrainRoutesCase.QNAME.getModule())),
- this.ribSupport.routeAttributesIdentifier());
+ ribSupport.routeAttributesIdentifier());
}
@Test
public void testRoutesCaseClass() {
- assertEquals(RouteTargetConstrainRoutesCase.class, this.ribSupport.routesCaseClass());
+ assertEquals(RouteTargetConstrainRoutesCase.class, ribSupport.routesCaseClass());
}
@Test
public void testRoutesContainerClass() {
- assertEquals(RouteTargetConstrainRoutes.class, this.ribSupport.routesContainerClass());
+ assertEquals(RouteTargetConstrainRoutes.class, ribSupport.routesContainerClass());
}
@Test
public void testRoutesListClass() {
- assertEquals(RouteTargetConstrainRoute.class, this.ribSupport.routesListClass());
+ assertEquals(RouteTargetConstrainRoute.class, ribSupport.routesListClass());
}
@Test
final Routes emptyCase = new RouteTargetConstrainRoutesCaseBuilder().build();
DataTreeCandidateNode tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(),
createRoutes(emptyCase)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes emptyRoutes = new RouteTargetConstrainRoutesCaseBuilder()
.setRouteTargetConstrainRoutes(new RouteTargetConstrainRoutesBuilder().build()).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(emptyRoutes)).getRootNode();
- assertTrue(this.ribSupport.changedRoutes(tree).isEmpty());
+ assertTrue(ribSupport.changedRoutes(tree).isEmpty());
final Routes routes = new RouteTargetConstrainRoutesCaseBuilder()
.setRouteTargetConstrainRoutes(RT_ROUTES).build();
tree = DataTreeCandidates.fromNormalizedNode(getRoutePath(), createRoutes(routes)).getRootNode();
- final Collection<DataTreeCandidateNode> result = this.ribSupport.changedRoutes(tree);
+ final Collection<DataTreeCandidateNode> result = ribSupport.changedRoutes(tree);
assertFalse(result.isEmpty());
}
}
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7223</artifactId>
+ <artifactId>rfc8294-ietf-routing-types</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc8294-ietf-routing-types</artifactId>
+ <artifactId>rfc8343</artifactId>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test tools -->
* 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.bgp.openconfig.routing.policy.impl;
import static java.util.Objects.requireNonNull;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.DefaultPolicyType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.apply.policy.group.apply.policy.Config;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.PolicyDefinitions;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
final class BGPRibPolicyImpl implements BGPRibRoutingPolicy {
- private static final InstanceIdentifier<RoutingPolicy> ROUTING_POLICY_IID
- = InstanceIdentifier.create(RoutingPolicy.class);
- private static final List<String> DEFAULT_IMPORT_POLICY = Collections.singletonList("default-odl-import-policy");
- private static final List<String> DEFAULT_EXPORT_POLICY = Collections.singletonList("default-odl-export-policy");
+ private static final InstanceIdentifier<RoutingPolicy> ROUTING_POLICY_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build();
+ private static final List<String> DEFAULT_IMPORT_POLICY = List.of("default-odl-import-policy");
+ private static final List<String> DEFAULT_EXPORT_POLICY = List.of("default-odl-export-policy");
private final DefaultPolicyType defaultExportPolicy;
private final DefaultPolicyType defaultImportPolicy;
private final List<String> exportPolicy;
ipolicy = DEFAULT_IMPORT_POLICY;
}
- this.defaultExportPolicy = requireNonNull(policyConfig.getDefaultExportPolicy());
- this.defaultImportPolicy = requireNonNull(policyConfig.getDefaultImportPolicy());
- this.exportPolicy = requireNonNull(epolicy);
- this.importPolicy = requireNonNull(ipolicy);
- this.ribBaseParameters = new PolicyRIBBaseParametersImpl(localAs, originatorId, clusterId);
+ defaultExportPolicy = requireNonNull(policyConfig.getDefaultExportPolicy());
+ defaultImportPolicy = requireNonNull(policyConfig.getDefaultImportPolicy());
+ exportPolicy = requireNonNull(epolicy);
+ importPolicy = requireNonNull(ipolicy);
+ ribBaseParameters = new PolicyRIBBaseParametersImpl(localAs, originatorId, clusterId);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<Statement> loadStatements(final String key) throws ExecutionException, InterruptedException {
- final ReadTransaction tr = this.databroker.newReadOnlyTransaction();
+ final ReadTransaction tr = databroker.newReadOnlyTransaction();
final Optional<Statements> result =
tr.read(LogicalDatastoreType.CONFIGURATION, ROUTING_POLICY_IID.child(PolicyDefinitions.class)
.child(PolicyDefinition.class, new PolicyDefinitionKey(key)).child(Statements.class)).get();
if (!result.isPresent()) {
- return Collections.emptyList();
+ return List.of();
}
return result.get().getStatement();
}
public Optional<Attributes> applyImportPolicies(final BGPRouteEntryImportParameters policyParameters,
final Attributes attributes, final Class<? extends AfiSafiType> afiSafiType) {
RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
- for (final String policyName : this.importPolicy) {
- for (final Statement statement : this.statements.getUnchecked(policyName)) {
- currentAttributes = this.policyRegistry
- .applyImportStatement(this.ribBaseParameters, afiSafiType, policyParameters, currentAttributes,
+ for (final String policyName : importPolicy) {
+ for (final Statement statement : statements.getUnchecked(policyName)) {
+ currentAttributes = policyRegistry
+ .applyImportStatement(ribBaseParameters, afiSafiType, policyParameters, currentAttributes,
statement);
}
}
if (!currentAttributes.anyConditionSatisfied()) {
- if (DefaultPolicyType.REJECTROUTE.equals(this.defaultImportPolicy)) {
+ if (DefaultPolicyType.REJECTROUTE.equals(defaultImportPolicy)) {
return Optional.empty();
}
}
public Optional<Attributes> applyExportPolicies(final BGPRouteEntryExportParameters policyParameters,
final Attributes attributes, final Class<? extends AfiSafiType> afiSafi) {
RouteAttributeContainer currentAttributes = routeAttributeContainerFalse(attributes);
- for (final String policyName : this.exportPolicy) {
- for (final Statement statement : this.statements.getUnchecked(policyName)) {
- currentAttributes = this.policyRegistry.applyExportStatement(
- this.ribBaseParameters, afiSafi, policyParameters, currentAttributes, statement);
+ for (final String policyName : exportPolicy) {
+ for (final Statement statement : statements.getUnchecked(policyName)) {
+ currentAttributes = policyRegistry.applyExportStatement(
+ ribBaseParameters, afiSafi, policyParameters, currentAttributes, statement);
}
}
if (!currentAttributes.anyConditionSatisfied()) {
- if (DefaultPolicyType.REJECTROUTE.equals(this.defaultExportPolicy)) {
+ if (DefaultPolicyType.REJECTROUTE.equals(defaultExportPolicy)) {
return Optional.empty();
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Tests-->
import java.util.List;
import java.util.Objects;
+import java.util.Set;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.bgp.attribute.conditions.AsPathLength;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.policy.definitions.policy.definition.statements.statement.conditions.BgpConditions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
}
private static boolean matchAfiSafi(final Class<? extends AfiSafiType> afiSafi,
- final List<Class<? extends AfiSafiType>> afiSafiIn) {
+ final Set<Class<? extends AfiSafiType>> afiSafiIn) {
return afiSafiIn == null || afiSafiIn.contains(afiSafi);
}
if (total == 0) {
total = segments.stream().map(AsPathSegment::getAsSet)
- .filter(Objects::nonNull).mapToInt(List::size).sum();
+ .filter(Objects::nonNull).mapToInt(Set::size).sum();
}
final Class<? extends AttributeComparison> comp = asPathLength.getOperator();
return false;
}
- private static boolean matchNextHopIn(final CNextHop nextHop, final List<IpAddress> nextHopIn) {
+ private static boolean matchNextHopIn(final CNextHop nextHop, final Set<IpAddress> nextHopIn) {
if (nextHop == null || nextHopIn == null || nextHop instanceof EmptyNextHopCase) {
return true;
}
*/
package org.opendaylight.protocol.bgp.openconfig.routing.policy.spi;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
+import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.config.loader.routing.policy.AbstractOpenconfigRoutingPolicyLoaderTest;
-import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementRegistry;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.PolicyDefinitions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.PolicyDefinition;
protected final StatementRegistry statementRegistry = new StatementRegistry();
protected List<Statement> loadStatement(final String policyName) throws ExecutionException, InterruptedException {
- final ReadWriteTransaction rt = getDataBroker().newReadWriteTransaction();
- final PolicyDefinition policy = rt.read(LogicalDatastoreType.CONFIGURATION,
- InstanceIdentifier.create(RoutingPolicy.class).child(PolicyDefinitions.class)
- .child(PolicyDefinition.class, new PolicyDefinitionKey(policyName))).get().get();
- return policy.getStatements().getStatement();
+ final ListenableFuture<Optional<PolicyDefinition>> future;
+
+ try (var tx = getDataBroker().newReadOnlyTransaction()) {
+ future = tx.read(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(PolicyDefinitions.class)
+ .child(PolicyDefinition.class, new PolicyDefinitionKey(policyName)));
+ }
+
+ return future.get().orElseThrow().getStatements().getStatement();
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test dependencies -->
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.CommunitySets;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.community.sets.CommunitySet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.community.sets.CommunitySetKey;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.Communities;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class AbstractCommunityHandler {
- private static final InstanceIdentifier<CommunitySets> COMMUNITY_SETS_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
+ private static final InstanceIdentifier<CommunitySets> COMMUNITY_SETS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
.child(CommunitySets.class);
protected final LoadingCache<String, List<Communities>> communitySets;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets.ExtCommunitySet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets.ExtCommunitySetKey;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.ext.community.sets.ext.community.set.ExtCommunityMember;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.ExtendedCommunities;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class AbstractExtCommunityHandler {
- private static final InstanceIdentifier<ExtCommunitySets> EXT_COMMUNITY_SETS_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
+ private static final InstanceIdentifier<ExtCommunitySets> EXT_COMMUNITY_SETS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
.child(ExtCommunitySets.class);
private final DataBroker databroker;
protected final LoadingCache<String, List<ExtendedCommunities>> extCommunitySets = CacheBuilder.newBuilder()
this.databroker = requireNonNull(databroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<ExtendedCommunities> loadCommunitySet(final String key)
throws ExecutionException, InterruptedException {
final FluentFuture<Optional<ExtCommunitySet>> future;
- try (ReadTransaction tr = this.databroker.newReadOnlyTransaction()) {
+ try (ReadTransaction tr = databroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
EXT_COMMUNITY_SETS_IID.child(ExtCommunitySet.class, new ExtCommunitySetKey(key)));
}
return result.map(AbstractExtCommunityHandler::toExtendedCommunitiesList).orElse(Collections.emptyList());
}
- private static List<ExtendedCommunities> toExtendedCommunitiesList(ExtCommunitySet extCommunitySets) {
+ private static List<ExtendedCommunities> toExtendedCommunitiesList(final ExtCommunitySet extCommunitySets) {
return extCommunitySets.getExtCommunityMember().stream()
.map(AbstractExtCommunityHandler::toExtendedCommunities).collect(Collectors.toList());
}
package org.opendaylight.protocol.bgp.openconfig.routing.policy.statement.conditions;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.RouteEntryBaseAttributes;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.policy.condition.BgpConditionsAugmentationPolicy;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryExportParameters;
private static boolean matchAfiSafi(
final Class<? extends AfiSafiType> afiSafi,
- final List<Class<? extends AfiSafiType>> afiSafiNotIn) {
+ final Set<Class<? extends AfiSafiType>> afiSafiNotIn) {
return !afiSafiNotIn.contains(afiSafi);
}
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.bgp.defined.sets.as.path.sets.AsPathSetKey;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
* Match a set of AS (All, ANY, INVERT).
*/
public final class MatchAsPathSetHandler implements BgpConditionsPolicy<MatchAsPathSet, AsPath> {
- private static final InstanceIdentifier<AsPathSets> AS_PATHS_SETS_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
+ private static final InstanceIdentifier<AsPathSets> AS_PATHS_SETS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
.child(AsPathSets.class);
private final DataBroker dataBroker;
private final LoadingCache<String, AsPathSet> sets = CacheBuilder.newBuilder()
this.dataBroker = requireNonNull(dataBroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private AsPathSet loadSets(final String key) throws ExecutionException, InterruptedException {
final FluentFuture<Optional<AsPathSet>> future;
- try (ReadTransaction tr = this.dataBroker.newReadOnlyTransaction()) {
+ try (ReadTransaction tr = dataBroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
AS_PATHS_SETS_IID.child(AsPathSet.class, new AsPathSetKey(key)));
}
if (asPath == null) {
return false;
}
- final AsPathSet asPathSetFilter = this.sets.getUnchecked(StringUtils
+ final AsPathSet asPathSetFilter = sets.getUnchecked(StringUtils
.substringBetween(asPathSetName, "=\"", "\""));
final List<Segments> segments = asPath.getSegments();
List<AsNumber> allAs = Stream.of(l1, l2).flatMap(Collection::stream).collect(Collectors.toList());
- final List<AsNumber> asPathSetFilterList = asPathSetFilter.getAsPathSetMember();
+ final Set<AsNumber> asPathSetFilterList = asPathSetFilter.getAsPathSetMember();
if (matchSetOptions.equals(MatchSetOptionsType.ALL)) {
return allAs.containsAll(asPathSetFilterList)
&& asPathSetFilterList.containsAll(allAs);
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.opendaylight.protocol.bgp.rib.spi.policy.BGPRouteEntryImportParameters;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.generic.defined.sets.NeighborSets;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.neighbor.set.NeighborSet;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.neighbor.set.NeighborSetKey;
*/
public final class MatchBgpNeighborSetHandler
implements BgpConditionsAugmentationPolicy<MatchBgpNeighborCondition, Void> {
- private static final InstanceIdentifier<NeighborSets> NEIGHBOR_SET_IID
- = InstanceIdentifier.create(RoutingPolicy.class)
+ private static final InstanceIdentifier<NeighborSets> NEIGHBOR_SET_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
.child(DefinedSets.class)
.child(NeighborSets.class);
private final DataBroker dataBroker;
this.dataBroker = requireNonNull(dataBroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private List<PeerId> loadRoleSets(final String key) throws ExecutionException, InterruptedException {
final FluentFuture<Optional<NeighborSet>> future;
- try (ReadTransaction tr = this.dataBroker.newReadOnlyTransaction()) {
+ try (ReadTransaction tr = dataBroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
NEIGHBOR_SET_IID.child(NeighborSet.class, new NeighborSetKey(key)));
final String neighborSetName,
final PeerId peerId,
final MatchSetOptionsRestrictedType matchSetOptions) {
- final List<PeerId> roles = this.peerSets.getUnchecked(StringUtils
+ final List<PeerId> roles = peerSets.getUnchecked(StringUtils
.substringBetween(neighborSetName, "=\"", "\""));
final boolean found = roles.contains(peerId);
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.BgpDefinedSets;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
*/
public final class MatchClusterIdSetHandler
implements BgpConditionsAugmentationPolicy<MatchClusterIdSetCondition, ClusterId> {
- private static final InstanceIdentifier<ClusterIdSets> CLUSTERS_ID_SETS_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
- .augmentation(BgpClusterIdSets.class).child(ClusterIdSets.class);
+ private static final InstanceIdentifier<ClusterIdSets> CLUSTERS_ID_SETS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
+ .augmentation(BgpClusterIdSets.class)
+ .child(ClusterIdSets.class);
private final DataBroker dataBroker;
private final LoadingCache<String, ClusterIdSet> sets = CacheBuilder.newBuilder()
.build(new CacheLoader<>() {
this.dataBroker = requireNonNull(dataBroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private ClusterIdSet loadSets(final String key) throws ExecutionException, InterruptedException {
final FluentFuture<Optional<ClusterIdSet>> future;
- try (ReadTransaction tr = this.dataBroker.newReadOnlyTransaction()) {
+ try (ReadTransaction tr = dataBroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
CLUSTERS_ID_SETS_IID.child(ClusterIdSet.class, new ClusterIdSetKey(key)));
}
final ClusterId clusterId, final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.odl.bgp._default.policy.rev200120.match.cluster.id.set.condition.grouping
.MatchClusterIdSetCondition matchClusterIdSetCondition) {
- final ClusterIdSet clusterIdSet = this.sets.getUnchecked(StringUtils
+ final ClusterIdSet clusterIdSet = sets.getUnchecked(StringUtils
.substringBetween(matchClusterIdSetCondition.getClusterIdSet(), "=\"", "\""));
if (clusterIdSet == null) {
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Optional;
import java.util.concurrent.ExecutionException;
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.BgpDefinedSets;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
*/
public final class MatchOriginatorIdSetHandler
implements BgpConditionsAugmentationPolicy<MatchOriginatorIdSetCondition, OriginatorId> {
- private static final InstanceIdentifier<OriginatorIdSets> ORIGINATOR_ID_SETS_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
- .augmentation(BgpOriginatorIdSets.class).child(OriginatorIdSets.class);
+ private static final InstanceIdentifier<OriginatorIdSets> ORIGINATOR_ID_SETS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
+ .augmentation(BgpOriginatorIdSets.class)
+ .child(OriginatorIdSets.class);
private final DataBroker dataBroker;
private final LoadingCache<String, OriginatorIdSet> sets = CacheBuilder.newBuilder()
.build(new CacheLoader<>() {
this.dataBroker = requireNonNull(dataBroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private OriginatorIdSet loadSets(final String key) throws ExecutionException, InterruptedException {
final FluentFuture<Optional<OriginatorIdSet>> future;
- try (ReadTransaction tr = this.dataBroker.newReadOnlyTransaction()) {
+ try (ReadTransaction tr = dataBroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
ORIGINATOR_ID_SETS_IID.child(OriginatorIdSet.class, new OriginatorIdSetKey(key)));
}
.odl.bgp._default.policy.rev200120.match.originator.id.set.condition.grouping
.MatchOriginatorIdSetCondition condition) {
- final OriginatorIdSet originatorIdSet = this.sets.getUnchecked(StringUtils
+ final OriginatorIdSet originatorIdSet = sets.getUnchecked(StringUtils
.substringBetween(condition.getOriginatorIdSet(), "=\"", "\""));
if (originatorIdSet == null) {
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.FluentFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
-import java.util.Collections;
-import java.util.List;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.apache.commons.lang3.StringUtils;
import org.opendaylight.mdsal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.policy.rev151009.routing.policy.defined.sets.BgpDefinedSets;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.AfiSafiType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.policy.types.rev151009.MatchSetOptionsRestrictedType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.DefinedSets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
* Match a Peer Role (FROM, TO).
*/
public final class MatchRoleSetHandler implements BgpConditionsAugmentationPolicy<MatchRoleSetCondition, Void> {
- private static final InstanceIdentifier<RoleSets> ROLE_SET_IID
- = InstanceIdentifier.create(RoutingPolicy.class).child(DefinedSets.class)
- .augmentation(DefinedSets1.class).child(BgpDefinedSets.class)
- .augmentation(BgpRoleSets.class).child(RoleSets.class);
+ private static final InstanceIdentifier<RoleSets> ROLE_SET_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(DefinedSets.class)
+ .augmentation(DefinedSets1.class)
+ .child(BgpDefinedSets.class)
+ .augmentation(BgpRoleSets.class)
+ .child(RoleSets.class);
private final DataBroker dataBroker;
- private final LoadingCache<String, List<PeerRole>> roleSets = CacheBuilder.newBuilder()
+ private final LoadingCache<String, Set<PeerRole>> roleSets = CacheBuilder.newBuilder()
.build(new CacheLoader<>() {
@Override
- public List<PeerRole> load(final String key) throws ExecutionException, InterruptedException {
+ public Set<PeerRole> load(final String key) throws ExecutionException, InterruptedException {
return loadRoleSets(key);
}
});
this.dataBroker = requireNonNull(dataBroker);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
- private List<PeerRole> loadRoleSets(final String key) throws ExecutionException, InterruptedException {
- final FluentFuture<Optional<RoleSet>> future;
- try (ReadTransaction tr = this.dataBroker.newReadOnlyTransaction()) {
+ private Set<PeerRole> loadRoleSets(final String key) throws ExecutionException, InterruptedException {
+ final FluentFuture<Optional<RoleSet>> future;
+ try (ReadTransaction tr = dataBroker.newReadOnlyTransaction()) {
future = tr.read(LogicalDatastoreType.CONFIGURATION,
ROLE_SET_IID.child(RoleSet.class, new RoleSetKey(key)));
}
- return future.get().map(RoleSet::getRole).orElse(Collections.emptyList());
+ return future.get().map(RoleSet::getRole).orElse(Set.of());
}
@Override
private boolean checkMatch(final String roleSetName, final PeerRole role,
final MatchSetOptionsRestrictedType matchSetOptions) {
- final List<PeerRole> roles = this.roleSets.getUnchecked(StringUtils
- .substringBetween(roleSetName, "=\"", "\""));
+ final Set<PeerRole> roles = roleSets.getUnchecked(StringUtils.substringBetween(roleSetName, "=\"", "\""));
final boolean found = roles.contains(role);
if (MatchSetOptionsRestrictedType.ANY.equals(matchSetOptions)) {
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.AbstractStatementRegistryTest;
import org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.StatementRegistry;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.PolicyDefinitions;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.PolicyDefinition;
final ListenableFuture<Optional<Statements>> future;
try (ReadTransaction rt = getDataBroker().newReadOnlyTransaction()) {
future = rt.read(LogicalDatastoreType.CONFIGURATION,
- InstanceIdentifier.create(RoutingPolicy.class)
- .child(PolicyDefinitions.class)
- .child(PolicyDefinition.class, new PolicyDefinitionKey(policyName))
- .child(Statements.class));
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build()
+ .child(PolicyDefinitions.class)
+ .child(PolicyDefinition.class, new PolicyDefinitionKey(policyName))
+ .child(Statements.class));
}
return future.get().orElseThrow().getStatement();
}
import static org.junit.Assert.assertNull;
import static org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer.routeAttributeContainerFalse;
-import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
@Override
public void setUp() throws Exception {
super.setUp();
- this.basicStatements = loadStatement("match-as-path-set-test");
- this.baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
+ basicStatements = loadStatement("match-as-path-set-test");
+ baseAttributes = new PolicyRIBBaseParametersImpl(LOCAL_AS, IPV4, CLUSTER);
}
@Test
public void testMatchAsPathAny() {
- Statement statement = this.basicStatements.stream()
+ Statement statement = basicStatements.stream()
.filter(st -> st.getName().equals("reject-match-as-path-any-set")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
new AttributesBuilder().build());
- RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ RouteAttributeContainer result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNotNull(result.getAttributes());
.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(
new SegmentsBuilder().setAsSequence(Collections.singletonList(
AsNumber.getDefaultInstance("65"))).build())).build()).build());
- result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNull(result.getAttributes());
@Test
public void testMatchAsPathAll() {
- Statement statement = this.basicStatements.stream()
+ Statement statement = basicStatements.stream()
.filter(st -> st.getName().equals("reject-match-as-path-all-set")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(new AttributesBuilder()
- .setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(
- new SegmentsBuilder().setAsSequence(Collections.singletonList(
+ .setAsPath(new AsPathBuilder().setSegments(List.of(
+ new SegmentsBuilder().setAsSequence(List.of(
AsNumber.getDefaultInstance("65"))).build())).build()).build());
- RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ RouteAttributeContainer result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNotNull(result.getAttributes());
attributeContainer = routeAttributeContainerFalse(
new AttributesBuilder()
- .setAsPath(new AsPathBuilder().setSegments(Arrays.asList(
- new SegmentsBuilder().setAsSet(Arrays.asList(
+ .setAsPath(new AsPathBuilder().setSegments(List.of(
+ new SegmentsBuilder().setAsSet(Set.of(
AsNumber.getDefaultInstance("65"),
AsNumber.getDefaultInstance("64")
)).build(),
- new SegmentsBuilder().setAsSet(Collections.singletonList(
+ new SegmentsBuilder().setAsSet(Set.of(
AsNumber.getDefaultInstance("63")
)).build()
)).build()).build());
- result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNull(result.getAttributes());
@Test
public void testMatchAsPathInverse() {
- Statement statement = this.basicStatements.stream()
+ Statement statement = basicStatements.stream()
.filter(st -> st.getName().equals("reject-match-as-path-inverse-set")).findFirst().get();
RouteAttributeContainer attributeContainer = routeAttributeContainerFalse(
new AttributesBuilder()
.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(
new SegmentsBuilder().setAsSequence(Collections.singletonList(
AsNumber.getDefaultInstance("65"))).build())).build()).build());
- RouteAttributeContainer result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ RouteAttributeContainer result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNotNull(result.getAttributes());
.setAsPath(new AsPathBuilder().setSegments(Collections.singletonList(
new SegmentsBuilder().setAsSequence(Collections.singletonList(
AsNumber.getDefaultInstance("200"))).build())).build()).build());
- result = this.statementRegistry.applyExportStatement(
- this.baseAttributes,
+ result = statementRegistry.applyExportStatement(
+ baseAttributes,
IPV4UNICAST.class,
- this.exportParameters,
+ exportParameters,
attributeContainer,
statement);
assertNull(result.getAttributes());
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<!-- test scope dependencies -->
package org.opendaylight.protocol.bgp.state;
+import com.google.common.collect.ImmutableSet;
import com.google.common.primitives.UnsignedInteger;
-import java.math.BigDecimal;
-import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
-import java.util.function.Function;
-import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.opendaylight.protocol.bgp.openconfig.spi.BGPTableTypeRegistryConsumer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.SentBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
return new NeighborsBuilder().setNeighbor(peerStats.stream()
.filter(Objects::nonNull)
.map(neighbor -> buildNeighbor(neighbor, bgpTableTypeRegistry))
- .collect(Collectors.toUnmodifiableMap(Neighbor::key, Function.identity()))).build();
+ .collect(BindingMap.toMap())).build();
}
/**
.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
.timers.StateBuilder()
.addAugmentation(new NeighborTimersStateAugmentationBuilder()
- .setNegotiatedHoldTime(BigDecimal.valueOf(neighbor.getNegotiatedHoldTime()))
+ .setNegotiatedHoldTime(Decimal64.valueOf(2, neighbor.getNegotiatedHoldTime()))
.setUptime(new Timeticks(Uint32.valueOf(uptimeTicks))).build())
.build())
.build();
*/
public static NeighborStateAugmentation buildCapabilityState(final @NonNull BGPSessionState neighbor) {
- final List<Class<? extends BgpCapability>> supportedCapabilities = buildSupportedCapabilities(neighbor);
+ final Set<Class<? extends BgpCapability>> supportedCapabilities = buildSupportedCapabilities(neighbor);
SessionState sessionState = null;
switch (neighbor.getSessionState()) {
case IDLE:
afiSafiJoin.addAll(neighbor.getAfiSafisReceived());
return afiSafiJoin.stream().map(tableKey -> buildAfiSafi(neighbor, tableKey, bgpTableTypeRegistry))
.filter(Objects::nonNull)
- .collect(Collectors.toUnmodifiableMap(AfiSafi::key, Function.identity()));
+ .collect(BindingMap.toMap());
}
private static @Nullable AfiSafi buildAfiSafi(final @NonNull BGPAfiSafiState neighbor,
*
* @return List containing supported capabilities
*/
- public static @NonNull List<Class<? extends BgpCapability>> buildSupportedCapabilities(
+ public static @NonNull Set<Class<? extends BgpCapability>> buildSupportedCapabilities(
final @NonNull BGPSessionState neighbor) {
- final List<Class<? extends BgpCapability>> supportedCapabilities = new ArrayList<>();
+ final var supportedCapabilities = ImmutableSet.<Class<? extends BgpCapability>>builder();
if (neighbor.isAddPathCapabilitySupported()) {
supportedCapabilities.add(ADDPATHS.class);
}
if (neighbor.isRouterRefreshCapabilitySupported()) {
supportedCapabilities.add(ROUTEREFRESH.class);
}
- return supportedCapabilities;
+ return supportedCapabilities.build();
}
}
import com.google.common.annotations.VisibleForTesting;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.PeerGroups;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
this.dataBroker = requireNonNull(dataBroker);
this.bgpTableTypeRegistry = requireNonNull(bgpTableTypeRegistry);
this.stateProvider = requireNonNull(stateProvider);
- this.networkInstanceIId = InstanceIdentifier.create(NetworkInstances.class)
+ networkInstanceIId =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
.child(NetworkInstance.class, new NetworkInstanceKey(networkInstanceName));
this.scheduler = scheduler;
- this.transactionChain = this.dataBroker.createMergingTransactionChain(this);
+ transactionChain = this.dataBroker.createMergingTransactionChain(this);
final TimerTask task = new TimerTask() {
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
}
};
- this.scheduleTask = this.scheduler.scheduleAtFixedRate(task, 0, period, timeUnit);
+ scheduleTask = this.scheduler.scheduleAtFixedRate(task, 0, period, timeUnit);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void updateBGPStats(final WriteOperations wtx) {
- final Set<String> oldStats = new HashSet<>(this.instanceIdentifiersCache.keySet());
- this.stateProvider.getRibStats().stream().filter(BGPRibState::isActive).forEach(bgpStateConsumer -> {
+ final Set<String> oldStats = new HashSet<>(instanceIdentifiersCache.keySet());
+ stateProvider.getRibStats().stream().filter(BGPRibState::isActive).forEach(bgpStateConsumer -> {
final KeyedInstanceIdentifier<Rib, RibKey> ribId = bgpStateConsumer.getInstanceIdentifier();
- final List<BGPPeerState> peerStats = this.stateProvider.getPeerStats().stream()
+ final List<BGPPeerState> peerStats = stateProvider.getPeerStats().stream()
.filter(BGPPeerState::isActive).filter(peerState -> ribId.equals(peerState.getInstanceIdentifier()))
.collect(Collectors.toList());
storeOperationalState(bgpStateConsumer, peerStats, ribId.getKey().getId().getValue(), wtx);
}
private synchronized void removeStoredOperationalState(final String ribId, final WriteOperations wtx) {
- final InstanceIdentifier<Bgp> bgpIID = this.instanceIdentifiersCache.remove(ribId);
+ final InstanceIdentifier<Bgp> bgpIID = instanceIdentifiersCache.remove(ribId);
wtx.delete(LogicalDatastoreType.OPERATIONAL, bgpIID);
}
private synchronized void storeOperationalState(final BGPRibState bgpStateConsumer,
final List<BGPPeerState> peerStats, final String ribId, final WriteOperations wtx) {
- final Global global = GlobalUtil.buildGlobal(bgpStateConsumer, this.bgpTableTypeRegistry);
+ final Global global = GlobalUtil.buildGlobal(bgpStateConsumer, bgpTableTypeRegistry);
final PeerGroups peerGroups = PeerGroupUtil.buildPeerGroups(peerStats);
- final Neighbors neighbors = NeighborUtil.buildNeighbors(peerStats, this.bgpTableTypeRegistry);
- InstanceIdentifier<Bgp> bgpIID = this.instanceIdentifiersCache.get(ribId);
+ final Neighbors neighbors = NeighborUtil.buildNeighbors(peerStats, bgpTableTypeRegistry);
+ InstanceIdentifier<Bgp> bgpIID = instanceIdentifiersCache.get(ribId);
if (bgpIID == null) {
final ProtocolKey protocolKey = new ProtocolKey(BGP.class, bgpStateConsumer.getInstanceIdentifier()
.getKey().getId().getValue());
- final KeyedInstanceIdentifier<Protocol, ProtocolKey> protocolIId = this.networkInstanceIId
+ final KeyedInstanceIdentifier<Protocol, ProtocolKey> protocolIId = networkInstanceIId
.child(Protocols.class).child(Protocol.class, protocolKey);
bgpIID = protocolIId.augmentation(NetworkInstanceProtocol.class).child(Bgp.class);
- this.instanceIdentifiersCache.put(ribId, bgpIID);
+ instanceIdentifiersCache.put(ribId, bgpIID);
}
final Bgp bgp = new BgpBuilder().setGlobal(global).setNeighbors(neighbors).setPeerGroups(peerGroups).build();
@Override
public synchronized void close() {
if (closed.compareAndSet(false, true)) {
- this.scheduleTask.cancel(true);
- if (!this.instanceIdentifiersCache.isEmpty()) {
- final WriteTransaction wTx = this.transactionChain.newWriteOnlyTransaction();
- this.instanceIdentifiersCache.values()
+ scheduleTask.cancel(true);
+ if (!instanceIdentifiersCache.isEmpty()) {
+ final WriteTransaction wTx = transactionChain.newWriteOnlyTransaction();
+ instanceIdentifiersCache.values()
.forEach(bgpIID -> wTx.delete(LogicalDatastoreType.OPERATIONAL, bgpIID));
- this.instanceIdentifiersCache.clear();
+ instanceIdentifiersCache.clear();
wTx.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
}
}, MoreExecutors.directExecutor());
}
- this.transactionChain.close();
- this.scheduler.shutdown();
+ transactionChain.close();
+ scheduler.shutdown();
}
}
import static org.mockito.Mockito.mock;
import static org.opendaylight.protocol.bgp.state.StateProviderImplTest.TABLES_KEY;
-import java.math.BigDecimal;
-import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborStateAugmentationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborTimersStateAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborTimersStateAugmentationBuilder;
+import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
@RunWith(MockitoJUnitRunner.StrictStubs.class)
@Before
public void setUp() throws Exception {
- doReturn(false).when(this.sessionState).isRouterRefreshCapabilitySupported();
- doReturn(false).when(this.sessionState).isMultiProtocolCapabilitySupported();
- doReturn(false).when(this.sessionState).isGracefulRestartCapabilitySupported();
- doReturn(false).when(this.sessionState).isAsn32CapabilitySupported();
- doReturn(false).when(this.sessionState).isAddPathCapabilitySupported();
- doAnswer(invocation -> NeighborUtilTest.this.state).when(this.sessionState).getSessionState();
- doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
- doReturn(Collections.singleton(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisReceived();
- doAnswer(invocation -> NeighborUtilTest.this.afiSafi).when(this.tableRegistry).getAfiSafiType(eq(TABLES_KEY));
- doReturn(false).when(this.bgpAfiSafiState).isAfiSafiSupported(eq(TABLES_KEY));
- doReturn(false).when(this.bgpAfiSafiState).isGracefulRestartAdvertized(eq(TABLES_KEY));
- doReturn(false).when(this.bgpAfiSafiState).isGracefulRestartReceived(eq(TABLES_KEY));
- doReturn(false).when(this.bgpAfiSafiState).isLlGracefulRestartAdvertised(eq(TABLES_KEY));
- doReturn(false).when(this.bgpAfiSafiState).isLlGracefulRestartReceived(eq(TABLES_KEY));
- doReturn(0).when(this.bgpAfiSafiState).getLlGracefulRestartTimer(eq(TABLES_KEY));
+ doReturn(false).when(sessionState).isRouterRefreshCapabilitySupported();
+ doReturn(false).when(sessionState).isMultiProtocolCapabilitySupported();
+ doReturn(false).when(sessionState).isGracefulRestartCapabilitySupported();
+ doReturn(false).when(sessionState).isAsn32CapabilitySupported();
+ doReturn(false).when(sessionState).isAddPathCapabilitySupported();
+ doAnswer(invocation -> NeighborUtilTest.this.state).when(sessionState).getSessionState();
+ doReturn(Set.of(TABLES_KEY)).when(bgpAfiSafiState).getAfiSafisAdvertized();
+ doReturn(Set.of(TABLES_KEY)).when(bgpAfiSafiState).getAfiSafisReceived();
+ doAnswer(invocation -> NeighborUtilTest.this.afiSafi).when(tableRegistry).getAfiSafiType(eq(TABLES_KEY));
+ doReturn(false).when(bgpAfiSafiState).isAfiSafiSupported(eq(TABLES_KEY));
+ doReturn(false).when(bgpAfiSafiState).isGracefulRestartAdvertized(eq(TABLES_KEY));
+ doReturn(false).when(bgpAfiSafiState).isGracefulRestartReceived(eq(TABLES_KEY));
+ doReturn(false).when(bgpAfiSafiState).isLlGracefulRestartAdvertised(eq(TABLES_KEY));
+ doReturn(false).when(bgpAfiSafiState).isLlGracefulRestartReceived(eq(TABLES_KEY));
+ doReturn(0).when(bgpAfiSafiState).getLlGracefulRestartTimer(eq(TABLES_KEY));
}
@Test
public void testBuildCapabilityState() {
final NeighborStateAugmentationBuilder expected = new NeighborStateAugmentationBuilder()
- .setSupportedCapabilities(Collections.emptyList())
+ .setSupportedCapabilities(Set.of())
.setSessionState(SessionState.IDLE);
- assertEquals(expected.build(), NeighborUtil.buildCapabilityState(this.sessionState));
+ assertEquals(expected.build(), NeighborUtil.buildCapabilityState(sessionState));
- this.state = State.OPEN_CONFIRM;
+ state = State.OPEN_CONFIRM;
expected.setSessionState(SessionState.OPENCONFIRM);
- assertEquals(expected.build(), NeighborUtil.buildCapabilityState(this.sessionState));
+ assertEquals(expected.build(), NeighborUtil.buildCapabilityState(sessionState));
}
@Test
doReturn(90L).when(timerState).getNegotiatedHoldTime();
doReturn(5000L).when(timerState).getUpTime();
- final NeighborTimersStateAugmentation timerStateAug = new NeighborTimersStateAugmentationBuilder()
- .setNegotiatedHoldTime(BigDecimal.valueOf(90L)).setUptime(new Timeticks(Uint32.valueOf(500))).build();
- final Timers expectedTimers = new TimersBuilder().setState(
- new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers
- .StateBuilder().addAugmentation(timerStateAug).build())
- .build();
+ final Timers expectedTimers = new TimersBuilder()
+ .setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers
+ .StateBuilder()
+ .addAugmentation(new NeighborTimersStateAugmentationBuilder()
+ .setNegotiatedHoldTime(Decimal64.valueOf(2, 90))
+ .setUptime(new Timeticks(Uint32.valueOf(500)))
+ .build())
+ .build())
+ .build();
assertEquals(expectedTimers, NeighborUtil.buildTimer(timerState));
}
doReturn(42949673015L).when(timerState).getUpTime();
final NeighborTimersStateAugmentation timerStateAug = new NeighborTimersStateAugmentationBuilder()
- .setNegotiatedHoldTime(BigDecimal.valueOf(90L)).setUptime(new Timeticks(Uint32.valueOf(5))).build();
+ .setNegotiatedHoldTime(Decimal64.valueOf(2, 90)).setUptime(new Timeticks(Uint32.valueOf(5))).build();
final Timers expectedTimers = new TimersBuilder().setState(
new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers
.StateBuilder().addAugmentation(timerStateAug).build()).build();
@Test
public void buildAfisSafisState() {
- assertEquals(Collections.emptyMap(),
- NeighborUtil.buildAfisSafisState(this.bgpAfiSafiState, this.tableRegistry));
+ assertEquals(Map.of(), NeighborUtil.buildAfisSafisState(bgpAfiSafiState, tableRegistry));
final GracefulRestart graceful = new GracefulRestartBuilder()
.setState(new StateBuilder().addAugmentation(
.multiprotocol.rev151009.bgp.common.afi.safi.list.afi.safi.StateBuilder()
.addAugmentation(new NeighborAfiSafiStateAugmentationBuilder().setActive(false).build()).build();
- this.afiSafi = IPV4UNICAST.class;
- final AfiSafi expected = new AfiSafiBuilder().setAfiSafiName(this.afiSafi)
+ afiSafi = IPV4UNICAST.class;
+ final AfiSafi expected = new AfiSafiBuilder().setAfiSafiName(afiSafi)
.setState(afiSafiState)
.setGracefulRestart(graceful).build();
- assertEquals(Collections.singletonMap(expected.key(), expected),
- NeighborUtil.buildAfisSafisState(this.bgpAfiSafiState, this.tableRegistry));
+ assertEquals(BindingMap.of(expected), NeighborUtil.buildAfisSafisState(bgpAfiSafiState, tableRegistry));
}
-}
\ No newline at end of file
+}
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.Uninterruptibles;
-import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.MPBGP;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.ROUTEREFRESH;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint64;
private final PortNumber remotePort = new PortNumber(Uint16.valueOf(179));
private final Uint16 restartTime = Uint16.valueOf(15);
private final String ribId = "identifier-test";
- private final InstanceIdentifier<Bgp> bgpInstanceIdentifier = InstanceIdentifier.create(NetworkInstances.class)
- .child(NetworkInstance.class, new NetworkInstanceKey("global-bgp")).child(Protocols.class)
- .child(Protocol.class, new ProtocolKey(BGP.class, this.ribId)).augmentation(NetworkInstanceProtocol.class)
+ private final InstanceIdentifier<Bgp> bgpInstanceIdentifier =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
+ .child(NetworkInstance.class, new NetworkInstanceKey("global-bgp"))
+ .child(Protocols.class)
+ .child(Protocol.class, new ProtocolKey(BGP.class, ribId))
+ .augmentation(NetworkInstanceProtocol.class)
.child(Bgp.class);
static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
private final AsNumber as = new AsNumber(Uint32.valueOf(72));
@Before
public void setUp() {
- doReturn(IPV4UNICAST.class).when(this.tableTypeRegistry).getAfiSafiType(eq(TABLES_KEY));
+ doReturn(IPV4UNICAST.class).when(tableTypeRegistry).getAfiSafiType(eq(TABLES_KEY));
- doReturn(this.bgpRibStates).when(this.stateProvider).getRibStats();
- doReturn(this.bgpPeerStates).when(this.stateProvider).getPeerStats();
+ doReturn(bgpRibStates).when(stateProvider).getRibStats();
+ doReturn(bgpPeerStates).when(stateProvider).getPeerStats();
final KeyedInstanceIdentifier<Rib, RibKey> iid = InstanceIdentifier.create(BgpRib.class)
- .child(Rib.class, new RibKey(new RibId(this.ribId)));
- doReturn(iid).when(this.bgpRibState).getInstanceIdentifier();
- doReturn(this.as).when(this.bgpRibState).getAs();
- doReturn(this.bgpId).when(this.bgpRibState).getRouteId();
-
- doAnswer(invocation -> this.totalPathsCounter.longValue())
- .when(this.bgpRibState).getTotalPathsCount();
- doAnswer(invocation -> this.totalPrefixesCounter.longValue())
- .when(this.bgpRibState).getTotalPrefixesCount();
- doAnswer(invocation -> this.totalPathsCounter.longValue())
- .when(this.bgpRibState).getPathCount(eq(TABLES_KEY));
- doAnswer(invocation -> this.totalPrefixesCounter.longValue())
- .when(this.bgpRibState).getPrefixesCount(eq(TABLES_KEY));
+ .child(Rib.class, new RibKey(new RibId(ribId)));
+ doReturn(iid).when(bgpRibState).getInstanceIdentifier();
+ doReturn(as).when(bgpRibState).getAs();
+ doReturn(bgpId).when(bgpRibState).getRouteId();
+
+ doAnswer(invocation -> totalPathsCounter.longValue())
+ .when(bgpRibState).getTotalPathsCount();
+ doAnswer(invocation -> totalPrefixesCounter.longValue())
+ .when(bgpRibState).getTotalPrefixesCount();
+ doAnswer(invocation -> totalPathsCounter.longValue())
+ .when(bgpRibState).getPathCount(eq(TABLES_KEY));
+ doAnswer(invocation -> totalPrefixesCounter.longValue())
+ .when(bgpRibState).getPrefixesCount(eq(TABLES_KEY));
doAnswer(invocation -> Map.of(TABLES_KEY,
- this.totalPathsCounter.longValue())).when(this.bgpRibState).getPathsCount();
+ totalPathsCounter.longValue())).when(bgpRibState).getPathsCount();
// Mock Peer
- doReturn("test-group").when(this.bgpPeerState).getGroupId();
- doReturn(iid).when(this.bgpPeerState).getInstanceIdentifier();
- doAnswer(invocation -> this.totalPrefixesCounter.longValue()).when(this.bgpPeerState).getTotalPrefixes();
- doAnswer(invocation -> this.totalPathsCounter.longValue()).when(this.bgpPeerState).getTotalPathsCount();
- doReturn(this.neighborAddress).when(this.bgpPeerState).getNeighborAddress();
- doReturn(this.bgpSessionState).when(this.bgpPeerState).getBGPSessionState();
- doReturn(this.bgpPeerMessagesState).when(this.bgpPeerState).getBGPPeerMessagesState();
-
- doReturn(1L).when(this.bgpPeerMessagesState).getNotificationMessagesReceivedCount();
- doReturn(1L).when(this.bgpPeerMessagesState).getNotificationMessagesSentCount();
- doReturn(1L).when(this.bgpPeerMessagesState).getUpdateMessagesReceivedCount();
- doReturn(1L).when(this.bgpPeerMessagesState).getUpdateMessagesSentCount();
- doReturn(State.UP).when(this.bgpSessionState).getSessionState();
- doReturn(true).when(this.bgpSessionState).isAddPathCapabilitySupported();
- doReturn(true).when(this.bgpSessionState).isAsn32CapabilitySupported();
- doReturn(true).when(this.bgpSessionState).isGracefulRestartCapabilitySupported();
- doReturn(true).when(this.bgpSessionState).isMultiProtocolCapabilitySupported();
- doReturn(true).when(this.bgpSessionState).isRouterRefreshCapabilitySupported();
-
- doReturn(this.timersState).when(this.bgpPeerState).getBGPTimersState();
- doReturn(10L).when(this.timersState).getNegotiatedHoldTime();
- doReturn(10L).when(this.timersState).getUpTime();
-
- doReturn(this.bgpTransportState).when(this.bgpPeerState).getBGPTransportState();
- doReturn(this.localPort).when(this.bgpTransportState).getLocalPort();
- doReturn(this.neighborAddress).when(this.bgpTransportState).getRemoteAddress();
- doReturn(this.remotePort).when(this.bgpTransportState).getRemotePort();
-
- doReturn(this.bgpErrorHandlingState).when(this.bgpPeerState).getBGPErrorHandlingState();
- doReturn(1L).when(this.bgpErrorHandlingState).getErroneousUpdateReceivedCount();
-
- doReturn(this.bgpGracelfulRestartState).when(this.bgpPeerState).getBGPGracelfulRestart();
- doReturn(true).when(this.bgpGracelfulRestartState).isLocalRestarting();
- doReturn(true).when(this.bgpGracelfulRestartState).isPeerRestarting();
- doReturn(this.restartTime.toJava()).when(this.bgpGracelfulRestartState).getPeerRestartTime();
- doReturn(BgpAfiSafiGracefulRestartState.Mode.BILATERAL).when(this.bgpGracelfulRestartState).getMode();
-
- doReturn(this.bgpAfiSafiState).when(this.bgpPeerState).getBGPAfiSafiState();
- doReturn(Set.of(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisAdvertized();
- doReturn(Set.of(TABLES_KEY)).when(this.bgpAfiSafiState).getAfiSafisReceived();
- doReturn(1L).when(this.bgpAfiSafiState).getPrefixesInstalledCount(any());
- doReturn(2L).when(this.bgpAfiSafiState).getPrefixesReceivedCount(any());
- doReturn(1L).when(this.bgpAfiSafiState).getPrefixesSentCount(any());
- doReturn(true).when(this.bgpAfiSafiState).isAfiSafiSupported(any());
- doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartAdvertized(any());
- doReturn(true).when(this.bgpAfiSafiState).isGracefulRestartReceived(any());
- doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartAdvertised(any());
- doReturn(true).when(this.bgpAfiSafiState).isLlGracefulRestartReceived(any());
- doReturn(60).when(this.bgpAfiSafiState).getLlGracefulRestartTimer(any());
+ doReturn("test-group").when(bgpPeerState).getGroupId();
+ doReturn(iid).when(bgpPeerState).getInstanceIdentifier();
+ doAnswer(invocation -> totalPrefixesCounter.longValue()).when(bgpPeerState).getTotalPrefixes();
+ doAnswer(invocation -> totalPathsCounter.longValue()).when(bgpPeerState).getTotalPathsCount();
+ doReturn(neighborAddress).when(bgpPeerState).getNeighborAddress();
+ doReturn(bgpSessionState).when(bgpPeerState).getBGPSessionState();
+ doReturn(bgpPeerMessagesState).when(bgpPeerState).getBGPPeerMessagesState();
+
+ doReturn(1L).when(bgpPeerMessagesState).getNotificationMessagesReceivedCount();
+ doReturn(1L).when(bgpPeerMessagesState).getNotificationMessagesSentCount();
+ doReturn(1L).when(bgpPeerMessagesState).getUpdateMessagesReceivedCount();
+ doReturn(1L).when(bgpPeerMessagesState).getUpdateMessagesSentCount();
+ doReturn(State.UP).when(bgpSessionState).getSessionState();
+ doReturn(true).when(bgpSessionState).isAddPathCapabilitySupported();
+ doReturn(true).when(bgpSessionState).isAsn32CapabilitySupported();
+ doReturn(true).when(bgpSessionState).isGracefulRestartCapabilitySupported();
+ doReturn(true).when(bgpSessionState).isMultiProtocolCapabilitySupported();
+ doReturn(true).when(bgpSessionState).isRouterRefreshCapabilitySupported();
+
+ doReturn(timersState).when(bgpPeerState).getBGPTimersState();
+ doReturn(10L).when(timersState).getNegotiatedHoldTime();
+ doReturn(10L).when(timersState).getUpTime();
+
+ doReturn(bgpTransportState).when(bgpPeerState).getBGPTransportState();
+ doReturn(localPort).when(bgpTransportState).getLocalPort();
+ doReturn(neighborAddress).when(bgpTransportState).getRemoteAddress();
+ doReturn(remotePort).when(bgpTransportState).getRemotePort();
+
+ doReturn(bgpErrorHandlingState).when(bgpPeerState).getBGPErrorHandlingState();
+ doReturn(1L).when(bgpErrorHandlingState).getErroneousUpdateReceivedCount();
+
+ doReturn(bgpGracelfulRestartState).when(bgpPeerState).getBGPGracelfulRestart();
+ doReturn(true).when(bgpGracelfulRestartState).isLocalRestarting();
+ doReturn(true).when(bgpGracelfulRestartState).isPeerRestarting();
+ doReturn(restartTime.toJava()).when(bgpGracelfulRestartState).getPeerRestartTime();
+ doReturn(BgpAfiSafiGracefulRestartState.Mode.BILATERAL).when(bgpGracelfulRestartState).getMode();
+
+ doReturn(bgpAfiSafiState).when(bgpPeerState).getBGPAfiSafiState();
+ doReturn(Set.of(TABLES_KEY)).when(bgpAfiSafiState).getAfiSafisAdvertized();
+ doReturn(Set.of(TABLES_KEY)).when(bgpAfiSafiState).getAfiSafisReceived();
+ doReturn(1L).when(bgpAfiSafiState).getPrefixesInstalledCount(any());
+ doReturn(2L).when(bgpAfiSafiState).getPrefixesReceivedCount(any());
+ doReturn(1L).when(bgpAfiSafiState).getPrefixesSentCount(any());
+ doReturn(true).when(bgpAfiSafiState).isAfiSafiSupported(any());
+ doReturn(true).when(bgpAfiSafiState).isGracefulRestartAdvertized(any());
+ doReturn(true).when(bgpAfiSafiState).isGracefulRestartReceived(any());
+ doReturn(true).when(bgpAfiSafiState).isLlGracefulRestartAdvertised(any());
+ doReturn(true).when(bgpAfiSafiState).isLlGracefulRestartReceived(any());
+ doReturn(60).when(bgpAfiSafiState).getLlGracefulRestartTimer(any());
}
@Override
@Test
public void testActiveStateProvider() throws Exception {
- doReturn(true).when(this.bgpRibState).isActive();
- doReturn(true).when(this.bgpPeerState).isActive();
+ doReturn(true).when(bgpRibState).isActive();
+ doReturn(true).when(bgpPeerState).isActive();
try (StateProviderImpl stateProvider =
// FIXME: use a properly-controlled executor service
new StateProviderImpl(getDataBroker(), 1, tableTypeRegistry, this.stateProvider, "global-bgp")) {
final Global globalExpected = buildGlobalExpected(0);
- this.bgpRibStates.add(this.bgpRibState);
- readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
+ bgpRibStates.add(bgpRibState);
+ readDataOperational(getDataBroker(), bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected, global);
return bgpRib;
});
- this.totalPathsCounter.increment();
- this.totalPrefixesCounter.increment();
+ totalPathsCounter.increment();
+ totalPrefixesCounter.increment();
final Global globalExpected2 = buildGlobalExpected(1);
- readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
+ readDataOperational(getDataBroker(), bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected2, global);
return bgpRib;
});
- this.totalPathsCounter.decrement();
- this.totalPrefixesCounter.decrement();
+ totalPathsCounter.decrement();
+ totalPrefixesCounter.decrement();
final Global globalExpected3 = buildGlobalExpected(0);
- readDataOperational(getDataBroker(), this.bgpInstanceIdentifier, bgpRib -> {
+ readDataOperational(getDataBroker(), bgpInstanceIdentifier, bgpRib -> {
final Global global = bgpRib.getGlobal();
assertEquals(globalExpected3, global);
assertNull(bgpRib.getNeighbors());
return bgpRib;
});
- this.bgpPeerStates.add(this.bgpPeerState);
+ bgpPeerStates.add(bgpPeerState);
final PeerGroup peerGroupExpected = buildGroupExpected();
- this.totalPathsCounter.increment();
- this.totalPrefixesCounter.increment();
+ totalPathsCounter.increment();
+ totalPrefixesCounter.increment();
final AfiSafis expectedAfiSafis = buildAfiSafis();
final ErrorHandling expectedErrorHandling = buildErrorHandling();
assertEquals(expectedBgpNeighborState, stateResult.augmentation(BgpNeighborStateAugmentation.class));
assertEquals(BgpNeighborState.SessionState.ESTABLISHED, stateResult
.augmentation(NeighborStateAugmentation.class).getSessionState());
- final List<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult
+ final Set<Class<? extends BgpCapability>> supportedCapabilitiesResult = stateResult
.augmentation(NeighborStateAugmentation.class).getSupportedCapabilities();
- assertTrue(supportedCapabilitiesResult.containsAll(this.supportedCap));
+ assertTrue(supportedCapabilitiesResult.containsAll(supportedCap));
return bgpRib;
});
- this.bgpRibStates.clear();
- checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
+ bgpRibStates.clear();
+ checkNotPresentOperational(getDataBroker(), bgpInstanceIdentifier);
}
}
@Test
public void testInactiveStateProvider() throws Exception {
- doReturn(false).when(this.bgpRibState).isActive();
+ doReturn(false).when(bgpRibState).isActive();
try (StateProviderImpl stateProvider =
new StateProviderImpl(getDataBroker(), 100, TimeUnit.MILLISECONDS, tableTypeRegistry,
// FIXME: use a properly-controlled executor service ...
"global-bgp", Executors.newScheduledThreadPool(1))) {
- bgpRibStates.add(this.bgpRibState);
+ bgpRibStates.add(bgpRibState);
/// ... and trigger here
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
+ checkNotPresentOperational(getDataBroker(), bgpInstanceIdentifier);
- bgpPeerStates.add(this.bgpPeerState);
+ bgpPeerStates.add(bgpPeerState);
/// ... and trigger here
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
+ checkNotPresentOperational(getDataBroker(), bgpInstanceIdentifier);
bgpRibStates.clear();
/// ... and trigger here
Uninterruptibles.sleepUninterruptibly(500, TimeUnit.MILLISECONDS);
- checkNotPresentOperational(getDataBroker(), this.bgpInstanceIdentifier);
+ checkNotPresentOperational(getDataBroker(), bgpInstanceIdentifier);
}
}
+ LoggerFactory.getLogger(StateProviderImpl.class).getClass());
}
- doReturn(true).when(this.bgpRibState).isActive();
+ doReturn(true).when(bgpRibState).isActive();
- this.bgpRibStates.add(this.bgpRibState);
+ bgpRibStates.add(bgpRibState);
ScheduledFuture<?> mockScheduledFuture = mock(ScheduledFuture.class);
doReturn(true).when(mockScheduledFuture).cancel(anyBoolean());
return new TimersBuilder()
.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
.timers.StateBuilder()
- .setConnectRetry(BigDecimal.valueOf(30))
- .setHoldTime(BigDecimal.valueOf(90))
- .setKeepaliveInterval(BigDecimal.valueOf(30))
- .setMinimumAdvertisementInterval(BigDecimal.valueOf(30))
+ .setConnectRetry(Decimal64.valueOf(2, 30))
+ .setHoldTime(Decimal64.valueOf(2, 90))
+ .setKeepaliveInterval(Decimal64.valueOf(2, 30))
+ .setMinimumAdvertisementInterval(Decimal64.valueOf(2, 30))
.addAugmentation(new NeighborTimersStateAugmentationBuilder()
- .setNegotiatedHoldTime(BigDecimal.TEN)
+ .setNegotiatedHoldTime(Decimal64.valueOf(2, 10))
.setUptime(new Timeticks(Uint32.ONE)).build())
.build())
.build();
.setMtuDiscovery(false)
.setPassiveMode(false)
.addAugmentation(new NeighborTransportStateAugmentationBuilder()
- .setLocalPort(this.localPort)
- .setRemotePort(this.remotePort)
+ .setLocalPort(localPort)
+ .setRemotePort(remotePort)
.setRemoteAddress(new IpAddress(neighborAddress.getIpv4AddressNoZone())).build())
.build()).build();
}
.setPeerRestartTime(Uint16.ZERO)
.setLocalRestarting(true)
.setPeerRestarting(true)
- .setPeerRestartTime(this.restartTime)
+ .setPeerRestartTime(restartTime)
.setMode(BgpAfiSafiGracefulRestartState.Mode.BILATERAL);
final GracefulRestart gracefulRestart = new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp
.rev151009.bgp.graceful.restart.GracefulRestartBuilder().setState(new org.opendaylight.yang.gen.v1.http
return new GlobalBuilder()
.setState(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
.StateBuilder()
- .setRouterId(new Ipv4Address(this.bgpId.getValue()))
+ .setRouterId(new Ipv4Address(bgpId.getValue()))
.setTotalPrefixes(Uint32.valueOf(prefixesAndPaths))
.setTotalPaths(Uint32.valueOf(prefixesAndPaths))
- .setAs(this.as)
+ .setAs(as)
.build())
.setAfiSafis(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base
.AfiSafisBuilder()
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
import static java.util.Objects.requireNonNull;
import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.protocol.bgp.parser.BGPError;
private final ReferenceCache refCache;
private static final Logger LOG = LoggerFactory.getLogger(AsPathAttributeParser.class);
- private static final AsPath EMPTY = new AsPathBuilder().setSegments(Collections.emptyList()).build();
+ private static final AsPath EMPTY = new AsPathBuilder().setSegments(List.of()).build();
public AsPathAttributeParser(final ReferenceCache refCache) {
this.refCache = requireNonNull(refCache);
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder,
final RevisedErrorHandling errorHandling, final PeerSpecificParserConstraint constraint)
throws BGPDocumentedException, BGPTreatAsWithdrawException {
- builder.setAsPath(parseAsPath(this.refCache, buffer, errorHandling));
+ builder.setAsPath(parseAsPath(refCache, buffer, errorHandling));
}
@Override
ases.add(new SegmentsBuilder().setAsSequence(asList).build());
isSequence = true;
} else {
- ases.add(new SegmentsBuilder().setAsSet(asList).build());
+ ases.add(new SegmentsBuilder().setAsSet(ImmutableSet.copyOf(asList)).build());
}
}
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableList.Builder;
import io.netty.buffer.ByteBuf;
-import java.util.List;
+import java.util.Collection;
import org.opendaylight.protocol.util.ReferenceCache;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
return coll.build();
}
- static void serializeAsList(final List<AsNumber> asList, final SegmentType type, final ByteBuf byteAggregator) {
+ static void serializeAsList(final Collection<AsNumber> asList, final SegmentType type,
+ final ByteBuf byteAggregator) {
if (asList == null) {
return;
}
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.ByteArrayOutputStream;
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("10.0.0.2")).build()).build();
- final List<Communities> comms = new ArrayList<>();
- comms.add((Communities) CommunityUtil.NO_EXPORT);
- comms.add((Communities) CommunityUtil.NO_ADVERTISE);
- comms.add((Communities) CommunityUtil.NO_EXPORT_SUBCONFED);
- comms.add((Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
+ final List<Communities> comms = List.of(
+ (Communities) CommunityUtil.NO_EXPORT,
+ (Communities) CommunityUtil.NO_ADVERTISE,
+ (Communities) CommunityUtil.NO_EXPORT_SUBCONFED,
+ (Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
final UpdateBuilder builder = new UpdateBuilder();
assertNull(message.getWithdrawnRoutes());
// attributes
- final List<AsNumber> asNumbers = new ArrayList<>();
- asNumbers.add(new AsNumber(Uint32.valueOf(30)));
- final List<Segments> asPath = new ArrayList<>();
- asPath.add(new SegmentsBuilder().setAsSequence(asNumbers).build());
- final List<AsNumber> asSet = List.of(new AsNumber(Uint32.TEN), new AsNumber(Uint32.valueOf(20)));
- asPath.add(new SegmentsBuilder().setAsSet(asSet).build());
+ final List<Segments> asPath = List.of(
+ new SegmentsBuilder().setAsSequence(List.of(new AsNumber(Uint32.valueOf(30)))).build(),
+ new SegmentsBuilder()
+ // Predictable iteration order
+ .setAsSet(ImmutableSet.of(new AsNumber(Uint32.TEN), new AsNumber(Uint32.valueOf(20)))).build());
final Aggregator aggregator = new AggregatorBuilder().setAsNumber(new AsNumber(Uint32.valueOf(30)))
.setNetworkAddress(new Ipv4AddressNoZone("10.0.0.9")).build();
assertNull(message.getWithdrawnRoutes());
// check nlri
- final List<Nlri> nlris = new ArrayList<>();
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.3.0/24")).build());
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.2.0/24")).build());
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.1.0/24")).build());
+ final List<Nlri> nlris = List.of(
+ new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.3.0/24")).build(),
+ new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.2.0/24")).build(),
+ new NlriBuilder().setPrefix(new Ipv4Prefix("10.30.1.0/24")).build());
assertEquals(nlris, message.getNlri());
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("3.3.3.3")).build()).build();
- final List<ExtendedCommunities> comms = new ArrayList<>();
- comms.add(new ExtendedCommunitiesBuilder()
+ final List<ExtendedCommunities> comms = List.of(new ExtendedCommunitiesBuilder()
.setTransitive(true)
.setExtendedCommunity(new RouteTargetIpv4CaseBuilder()
.setRouteTargetIpv4(new RouteTargetIpv4Builder()
assertNull(message.getWithdrawnRoutes());
// attributes
- final List<AsNumber> asNumbers = new ArrayList<>();
- asNumbers.add(new AsNumber(Uint32.valueOf(65002)));
- final List<Segments> asPath = new ArrayList<>();
- asPath.add(new SegmentsBuilder().setAsSequence(asNumbers).build());
+ final List<Segments> asPath = List.of(
+ new SegmentsBuilder().setAsSequence(List.of(new AsNumber(Uint32.valueOf(65002)))).build());
final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(
new Ipv4NextHopBuilder().setGlobal(new Ipv4AddressNoZone("10.0.0.2")).build()).build();
- final List<Communities> comms = new ArrayList<>();
- comms.add((Communities) CommunityUtil.NO_EXPORT);
- comms.add((Communities) CommunityUtil.NO_ADVERTISE);
- comms.add((Communities) CommunityUtil.NO_EXPORT_SUBCONFED);
- comms.add((Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
+ final List<Communities> comms = List.of(
+ (Communities) CommunityUtil.NO_EXPORT,
+ (Communities) CommunityUtil.NO_ADVERTISE,
+ (Communities) CommunityUtil.NO_EXPORT_SUBCONFED,
+ (Communities) CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF10));
final UpdateBuilder builder = new UpdateBuilder();
// check nlri
- final List<Nlri> nlris = new ArrayList<>();
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.1.0/24")).setPathId(new PathId(Uint32.ONE))
- .build());
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.1.0/24")).setPathId(new PathId(Uint32.TWO))
- .build());
- nlris.add(new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.0.0/24")).setPathId(new PathId(Uint32.ONE))
- .build());
+ final List<Nlri> nlris = List.of(
+ new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.1.0/24")).setPathId(new PathId(Uint32.ONE)).build(),
+ new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.1.0/24")).setPathId(new PathId(Uint32.TWO)).build(),
+ new NlriBuilder().setPrefix(new Ipv4Prefix("172.17.0.0/24")).setPathId(new PathId(Uint32.ONE)).build());
assertEquals(nlris, message.getNlri());
mpConstraint);
// attributes
- final List<WithdrawnRoutes> withdrawnRoutes = new ArrayList<>();
- withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30"))
- .setPathId(new PathId(Uint32.ONE)).build());
- withdrawnRoutes.add(new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("172.16.0.4/30"))
- .setPathId(new PathId(Uint32.TWO)).build());
+ final List<WithdrawnRoutes> withdrawnRoutes = List.of(
+ new WithdrawnRoutesBuilder()
+ .setPrefix(new Ipv4Prefix("172.16.0.4/30")).setPathId(new PathId(Uint32.ONE)).build(),
+ new WithdrawnRoutesBuilder()
+ .setPrefix(new Ipv4Prefix("172.16.0.4/30")).setPathId(new PathId(Uint32.TWO)).build());
// check API message
final Update expectedMessage = new UpdateBuilder().setWithdrawnRoutes(withdrawnRoutes).build();
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.List;
final Attributes attr = new AttributesBuilder()
.setAsPath(new AsPathBuilder()
.setSegments(List.of(
- new SegmentsBuilder().setAsSet(List.of(new AsNumber(Uint32.ONE), new AsNumber(Uint32.TWO))).build(),
new SegmentsBuilder()
- .setAsSequence(List.of(new AsNumber(Uint32.valueOf(3)), new AsNumber(Uint32.valueOf(4))))
- .build()))
+ // For testing purposes we need a predictable iteration order
+ .setAsSet(ImmutableSet.of(new AsNumber(Uint32.ONE), new AsNumber(Uint32.TWO)))
+ .build(),
+ new SegmentsBuilder()
+ .setAsSequence(List.of(new AsNumber(Uint32.valueOf(3)), new AsNumber(Uint32.valueOf(4))))
+ .build()))
.build())
.build();
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Testing dependencies -->
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
final NodeIdentifier semantics;
NamespaceSpecificIds(final @NonNull QNameModule namespace) {
- this.asPath = List.of(NodeIdentifier.create(AsPath.QNAME.bindTo(namespace).intern()),
+ asPath = List.of(NodeIdentifier.create(AsPath.QNAME.bindTo(namespace).intern()),
NodeIdentifier.create(QName.create(namespace, "segments").intern()));
- this.locPref = List.of(NodeIdentifier.create(LocalPref.QNAME.bindTo(namespace).intern()),
+ locPref = List.of(NodeIdentifier.create(LocalPref.QNAME.bindTo(namespace).intern()),
NodeIdentifier.create(QName.create(namespace, "pref").intern()));
- this.med = List.of(NodeIdentifier.create(MultiExitDisc.QNAME.bindTo(namespace).intern()),
+ med = List.of(NodeIdentifier.create(MultiExitDisc.QNAME.bindTo(namespace).intern()),
NodeIdentifier.create(QName.create(namespace, "med").intern()));
- this.orig = List.of(NodeIdentifier.create(Origin.QNAME.bindTo(namespace).intern()),
+ orig = List.of(NodeIdentifier.create(Origin.QNAME.bindTo(namespace).intern()),
NodeIdentifier.create(QName.create(namespace, "value").intern()));
- this.asSetNid = NodeIdentifier.create(QName.create(namespace, "as-set").intern());
- this.asSeqNid = NodeIdentifier.create(QName.create(namespace, "as-sequence").intern());
- this.communities = NodeIdentifier.create(Communities.QNAME.bindTo(namespace).intern());
- this.asNumber = NodeIdentifier.create(QName.create(namespace, "as-number").intern());
- this.semantics = NodeIdentifier.create(QName.create(namespace, "semantics").intern());
+ asSetNid = NodeIdentifier.create(QName.create(namespace, "as-set").intern());
+ asSeqNid = NodeIdentifier.create(QName.create(namespace, "as-sequence").intern());
+ communities = NodeIdentifier.create(Communities.QNAME.bindTo(namespace).intern());
+ asNumber = NodeIdentifier.create(QName.create(namespace, "as-number").intern());
+ semantics = NodeIdentifier.create(QName.create(namespace, "semantics").intern());
}
}
final UnkeyedListNode segments = (UnkeyedListNode) maybeSegments.get();
final List<Segments> segs = extractSegments(segments, ids);
if (!segs.isEmpty()) {
- this.peerAs = BesthPathStateUtil.getPeerAs(segs);
- this.asPathLength = countAsPath(segs);
+ peerAs = BesthPathStateUtil.getPeerAs(segs);
+ asPathLength = countAsPath(segs);
}
}
depreferenced = false;
}
- this.resolved = true;
+ resolved = true;
}
private static boolean isStale(final NamespaceSpecificIds ids, final UnkeyedListEntryNode community) {
@Override
public Uint32 getLocalPref() {
resolveValues();
- return this.localPref;
+ return localPref;
}
@Override
public long getMultiExitDisc() {
resolveValues();
- return this.multiExitDisc;
+ return multiExitDisc;
}
@Override
public BgpOrigin getOrigin() {
resolveValues();
- return this.origin;
+ return origin;
}
@Override
public long getPeerAs() {
resolveValues();
- return this.peerAs;
+ return peerAs;
}
@Override
public int getAsPathLength() {
resolveValues();
- return this.asPathLength;
+ return asPathLength;
}
@Override
public ContainerNode getAttributes() {
- return this.attributes;
+ return attributes;
}
@Override
}
private ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
- toStringHelper.add("attributes", this.attributes);
- toStringHelper.add("localPref", this.localPref);
- toStringHelper.add("multiExitDisc", this.multiExitDisc);
- toStringHelper.add("origin", this.origin);
- toStringHelper.add("resolved", this.resolved);
- toStringHelper.add("depreferenced", this.depreferenced);
+ toStringHelper.add("attributes", attributes);
+ toStringHelper.add("localPref", localPref);
+ toStringHelper.add("multiExitDisc", multiExitDisc);
+ toStringHelper.add("origin", origin);
+ toStringHelper.add("resolved", resolved);
+ toStringHelper.add("depreferenced", depreferenced);
return toStringHelper;
}
public int hashCode() {
final int prime = 31;
int result = 1;
- result = prime * result + this.attributes.hashCode();
- result = prime * result + (this.localPref == null ? 0 : this.localPref.hashCode());
+ result = prime * result + attributes.hashCode();
+ result = prime * result + (localPref == null ? 0 : localPref.hashCode());
result = prime * result + Long.hashCode(multiExitDisc);
- result = prime * result + (this.origin == null ? 0 : this.origin.hashCode());
+ result = prime * result + (origin == null ? 0 : origin.hashCode());
result = prime * result + Boolean.hashCode(depreferenced);
return result;
}
if (!attributes.equals(other.attributes)) {
return false;
}
- if (!Objects.equals(this.localPref, other.localPref)) {
+ if (!Objects.equals(localPref, other.localPref)) {
return false;
}
if (multiExitDisc != other.multiExitDisc) {
return depreferenced == other.depreferenced;
}
- private List<Segments> extractSegments(final UnkeyedListNode segments, final NamespaceSpecificIds ids) {
+ private static List<Segments> extractSegments(final UnkeyedListNode segments, final NamespaceSpecificIds ids) {
// list segments
final List<Segments> extracted = new ArrayList<>();
for (final UnkeyedListEntryNode segment : segments.body()) {
final SegmentsBuilder sb = new SegmentsBuilder();
// We are expecting that segment contains either as-sequence or as-set,
// so just one of them will be set, other would be null
- sb.setAsSequence(extractAsList(segment, ids.asSeqNid))
- .setAsSet(extractAsList(segment, ids.asSetNid));
+ sb.setAsSequence(extractAsList(new ArrayList<>(), segment, ids.asSeqNid))
+ .setAsSet(extractAsList(new LinkedHashSet<>(), segment, ids.asSetNid));
extracted.add(sb.build());
}
return extracted;
}
- private static List<AsNumber> extractAsList(final UnkeyedListEntryNode segment, final NodeIdentifier nid) {
- final List<AsNumber> ases = new ArrayList<>();
+ private static <T extends Collection<AsNumber>> T extractAsList(final T ases,
+ final UnkeyedListEntryNode segment, final NodeIdentifier nid) {
final Optional<NormalizedNode> maybeAsList = NormalizedNodes.findNode(segment, nid);
if (maybeAsList.isPresent()) {
final LeafSetNode<?> list = (LeafSetNode<?>)maybeAsList.get();
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-data-tree-api</artifactId>
+ </dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-impl</artifactId>
</dependency>
<dependency>
<groupId>io.netty</groupId>
- <artifactId>netty-transport-native-epoll</artifactId>
- <classifier>linux-x86_64</classifier>
+ <artifactId>netty-transport-classes-epoll</artifactId>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.metatype.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@GuardedBy("this")
private FluentFuture<? extends CommitInfo> submitted;
+ @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
+ justification = "False positive on synchronized createDomChain()")
AbstractPeer(
final RIB rib,
final String peerName,
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import java.util.concurrent.atomic.LongAdder;
import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
@Override
- public void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+ public void onDataTreeChanged(final List<DataTreeCandidate> changes) {
LOG.debug("Data change received for AdjRibOut {}", changes);
for (final DataTreeCandidate tc : changes) {
LOG.trace("Change {} type {}", tc.getRootNode(), tc.getRootNode().getModificationType());
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.opendaylight.mdsal.common.api.CommitInfo;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final BGPTableTypeRegistryConsumer tableTypeRegistry,
final ApplicationRibId applicationRibId, final Ipv4AddressNoZone ipAddress, final RIB rib) {
super(rib, applicationRibId.getValue(), APP_PEER_GROUP, PeerRole.Internal,
- new IpAddressNoZone(ipAddress), Collections.emptySet());
+ new IpAddressNoZone(ipAddress), Set.of());
this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
final RIB targetRib = requireNonNull(rib);
- this.peerId = RouterIds.createPeerId(ipAddress);
+ peerId = RouterIds.createPeerId(ipAddress);
final YangInstanceIdentifier peerRib = targetRib.getYangRibId().node(PEER_NID)
.node(IdentifierUtils.domPeerId(peerId));
- this.adjRibsInId = peerRib.node(ADJRIBIN_NID).node(TABLES_NID).toOptimized();
- this.peerRibOutIId = peerRib.node(ADJRIBOUT_NID).node(TABLES_NID).toOptimized();
+ adjRibsInId = peerRib.node(ADJRIBIN_NID).node(TABLES_NID).toOptimized();
+ peerRibOutIId = peerRib.node(ADJRIBOUT_NID).node(TABLES_NID).toOptimized();
}
public synchronized void instantiateServiceInstance(final DOMDataTreeChangeService dataTreeChangeService,
final DOMDataTreeIdentifier appPeerDOMId) {
setActive(true);
- final Set<TablesKey> localTables = this.rib.getLocalTablesKeys();
- localTables.forEach(tablesKey -> this.supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey)));
- setAdvertizedGracefulRestartTableTypes(Collections.emptyList());
+ final Set<TablesKey> localTables = rib.getLocalTablesKeys();
+ localTables.forEach(tablesKey -> supportedTables.add(RibSupportUtils.toYangTablesKey(tablesKey)));
+ setAdvertizedGracefulRestartTableTypes(List.of());
createDomChain();
- this.adjRibInWriter = AdjRibInWriter.create(this.rib.getYangRibId(), PeerRole.Internal, this);
- final RIBSupportContextRegistry context = this.rib.getRibSupportContext();
+ adjRibInWriter = AdjRibInWriter.create(rib.getYangRibId(), PeerRole.Internal, this);
+ final RIBSupportContextRegistry context = rib.getRibSupportContext();
final RegisterAppPeerListener registerAppPeerListener = () -> {
synchronized (this) {
if (getDomChain() != null) {
- this.registration = dataTreeChangeService.registerDataTreeChangeListener(appPeerDOMId, this);
+ registration = dataTreeChangeService.registerDataTreeChangeListener(appPeerDOMId, this);
}
}
};
- this.peerPath = createPeerPath(this.peerId);
- this.adjRibInWriter = this.adjRibInWriter.transform(this.peerId, this.peerPath, context, localTables,
- Collections.emptyMap(), registerAppPeerListener);
- this.effectiveRibInWriter = new EffectiveRibInWriter(this, this.rib,
- this.rib.createPeerDOMChain(this), this.peerPath, localTables, this.tableTypeRegistry,
- new ArrayList<>(), this.rtCache);
- this.effectiveRibInWriter.init();
- this.bgpSessionState.registerMessagesCounter(this);
- this.trackerRegistration = this.rib.getPeerTracker().registerPeer(this);
+ peerPath = createPeerPath(peerId);
+ adjRibInWriter = adjRibInWriter.transform(peerId, peerPath, context, localTables,
+ Map.of(), registerAppPeerListener);
+ effectiveRibInWriter = new EffectiveRibInWriter(this, rib,
+ rib.createPeerDOMChain(this), peerPath, localTables, tableTypeRegistry,
+ new ArrayList<>(), rtCache);
+ effectiveRibInWriter.init();
+ bgpSessionState.registerMessagesCounter(this);
+ trackerRegistration = rib.getPeerTracker().registerPeer(this);
}
@Override
* be determined in LocRib.
*/
@Override
- public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+ public synchronized void onDataTreeChanged(final List<DataTreeCandidate> changes) {
final DOMTransactionChain chain = getDomChain();
if (chain == null) {
LOG.trace("Skipping data changed called to Application Peer. Change : {}", changes);
verify(lastArg instanceof NodeIdentifierWithPredicates,
"Unexpected type %s in path %s", lastArg.getClass(), path);
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) lastArg;
- if (!this.supportedTables.contains(tableKey)) {
+ if (!supportedTables.contains(tableKey)) {
LOG.trace("Skipping received data change for non supported family {}.", tableKey);
continue;
}
for (final DataTreeCandidateNode child : tc.getRootNode().getChildNodes()) {
final PathArgument childIdentifier = child.getIdentifier();
- final YangInstanceIdentifier tableId = this.adjRibsInId.node(tableKey).node(childIdentifier);
+ final YangInstanceIdentifier tableId = adjRibsInId.node(tableKey).node(childIdentifier);
switch (child.getModificationType()) {
case DELETE:
case DISAPPEARED:
@Override
public synchronized FluentFuture<? extends CommitInfo> close() {
setActive(false);
- if (this.registration != null) {
- this.registration.close();
- this.registration = null;
+ if (registration != null) {
+ registration.close();
+ registration = null;
}
- if (this.adjRibInWriter != null) {
- this.adjRibInWriter.releaseChain();
+ if (adjRibInWriter != null) {
+ adjRibInWriter.releaseChain();
}
- if (this.effectiveRibInWriter != null) {
- this.effectiveRibInWriter.close();
+ if (effectiveRibInWriter != null) {
+ effectiveRibInWriter.close();
}
- final FluentFuture<? extends CommitInfo> future = removePeer(this.peerPath);
+ final FluentFuture<? extends CommitInfo> future = removePeer(peerPath);
closeDomChain();
- if (this.trackerRegistration != null) {
- this.trackerRegistration.close();
- this.trackerRegistration = null;
+ if (trackerRegistration != null) {
+ trackerRegistration.close();
+ trackerRegistration = null;
}
return future;
}
@Override
public boolean supportsTable(final TablesKey tableKey) {
- return this.rib.supportsTable(tableKey);
+ return rib.supportsTable(tableKey);
}
@Override
public YangInstanceIdentifier getRibOutIId(final NodeIdentifierWithPredicates tablekey) {
- return this.tablesIId.getUnchecked(tablekey);
+ return tablesIId.getUnchecked(tablekey);
}
@Override
@Override
public BGPSessionState getBGPSessionState() {
- return this.bgpSessionState;
+ return bgpSessionState;
}
@Override
public BGPTimersState getBGPTimersState() {
- return this.bgpSessionState;
+ return bgpSessionState;
}
@Override
public BGPTransportState getBGPTransportState() {
- return this.bgpSessionState;
+ return bgpSessionState;
}
}
releaseConnection(true);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void onRibOutChainFailed(final Throwable cause) {
LOG.error("RibOut transaction chain failed.", cause);
releaseConnection(false);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.peer.rpc.rev180329.RouteRefreshRequestOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
@Override
public ListenableFuture<RpcResult<ResetSessionOutput>> resetSession(final ResetSessionInput input) {
- final ListenableFuture<?> f = this.peerRPCs.releaseConnection();
+ final ListenableFuture<?> f = peerRPCs.releaseConnection();
return Futures.transform(f, input1 -> {
if (f.isDone()) {
return RpcResultBuilder.success(new ResetSessionOutputBuilder().build()).build();
}
private ChannelFuture sendRRMessage(final RouteRefreshRequestInput input) {
- if (!this.supportedFamilies.contains(new TablesKey(input.getAfi(), input.getSafi()))) {
+ if (!supportedFamilies.contains(new TablesKey(input.getAfi(), input.getSafi()))) {
LOG.info("Unsupported afi/safi: {}, {}.", input.getAfi(), input.getSafi());
return null;
}
final RouteRefresh msg = new RouteRefreshBuilder().setAfi(input.getAfi()).setSafi(input.getSafi()).build();
- return ((BGPSessionImpl) this.session).getLimiter().writeAndFlush(msg);
+ return ((BGPSessionImpl) session).getLimiter().writeAndFlush(msg);
}
}
.child(LocRib.class)
.child(Tables.class)
.build();
- private static final InstanceIdentifier<MpReachNlri> MP_REACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path
- .attributes.Attributes.class)
- .augmentation(AttributesReach.class)
- .child(MpReachNlri.class);
- private static final InstanceIdentifier<MpUnreachNlri> MP_UNREACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path
- .attributes.Attributes.class).augmentation(AttributesUnreach.class).child(MpUnreachNlri.class);
static {
final Builder<Class<? extends DataObject>> acb = ImmutableSet.builder();
final Builder<Class<? extends BindingObject>> acb = ImmutableSet.builder();
acb.addAll(ATTRIBUTE_CACHEABLES);
acb.addAll(this.ribSupport.cacheableAttributeObjects());
- this.cacheableAttributes = acb.build();
+ cacheableAttributes = acb.build();
}
@Override
final BindingDataObjectCodecTreeNode tableCodecContext = tree.getSubtreeCodec(TABLE_BASE_II);
final BindingDataObjectCodecTreeNode<? extends Route> routeListCodec = tableCodecContext
.streamChild(Routes.class)
- .streamChild(this.ribSupport.routesCaseClass())
- .streamChild(this.ribSupport.routesContainerClass())
- .streamChild(this.ribSupport.routesListClass());
-
- this.attributesCodec = routeListCodec.streamChild(Attributes.class)
- .createCachingCodec(this.cacheableAttributes);
- this.reachNlriCodec = tree.getSubtreeCodec(MP_REACH_NLRI_II)
- .createCachingCodec(this.ribSupport.cacheableNlriObjects());
- this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II)
- .createCachingCodec(this.ribSupport.cacheableNlriObjects());
+ .streamChild(ribSupport.routesCaseClass())
+ .streamChild(ribSupport.routesContainerClass())
+ .streamChild(ribSupport.routesListClass());
+
+ attributesCodec = routeListCodec.streamChild(Attributes.class)
+ .createCachingCodec(cacheableAttributes);
+
+ final var attrCodec = tree.streamChild(Update.class)
+ .streamChild(Attributes.class);
+ reachNlriCodec = attrCodec.streamChild(AttributesReach.class)
+ .streamChild(MpReachNlri.class)
+ .createCachingCodec(ribSupport.cacheableNlriObjects());
+ unreachNlriCodec = attrCodec.streamChild(AttributesUnreach.class)
+ .streamChild(MpUnreachNlri.class)
+ .createCachingCodec(ribSupport.cacheableNlriObjects());
}
@Override
public ContainerNode serializeUnreachNlri(final MpUnreachNlri nlri) {
- Preconditions.checkState(this.unreachNlriCodec != null, "MpReachNlri codec not available");
- return (ContainerNode) this.unreachNlriCodec.serialize(nlri);
+ Preconditions.checkState(unreachNlriCodec != null, "MpReachNlri codec not available");
+ return (ContainerNode) unreachNlriCodec.serialize(nlri);
}
@Override
public ContainerNode serializeReachNlri(final MpReachNlri nlri) {
- Preconditions.checkState(this.reachNlriCodec != null, "MpReachNlri codec not available");
- return (ContainerNode) this.reachNlriCodec.serialize(nlri);
+ Preconditions.checkState(reachNlriCodec != null, "MpReachNlri codec not available");
+ return (ContainerNode) reachNlriCodec.serialize(nlri);
}
@Override
public Attributes deserializeAttributes(final NormalizedNode attributes) {
- Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
- return this.attributesCodec.deserialize(attributes);
+ Preconditions.checkState(attributesCodec != null, "Attributes codec not available");
+ return attributesCodec.deserialize(attributes);
}
@Override
public ContainerNode serializeAttributes(final Attributes pathAttr) {
- Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
+ Preconditions.checkState(attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.removeAugmentation(AttributesReach.class);
a.removeAugmentation(AttributesUnreach.class);
- return (ContainerNode) this.attributesCodec.serialize(a.build());
+ return (ContainerNode) attributesCodec.serialize(a.build());
}
}
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
final BGPTableTypeRegistryConsumer tableTypeRegistry,
final List<RouteTarget> rtMemberships,
final ClientRouteTargetContrainCache rtCache) {
- this.registry = requireNonNull(rib.getRibSupportContext());
+ registry = requireNonNull(rib.getRibSupportContext());
this.chain = requireNonNull(chain);
this.peerIId = requireNonNull(peerIId);
- this.effRibTables = this.peerIId.node(EFFRIBIN_NID);
- this.prefixesInstalled = buildPrefixesTables(tables);
- this.prefixesReceived = buildPrefixesTables(tables);
- this.ribPolicies = requireNonNull(rib.getRibPolicies());
- this.service = requireNonNull(rib.getService());
+ effRibTables = this.peerIId.node(EFFRIBIN_NID);
+ prefixesInstalled = buildPrefixesTables(tables);
+ prefixesReceived = buildPrefixesTables(tables);
+ ribPolicies = requireNonNull(rib.getRibPolicies());
+ service = requireNonNull(rib.getService());
this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
- this.peerImportParameters = peer;
+ peerImportParameters = peer;
this.rtMemberships = rtMemberships;
this.rtCache = rtCache;
- this.vpnTableRefresher = rib;
+ vpnTableRefresher = rib;
}
public void init() {
final DOMDataTreeIdentifier treeId = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
- this.peerIId.node(ADJRIBIN_NID).node(TABLES_NID));
- LOG.debug("Registered Effective RIB on {}", this.peerIId);
- this.reg = requireNonNull(this.service).registerDataTreeChangeListener(treeId, this);
+ peerIId.node(ADJRIBIN_NID).node(TABLES_NID));
+ LOG.debug("Registered Effective RIB on {}", peerIId);
+ reg = requireNonNull(service).registerDataTreeChangeListener(treeId, this);
}
private static Map<TablesKey, LongAdder> buildPrefixesTables(final Set<TablesKey> tables) {
}
@Override
- public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
- if (this.chain == null) {
+ public synchronized void onDataTreeChanged(final List<DataTreeCandidate> changes) {
+ if (chain == null) {
LOG.trace("Chain closed. Ignoring Changes : {}", changes);
return;
}
final DataTreeCandidateNode root = tc.getRootNode();
for (final DataTreeCandidateNode table : root.getChildNodes()) {
if (tx == null) {
- tx = this.chain.newWriteOnlyTransaction();
+ tx = chain.newWriteOnlyTransaction();
}
changeDataTree(tx, rootPath, root, table);
}
if (tx != null) {
final FluentFuture<? extends CommitInfo> future = tx.commit();
- this.submitted = future;
+ submitted = future;
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
}
//Refresh VPN Table if RT Memberships were updated
- if (this.rtMembershipsUpdated) {
- this.vpnTableRefresher.refreshTable(IVP4_VPN_TABLE_KEY, this.peerImportParameters.getFromPeerId());
- this.vpnTableRefresher.refreshTable(IVP6_VPN_TABLE_KEY, this.peerImportParameters.getFromPeerId());
- this.rtMembershipsUpdated = false;
+ if (rtMembershipsUpdated) {
+ vpnTableRefresher.refreshTable(IVP4_VPN_TABLE_KEY, peerImportParameters.getFromPeerId());
+ vpnTableRefresher.refreshTable(IVP6_VPN_TABLE_KEY, peerImportParameters.getFromPeerId());
+ rtMembershipsUpdated = false;
}
}
@Override
public synchronized void close() {
- if (this.reg != null) {
- this.reg.close();
- this.reg = null;
+ if (reg != null) {
+ reg.close();
+ reg = null;
}
- if (this.submitted != null) {
+ if (submitted != null) {
try {
- this.submitted.get();
+ submitted.get();
} catch (final InterruptedException | ExecutionException throwable) {
LOG.error("Write routes failed", throwable);
}
}
- if (this.chain != null) {
- this.chain.close();
- this.chain = null;
+ if (chain != null) {
+ chain.close();
+ chain = null;
}
- this.prefixesReceived.values().forEach(LongAdder::reset);
- this.prefixesInstalled.values().forEach(LongAdder::reset);
+ prefixesReceived.values().forEach(LongAdder::reset);
+ prefixesInstalled.values().forEach(LongAdder::reset);
}
@Override
public long getPrefixedReceivedCount(final TablesKey tablesKey) {
- final LongAdder counter = this.prefixesReceived.get(tablesKey);
+ final LongAdder counter = prefixesReceived.get(tablesKey);
if (counter == null) {
return 0;
}
@Override
public Set<TablesKey> getTableKeys() {
- return ImmutableSet.copyOf(this.prefixesReceived.keySet());
+ return ImmutableSet.copyOf(prefixesReceived.keySet());
}
@Override
public boolean isSupported(final TablesKey tablesKey) {
- return this.prefixesReceived.containsKey(tablesKey);
+ return prefixesReceived.containsKey(tablesKey);
}
@Override
public long getPrefixedInstalledCount(final TablesKey tablesKey) {
- final LongAdder counter = this.prefixesInstalled.get(tablesKey);
+ final LongAdder counter = prefixesInstalled.get(tablesKey);
if (counter == null) {
return 0;
}
@Override
public long getTotalPrefixesInstalled() {
- return this.prefixesInstalled.values().stream().mapToLong(LongAdder::longValue).sum();
+ return prefixesInstalled.values().stream().mapToLong(LongAdder::longValue).sum();
}
@Holding("this")
verify(lastArg instanceof NodeIdentifierWithPredicates, "Unexpected type %s in path %s", lastArg.getClass(),
rootPath);
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) lastArg;
- final RIBSupportContext ribContext = this.registry.getRIBSupportContext(tableKey);
+ final RIBSupportContext ribContext = registry.getRIBSupportContext(tableKey);
if (ribContext == null) {
LOG.warn("Table {} is not supported, ignoring event", tableKey);
return;
for (final MapEntryNode routeBefore : deletedRoutes) {
deleteRouteTarget(ribSupport, routesPath.node(routeBefore.getIdentifier()), routeBefore);
}
- this.rtMembershipsUpdated = true;
+ rtMembershipsUpdated = true;
}
final TablesKey tablesKey = ribSupport.getTablesKey();
tx.delete(LogicalDatastoreType.OPERATIONAL, routeIdPath);
LOG.debug("Route deleted. routeId={}", routeIdPath);
final TablesKey tablesKey = ribSupport.getTablesKey();
- CountersUtil.decrement(this.prefixesInstalled.get(tablesKey), tablesKey);
+ CountersUtil.decrement(prefixesInstalled.get(tablesKey), tablesKey);
}
private void writeRoute(final DOMDataTreeWriteTransaction tx, final RIBSupport<?, ?> ribSupport,
final YangInstanceIdentifier routePath, final Optional<NormalizedNode> routeBefore,
final NormalizedNode routeAfter, final boolean longLivedStale) {
final TablesKey tablesKey = ribSupport.getTablesKey();
- CountersUtil.increment(this.prefixesReceived.get(tablesKey), tablesKey);
+ CountersUtil.increment(prefixesReceived.get(tablesKey), tablesKey);
// Lookup per-table attributes from RIBSupport
final ContainerNode advertisedAttrs = (ContainerNode) NormalizedNodes.findNode(routeAfter,
ribSupport.routeAttributesIdentifier()).orElse(null);
}
handleRouteTarget(ModificationType.WRITE, ribSupport, routePath, routeAfter);
tx.put(LogicalDatastoreType.OPERATIONAL, routePath, routeAfter);
- CountersUtil.increment(this.prefixesInstalled.get(tablesKey), tablesKey);
+ CountersUtil.increment(prefixesInstalled.get(tablesKey), tablesKey);
final Attributes attToStore = optEffAtt.get();
if (!attToStore.equals(routeAttrs)) {
private void addRouteTarget(final RouteTargetConstrainRoute rtc) {
final RouteTarget rtMembership = RouteTargetMembeshipUtil.getRT(rtc);
- if (PeerRole.Ebgp != this.peerImportParameters.getFromPeerRole()) {
- this.rtCache.cacheRoute(rtc);
+ if (PeerRole.Ebgp != peerImportParameters.getFromPeerRole()) {
+ rtCache.cacheRoute(rtc);
}
- this.rtMemberships.add(rtMembership);
+ rtMemberships.add(rtMembership);
}
private void deleteRouteTarget(final RIBSupport<?, ?> ribSupport, final YangInstanceIdentifier routeIdPath,
private void deleteRouteTarget(final RouteTargetConstrainRoute rtc) {
final RouteTarget rtMembership = RouteTargetMembeshipUtil.getRT(rtc);
- if (PeerRole.Ebgp != this.peerImportParameters.getFromPeerRole()) {
- this.rtCache.uncacheRoute(rtc);
+ if (PeerRole.Ebgp != peerImportParameters.getFromPeerRole()) {
+ rtCache.uncacheRoute(rtc);
}
- this.rtMemberships.remove(rtMembership);
+ rtMemberships.remove(rtMembership);
}
private void handleRouteTarget(final ModificationType modificationType, final RIBSupport<?, ?> ribSupport,
} else {
addRouteTarget(rtc);
}
- this.rtMembershipsUpdated = true;
+ rtMembershipsUpdated = true;
}
}
}
private YangInstanceIdentifier effectiveTablePath(final NodeIdentifierWithPredicates tableKey) {
- return this.effRibTables.node(TABLES_NID).node(tableKey);
+ return effRibTables.node(TABLES_NID).node(tableKey);
}
private static YangInstanceIdentifier routeMapPath(final RIBSupport<?, ?> ribSupport,
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
*/
@Override
@SuppressWarnings("checkstyle:illegalCatch")
- public synchronized void onDataTreeChanged(final Collection<DataTreeCandidate> changes) {
+ public synchronized void onDataTreeChanged(final List<DataTreeCandidate> changes) {
if (this.chain == null) {
LOG.trace("Chain closed, ignoring received data change {} to LocRib {}", changes, this);
return;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import org.opendaylight.protocol.bgp.rib.impl.spi.CodecsRegistry;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContext;
import org.opendaylight.protocol.bgp.rib.impl.spi.RIBSupportContextRegistry;
return new RIBSupportContextRegistryImpl(extensions, codecs);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private RIBSupportContextImpl createRIBSupportContext(final RIBSupport<?, ?> support) {
return new RIBSupportContextImpl(support, this.codecs);
}
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import org.slf4j.LoggerFactory;
@VisibleForTesting
+@SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR", justification = "Non-final for Mockito.spy()")
public class BGPClusterSingletonService implements ClusterSingletonService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(BGPClusterSingletonService.class);
synchronized (BGPClusterSingletonService.this) {
if (ribImpl != null) {
done.setFuture(Futures.transform(ribImpl.closeServiceInstance(),
- input -> Empty.getInstance(), MoreExecutors.directExecutor()));
+ input -> Empty.value(), MoreExecutors.directExecutor()));
} else {
- done.set(Empty.getInstance());
+ done.set(Empty.value());
}
}
}
import com.google.common.collect.Iterables;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.concurrent.Future;
import java.net.InetSocketAddress;
import java.util.ArrayList;
this.stateProviderRegistry = requireNonNull(stateProviderRegistry);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static List<OptionalCapabilities> getBgpCapabilities(final AfiSafis afiSafis, final RIB rib,
final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<OptionalCapabilities> caps = new ArrayList<>();
import com.google.common.util.concurrent.FluentFuture;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.PeerGroups;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceBuilder;
this.routingPolicyFactory = requireNonNull(routingPolicyFactory);
this.codecsRegistry = requireNonNull(codecsRegistry);
this.domDataBroker = requireNonNull(domDataBroker);
- networkInstanceIId = InstanceIdentifier.create(NetworkInstances.class)
+ networkInstanceIId =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
.child(NetworkInstance.class, new NetworkInstanceKey(this.networkInstanceName));
initializeNetworkInstance(dataBroker, networkInstanceIId).addCallback(new FutureCallback<CommitInfo>() {
@Override
LOG.info("BGP Deployer {} started.", networkInstanceName);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private Optional<PeerGroup> loadPeerGroup(final InstanceIdentifier<PeerGroup> peerGroupIid)
throws ExecutionException, InterruptedException {
final FluentFuture<Optional<PeerGroup>> future;
import static java.util.Objects.requireNonNull;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
* @return true if initial connection was established successfully, false if initial connection failed due
* to e.g. Connection refused, Negotiation failed
*/
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized boolean isInitialConnectFinished() {
requireNonNull(this.pending);
return this.pending.isDone() && this.pending.isSuccess();
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void reconnect() {
requireNonNull(this.pending);
this.pending.reconnect();
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidate;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
localTables.add(new BgpTableTypeImpl(IPV6_AFI, SAFI));
final CurrentAdapterSerializer serializer = mappingService.currentSerializer();
- this.a1.startRIBExtensionProvider(context, serializer);
+ a1.startRIBExtensionProvider(context, serializer);
mockedMethods();
- doReturn(mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider)
+ doReturn(mock(ClusterSingletonServiceRegistration.class)).when(clusterSingletonServiceProvider)
.registerClusterSingletonService(any(ClusterSingletonService.class));
- this.rib = new RIBImpl(this.tableRegistry, new RibId("test"), new AsNumber(Uint32.valueOf(5)), RIB_ID, context,
- this.dispatcher, new ConstantCodecsRegistry(serializer), this.dom, this.policies,
+ rib = new RIBImpl(tableRegistry, new RibId("test"), new AsNumber(Uint32.valueOf(5)), RIB_ID, context,
+ dispatcher, new ConstantCodecsRegistry(serializer), dom, policies,
localTables, Collections.singletonMap(KEY,
BasePathSelectionModeFactory.createBestPathSelectionStrategy()));
}
private void mockedMethods() throws Exception {
MockitoAnnotations.initMocks(this);
- doReturn(new TestListenerRegistration()).when(this.service)
+ doReturn(new TestListenerRegistration()).when(service)
.registerDataTreeChangeListener(any(DOMDataTreeIdentifier.class),
any(ClusteredDOMDataTreeChangeListener.class));
- doNothing().when(this.domTransWrite).put(eq(LogicalDatastoreType.OPERATIONAL),
+ doNothing().when(domTransWrite).put(eq(LogicalDatastoreType.OPERATIONAL),
any(YangInstanceIdentifier.class), any(NormalizedNode.class));
- doNothing().when(this.domTransWrite).delete(eq(LogicalDatastoreType.OPERATIONAL),
+ doNothing().when(domTransWrite).delete(eq(LogicalDatastoreType.OPERATIONAL),
any(YangInstanceIdentifier.class));
- doNothing().when(this.domTransWrite).merge(eq(LogicalDatastoreType.OPERATIONAL),
+ doNothing().when(domTransWrite).merge(eq(LogicalDatastoreType.OPERATIONAL),
any(YangInstanceIdentifier.class), any(NormalizedNode.class));
- doNothing().when(this.domChain).close();
- doReturn(this.domTransWrite).when(this.domChain).newWriteOnlyTransaction();
+ doNothing().when(domChain).close();
+ doReturn(domTransWrite).when(domChain).newWriteOnlyTransaction();
doNothing().when(getTransaction()).put(eq(LogicalDatastoreType.OPERATIONAL),
eq(YangInstanceIdentifier.of(BgpRib.QNAME)), any(NormalizedNode.class));
- doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, this.service)).when(this.dom)
+ doReturn(ImmutableClassToInstanceMap.of(DOMDataTreeChangeService.class, service)).when(dom)
.getExtensions();
- doReturn(this.domChain).when(this.dom).createMergingTransactionChain(any(DOMTransactionChainListener.class));
- doReturn(Optional.empty()).when(this.future).get();
- doReturn(this.future).when(this.domTransWrite).commit();
- doNothing().when(this.future).addListener(any(Runnable.class), any(Executor.class));
+ doReturn(domChain).when(dom).createMergingTransactionChain(any(DOMTransactionChainListener.class));
+ doReturn(Optional.empty()).when(future).get();
+ doReturn(future).when(domTransWrite).commit();
+ doNothing().when(future).addListener(any(Runnable.class), any(Executor.class));
}
- public Collection<DataTreeCandidate> ipv4Input(final YangInstanceIdentifier target,
+ public List<DataTreeCandidate> ipv4Input(final YangInstanceIdentifier target,
final ModificationType type, final Ipv4Prefix... prefix) {
- final Collection<DataTreeCandidate> col = new HashSet<>();
+ final List<DataTreeCandidate> col = new ArrayList<>();
final DataTreeCandidate candidate = mock(DataTreeCandidate.class);
final DataTreeCandidateNode rootNode = mock(DataTreeCandidateNode.class);
doReturn(rootNode).when(candidate).getRootNode();
}
public RIBImpl getRib() {
- return this.rib;
+ return rib;
}
public DOMDataTreeWriteTransaction getTransaction() {
- return this.domTransWrite;
+ return domTransWrite;
}
- private class TestListenerRegistration implements ListenerRegistration<EventListener> {
+ private static class TestListenerRegistration implements ListenerRegistration<EventListener> {
@Override
public EventListener getInstance() {
return null;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
+import org.opendaylight.yangtools.yang.data.tree.api.ModificationType;
public class PeerTest extends AbstractRIBTestSetup {
@Before
public void setUp() throws Exception {
super.setUp();
- this.routes = new HashMap<>();
+ routes = new HashMap<>();
overrideMockedBehaviour();
}
final QName nodeType = node.getIdentifier().getNodeType();
if (nodeType.equals(Ipv4Route.QNAME) || nodeType.equals(PREFIX_QNAME)) {
- this.routes.put((YangInstanceIdentifier) args[1], node);
+ routes.put((YangInstanceIdentifier) args[1], node);
}
return args[1];
}).when(getTransaction()).put(eq(LogicalDatastoreType.OPERATIONAL),
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- this.routes.remove(args[1]);
+ routes.remove(args[1]);
return args[1];
}).when(getTransaction()).delete(eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
}
final Ipv4Prefix first = new Ipv4Prefix("127.0.0.2/32");
final Ipv4Prefix second = new Ipv4Prefix("127.0.0.1/32");
final Ipv4Prefix third = new Ipv4Prefix("127.0.0.3/32");
- this.peer = new ApplicationPeer(this.tableRegistry,
- new ApplicationRibId(this.neighborAddress.getIpv4AddressNoZone().getValue()),
- this.neighborAddress.getIpv4AddressNoZone(), getRib());
- this.peer.instantiateServiceInstance(null, null);
+ peer = new ApplicationPeer(tableRegistry,
+ new ApplicationRibId(neighborAddress.getIpv4AddressNoZone().getValue()),
+ neighborAddress.getIpv4AddressNoZone(), getRib());
+ peer.instantiateServiceInstance(null, null);
final YangInstanceIdentifier base = getRib().getYangRibId().node(LocRib.QNAME)
.node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(KEY));
- this.peer.onDataTreeChanged(ipv4Input(base, ModificationType.WRITE, first, second, third));
- assertEquals(3, this.routes.size());
+ peer.onDataTreeChanged(ipv4Input(base, ModificationType.WRITE, first, second, third));
+ assertEquals(3, routes.size());
- this.peer.onDataTreeChanged(ipv4Input(base, ModificationType.DELETE, third));
- assertEquals(2, this.routes.size());
+ peer.onDataTreeChanged(ipv4Input(base, ModificationType.DELETE, third));
+ assertEquals(2, routes.size());
}
@Test
public void testClassicPeer() throws Exception {
- this.classic = AbstractAddPathTest.configurePeer(this.tableRegistry,
- this.neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
- this.classic.instantiateServiceInstance();
+ classic = AbstractAddPathTest.configurePeer(tableRegistry,
+ neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
+ classic.instantiateServiceInstance();
this.mockSession();
- assertEquals(this.neighborAddress.getIpv4AddressNoZone().getValue(), this.classic.getName());
- this.classic.onSessionUp(this.session);
+ assertEquals(neighborAddress.getIpv4AddressNoZone().getValue(), classic.getName());
+ classic.onSessionUp(session);
assertEquals("BGPPeer{name=127.0.0.1, tables=[TablesKey{_afi=interface org.opendaylight.yang.gen.v1"
+ ".urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv4AddressFamily,"
+ " _safi=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types"
+ ".rev200120.UnicastSubsequentAddressFamily}]}",
- this.classic.toString());
+ classic.toString());
final Nlri n1 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
final Nlri n2 = new NlriBuilder().setPrefix(new Ipv4Prefix("127.0.0.1/32")).build();
final AttributesBuilder ab = new AttributesBuilder();
ub.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
try {
- this.classic.onMessage(this.session, ub.build());
+ classic.onMessage(session, ub.build());
fail();
} catch (final BGPDocumentedException e) {
assertEquals(BGPError.MANDATORY_ATTR_MISSING_MSG + "LOCAL_PREF", e.getMessage());
assertEquals(BGPError.WELL_KNOWN_ATTR_MISSING.getSubcode(), e.getError().getSubcode());
assertArrayEquals(new byte[]{LocalPreferenceAttributeParser.TYPE}, e.getData());
}
- assertEquals(0, this.routes.size());
+ assertEquals(0, routes.size());
final LocalPref localPref = new LocalPrefBuilder().setPref(Uint32.valueOf(100)).build();
ub.setAttributes(ab.setLocalPref(localPref).build());
- this.classic.onMessage(this.session, ub.build());
- assertEquals(3, this.routes.size());
+ classic.onMessage(session, ub.build());
+ assertEquals(3, routes.size());
//create new peer so that it gets advertized routes from RIB
- final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(this.tableRegistry,
- this.neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
+ final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(tableRegistry,
+ neighborAddress.getIpv4AddressNoZone(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry());
testingPeer.instantiateServiceInstance();
- testingPeer.onSessionUp(this.session);
- assertEquals(3, this.routes.size());
+ testingPeer.onSessionUp(session);
+ assertEquals(3, routes.size());
final Nlri n11 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.0/28")).build();
final Nlri n22 = new NlriBuilder().setPrefix(new Ipv4Prefix("8.0.1.16/28")).build();
final WithdrawnRoutes w3 = new WithdrawnRoutesBuilder().setPrefix(new Ipv4Prefix("2.2.2.2/24")).build();
final List<WithdrawnRoutes> wrs = Lists.newArrayList(w1, w2, w3);
ub.setWithdrawnRoutes(wrs);
- this.classic.onMessage(this.session, ub.build());
- assertEquals(2, this.routes.size());
- this.classic.onMessage(this.session, new KeepaliveBuilder().build());
- this.classic.onMessage(this.session, new UpdateBuilder()
+ classic.onMessage(session, ub.build());
+ assertEquals(2, routes.size());
+ classic.onMessage(session, new KeepaliveBuilder().build());
+ classic.onMessage(session, new UpdateBuilder()
.setAttributes(new AttributesBuilder()
.addAugmentation(new AttributesUnreachBuilder()
.setMpUnreachNlri(new MpUnreachNlriBuilder().setAfi(IPV4_AFI).setSafi(SAFI).build())
.build())
.build())
.build());
- this.classic.onMessage(this.session, new RouteRefreshBuilder().setAfi(IPV4_AFI).setSafi(SAFI).build());
- this.classic.onMessage(this.session, new RouteRefreshBuilder()
+ classic.onMessage(session, new RouteRefreshBuilder().setAfi(IPV4_AFI).setSafi(SAFI).build());
+ classic.onMessage(session, new RouteRefreshBuilder()
.setAfi(Ipv6AddressFamily.class)
.setSafi(SAFI).build());
- assertEquals(2, this.routes.size());
- this.classic.releaseConnection();
+ assertEquals(2, routes.size());
+ classic.releaseConnection();
}
private void mockSession() {
.setHoldTimer(Uint16.valueOf(50))
.setMyAsNumber(Uint16.valueOf(72))
.setBgpParameters(params).build();
- this.session = new BGPSessionImpl(this.classic, channel, openObj, 30, null);
- this.session.setChannelExtMsgCoder(openObj);
+ session = new BGPSessionImpl(classic, channel, openObj, 30, null);
+ session.setChannelExtMsgCoder(openObj);
}
}
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.Bgp;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Global;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.top.bgp.Neighbors;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
UnicastSubsequentAddressFamily.class);
private static final String NETWORK_INSTANCE_NAME = "network-test";
private static final KeyedInstanceIdentifier<NetworkInstance, NetworkInstanceKey> NETWORK_II =
- InstanceIdentifier.create(NetworkInstances.class)
- .child(NetworkInstance.class, new NetworkInstanceKey(NETWORK_INSTANCE_NAME));
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
+ .child(NetworkInstance.class, new NetworkInstanceKey(NETWORK_INSTANCE_NAME));
private static final String KEY = "bgp";
private static final InstanceIdentifier<Bgp> BGP_II = NETWORK_II.child(Protocols.class)
.child(Protocol.class, new ProtocolKey(BGP.class, KEY))
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import java.math.BigDecimal;
import java.net.InetSocketAddress;
import java.util.Map;
import java.util.concurrent.ExecutionException;
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.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborAddPathsConfigBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.NeighborTransportConfigBuilder;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint8;
.addAugmentation(new NeighborAddPathsConfigBuilder().setReceive(true).setSendMax(Uint8.ZERO).build())
.build();
static final Map<AfiSafiKey, AfiSafi> AFI_SAFI = Map.of(AFI_SAFI_IPV4.key(), AFI_SAFI_IPV4);
- private static final BigDecimal DEFAULT_TIMERS = BigDecimal.valueOf(30);
+ private static final Decimal64 DEFAULT_TIMERS = Decimal64.valueOf(2, 30);
private BgpPeer bgpPeer;
static Neighbor createNeighborExpected(final IpAddress neighborAddress) {
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV6UNICAST;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.PeerType;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.RrClusterIdType;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.UnicastSubsequentAddressFamily;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint16;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
private static final PeerGroup EMPTY_PEERGROUP = new PeerGroupBuilder().setPeerGroupName("foo").build();
private static final String KEY = "bgp";
- private static final InstanceIdentifier<Bgp> BGP_II = InstanceIdentifier.create(NetworkInstances.class)
- .child(NetworkInstance.class, new NetworkInstanceKey("identifier-test")).child(Protocols.class)
- .child(Protocol.class, new ProtocolKey(BGP.class, KEY)).augmentation(NetworkInstanceProtocol.class)
- .child(Bgp.class);
+ private static final InstanceIdentifier<Bgp> BGP_II =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
+ .child(NetworkInstance.class, new NetworkInstanceKey("identifier-test"))
+ .child(Protocols.class)
+ .child(Protocol.class, new ProtocolKey(BGP.class, KEY))
+ .augmentation(NetworkInstanceProtocol.class)
+ .child(Bgp.class);
private static final NeighborKey NEIGHBOR_KEY = new NeighborKey(NEIGHBOR_ADDRESS);
private static final Ipv4Address ROUTER_ID = new Ipv4Address("1.2.3.4");
private static final Ipv4Address CLUSTER_ID = new Ipv4Address("4.3.2.1");
assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(),
OpenConfigMappingUtil.getHoldTimer(NEIGHBOR, EMPTY_PEERGROUP));
TimersBuilder builder = new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net
- .yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(BigDecimal.TEN).build());
+ .yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setHoldTime(Decimal64.valueOf(2, 10))
+ .build());
assertEquals(BigDecimal.TEN.intValue(), OpenConfigMappingUtil.getHoldTimer(NEIGHBOR, new PeerGroupBuilder()
.setPeerGroupName("foo").setTimers(builder.build()).build()));
}
assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(), OpenConfigMappingUtil.getRetryTimer(NEIGHBOR, null));
assertEquals(DEFAULT_TIMERS.toBigInteger().intValue(),
OpenConfigMappingUtil.getRetryTimer(EMPTY_NEIGHBOR, null));
- TimersBuilder builder = new TimersBuilder().setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net
- .yang.bgp.rev151009.bgp.neighbor.group.timers.ConfigBuilder().setConnectRetry(BigDecimal.TEN).build());
+ TimersBuilder builder = new TimersBuilder()
+ .setConfig(new org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers
+ .ConfigBuilder().setConnectRetry(Decimal64.valueOf(2, 10)).build());
assertEquals(BigDecimal.TEN.intValue(), OpenConfigMappingUtil.getRetryTimer(new NeighborBuilder()
.setNeighborAddress(NEIGHBOR_ADDRESS).setTimers(builder.build()).build(), null));
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test dependencies -->
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
import org.opendaylight.yangtools.yang.data.api.schema.builder.DataContainerNodeBuilder;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
/**
* Interface implemented for AFI/SAFI-specific RIB extensions. The extensions need
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNull;
import org.junit.Before;
import org.mockito.Mock;
import org.opendaylight.mdsal.binding.dom.adapter.AdapterContext;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractDataBrokerTestCustomizer;
+import org.opendaylight.mdsal.binding.dom.codec.api.BindingDataObjectCodecTreeNode;
import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
protected static final Attributes ATTRIBUTES = new AttributesBuilder().build();
private static final InstanceIdentifier<LocRib> RIB = InstanceIdentifier.builder(BgpRib.class)
.child(Rib.class, new RibKey(new RibId("rib"))).child(LocRib.class).build();
- private static final InstanceIdentifier<Attributes> ATTRIBUTES_IID = InstanceIdentifier.create(Update.class)
- .child(Attributes.class);
- private static final InstanceIdentifier<MpUnreachNlri> MP_UNREACH_IID = ATTRIBUTES_IID
- .augmentation(AttributesUnreach.class).child(MpUnreachNlri.class);
- private static final InstanceIdentifier<MpReachNlri> MP_REACH_IID = ATTRIBUTES_IID
- .augmentation(AttributesReach.class).child(MpReachNlri.class);
+
@Mock
protected DOMDataTreeWriteTransaction tx;
protected List<InstanceIdentifier<R>> deletedRoutes;
return customizer;
}
+ private @NonNull BindingDataObjectCodecTreeNode<Attributes> updateAttributesCodec() {
+ return adapter.currentSerializer().streamChild(Update.class).streamChild(Attributes.class);
+ }
+
protected final ContainerNode createNlriWithDrawnRoute(final DestinationType destUnreach) {
- final MpUnreachNlri mpReach = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder()
- .setDestinationType(destUnreach).build()).build();
- final Map.Entry<YangInstanceIdentifier, NormalizedNode> result = this.adapter.currentSerializer()
- .toNormalizedNode(MP_UNREACH_IID, mpReach);
- return (ContainerNode) result.getValue();
+ return (ContainerNode) updateAttributesCodec()
+ .streamChild(AttributesUnreach.class).streamChild(MpUnreachNlri.class)
+ .serialize(new MpUnreachNlriBuilder()
+ .setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(destUnreach).build())
+ .build());
}
protected final ContainerNode createNlriAdvertiseRoute(final DestinationType destReach) {
- final MpReachNlri mpReach = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder()
- .setDestinationType(destReach).build()).build();
- final Map.Entry<YangInstanceIdentifier, NormalizedNode> result = this.adapter.currentSerializer()
- .toNormalizedNode(MP_REACH_IID, mpReach);
- return (ContainerNode) result.getValue();
+ return (ContainerNode) updateAttributesCodec()
+ .streamChild(AttributesReach.class).streamChild(MpReachNlri.class)
+ .serialize(new MpReachNlriBuilder()
+ .setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(destReach).build())
+ .build());
}
protected final ContainerNode createAttributes() {
- return (ContainerNode) this.adapter.currentSerializer().toNormalizedNode(ATTRIBUTES_IID, ATTRIBUTES).getValue();
+ return (ContainerNode) updateAttributesCodec().serialize(ATTRIBUTES);
}
protected final MapEntryNode createEmptyTable() {
import static org.mockito.Mockito.doReturn;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidateNode;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
+import org.opendaylight.yangtools.yang.data.tree.api.DataTreeCandidateNode;
public class RIBSupportTest extends AbstractConcurrentDataBrokerTest {
private static final String ROUTE_KEY = "prefix";
public void setUp() throws Exception {
super.setup();
MockitoAnnotations.initMocks(this);
- this.ribSupportTestImp = new RIBSupportTestImp(context.currentSerializer());
- this.emptyTree = Mockito.mock(DataTreeCandidateNode.class);
- this.emptySubTree = Mockito.mock(DataTreeCandidateNode.class);
- this.subTree = Mockito.mock(DataTreeCandidateNode.class);
+ ribSupportTestImp = new RIBSupportTestImp(context.currentSerializer());
+ emptyTree = Mockito.mock(DataTreeCandidateNode.class);
+ emptySubTree = Mockito.mock(DataTreeCandidateNode.class);
+ subTree = Mockito.mock(DataTreeCandidateNode.class);
final DataTreeCandidateNode emptyNode = Mockito.mock(DataTreeCandidateNode.class);
final DataTreeCandidateNode node = Mockito.mock(DataTreeCandidateNode.class);
- doReturn(Optional.empty()).when(this.emptyTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.empty()).when(emptyTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
- doReturn(Optional.of(emptyNode)).when(this.emptySubTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.of(emptyNode)).when(emptySubTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
doReturn(Optional.empty()).when(emptyNode).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
- doReturn(Optional.of(node)).when(this.subTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
+ doReturn(Optional.of(node)).when(subTree).getModifiedChild(IPV4_ROUTES_IDENTIFIER);
doReturn(Optional.of(node)).when(node).getModifiedChild(new NodeIdentifier(Ipv4Route.QNAME));
final Collection<DataTreeCandidateNode> emptyCollection = new HashSet<>();
doReturn(emptyCollection).when(node).getChildNodes();
- this.tx = Mockito.mock(DOMDataTreeWriteTransaction.class);
- this.nlri = Mockito.mock(ContainerNode.class);
- this.attributes = ImmutableContainerNodeBuilder.create()
+ tx = Mockito.mock(DOMDataTreeWriteTransaction.class);
+ nlri = Mockito.mock(ContainerNode.class);
+ attributes = ImmutableContainerNodeBuilder.create()
.withNodeIdentifier(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME
.getLocalName().intern()))).build();
final ContainerNode destination = Mockito.mock(ContainerNode.class);
final ChoiceNode destinations = Mockito.mock(ChoiceNode.class);
final ContainerNode route = Mockito.mock(ContainerNode.class);
- doReturn(destination).when(this.nlri).childByArg(new NodeIdentifier(WithdrawnRoutes.QNAME));
- doReturn(destination).when(this.nlri).childByArg(new NodeIdentifier(AdvertizedRoutes.QNAME));
+ doReturn(destination).when(nlri).childByArg(new NodeIdentifier(WithdrawnRoutes.QNAME));
+ doReturn(destination).when(nlri).childByArg(new NodeIdentifier(AdvertizedRoutes.QNAME));
doReturn(destinations).when(destination).childByArg(new NodeIdentifier(DestinationType.QNAME));
doReturn(route).when(destinations).childByArg(new NodeIdentifier(Ipv4Prefixes.QNAME));
doReturn(emptyCollection).when(route).body();
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- this.routesMap.remove(args[1]);
+ routesMap.remove(args[1]);
return args[1];
- }).when(this.tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
+ }).when(tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
final NormalizedNode node1 = (NormalizedNode) args[2];
- this.routesMap.put((YangInstanceIdentifier) args[1], node1);
+ routesMap.put((YangInstanceIdentifier) args[1], node1);
return args[1];
- }).when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class),
+ }).when(tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class),
any(NormalizedNode.class));
- this.mapEntryNode = Mockito.mock(MapEntryNode.class);
+ mapEntryNode = Mockito.mock(MapEntryNode.class);
}
@Override
protected final AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer() {
final AbstractDataBrokerTestCustomizer customizer = super.createDataBrokerTestCustomizer();
- this.context = customizer.getAdapterContext();
+ context = customizer.getAdapterContext();
return customizer;
}
@Test
public void routesCaseClass() {
- assertEquals(Ipv4RoutesCase.class, this.ribSupportTestImp.routesCaseClass());
+ assertEquals(Ipv4RoutesCase.class, ribSupportTestImp.routesCaseClass());
}
@Test
public void routesContainerClass() {
- assertEquals(Ipv4Routes.class, this.ribSupportTestImp.routesContainerClass());
+ assertEquals(Ipv4Routes.class, ribSupportTestImp.routesContainerClass());
}
@Test
public void routesListClass() {
- assertEquals(Ipv4Route.class, this.ribSupportTestImp.routesListClass());
+ assertEquals(Ipv4Route.class, ribSupportTestImp.routesListClass());
}
@Test
public void routeQName() {
- assertEquals(Ipv4Route.QNAME, this.ribSupportTestImp.routeQName());
+ assertEquals(Ipv4Route.QNAME, ribSupportTestImp.routeQName());
}
@Test
public void routeNid() {
- assertEquals(new NodeIdentifier(Ipv4Route.QNAME),this.ribSupportTestImp.routeNid());
+ assertEquals(new NodeIdentifier(Ipv4Route.QNAME),ribSupportTestImp.routeNid());
}
@Test
public void getAfi() {
- assertEquals(Ipv4AddressFamily.class,this.ribSupportTestImp.getAfi());
+ assertEquals(Ipv4AddressFamily.class,ribSupportTestImp.getAfi());
}
@Test
public void getSafi() {
- assertEquals(UnicastSubsequentAddressFamily.class,this.ribSupportTestImp.getSafi());
+ assertEquals(UnicastSubsequentAddressFamily.class,ribSupportTestImp.getSafi());
}
@Test
public void routesContainerIdentifier() {
- assertEquals(IPV4_ROUTES_IDENTIFIER,this.ribSupportTestImp.routesContainerIdentifier());
+ assertEquals(IPV4_ROUTES_IDENTIFIER,ribSupportTestImp.routesContainerIdentifier());
}
@Test
public void routeAttributesIdentifier() {
assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME,
- Attributes.QNAME.getLocalName().intern())),this.ribSupportTestImp.routeAttributesIdentifier());
+ Attributes.QNAME.getLocalName().intern())),ribSupportTestImp.routeAttributesIdentifier());
}
@Test
public void routePath() {
assertEquals(LOC_RIB_TARGET.node(ROUTES_IDENTIFIER)
.node(Ipv4Routes.QNAME).node(Ipv4Route.QNAME).node(PREFIX_NII),
- this.ribSupportTestImp.routePath(LOC_RIB_TARGET, PREFIX_NII));
+ ribSupportTestImp.routePath(LOC_RIB_TARGET, PREFIX_NII));
}
@Test
public void changedRoutes() {
- assertTrue(ribSupportTestImp.changedRoutes(this.emptyTree).isEmpty());
- assertTrue(ribSupportTestImp.changedRoutes(this.emptySubTree).isEmpty());
- assertNotNull(ribSupportTestImp.changedRoutes(this.subTree));
+ assertTrue(ribSupportTestImp.changedRoutes(emptyTree).isEmpty());
+ assertTrue(ribSupportTestImp.changedRoutes(emptySubTree).isEmpty());
+ assertNotNull(ribSupportTestImp.changedRoutes(subTree));
}
@Test
public void putRoutes() {
- this.ribSupportTestImp.putRoutes(this.tx, LOC_RIB_TARGET, this.nlri, this.attributes);
- assertFalse(this.routesMap.isEmpty());
+ ribSupportTestImp.putRoutes(tx, LOC_RIB_TARGET, nlri, attributes);
+ assertFalse(routesMap.isEmpty());
}
@Test
public void deleteRoutes() {
- this.ribSupportTestImp.deleteRoutes(this.tx, LOC_RIB_TARGET, this.nlri);
- assertTrue(this.routesMap.isEmpty());
+ ribSupportTestImp.deleteRoutes(tx, LOC_RIB_TARGET, nlri);
+ assertTrue(routesMap.isEmpty());
}
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(),
- this.ribSupportTestImp.buildUpdate(routes, routes, attr));
+ ribSupportTestImp.buildUpdate(routes, routes, attr));
- routes.add(this.mapEntryNode);
+ routes.add(mapEntryNode);
final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class)
.setSafi(UnicastSubsequentAddressFamily.class)
.setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().build()).build();
final Attributes attMpR = new AttributesBuilder().addAugmentation(
new AttributesReachBuilder().setMpReachNlri(mpReach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpR).build(),
- this.ribSupportTestImp.buildUpdate(routes, Collections.emptySet(), attr));
+ ribSupportTestImp.buildUpdate(routes, Set.of(), attr));
final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class)
.setSafi(UnicastSubsequentAddressFamily.class)
final Attributes attMpU = new AttributesBuilder().addAugmentation(
new AttributesUnreachBuilder().setMpUnreachNlri(mpUnreach).build()).build();
assertEquals(new UpdateBuilder().setAttributes(attMpU).build(),
- this.ribSupportTestImp.buildUpdate(Collections.emptySet(), routes, attr));
+ ribSupportTestImp.buildUpdate(Set.of(), routes, attr));
}
}
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test dependencies -->
import static java.util.Objects.requireNonNull;
import com.google.common.annotations.VisibleForTesting;
-import java.math.BigDecimal;
+import com.google.common.collect.ImmutableSet;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
* @author Philippe Niger
*/
public class LinkstateGraphBuilder extends AbstractTopologyBuilder<LinkstateRoute> {
+ private static final Logger LOG = LoggerFactory.getLogger(LinkstateGraphBuilder.class);
private static final TopologyTypes LINKSTATE_TOPOLOGY_TYPE = new TopologyTypesBuilder().addAugmentation(
new TopologyTypes1Builder().setBgpLinkstateTopology(new BgpLinkstateTopologyBuilder().build()).build())
.build();
-
private static final String UNHANDLED_OBJECT_CLASS = "Unhandled object class {}";
-
- private static final Logger LOG = LoggerFactory.getLogger(LinkstateGraphBuilder.class);
+ private static final int MAX_PRIORITY = 8;
private final ConnectedGraph cgraph;
final TopologyId topologyId, final ConnectedGraphProvider provider) {
super(dataProvider, locRibReference, topologyId, LINKSTATE_TOPOLOGY_TYPE, LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class);
- this.cgraph = requireNonNull(provider).createConnectedGraph("ted://" + topologyId.getValue(),
+ cgraph = requireNonNull(provider).createConnectedGraph("ted://" + topologyId.getValue(),
DomainScope.IntraDomain);
/* LinkStateGraphBuilder doesn't write information in the Network Topology tree of the Data Store.
* This is performed by ConnectedGraphProvider which write element in Graph tree of the Data Store */
- this.networkTopologyTransaction = false;
+ networkTopologyTransaction = false;
LOG.info("Started Traffic Engineering Graph Builder");
}
final int listenerResetEnforceCounter) {
super(dataProvider, locRibReference, topologyId, LINKSTATE_TOPOLOGY_TYPE, LinkstateAddressFamily.class,
LinkstateSubsequentAddressFamily.class, listenerResetLimitInMillsec, listenerResetEnforceCounter);
- this.cgraph = requireNonNull(provider).createConnectedGraph("ted://" + topologyId.getValue(),
+ cgraph = requireNonNull(provider).createConnectedGraph("ted://" + topologyId.getValue(),
DomainScope.IntraDomain);
/* LinkStateGraphBuilder doesn't write information in the Network Topology tree of the Data Store.
* This is performed by ConnectedGraphProvider which write element in Graph tree of the Data Store */
- this.networkTopologyTransaction = false;
+ networkTopologyTransaction = false;
LOG.info("Started Traffic Engineering Graph Builder");
}
cgraph.addPrefix(prefix);
}
- private static final int MAX_PRIORITY = 8;
-
/**
* Create Edge Attributes from Link attributes.
*
builder.setUtilizedBandwidth(bandwithToDecimalBandwidth(la.getUtilizedBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
- List<Uint32> srlgs = new ArrayList<>();
+ final var srlgs = ImmutableSet.<Uint32>builder();
for (SrlgId srlg : la.getSharedRiskLinkGroups()) {
srlgs.add(srlg.getValue());
}
- builder.setSrlgs(srlgs);
+ builder.setSrlgs(srlgs.build());
}
for (SrAdjIds adj : la.nonnullSrAdjIds()) {
if (adj.getSidLabelIndex() instanceof LocalLabelCase) {
}
private static DecimalBandwidth bandwithToDecimalBandwidth(final Bandwidth bw) {
- return new DecimalBandwidth(BigDecimal.valueOf(ByteBuffer.wrap(bw.getValue()).getFloat()));
+ return new DecimalBandwidth(ProtocolUtil.bandwidthToDecimal64(bw));
}
private static Uint64 ipv4ToKey(final Ipv4InterfaceIdentifier ifId) {
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
synchronized void addLink(final LinkId id, final boolean isRemote) {
if (isRemote) {
- this.remote.add(id);
+ remote.add(id);
} else {
- this.local.add(id);
+ local.add(id);
}
}
synchronized boolean removeLink(final LinkId id, final boolean isRemote) {
final boolean removed;
if (isRemote) {
- removed = this.remote.remove(id);
+ removed = remote.remove(id);
} else {
- removed = this.local.remove(id);
+ removed = local.remove(id);
}
if (!removed) {
- LOG.warn("Removed non-reference link {} from TP {} isRemote {}", this.tp.getTpId().getValue(),
+ LOG.warn("Removed non-reference link {} from TP {} isRemote {}", tp.getTpId().getValue(),
id.getValue(), isRemote);
}
- return this.local.isEmpty() && this.remote.isEmpty();
+ return local.isEmpty() && remote.isEmpty();
}
TerminationPoint getTp() {
- return this.tp;
+ return tp;
}
}
private NodeSrHolder sr;
NodeHolder(final NodeId id) {
- this.inab = new IgpNodeAttributesBuilder();
- this.nb = new NodeBuilder().withKey(new NodeKey(id)).setNodeId(id);
+ inab = new IgpNodeAttributesBuilder();
+ nb = new NodeBuilder().withKey(new NodeKey(id)).setNodeId(id);
}
/**
* @return True if the node has been purged, false otherwise.
*/
boolean syncState(final WriteTransaction trans) {
- final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(this.nb.key());
+ final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(nb.key());
/*
* Transaction's putOperationalData() does a merge. Force it onto a replace
*/
trans.delete(LogicalDatastoreType.OPERATIONAL, nid);
- if (!this.advertized) {
- if (this.tps.isEmpty() && this.prefixes.isEmpty()) {
- LOG.trace("Removing unadvertized unused node {}", this.nb.getNodeId().getValue());
+ if (!advertized) {
+ if (tps.isEmpty() && prefixes.isEmpty()) {
+ LOG.trace("Removing unadvertized unused node {}", nb.getNodeId().getValue());
return true;
}
- LOG.trace("Node {} is still implied by {} TPs and {} prefixes", this.nb.getNodeId().getValue(),
- this.tps.size(), this.prefixes.size());
+ LOG.trace("Node {} is still implied by {} TPs and {} prefixes", nb.getNodeId().getValue(),
+ tps.size(), prefixes.size());
}
// Re-generate termination points
- this.nb.setTerminationPoint(BindingMap.ordered(Collections2.transform(this.tps.values(), TpHolder::getTp)));
+ nb.setTerminationPoint(BindingMap.ordered(Collections2.transform(tps.values(), TpHolder::getTp)));
// Re-generate prefixes
- this.inab.setPrefix(BindingMap.ordered(this.prefixes.values()));
+ inab.setPrefix(BindingMap.ordered(prefixes.values()));
// Write the node out
- if (this.sr != null && this.sr.getSegmentCount() > 0) {
- this.nb.addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
- .rev130819.Node1Builder().setSegments(BindingMap.ordered(this.sr.getSegments())).build());
+ if (sr != null && sr.getSegmentCount() > 0) {
+ nb.addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
+ .rev130819.Node1Builder().setSegments(BindingMap.ordered(sr.getSegments())).build());
}
- final Node n = this.nb
- .addAugmentation(new Node1Builder().setIgpNodeAttributes(this.inab.build()).build())
+ final Node n = nb
+ .addAugmentation(new Node1Builder().setIgpNodeAttributes(inab.build()).build())
.build();
trans.put(LogicalDatastoreType.OPERATIONAL, nid, n);
LOG.trace("Created node {} at {}", n, nid);
}
boolean checkForRemoval(final WriteTransaction trans) {
- final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(this.nb.key());
+ final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(nb.key());
- if (!this.advertized) {
- if (this.tps.isEmpty() && this.prefixes.isEmpty()) {
+ if (!advertized) {
+ if (tps.isEmpty() && prefixes.isEmpty()) {
trans.delete(LogicalDatastoreType.OPERATIONAL, nid);
- LOG.trace("Removing unadvertized unused node {}", this.nb.getNodeId().getValue());
+ LOG.trace("Removing unadvertized unused node {}", nb.getNodeId().getValue());
return true;
}
- LOG.trace("Node {} is still implied by {} TPs and {} prefixes", this.nb.getNodeId().getValue(),
- this.tps.size(), this.prefixes.size());
+ LOG.trace("Node {} is still implied by {} TPs and {} prefixes", nb.getNodeId().getValue(),
+ tps.size(), prefixes.size());
}
return false;
}
synchronized void removeTp(final TpId tp, final LinkId link, final boolean isRemote) {
- final TpHolder h = this.tps.get(tp);
+ final TpHolder h = tps.get(tp);
if (h != null) {
if (h.removeLink(link, isRemote)) {
- this.tps.remove(tp);
+ tps.remove(tp);
LOG.trace("Removed TP {}", tp.getValue());
}
} else {
}
void addTp(final TerminationPoint tp, final LinkId link, final boolean isRemote) {
- final TpHolder h = this.tps.computeIfAbsent(tp.getTpId(), k -> new TpHolder(tp));
+ final TpHolder h = tps.computeIfAbsent(tp.getTpId(), k -> new TpHolder(tp));
h.addLink(link, isRemote);
}
void addPrefix(final Prefix pfx) {
- this.prefixes.put(pfx.key(), pfx);
+ prefixes.put(pfx.key(), pfx);
}
void removePrefix(final PrefixCase prefixCase) {
- this.prefixes.remove(new PrefixKey(prefixCase.getPrefixDescriptors().getIpReachabilityInformation()));
+ prefixes.remove(new PrefixKey(prefixCase.getPrefixDescriptors().getIpReachabilityInformation()));
}
void unadvertized() {
- this.inab = new IgpNodeAttributesBuilder();
- this.nb = new NodeBuilder().withKey(this.nb.key()).setNodeId(this.nb.getNodeId());
- this.advertized = false;
- LOG.debug("Node {} is unadvertized", this.nb.getNodeId().getValue());
+ inab = new IgpNodeAttributesBuilder();
+ nb = new NodeBuilder().withKey(nb.key()).setNodeId(nb.getNodeId());
+ advertized = false;
+ LOG.debug("Node {} is unadvertized", nb.getNodeId().getValue());
}
void advertized(final NodeBuilder nodeBuilder, final IgpNodeAttributesBuilder igpNodeAttBuilder) {
- this.nb = requireNonNull(nodeBuilder);
- this.inab = requireNonNull(igpNodeAttBuilder);
- this.advertized = true;
+ nb = requireNonNull(nodeBuilder);
+ inab = requireNonNull(igpNodeAttBuilder);
+ advertized = true;
LOG.debug("Node {} is advertized", nodeBuilder.getNodeId().getValue());
}
NodeId getNodeId() {
- return this.nb.getNodeId();
+ return nb.getNodeId();
}
NodeSrHolder getSrHolder() {
- return this.sr;
+ return sr;
}
NodeSrHolder createSrHolderIfRequired() {
- if (this.sr == null) {
- this.sr = new NodeSrHolder(this.nb.getNodeId());
+ if (sr == null) {
+ sr = new NodeSrHolder(nb.getNodeId());
}
- return this.sr;
+ return sr;
}
}
void addSrgb(final WriteTransaction trans, final boolean updateNode, final Long srgbFirstVal,
final Integer srgbRangeSz) {
- this.srgbFirstValue = srgbFirstVal;
- this.srgbRangeSize = srgbRangeSz;
- this.srPrefixes.entrySet().forEach(entry -> {
+ srgbFirstValue = srgbFirstVal;
+ srgbRangeSize = srgbRangeSz;
+ srPrefixes.entrySet().forEach(entry -> {
final IpPrefix ippfx = entry.getKey();
final SrPrefix srPrefix = entry.getValue();
final SidLabelIndex sidLabelIndex = srPrefix.getSidLabelIndex();
if (sidLabelIndex instanceof SidCase) {
final Long sidIndex = ((SidCase) sidLabelIndex).getSid().longValue();
- if (sidIndex >= this.srgbRangeSize) {
+ if (sidIndex >= srgbRangeSize) {
LOG.warn("Prefix SID index {} is outside the SRGB range of {} for node {}", sidIndex,
- this.srgbRangeSize, this.nodeId.getValue());
+ srgbRangeSize, nodeId.getValue());
return;
}
- final Long prefixSid = this.srgbFirstValue + sidIndex;
+ final Long prefixSid = srgbFirstValue + sidIndex;
final boolean isNodeSid = isAssociatedWithNodeSid(ippfx, srPrefix);
addPrefixSid(trans, updateNode, ippfx, prefixSid, isNodeSid);
}
}
void removeSrgb(final WriteTransaction trans) {
- this.srgbFirstValue = null;
- this.srgbRangeSize = null;
- this.srPrefixes.entrySet().forEach(entry -> {
+ srgbFirstValue = null;
+ srgbRangeSize = null;
+ srPrefixes.entrySet().forEach(entry -> {
final IpPrefix ippfx = entry.getKey();
final SrPrefix srPrefix = entry.getValue();
final SidLabelIndex sidLabelIndex = srPrefix.getSidLabelIndex();
void addSrPrefix(final WriteTransaction trans, final boolean updateNode, final IpPrefix ippfx,
final SrPrefix srPrefix) {
- this.srPrefixes.put(ippfx, srPrefix);
+ srPrefixes.put(ippfx, srPrefix);
final SidLabelIndex sidLabelIndex = srPrefix.getSidLabelIndex();
Long prefixSid = null;
if (sidLabelIndex instanceof LocalLabelCase) {
prefixSid = ((LocalLabelCase) sidLabelIndex).getLocalLabel().getValue().longValue();
} else if (sidLabelIndex instanceof SidCase) {
- if (this.srgbFirstValue != null && this.srgbRangeSize != null) {
+ if (srgbFirstValue != null && srgbRangeSize != null) {
final Long sidIndex = ((SidCase) sidLabelIndex).getSid().longValue();
- if (sidIndex >= this.srgbRangeSize) {
+ if (sidIndex >= srgbRangeSize) {
LOG.warn("Prefix SID index {} is outside the SRGB range of {} for node {}", sidIndex,
- this.srgbRangeSize, this.nodeId.getValue());
+ srgbRangeSize, nodeId.getValue());
return;
}
- prefixSid = this.srgbFirstValue + sidIndex;
+ prefixSid = srgbFirstValue + sidIndex;
}
}
if (prefixSid != null) {
}
void removeSrPrefix(final WriteTransaction trans, final IpPrefix ippfx) {
- if (!this.srPrefixes.containsKey(ippfx)) {
+ if (!srPrefixes.containsKey(ippfx)) {
return;
}
removePrefixSid(trans, true, ippfx);
- this.srPrefixes.remove(ippfx);
+ srPrefixes.remove(ippfx);
}
void addPrefixSid(final WriteTransaction trans, final boolean updateNode, final IpPrefix ippfx,
final Long prefixSid, final boolean isNodeSid) {
LOG.trace("Adding prefix SID {} for prefix {} on node {}", prefixSid, ippfx.stringValue(),
- this.nodeId.getValue());
+ nodeId.getValue());
final SegmentId segmentId = new SegmentId(Uint32.valueOf(prefixSid));
final Segments prefixSegment = new SegmentsBuilder()
.setSegmentId(segmentId)
.setPrefix(ippfx).setNodeSid(isNodeSid ? isNodeSid : null).build())
.build())
.build();
- this.prefixSegments.put(ippfx, prefixSegment);
- this.segments.add(prefixSegment);
+ prefixSegments.put(ippfx, prefixSegment);
+ segments.add(prefixSegment);
addSegment(trans, updateNode, prefixSegment);
}
void removePrefixSid(final WriteTransaction trans, final boolean updateNode, final IpPrefix ippfx) {
- if (!this.prefixSegments.containsKey(ippfx)) {
+ if (!prefixSegments.containsKey(ippfx)) {
return;
}
LOG.trace("Removing prefix SID for prefix {} on node {}", ippfx.stringValue(),
- this.nodeId.getValue());
- final Segments prefixSegment = this.prefixSegments.remove(ippfx);
- this.segments.remove(prefixSegment);
+ nodeId.getValue());
+ final Segments prefixSegment = prefixSegments.remove(ippfx);
+ segments.remove(prefixSegment);
removeSegment(trans, updateNode, prefixSegment);
}
void addAdjacencySid(final WriteTransaction trans, final boolean updateNode, final LinkId linkId,
final Long adjSid) {
LOG.trace("Adding adjacency SID {} for link {} on node {}", adjSid, linkId.getValue(),
- this.nodeId.getValue());
+ nodeId.getValue());
final SegmentId segmentId = new SegmentId(Uint32.valueOf(adjSid));
final SegmentsBuilder sb = new SegmentsBuilder();
sb.setSegmentId(segmentId);
sb.setSegmentSpecification(new AdjacencyCaseBuilder()
.setAdjacency(new AdjacencyBuilder().setAdjacency(linkId).build()).build());
final Segments adjSegment = sb.build();
- this.adjSegments.put(linkId, adjSegment);
- this.segments.add(adjSegment);
+ adjSegments.put(linkId, adjSegment);
+ segments.add(adjSegment);
addSegment(trans, updateNode, adjSegment);
}
void removeAdjacencySid(final WriteTransaction trans, final LinkId linkId) {
- if (!this.adjSegments.containsKey(linkId)) {
+ if (!adjSegments.containsKey(linkId)) {
return;
}
LOG.trace("Removing adjacency SID for link {} on node {}", linkId.getValue(),
- this.nodeId.getValue());
- final Segments adjSegment = this.adjSegments.remove(linkId);
- this.segments.remove(adjSegment);
+ nodeId.getValue());
+ final Segments adjSegment = adjSegments.remove(linkId);
+ segments.remove(adjSegment);
removeSegment(trans, true, adjSegment);
}
void addSegment(final WriteTransaction trans, final boolean updateNode, final Segments segment) {
if (updateNode) {
- final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(this.nodeId));
+ final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(nodeId));
final InstanceIdentifier<Segments> segmentIId = nodeIId.builder()
.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
.rev130819.Node1.class)
void removeSegment(final WriteTransaction trans, final boolean updateNode, final Segments segment) {
if (updateNode) {
- final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(this.nodeId));
+ final InstanceIdentifier<Node> nodeIId = getNodeInstanceIdentifier(new NodeKey(nodeId));
final InstanceIdentifier<Segments> segmentIId = nodeIId.builder()
.augmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.sr
.rev130819.Node1.class)
}
List<Segments> getSegments() {
- return this.segments;
+ return segments;
}
int getSegmentCount() {
- return this.segments.size();
+ return segments.size();
}
}
if (ip != null) {
LOG.debug("IP termination point type: {}", ip);
- return new IpBuilder().setIpAddress(Lists.newArrayList(ip)).build();
+ return new IpBuilder().setIpAddress(Set.of(ip)).build();
}
return null;
}
private NodeHolder getNode(final NodeId id) {
- return this.nodes.computeIfAbsent(id, NodeHolder::new);
+ return nodes.computeIfAbsent(id, NodeHolder::new);
}
private void putNode(final WriteTransaction trans, final NodeHolder holder) {
if (holder.syncState(trans)) {
- this.nodes.remove(holder.getNodeId());
+ nodes.remove(holder.getNodeId());
}
}
private void checkNodeForRemoval(final WriteTransaction trans, final NodeHolder holder) {
if (holder.checkForRemoval(trans)) {
- this.nodes.remove(holder.getNodeId());
+ nodes.remove(holder.getNodeId());
}
}
lb.setDestination(new DestinationBuilder().setDestNode(dstNode).setDestTp(dstTp.getTpId()).build());
LOG.trace("Created TP {} as link source", srcTp);
- NodeHolder snh = this.nodes.get(srcNode);
+ NodeHolder snh = nodes.get(srcNode);
if (snh == null) {
snh = getNode(srcNode);
snh.addTp(srcTp, lb.getLinkId(), false);
}
LOG.debug("Created TP {} as link destination", dstTp);
- NodeHolder dnh = this.nodes.get(dstNode);
+ NodeHolder dnh = nodes.get(dstNode);
if (dnh == null) {
dnh = getNode(dstNode);
dnh.addTp(dstTp, lb.getLinkId(), true);
private void removeTp(final WriteTransaction trans, final NodeId node, final TpId tp,
final LinkId link, final boolean isRemote) {
- final NodeHolder nh = this.nodes.get(node);
+ final NodeHolder nh = nodes.get(node);
if (nh != null) {
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
trans.delete(LogicalDatastoreType.OPERATIONAL, nid.child(TerminationPoint.class,
na = null;
}
final IgpNodeAttributesBuilder inab = new IgpNodeAttributesBuilder();
- final List<IpAddress> ids = new ArrayList<>();
+ final var idsBuilder = ImmutableSet.<IpAddress>builder();
Long srgbFirstValue = null;
Integer srgbRangeSize = null;
if (na != null) {
if (na.getIpv4RouterId() != null) {
- ids.add(new IpAddress(na.getIpv4RouterId()));
+ idsBuilder.add(new IpAddress(na.getIpv4RouterId()));
}
if (na.getIpv6RouterId() != null) {
- ids.add(new IpAddress(na.getIpv6RouterId()));
+ idsBuilder.add(new IpAddress(na.getIpv6RouterId()));
}
if (na.getDynamicHostname() != null) {
inab.setName(new DomainName(na.getDynamicHostname()));
: null;
}
}
+ final var ids = idsBuilder.build();
if (!ids.isEmpty()) {
inab.setRouterId(ids);
}
private void removeNode(final WriteTransaction trans, final UriBuilder base, final NodeCase nodeCase) {
final NodeId id = buildNodeId(base, nodeCase.getNodeDescriptors());
- final NodeHolder nh = this.nodes.get(id);
+ final NodeHolder nh = nodes.get(id);
if (nh != null) {
nh.unadvertized();
nh.createSrHolderIfRequired().removeSrgb(trans);
* All set, but... the hosting node may not exist, we may need to fake it.
*/
final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
- NodeHolder nh = this.nodes.get(node);
+ NodeHolder nh = nodes.get(node);
if (nh == null) {
nh = getNode(node);
nh.addPrefix(pfx);
private void removePrefix(final WriteTransaction trans, final UriBuilder base, final PrefixCase prefixCase) {
final NodeId node = buildNodeId(base, prefixCase.getAdvertisingNodeDescriptors());
- final NodeHolder nh = this.nodes.get(node);
+ final NodeHolder nh = nodes.get(node);
if (nh != null) {
LOG.debug("Removed prefix {}", prefixCase);
final InstanceIdentifier<Node> nid = getNodeInstanceIdentifier(new NodeKey(nh.getNodeId()));
}
protected void addSrAwareTopologyType(final WriteTransaction trans) {
- if (this.srAwareTopologyTypeAdded) {
+ if (srAwareTopologyTypeAdded) {
return;
}
LOG.debug("Adding SR-aware topology-type for topology {}",
getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
trans.put(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier().child(TopologyTypes.class),
SR_AWARE_LINKSTATE_TOPOLOGY_TYPE);
- this.srAwareTopologyTypeAdded = true;
+ srAwareTopologyTypeAdded = true;
}
protected void removeSrAwareTopologyTypeIfRequired(final WriteTransaction trans) {
- if (!this.srAwareTopologyTypeAdded) {
+ if (!srAwareTopologyTypeAdded) {
return;
}
- final boolean isSidPresent = this.nodes.values().stream().filter(nh -> nh.getSrHolder() != null)
+ final boolean isSidPresent = nodes.values().stream().filter(nh -> nh.getSrHolder() != null)
.map(nh -> nh.getSrHolder().getSegmentCount()).anyMatch(cnt -> cnt != 0);
if (isSidPresent) {
return;
getInstanceIdentifier().firstKeyOf(Topology.class).getTopologyId().getValue());
trans.put(LogicalDatastoreType.OPERATIONAL, getInstanceIdentifier().child(TopologyTypes.class),
LINKSTATE_TOPOLOGY_TYPE);
- this.srAwareTopologyTypeAdded = false;
+ srAwareTopologyTypeAdded = false;
}
@Override
@Override
protected void clearTopology() {
- this.nodes.clear();
- this.srAwareTopologyTypeAdded = false;
+ nodes.clear();
+ srAwareTopologyTypeAdded = false;
}
}
*/
package org.opendaylight.bgpcep.bgp.topology.provider;
+import com.google.common.collect.ImmutableSet;
import com.google.common.io.BaseEncoding;
import java.math.BigDecimal;
+import java.math.RoundingMode;
import java.nio.ByteBuffer;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.List;
import java.util.Map;
-import java.util.stream.Collectors;
+import java.util.Set;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.IsisAreaIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeFlagBits;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NodeIdentifier;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.router.type.PseudonodeBuilder;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.prefix.attributes.OspfPrefixAttributesBuilder;
import org.opendaylight.yangtools.yang.binding.util.BindingMap;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Empty;
import org.opendaylight.yangtools.yang.common.Uint8;
public final class ProtocolUtil {
+ private static final Decimal64 MIN_BANDWIDTH = Decimal64.minValueIn(2);
+ private static final float MIN_BANDWIDTH_FLT = MIN_BANDWIDTH.floatValue();
+ private static final Decimal64 MAX_BANDWIDTH = Decimal64.maxValueIn(2);
+ private static final float MAX_BANDWIDTH_FLT = MAX_BANDWIDTH.floatValue();
+
private ProtocolUtil() {
// Hidden on purpose
}
if (ri instanceof OspfPseudonodeCase) {
final OspfPseudonode pn = ((OspfPseudonodeCase) ri).getOspfPseudonode();
- ab.setRouterType(new PseudonodeBuilder().setPseudonode(Empty.getInstance()).build());
+ ab.setRouterType(new PseudonodeBuilder().setPseudonode(Empty.value()).build());
ab.setDrInterfaceId(pn.getLanInterface().getValue());
} else if (ri instanceof OspfNodeCase && na.getNodeFlags() != null) {
// TODO: what should we do with in.getOspfRouterId()?
final NodeFlagBits nf = na.getNodeFlags();
if (nf.getAbr() != null) {
- ab.setRouterType(new AbrBuilder().setAbr(nf.getAbr() ? Empty.getInstance() : null).build());
+ ab.setRouterType(new AbrBuilder().setAbr(nf.getAbr() ? Empty.value() : null).build());
} else if (nf.getExternal() != null) {
- ab.setRouterType(new InternalBuilder().setInternal(nf.getExternal() ? null : Empty.getInstance())
+ ab.setRouterType(new InternalBuilder().setInternal(nf.getExternal() ? null : Empty.value())
.build());
}
}
}
- private static List<IsoNetId> toIsoNetIds(final List<IsisAreaIdentifier> areaIds, final String systemId) {
+ private static Set<IsoNetId> toIsoNetIds(final Set<IsisAreaIdentifier> areaIds, final String systemId) {
return areaIds.stream().map(input -> new IsoNetId(UriBuilder.toIsoNetId(input, systemId)))
- .collect(Collectors.toList());
+ .collect(ImmutableSet.toImmutableSet());
}
- private static List<Uint8> nodeMultiTopology(final List<TopologyIdentifier> list) {
- final List<Uint8> ret = new ArrayList<>(list.size());
+ private static Set<Uint8> nodeMultiTopology(final Set<TopologyIdentifier> list) {
+ final var builder = ImmutableSet.<Uint8>builderWithExpectedSize(list.size());
for (final TopologyIdentifier id : list) {
- ret.add(Uint8.valueOf(id.getValue()));
+ builder.add(Uint8.valueOf(id.getValue()));
}
- return ret;
+ return builder.build();
}
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021
tb.setUnreservedBandwidth(unreservedBandwidthList(la.nonnullUnreservedBandwidth().values()));
}
if (la.getMaxLinkBandwidth() != null) {
- tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
+ tb.setMaxLinkBandwidth(bandwidthToDecimal64(la.getMaxLinkBandwidth()));
}
if (la.getMaxReservableBandwidth() != null) {
- tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
+ tb.setMaxResvLinkBandwidth(bandwidthToDecimal64(la.getMaxReservableBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
tb.setSrlg(new SrlgBuilder()
tb.setUnreservedBandwidth(unreservedBandwidthList(la.nonnullUnreservedBandwidth().values()));
}
if (la.getMaxLinkBandwidth() != null) {
- tb.setMaxLinkBandwidth(bandwidthToBigDecimal(la.getMaxLinkBandwidth()));
+ tb.setMaxLinkBandwidth(bandwidthToDecimal64(la.getMaxLinkBandwidth()));
}
if (la.getMaxReservableBandwidth() != null) {
- tb.setMaxResvLinkBandwidth(bandwidthToBigDecimal(la.getMaxReservableBandwidth()));
+ tb.setMaxResvLinkBandwidth(bandwidthToDecimal64(la.getMaxReservableBandwidth()));
}
if (la.getSharedRiskLinkGroups() != null) {
tb.setSrlg(new SrlgBuilder()
.IgpLinkAttributes1Builder().setIsisLinkAttributes(ilab.build()).build();
}
- private static Float bandwidthToFloat(final Bandwidth bandwidth) {
- return ByteBuffer.wrap(bandwidth.getValue()).getFloat();
- }
+ static Decimal64 bandwidthToDecimal64(final Bandwidth bandwidth) {
+ final float floatValue = ByteBuffer.wrap(bandwidth.getValue()).getFloat();
+ if (floatValue <= MIN_BANDWIDTH_FLT) {
+ return MIN_BANDWIDTH;
+ }
+ if (floatValue >= MAX_BANDWIDTH_FLT) {
+ return MAX_BANDWIDTH;
+ }
- private static BigDecimal bandwidthToBigDecimal(final Bandwidth bandwidth) {
- return BigDecimal.valueOf(bandwidthToFloat(bandwidth));
+ // Deal with rounding...
+ return Decimal64.of(2, BigDecimal.valueOf(floatValue)
+ .setScale(2, RoundingMode.HALF_UP)
+ .unscaledValue()
+ .longValueExact());
}
private static Map<UnreservedBandwidthKey, UnreservedBandwidth> unreservedBandwidthList(
.bgp.linkstate.rev200120.UnreservedBandwidth> input) {
return input.stream()
.map(bandwidth -> new UnreservedBandwidthBuilder()
- .setBandwidth(bandwidthToBigDecimal(bandwidth.getBandwidth()))
+ .setBandwidth(bandwidthToDecimal64(bandwidth.getBandwidth()))
.withKey(new UnreservedBandwidthKey(bandwidth.getPriority()))
.build())
.collect(BindingMap.toOrderedMap());
private AbstractRegistration registration;
- AbstractBgpTopologyProvider(final BgpTopologyDeployer deployer, final DataBroker dataBroker) {
- this.deployer = requireNonNull(deployer);
- this.dataBroker = requireNonNull(dataBroker);
- }
-
AbstractBgpTopologyProvider(final BgpTopologyDeployer deployer) {
- this(deployer, deployer.getDataBroker());
- register();
+ this.deployer = requireNonNull(deployer);
+ dataBroker = requireNonNull(deployer.getDataBroker());
}
final void register() {
@Activate
public Ipv4TopologyProvider(@Reference final BgpTopologyDeployer deployer) {
super(deployer);
+ register();
}
@Override
@Activate
public Ipv6TopologyProvider(@Reference final BgpTopologyDeployer deployer) {
super(deployer);
+ register();
}
@Override
@Activate
public LinkstateGraphProvider(@Reference final BgpTopologyDeployer deployer,
@Reference final ConnectedGraphProvider graphProvider) {
- super(deployer, deployer.getDataBroker());
+ super(deployer);
this.graphProvider = requireNonNull(graphProvider);
register();
}
@Activate
public LinkstateTopologyProvider(@Reference final BgpTopologyDeployer deployer) {
super(deployer);
+ register();
}
@Override
import static org.opendaylight.protocol.util.CheckUtil.checkNotPresentOperational;
import static org.opendaylight.protocol.util.CheckUtil.readDataOperational;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
import io.netty.buffer.Unpooled;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.junit.After;
import org.junit.Before;
@Override
public void setUp() {
super.setUp();
- this.linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID,
+ linkstateTopoBuilder = new LinkstateTopologyBuilder(getDataBroker(), LOC_RIB_REF, TEST_TOPOLOGY_ID,
LISTENER_RESTART_TIME, LISTENER_ENFORCE_COUNTER);
- this.linkstateTopoBuilder.start();
- this.tablePathIID =
+ linkstateTopoBuilder.start();
+ tablePathIID =
LOC_RIB_REF.getInstanceIdentifier().builder().child(LocRib.class)
.child(Tables.class,
new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class))
.build();
- this.linkstateNodeRouteKey = getLinkstateRouteKey("node-route");
- this.linkstatePrefixRouteKey = getLinkstateRouteKey("prefix-route");
- this.linkstateLinkRouteKey = getLinkstateRouteKey("link-route");
- this.linkstateNodeRouteIID = createLinkstateRouteIID(this.linkstateNodeRouteKey);
- this.linkstatePrefixRouteIID = createLinkstateRouteIID(this.linkstatePrefixRouteKey);
- this.linkstateLinkRouteIID = createLinkstateRouteIID(this.linkstateLinkRouteKey);
+ linkstateNodeRouteKey = getLinkstateRouteKey("node-route");
+ linkstatePrefixRouteKey = getLinkstateRouteKey("prefix-route");
+ linkstateLinkRouteKey = getLinkstateRouteKey("link-route");
+ linkstateNodeRouteIID = createLinkstateRouteIID(linkstateNodeRouteKey);
+ linkstatePrefixRouteIID = createLinkstateRouteIID(linkstatePrefixRouteKey);
+ linkstateLinkRouteIID = createLinkstateRouteIID(linkstateLinkRouteKey);
}
@After
public void tearDown() throws Exception {
- this.linkstateTopoBuilder.close();
- checkNotPresentOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier());
+ linkstateTopoBuilder.close();
+ checkNotPresentOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier());
}
@Test
public void testLinkstateTopologyBuilderTopologyTypes() throws InterruptedException, ExecutionException {
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
return topology;
});
@Test
public void testIsisLinkstateTopologyBuilder() throws InterruptedException, ExecutionException {
// create node
- updateLinkstateRoute(this.linkstateNodeRouteIID,
+ updateLinkstateRoute(linkstateNodeRouteIID,
createLinkstateNodeRoute(ProtocolId.IsisLevel2, "node1", NODE_1_AS, ROUTER_1_ID));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.nonnullNode().size());
final Node node1 = topology.nonnullNode().values().iterator().next();
assertEquals(NODE_1_ISIS_ID, node1.getNodeId().getValue());
final IgpNodeAttributes igpNode1 = node1.augmentation(Node1.class).getIgpNodeAttributes();
- assertEquals(ROUTER_1_ID, igpNode1.getRouterId().get(0).getIpv4Address().getValue());
+ assertEquals(ROUTER_1_ID, igpNode1.getRouterId().iterator().next().getIpv4Address().getValue());
assertEquals("node1", igpNode1.getName().getValue());
final IgpNodeAttributes1 igpNodeAttributes1 = igpNode1.augmentation(IgpNodeAttributes1.class);
assertEquals("0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes().getIso().getIsoSystemId()
assertEquals(ROUTER_1_ID, igpNodeAttributes1.getIsisNodeAttributes().getTed().getTeRouterIdIpv4()
.getValue());
assertEquals("47.0000.0000.0000.0000.0102.0304", igpNodeAttributes1.getIsisNodeAttributes()
- .getNet().get(0).getValue());
+ .getNet().iterator().next().getValue());
assertNull(igpNode1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf
.topology.rev131021.IgpNodeAttributes1.class));
assertEquals(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
});
// create link
- updateLinkstateRoute(this.linkstateLinkRouteIID,
+ updateLinkstateRoute(linkstateLinkRouteIID,
createLinkstateLinkRoute(ProtocolId.IsisLevel2, NODE_1_AS, NODE_2_AS, "link1"));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.nonnullLink().size());
final Link link1 = topology.nonnullLink().values().iterator().next();
assertEquals(2, topology.nonnullNode().size());
.getSegment().getValue().intValue());
return topology;
});
- removeLinkstateRoute(this.linkstateLinkRouteIID);
+ removeLinkstateRoute(linkstateLinkRouteIID);
// update node
- updateLinkstateRoute(this.linkstateNodeRouteIID,
+ updateLinkstateRoute(linkstateNodeRouteIID,
createLinkstateNodeRoute(ProtocolId.IsisLevel2, "updated-node", NODE_1_AS, ROUTER_2_ID));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.getNode().size());
final IgpNodeAttributes igpNode2 = topology.getNode().values().iterator().next().augmentation(Node1.class)
.getIgpNodeAttributes();
- assertEquals(ROUTER_2_ID, igpNode2.getRouterId().get(0).getIpv4Address().getValue());
+ assertEquals(ROUTER_2_ID, igpNode2.getRouterId().iterator().next().getIpv4Address().getValue());
assertEquals("updated-node", igpNode2.getName().getValue());
return topology;
});
// remove
- removeLinkstateRoute(this.linkstateNodeRouteIID);
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ removeLinkstateRoute(linkstateNodeRouteIID);
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(LinkstateTopologyBuilder.LINKSTATE_TOPOLOGY_TYPE, topology.getTopologyTypes());
assertNull(topology.getNode());
assertNull(topology.getLink());
@Test
public void testOspfLinkstateTopologyBuilder() throws InterruptedException, ExecutionException {
// create node
- updateLinkstateRoute(this.linkstateNodeRouteIID,
+ updateLinkstateRoute(linkstateNodeRouteIID,
createLinkstateNodeRoute(ProtocolId.Ospf, "node1", NODE_1_AS, ROUTER_1_ID));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.nonnullNode().size());
final Node node1 = topology.nonnullNode().values().iterator().next();
assertEquals(NODE_1_OSPF_ID, node1.getNodeId().getValue());
final IgpNodeAttributes igpNode1 = node1.augmentation(Node1.class).getIgpNodeAttributes();
- assertEquals(ROUTER_1_ID, igpNode1.getRouterId().get(0).getIpv4Address().getValue());
+ assertEquals(ROUTER_1_ID, igpNode1.getRouterId().iterator().next().getIpv4Address().getValue());
assertEquals("node1", igpNode1.getName().getValue());
assertNull(igpNode1.augmentation(IgpNodeAttributes1.class));
assertEquals(ROUTER_1_ID, igpNode1.augmentation(org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns
});
// update node with prefix
- updateLinkstateRoute(this.linkstatePrefixRouteIID,
+ updateLinkstateRoute(linkstatePrefixRouteIID,
createLinkstatePrefixRoute(ProtocolId.Ospf, NODE_1_AS, NODE_1_PREFIX, 500L, ROUTER_1_ID));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
final Node node1 = topology.nonnullNode().values().iterator().next();
final IgpNodeAttributes igpNode1 = node1.augmentation(Node1.class).getIgpNodeAttributes();
assertEquals(1, igpNode1.nonnullPrefix().size());
});
// create link
- updateLinkstateRoute(this.linkstateLinkRouteIID,
+ updateLinkstateRoute(linkstateLinkRouteIID,
createLinkstateLinkRoute(ProtocolId.Ospf, NODE_1_AS, NODE_2_AS, "link1"));
- readDataOperational(getDataBroker(), this.linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
+ readDataOperational(getDataBroker(), linkstateTopoBuilder.getInstanceIdentifier(), topology -> {
assertEquals(1, topology.nonnullLink().size());
final Link link1 = topology.nonnullLink().values().iterator().next();
assertEquals(2, topology.getNode().size());
@Test
@SuppressWarnings("checkstyle:IllegalCatch")
public void testRouteChangedError() throws Exception {
- final LinkstateTopologyBuilder spiedLinkstateTopologyBuilder = spy(this.linkstateTopoBuilder);
+ final LinkstateTopologyBuilder spiedLinkstateTopologyBuilder = spy(linkstateTopoBuilder);
doThrow(RuntimeException.class).when(spiedLinkstateTopologyBuilder).routeChanged(any(), any());
try {
spiedLinkstateTopologyBuilder.routeChanged(null, null);
}
private InstanceIdentifier<LinkstateRoute> createLinkstateRouteIID(final String linkstateRouteKey) {
- return this.tablePathIID.builder().child(LinkstateRoutesCase.class, LinkstateRoutes.class)
+ return tablePathIID.builder().child(LinkstateRoutesCase.class, LinkstateRoutes.class)
.child(LinkstateRoute.class, new LinkstateRouteKey(new PathId(Uint32.ZERO), linkstateRouteKey)).build();
}
private LinkstateRoute createLinkstateNodeRoute(final ProtocolId protocolId, final String nodeName,
final AsNumber asNumber, final String ipv4RouterId) {
- return createBaseBuilder(this.linkstateNodeRouteKey, protocolId)
+ return createBaseBuilder(linkstateNodeRouteKey, protocolId)
.setObjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate
.rev200120.linkstate.object.type.NodeCaseBuilder()
.setNodeDescriptors(new NodeDescriptorsBuilder()
.setNodeAttributes(new NodeAttributesBuilder()
.setDynamicHostname(nodeName)
.setIpv4RouterId(new Ipv4RouterIdentifier(ipv4RouterId))
- .setIsisAreaId(Collections.singletonList(
- new IsisAreaIdentifier(new byte[]{0x47})))
+ .setIsisAreaId(Set.of(new IsisAreaIdentifier(new byte[]{0x47})))
.setSrCapabilities(new SrCapabilitiesBuilder()
.setRangeSize(new Uint24(Uint32.valueOf(SRGB_RANGE)))
.setSidLabelIndex(new LocalLabelCaseBuilder()
private LinkstateRoute createLinkstatePrefixRoute(final ProtocolId protocolId, final AsNumber asNumber,
final String ipv4Prefix, final long igpMetric, final String ospfFwdAddress) {
- return createBaseBuilder(this.linkstatePrefixRouteKey, protocolId)
+ return createBaseBuilder(linkstatePrefixRouteKey, protocolId)
.setObjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120
.linkstate.object.type.PrefixCaseBuilder()
.setAdvertisingNodeDescriptors(new AdvertisingNodeDescriptorsBuilder()
private LinkstateRoute createLinkstateLinkRoute(final ProtocolId protocolId, final AsNumber localAs,
final AsNumber remoteAs, final String linkName) {
- return createBaseBuilder(this.linkstateLinkRouteKey, protocolId)
+ return createBaseBuilder(linkstateLinkRouteKey, protocolId)
.setObjectType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate
.rev200120.linkstate.object.type.LinkCaseBuilder()
.setLocalNodeDescriptors(new LocalNodeDescriptorsBuilder().setAsNumber(localAs)
.addAugmentation(new Attributes1Builder()
.setLinkStateAttribute(new LinkAttributesCaseBuilder()
.setLinkAttributes(new LinkAttributesBuilder()
- .setSharedRiskLinkGroups(Lists.newArrayList(
+ .setSharedRiskLinkGroups(ImmutableSet.of(
new SrlgId(Uint32.valueOf(5)), new SrlgId(Uint32.valueOf(15))))
.setAdminGroup(new AdministrativeGroup(Uint32.ZERO))
.setMaxLinkBandwidth(
.build()))
.setTeMetric(new TeMetric(Uint32.valueOf(100)))
.setLinkName(linkName)
- .setSrAdjIds(Collections.singletonList(new SrAdjIdsBuilder()
+ .setSrAdjIds(List.of(new SrAdjIdsBuilder()
.setSidLabelIndex(new LocalLabelCaseBuilder()
.setLocalLabel(new MplsLabel(Uint32.valueOf(ADJ_SID)))
.build())
<parent>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>binding-parent</artifactId>
- <version>8.0.11</version>
+ <version>9.0.1</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>io.netty</groupId>
- <artifactId>netty-transport-native-epoll</artifactId>
- <classifier>linux-x86_64</classifier>
+ <artifactId>netty-transport-classes-epoll</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
*/
package org.opendaylight.protocol.bmp.impl.app;
+import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static org.opendaylight.protocol.bmp.impl.app.TablesUtil.BMP_ATTRIBUTES_QNAME;
import static org.opendaylight.protocol.bmp.impl.app.TablesUtil.BMP_ROUTES_QNAME;
-import com.google.common.base.Preconditions;
import java.util.Map;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTree;
import org.opendaylight.mdsal.binding.dom.codec.api.BindingCodecTreeNode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
final class TableContext {
private static final ContainerNode EMPTY_TABLE_ATTRIBUTES = ImmutableNodes.containerNode(BMP_ATTRIBUTES_QNAME);
-
- private static final InstanceIdentifier<MpReachNlri> MP_REACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path
- .attributes.Attributes.class).augmentation(AttributesReach.class).child(MpReachNlri.class);
- private static final InstanceIdentifier<MpUnreachNlri> MP_UNREACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path
- .attributes.Attributes.class).augmentation(AttributesUnreach.class).child(MpUnreachNlri.class);
private static final NodeIdentifier BGP_ROUTES_NODE_ID = new NodeIdentifier(BMP_ROUTES_QNAME);
private final YangInstanceIdentifier tableId;
this.tableSupport = requireNonNull(tableSupport);
this.tableId = requireNonNull(tableId);
final BindingCodecTreeNode tableCodecContext = tree.getSubtreeCodec(tableId);
- Preconditions.checkState(tableCodecContext instanceof BindingDataObjectCodecTreeNode);
+
+ checkState(tableCodecContext instanceof BindingDataObjectCodecTreeNode);
final BindingDataObjectCodecTreeNode<?> routeListCodec = ((BindingDataObjectCodecTreeNode)tableCodecContext)
.streamChild(Routes.class)
.streamChild(this.tableSupport.routesCaseClass())
.streamChild(this.tableSupport.routesContainerClass())
.streamChild(this.tableSupport.routesListClass());
- this.attributesCodec = routeListCodec.streamChild(Attributes.class)
+ attributesCodec = routeListCodec.streamChild(Attributes.class)
.createCachingCodec(this.tableSupport.cacheableAttributeObjects());
- this.reachNlriCodec = tree.getSubtreeCodec(MP_REACH_NLRI_II)
- .createCachingCodec(this.tableSupport.cacheableNlriObjects());
- this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II)
- .createCachingCodec(this.tableSupport.cacheableNlriObjects());
+
+ final var updateAttributesCodec = tree.streamChild(Update.class)
+ .streamChild(Attributes.class);
+ reachNlriCodec = updateAttributesCodec.streamChild(AttributesReach.class)
+ .streamChild(MpReachNlri.class)
+ .createCachingCodec(this.tableSupport.cacheableNlriObjects());
+ unreachNlriCodec = updateAttributesCodec.streamChild(AttributesUnreach.class)
+ .streamChild(MpUnreachNlri.class)
+ .createCachingCodec(this.tableSupport.cacheableNlriObjects());
}
YangInstanceIdentifier getTableId() {
- return this.tableId;
+ return tableId;
}
void createTable(final DOMDataTreeWriteTransaction tx) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb =
ImmutableNodes.mapEntryBuilder();
- tb.withNodeIdentifier((NodeIdentifierWithPredicates) this.tableId.getLastPathArgument());
+ tb.withNodeIdentifier((NodeIdentifierWithPredicates) tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey =
- (NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
+ (NodeIdentifierWithPredicates) tableId.getLastPathArgument();
for (final Map.Entry<QName, Object> e : tableKey.entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
- tx.put(LogicalDatastoreType.OPERATIONAL, this.tableId,
+ tx.put(LogicalDatastoreType.OPERATIONAL, tableId,
tb.withChild(ImmutableChoiceNodeBuilder.create().withNodeIdentifier(
new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
void writeRoutes(final DOMDataTreeWriteTransaction tx, final MpReachNlri nlri, final Attributes attributes) {
final ContainerNode domNlri = serializeReachNlri(nlri);
final ContainerNode routeAttributes = serializeAttributes(attributes);
- this.tableSupport.putRoutes(tx, this.tableId, domNlri, routeAttributes, BGP_ROUTES_NODE_ID);
+ tableSupport.putRoutes(tx, tableId, domNlri, routeAttributes, BGP_ROUTES_NODE_ID);
}
void removeRoutes(final DOMDataTreeWriteTransaction tx, final MpUnreachNlri nlri) {
- this.tableSupport.deleteRoutes(tx, this.tableId, serializeUnreachNlri(nlri), BGP_ROUTES_NODE_ID);
+ tableSupport.deleteRoutes(tx, tableId, serializeUnreachNlri(nlri), BGP_ROUTES_NODE_ID);
}
private ContainerNode serializeUnreachNlri(final MpUnreachNlri nlri) {
- Preconditions.checkState(this.unreachNlriCodec != null, "MpUnReachNlri codec not available");
- return (ContainerNode) this.unreachNlriCodec.serialize(nlri);
+ checkState(unreachNlriCodec != null, "MpUnReachNlri codec not available");
+ return (ContainerNode) unreachNlriCodec.serialize(nlri);
}
private ContainerNode serializeReachNlri(final MpReachNlri nlri) {
- Preconditions.checkState(this.reachNlriCodec != null, "MpReachNlri codec not available");
- return (ContainerNode) this.reachNlriCodec.serialize(nlri);
+ checkState(reachNlriCodec != null, "MpReachNlri codec not available");
+ return (ContainerNode) reachNlriCodec.serialize(nlri);
}
private ContainerNode serializeAttributes(final Attributes pathAttr) {
- Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
+ checkState(attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.removeAugmentation(AttributesReach.class);
a.removeAugmentation(AttributesUnreach.class);
- return (ContainerNode) this.attributesCodec.serialize(a.build());
+ return (ContainerNode) attributesCodec.serialize(a.build());
}
}
<groupId>${project.groupId}</groupId>
<artifactId>testtool-util</artifactId>
</dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-transport-native-epoll</artifactId>
+ <classifier>linux-x86_64</classifier>
+ </dependency>
</dependencies>
<build>
<plugins>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv;
-import org.opendaylight.yangtools.concepts.Builder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public abstract class AbstractBmpMessageWithTlvParser<T extends Builder<?>> extends AbstractBmpMessageParser {
+public abstract class AbstractBmpMessageWithTlvParser<T> extends AbstractBmpMessageParser {
private static final Logger LOG = LoggerFactory.getLogger(AbstractBmpMessageWithTlvParser.class);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.PeerType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.header.PeerHeader;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.peer.header.PeerHeaderBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.binding.Notification;
import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
-public abstract class AbstractBmpPerPeerMessageParser<T extends Builder<?>> extends AbstractBmpMessageWithTlvParser<T> {
+public abstract class AbstractBmpPerPeerMessageParser<T> extends AbstractBmpMessageWithTlvParser<T> {
private static final int L_FLAG_POS = 1;
private static final int V_FLAG_POS = 0;
private static final int FLAGS_SIZE = 8;
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal.binding.model.ietf</groupId>
- <artifactId>rfc7223</artifactId>
+ <artifactId>rfc8343</artifactId>
<scope>test</scope>
</dependency>
<dependency>
package org.opendaylight.bgpcep.config.loader.impl;
import com.google.common.base.Stopwatch;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
abstract @NonNull File directory();
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void unregister(final ProcessorRegistration reg) {
configServices.remove(reg);
}
*/
package org.opendaylight.bgpcep.config.loader.impl;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.nio.file.ClosedWatchServiceException;
import java.nio.file.WatchKey;
import java.nio.file.WatchService;
private final AtomicBoolean closed = new AtomicBoolean();
private final Thread watcherThread;
+ @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
+ justification = "https://github.com/spotbugs/spotbugs/issues/1867")
AbstractWatchingConfigLoader() {
watcherThread = new Thread(this::dispatchEvents, "Config Loader Watcher Thread");
watcherThread.setDaemon(true);
watcherThread.interrupt();
try {
- this.watcherThread.join();
+ watcherThread.join();
} catch (InterruptedException e) {
LOG.warn("Interrupted while waiting for watcher thread to terminate", e);
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
import com.google.common.annotations.VisibleForTesting;
import org.junit.Test;
import org.opendaylight.bgpcep.config.loader.impl.AbstractConfigLoaderTest;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.OpenconfigNetworkInstanceData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.NetworkInstances;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstance;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.network.instance.rev151018.network.instance.top.network.instances.NetworkInstanceKey;
public class ProtocolsConfigFileProcessorTest extends AbstractConfigLoaderTest {
@VisibleForTesting
- static final InstanceIdentifier<Protocols> BGP_PROTOCOLS_IID = InstanceIdentifier.create(NetworkInstances.class)
+ static final InstanceIdentifier<Protocols> BGP_PROTOCOLS_IID =
+ InstanceIdentifier.builderOfInherited(OpenconfigNetworkInstanceData.class, NetworkInstances.class).build()
.child(NetworkInstance.class, new NetworkInstanceKey(ProtocolsConfigFileProcessor.GLOBAL_BGP_NAME))
.child(Protocols.class);
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
import org.junit.Before;
import org.opendaylight.bgpcep.config.loader.impl.AbstractConfigLoaderTest;
+import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.OpenconfigRoutingPolicyData;
import org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.RoutingPolicy;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class AbstractOpenconfigRoutingPolicyLoaderTest extends AbstractConfigLoaderTest {
private static final InstanceIdentifier<RoutingPolicy> ROUTING_POLICY_IID =
- InstanceIdentifier.create(RoutingPolicy.class);
+ InstanceIdentifier.builderOfInherited(OpenconfigRoutingPolicyData.class, RoutingPolicy.class).build();
OpenconfigRoutingConfigFileProcessor policyLoader;
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>karaf4-parent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>feature-repo-parent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-benchmark" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
-->
<features name="odl-bgpcep-bgp-dependencies-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="odl-bgpcep-bgp-dependencies" version="${project.version}">
- <feature version="[7,8)">odl-yangtools-data-api</feature>
+ <feature version="[8,9)">odl-yangtools-data-api</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-evpn" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-rfc8294-netty</feature>
+ <feature version="[9,10)">odl-mdsal-rfc8294-netty</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-labeled-unicast" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-rfc8294-netty</feature>
+ <feature version="[9,10)">odl-mdsal-rfc8294-netty</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-linkstate" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
- <feature version="[8,9)">odl-mdsal-rfc8294-netty</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
+ <feature version="[9,10)">odl-mdsal-rfc8294-netty</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-openconfig-rp-impl" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-openconfig-rp-statement" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-parser-api" version="${project.version}">
- <feature version="[4,5)">odl-controller-blueprint</feature>
- <feature version="[7,8)">odl-yangtools-data</feature>
- <feature version="[7,8)">odl-yangtools-netty</feature>
+ <feature version="[5,6)">odl-controller-blueprint</feature>
+ <feature version="[8,9)">odl-yangtools-data</feature>
+ <feature version="[8,9)">odl-yangtools-netty</feature>
</feature>
</features>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>odl-mdsal-model-rfc7223</artifactId>
+ <artifactId>odl-mdsal-model-rfc8343</artifactId>
<type>xml</type>
<classifier>features</classifier>
</dependency>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-rib-api" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-rfc7223</feature>
- <feature version="[8,9)">odl-mdsal-singleton-common</feature>
- <feature version="[8,9)">odl-mdsal-dom-api</feature>
- <feature version="[8,9)">odl-mdsal-binding-runtime-api</feature>
+ <feature version="[9,10)">odl-mdsal-model-rfc8343</feature>
+ <feature version="[9,10)">odl-mdsal-singleton-common</feature>
+ <feature version="[9,10)">odl-mdsal-dom-api</feature>
+ <feature version="[9,10)">odl-mdsal-binding-runtime-api</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bgp-rib-impl" version="${project.version}">
- <feature version="[4,5)">odl-controller-exp-netty-config</feature>
+ <feature version="[5,6)">odl-controller-exp-netty-config</feature>
<configfile finalname="etc/opendaylight/bgpcep/routing-policy-default-config.xml">mvn:org.opendaylight.bgpcep/bgp-config-example/${project.version}/xml/routing-policy-default-config</configfile>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-bgpcep-data-change-counter-${project.version}">
<feature name="odl-bgpcep-data-change-counter" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[9,10)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-bgpcep-${project.version}">
<feature name="odl-bgpcep-extras-dependencies" version="${project.version}">
- <feature version="[9,10)">odl-netty-4</feature>
+ <feature version="[10,11)">odl-netty-4</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-concepts" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-rfc6991</feature>
- <feature version="[8,9)">odl-mdsal-model-rfc8294</feature>
+ <feature version="[9,10)">odl-mdsal-model-rfc6991</feature>
+ <feature version="[9,10)">odl-mdsal-model-rfc8294</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-bmp-config-loader" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-config-loader-impl" version="${project.version}">
- <feature version="[7,8)">odl-yangtools-codec</feature>
+ <feature version="[8,9)">odl-yangtools-codec</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-config-loader-spi" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-binding-runtime</feature>
+ <feature version="[9,10)">odl-mdsal-binding-runtime</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-topology-config-loader" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-graph-api" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-rfc6991</feature>
- <feature version="[8,9)">odl-mdsal-model-rfc8294</feature>
+ <feature version="[9,10)">odl-mdsal-model-rfc6991</feature>
+ <feature version="[9,10)">odl-mdsal-model-rfc8294</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-graph" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-pcep-impl" version="${project.version}">
- <feature version="[4,5)">odl-controller-exp-netty-config</feature>
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-controller-exp-netty-config</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-pcep-p2mp-te-lsp" version="${project.version}">
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-bgpcep-${project.version}">
<feature name="odl-bgpcep-pcep-tunnel-provider" version="${project.version}">
- <feature version="[9,10)">odl-apache-commons-lang3</feature>
+ <feature version="[10,11)">odl-apache-commons-lang3</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-bgpcep-programming-api-${project.version}">
<feature name="odl-bgpcep-programming-api" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-singleton-common</feature>
+ <feature version="[9,10)">odl-mdsal-singleton-common</feature>
</feature>
</features>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-programming-impl" version="${project.version}">
- <feature version="[4,5)">odl-controller-exp-netty-config</feature>
- <feature version="[4,5)">odl-mdsal-broker</feature>
+ <feature version="[5,6)">odl-controller-exp-netty-config</feature>
+ <feature version="[5,6)">odl-mdsal-broker</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-rsvp-api" version="${project.version}">
- <feature version="[7,8)">odl-yangtools-netty</feature>
- <feature version="[4,5)">odl-controller-blueprint</feature>
+ <feature version="[8,9)">odl-yangtools-netty</feature>
+ <feature version="[5,6)">odl-controller-blueprint</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0">
<feature name="odl-bgpcep-topology-api" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
+ <feature version="[9,10)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
</feature>
</features>
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.4.0" name="odl-bgpcep-topology-tunnel-api-${project.version}">
<feature name="odl-bgpcep-topology-tunnel-api" version="${project.version}">
- <feature version="[8,9)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
+ <feature version="[9,10)">odl-mdsal-model-draft-clemm-netmod-yang-network-topo-01-minimal</feature>
</feature>
</features>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
</project>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>bundle-parent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>controller-artifacts</artifactId>
- <version>4.0.10</version>
+ <version>5.0.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yangtools-artifacts</artifactId>
- <version>7.0.14</version>
+ <version>8.0.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-artifacts</artifactId>
- <version>8.0.11</version>
+ <version>9.0.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>netconf-artifacts</artifactId>
- <version>2.0.14</version>
+ <version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.opendaylight.infrautils</groupId>
<artifactId>infrautils-artifacts</artifactId>
- <version>2.0.13</version>
+ <version>3.0.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
// vi: set smarttab et sw=4 tabstop=4:
module pcep-config {
- yang-version 1.1;
+ yang-version 1;
namespace "urn:opendaylight:params:xml:ns:yang:pcep:config";
prefix pd-config;
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>com.guicedee.services</groupId>
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
}
bytes.skipBytes(FLAGS_F_OFFSET);
final BitArray flags = BitArray.valueOf(bytes, FLAGS_SIZE);
- final List<RequestId> requestIDs = new ArrayList<>();
-
+ final var builder = ImmutableSet.<RequestId>builder();
while (bytes.isReadable()) {
- requestIDs.add(new RequestId(ByteBufUtils.readUint32(bytes)));
+ builder.add(new RequestId(ByteBufUtils.readUint32(bytes)));
}
+ final Set<RequestId> requestIDs = builder.build();
+
if (requestIDs.isEmpty()) {
throw new PCEPDeserializerException("Empty Svec Object - no request ids.");
}
checkArgument(object instanceof Svec, "Wrong instance of PCEPObject. Passed %s. Needed SvecObject.",
object.getClass());
final Svec svecObj = (Svec) object;
+ final Set<RequestId> requestIDs = svecObj.getRequestsIds();
+ checkArgument(!requestIDs.isEmpty(), "Empty Svec Object - no request ids.");
+
final ByteBuf body = Unpooled.buffer();
body.writeZero(FLAGS_F_OFFSET);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(P_FLAG_OFFSET, svecObj.getPartialPathDiverse());
flags.toByteBuf(body);
- final List<RequestId> requestIDs = svecObj.getRequestsIds();
- // FIXME: remove this assert
- assert !requestIDs.isEmpty() : "Empty Svec Object - no request ids.";
for (final RequestId requestId : requestIDs) {
ByteBufUtils.write(body, requestId.getValue());
}
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final Boolean ignore,
final P2mpIpv4 p2mpIpv4,
final ByteBuf buffer) {
- final List<Ipv4AddressNoZone> dest = p2mpIpv4.getDestinationIpv4Address();
+ final Set<Ipv4AddressNoZone> dest = p2mpIpv4.getDestinationIpv4Address();
checkArgument(dest != null, "DestinationIpv4Address is mandatory.");
final ByteBuf body = Unpooled.buffer(LEAF_TYPE_SIZE + Ipv4Util.IP4_LENGTH + Ipv4Util.IP4_LENGTH * dest.size());
checkArgument(p2mpIpv4.getSourceIpv4Address() != null, "SourceIpv4Address is mandatory.");
final P2mpIpv4Builder p2mpIpv4Builder = new P2mpIpv4Builder();
p2mpIpv4Builder.setP2mpLeaves(P2mpLeaves.forValue(bytes.readInt()));
p2mpIpv4Builder.setSourceIpv4Address(Ipv4Util.addressForByteBuf(bytes));
- List<Ipv4AddressNoZone> dest = new ArrayList<>();
+
+ final var dest = ImmutableSet.<Ipv4AddressNoZone>builder();
while (bytes.isReadable()) {
dest.add(Ipv4Util.addressForByteBuf(bytes));
}
- p2mpIpv4Builder.setDestinationIpv4Address(dest);
+ p2mpIpv4Builder.setDestinationIpv4Address(dest.build());
builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(p2mpIpv4Builder.build()).build());
return builder.build();
}
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final Boolean ignore,
final P2mpIpv6 p2mpIpv6,
final ByteBuf buffer) {
- final List<Ipv6AddressNoZone> dest = p2mpIpv6.getDestinationIpv6Address();
+ final Set<Ipv6AddressNoZone> dest = p2mpIpv6.getDestinationIpv6Address();
checkArgument(dest != null, "DestinationIpv6Address is mandatory.");
final ByteBuf body =
Unpooled.buffer(LEAF_TYPE_SIZE + Ipv6Util.IPV6_LENGTH + Ipv6Util.IPV6_LENGTH * dest.size());
final P2mpIpv6Builder p2mpIpv6Builder = new P2mpIpv6Builder()
.setP2mpLeaves(P2mpLeaves.forValue(bytes.readInt()))
.setSourceIpv6Address(Ipv6Util.addressForByteBuf(bytes));
- List<Ipv6AddressNoZone> dest = new ArrayList<>();
+ final var dest = ImmutableSet.<Ipv6AddressNoZone>builder();
while (bytes.isReadable()) {
dest.add(Ipv6Util.addressForByteBuf(bytes));
}
- p2mpIpv6Builder.setDestinationIpv6Address(dest);
+ p2mpIpv6Builder.setDestinationIpv6Address(dest.build());
return new EndpointsObjBuilder()
.setIgnore(header.getIgnore())
.setProcessingRule(header.getProcessingRule())
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final Boolean ignore,
final Ipv4DestinationCase ipv4Case,
final ByteBuf buffer) {
- final List<Ipv4AddressNoZone> dest = ipv4Case.getDestinationIpv4Address();
+ final Set<Ipv4AddressNoZone> dest = ipv4Case.getDestinationIpv4Address();
checkArgument(dest != null, "DestinationIpv4Address is mandatory.");
final ByteBuf body = Unpooled.buffer(Ipv4Util.IP4_LENGTH * dest.size());
dest.forEach(ipv4 -> Ipv4Util.writeIpv4Address(ipv4, body));
public UnreachDestinationObj parseObject(final ObjectHeader header, final ByteBuf bytes)
throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
- final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
if (bytes.readableBytes() % Ipv4Util.IP4_LENGTH != 0) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
- builder.setIgnore(header.getIgnore());
- builder.setProcessingRule(header.getProcessingRule());
- List<Ipv4AddressNoZone> dest = new ArrayList<>();
+ final var dest = ImmutableSet.<Ipv4AddressNoZone>builder();
while (bytes.isReadable()) {
dest.add(Ipv4Util.addressForByteBuf(bytes));
}
- builder.setDestination(new Ipv4DestinationCaseBuilder().setDestinationIpv4Address(dest).build());
- return builder.build();
+ return new UnreachDestinationObjBuilder()
+ .setIgnore(header.getIgnore())
+ .setProcessingRule(header.getProcessingRule())
+ .setDestination(new Ipv4DestinationCaseBuilder().setDestinationIpv4Address(dest.build()).build())
+ .build();
}
}
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Set;
import org.opendaylight.protocol.pcep.spi.CommonObjectParser;
import org.opendaylight.protocol.pcep.spi.ObjectUtil;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
final Boolean ignore,
final Ipv6DestinationCase ipv6Case,
final ByteBuf buffer) {
- final List<Ipv6AddressNoZone> dest = ipv6Case.getDestinationIpv6Address();
+ final Set<Ipv6AddressNoZone> dest = ipv6Case.getDestinationIpv6Address();
checkArgument(dest != null, "Destinationipv6Address is mandatory.");
final ByteBuf body = Unpooled.buffer(Ipv6Util.IPV6_LENGTH * dest.size());
dest.forEach(ipv6 -> Ipv6Util.writeIpv6Address(ipv6, body));
public UnreachDestinationObj parseObject(final ObjectHeader header, final ByteBuf bytes)
throws PCEPDeserializerException {
checkArgument(bytes != null && bytes.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
- final UnreachDestinationObjBuilder builder = new UnreachDestinationObjBuilder();
if (bytes.readableBytes() % Ipv6Util.IPV6_LENGTH != 0) {
throw new PCEPDeserializerException("Wrong length of array of bytes.");
}
- builder.setIgnore(header.getIgnore());
- builder.setProcessingRule(header.getProcessingRule());
- List<Ipv6AddressNoZone> dest = new ArrayList<>();
+ final var dest = ImmutableSet.<Ipv6AddressNoZone>builder();
while (bytes.isReadable()) {
dest.add(Ipv6Util.addressForByteBuf(bytes));
}
- return builder.setDestination(new Ipv6DestinationCaseBuilder().setDestinationIpv6Address(dest).build())
- .build();
+ return new UnreachDestinationObjBuilder()
+ .setIgnore(header.getIgnore())
+ .setProcessingRule(header.getProcessingRule())
+ .setDestination(new Ipv6DestinationCaseBuilder().setDestinationIpv6Address(dest.build()).build())
+ .build();
}
}
*/
package org.opendaylight.protocol.pcep.parser.object.unreach;
-import com.google.common.base.Preconditions;
+import static com.google.common.base.Preconditions.checkArgument;
+
import io.netty.buffer.ByteBuf;
import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
public final class PCEPUnreachDestinationSerializer implements ObjectSerializer {
@Override
public void serializeObject(final Object object, final ByteBuf buffer) {
- Preconditions.checkArgument(object instanceof UnreachDestinationObj,
+ checkArgument(object instanceof UnreachDestinationObj,
"Wrong instance of PCEPObject. Passed %s. Needed UnreachDestinationObj.", object.getClass());
final UnreachDestinationObj uPObj = (UnreachDestinationObj) object;
final Destination destination = uPObj.getDestination();
import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
import org.opendaylight.protocol.pcep.spi.TlvParser;
import org.opendaylight.protocol.pcep.spi.TlvSerializer;
throw new PCEPDeserializerException("Wrong length of array of bytes. Passed: " + buffer.readableBytes()
+ ".");
}
- final List<OfId> ofCodes = new ArrayList<>();
+ final var ofCodes = ImmutableSet.<OfId>builder();
while (buffer.isReadable()) {
ofCodes.add(new OfId(ByteBufUtils.readUint16(buffer)));
}
- return new OfListBuilder().setCodes(ofCodes).build();
+ return new OfListBuilder().setCodes(ofCodes.build()).build();
}
@Override
checkArgument(tlv instanceof OfList, "OFListTlv is mandatory.");
final OfList oft = (OfList) tlv;
final ByteBuf body = Unpooled.buffer();
- final List<OfId> ofCodes = oft.getCodes();
- for (OfId id : ofCodes) {
+ for (OfId id : oft.getCodes()) {
ByteBufUtils.write(body, id.getValue());
}
TlvUtil.formatTlv(TYPE, body, buffer);
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMap.Builder;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.util.Map;
abstract void writeEntry(ByteBuf buf, BindingTypeValue value);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125.MplsLabel
getMplsLabel(final long mplsStackEntry) {
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.concepts.rev131125
.MplsLabel(Uint32.valueOf(mplsStackEntry >> LABEL_SHIFT & LABEL_MASK));
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private static long getMplsStackEntry(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network
.concepts.rev131125.MplsLabel mplsLabel) {
return mplsLabel.getValue().toJava() << LABEL_SHIFT;
* Class for setting up TLS connection.
*/
public class SslContextFactory {
-
+ private static final Logger LOG = LoggerFactory.getLogger(SslContextFactory.class);
private static final String PROTOCOL = "TLS";
- private final Tls tlsConfig;
- private static final Logger LOG = LoggerFactory
- .getLogger(SslContextFactory.class);
+ private final Tls tlsConfig;
/**
* SslContextFactory provides information about the TLS context and configuration.
}
public SSLContext getServerContext() {
+ final var keyStoreType = tlsConfig.getKeystoreType();
+ if (keyStoreType == null) {
+ LOG.warn("No keystore type, not initializing server-side context");
+ return null;
+ }
+
+ // FIXME: refactor these for defensiveness
try {
- final KeyStore ks = KeyStore.getInstance(this.tlsConfig.getKeystoreType().name());
- ks.load(SslKeyStore.asInputStream(this.tlsConfig.getKeystore(), this.tlsConfig.getKeystorePathType()),
- this.tlsConfig.getKeystorePassword().toCharArray());
+ final KeyStore ks = KeyStore.getInstance(keyStoreType.name());
+ ks.load(SslKeyStore.asInputStream(tlsConfig.getKeystore(), tlsConfig.getKeystorePathType()),
+ tlsConfig.getKeystorePassword().toCharArray());
final KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- kmf.init(ks, this.tlsConfig.getCertificatePassword().toCharArray());
+ kmf.init(ks, tlsConfig.getCertificatePassword().toCharArray());
- final KeyStore ts = KeyStore.getInstance(this.tlsConfig.getTruststoreType().name());
- ts.load(SslKeyStore.asInputStream(this.tlsConfig.getTruststore(), this.tlsConfig.getTruststorePathType()),
- this.tlsConfig.getTruststorePassword().toCharArray());
+ final KeyStore ts = KeyStore.getInstance(tlsConfig.getTruststoreType().name());
+ ts.load(SslKeyStore.asInputStream(tlsConfig.getTruststore(), tlsConfig.getTruststorePathType()),
+ tlsConfig.getTruststorePassword().toCharArray());
final TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(ts);
LOG.warn(
"CertificateException - Unable to get a certificate (check password) to set the server-side SSLContext",
e);
- } catch (final KeyManagementException | UnrecoverableKeyException | NullPointerException e) {
+ } catch (final KeyManagementException | UnrecoverableKeyException e) {
LOG.warn("Exception - Failed to initialize the server-side SSLContext", e);
}
//TODO try to use default SSLContext instance?
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
@Before
public void setUp() {
- this.ctx = new SimplePCEPExtensionProviderContext();
- this.act = new BaseParserExtensionActivator();
- this.viAct = new TestVendorInformationActivator();
- this.act.start(this.ctx);
- this.viAct.start(this.ctx);
- this.tlvRegistry = this.ctx.getTlvHandlerRegistry();
- this.viTlvRegistry = this.ctx.getVendorInformationTlvRegistry();
+ ctx = new SimplePCEPExtensionProviderContext();
+ act = new BaseParserExtensionActivator();
+ viAct = new TestVendorInformationActivator();
+ act.start(ctx);
+ viAct.start(ctx);
+ tlvRegistry = ctx.getTlvHandlerRegistry();
+ viTlvRegistry = ctx.getVendorInformationTlvRegistry();
}
@Test
public void testOpenObjectWOTLV() throws PCEPDeserializerException, IOException {
- final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin"));
final OpenBuilder builder = new OpenBuilder()
@Test
public void testCloseObject() throws IOException, PCEPDeserializerException {
- final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin"));
final CCloseBuilder builder = new CCloseBuilder()
@Test
public void testERObject() throws Exception {
final PCEPExplicitRouteObjectParser parser =
- new PCEPExplicitRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+ new PCEPExplicitRouteObjectParser(ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result =
Unpooled.wrappedBuffer(
ByteArray.fileToBytes("src/test/resources/PCEPExplicitRouteObject1PackOfSubobjects.bin"));
@Test
public void testIRObject() throws Exception {
final PCEPIncludeRouteObjectParser parser =
- new PCEPIncludeRouteObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+ new PCEPIncludeRouteObjectParser(ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result =
Unpooled.wrappedBuffer(
ByteArray.fileToBytes("src/test/resources/PCEPIncludeRouteObject1PackOfSubobjects.bin"));
@Test
public void testRRObject() throws Exception {
final PCEPReportedRouteObjectParser parser =
- new PCEPReportedRouteObjectParser(this.ctx.getRROSubobjectHandlerRegistry());
+ new PCEPReportedRouteObjectParser(ctx.getRROSubobjectHandlerRegistry());
final ByteBuf result =
Unpooled.wrappedBuffer(
ByteArray.fileToBytes("src/test/resources/PCEPReportedRouteObject1PackOfSubobjects.bin"));
builder.setAddressFamily(new P2mpIpv4CaseBuilder().setP2mpIpv4(new P2mpIpv4Builder()
.setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
.setSourceIpv4Address(Ipv4Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
- .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.255"),
+ .setDestinationIpv4Address(ImmutableSet.of(new Ipv4AddressNoZone("255.255.255.255"),
new Ipv4AddressNoZone("255.255.255.252"))).build()).build());
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
builder.setAddressFamily(new P2mpIpv6CaseBuilder().setP2mpIpv6(new P2mpIpv6Builder()
.setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
.setSourceIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.wrappedBuffer(srcIPBytes)))
- .setDestinationIpv6Address(Arrays.asList(
+ .setDestinationIpv6Address(ImmutableSet.of(
new Ipv6AddressNoZone("2:5dd2:ffec:a1b6:581e:9f50::"),
new Ipv6AddressNoZone("3:5dd2:ffec:a1b6:581e:9f50::")
)).build()).build());
@Test
public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(tlvRegistry, viTlvRegistry);
final ErrorObjectBuilder builder = new ErrorObjectBuilder()
.setProcessingRule(true)
@Test
public void testLspaObject() throws IOException, PCEPDeserializerException {
- final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(tlvRegistry, viTlvRegistry);
final LspaBuilder builder = new LspaBuilder()
.setProcessingRule(true)
@Test
public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
- final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(tlvRegistry, viTlvRegistry);
ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin"));
@Test
public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
final PCEPNotificationObjectParser parser =
- new PCEPNotificationObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ new PCEPNotificationObjectParser(tlvRegistry, viTlvRegistry);
final CNotificationBuilder builder = new CNotificationBuilder()
.setProcessingRule(true)
@Test
public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
final PCEPRequestParameterObjectParser parser =
- new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ new PCEPRequestParameterObjectParser(tlvRegistry, viTlvRegistry);
final RpBuilder builder = new RpBuilder()
.setProcessingRule(true)
.setSrlgDiverse(false)
.setPartialPathDiverse(false)
.setLinkDirectionDiverse(false)
- .setRequestsIds(Lists.newArrayList(new RequestId(Uint32.valueOf(0xFF))));
+ .setRequestsIds(Set.of(new RequestId(Uint32.valueOf(0xFF))));
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin"));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(false, false),
builder.setLinkDiverse(true);
builder.setSrlgDiverse(true);
- final List<RequestId> requestIDs = new ArrayList<>();
- requestIDs.add(new RequestId(Uint32.valueOf(0xFFFFFFFFL)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x00000001L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x01234567L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x89ABCDEFL)));
- requestIDs.add(new RequestId(Uint32.valueOf(0xFEDCBA98L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x76543210L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x15825266L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x48120BBEL)));
- requestIDs.add(new RequestId(Uint32.valueOf(0x25FB7E52L)));
- requestIDs.add(new RequestId(Uint32.valueOf(0xB2F2546BL)));
-
- builder.setRequestsIds(requestIDs);
+ builder.setRequestsIds(ImmutableSet.of(
+ // Order is important for assertion
+ new RequestId(Uint32.valueOf(0xFFFFFFFFL)),
+ new RequestId(Uint32.valueOf(0x00000001L)),
+ new RequestId(Uint32.valueOf(0x01234567L)),
+ new RequestId(Uint32.valueOf(0x89ABCDEFL)),
+ new RequestId(Uint32.valueOf(0xFEDCBA98L)),
+ new RequestId(Uint32.valueOf(0x76543210L)),
+ new RequestId(Uint32.valueOf(0x15825266L)),
+ new RequestId(Uint32.valueOf(0x48120BBEL)),
+ new RequestId(Uint32.valueOf(0x25FB7E52L)),
+ new RequestId(Uint32.valueOf(0xB2F2546BL))));
assertEquals(builder.build(), parser.parseObject(new ObjectHeaderImpl(true, false),
result.slice(4, result.readableBytes() - 4)));
@Test
public void testExcludeRouteObject() throws Exception {
final PCEPExcludeRouteObjectParser parser =
- new PCEPExcludeRouteObjectParser(this.ctx.getXROSubobjectHandlerRegistry());
+ new PCEPExcludeRouteObjectParser(ctx.getXROSubobjectHandlerRegistry());
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPExcludeRouteObject.1.bin"));
@Test
public void testPathKeyObject() throws Exception {
- final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+ final PCEPPathKeyObjectParser parser = new PCEPPathKeyObjectParser(ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPPathKeyObject.bin"));
@Test
public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
final PCEPObjectiveFunctionObjectParser parser =
- new PCEPObjectiveFunctionObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ new PCEPObjectiveFunctionObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin"));
@Test
public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
final PCEPGlobalConstraintsObjectParser parser =
- new PCEPGlobalConstraintsObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ new PCEPGlobalConstraintsObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin"));
@Test
public void testIgnoreUknownObject() throws PCEPDeserializerException {
final Object object =
- this.ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
+ ctx.getObjectHandlerRegistry().parseObject(35, 1, new ObjectHeaderImpl(false, false), null);
assertNull(object);
}
@Test
public void testUnrecognizedObjectType() throws PCEPDeserializerException {
final Object object =
- this.ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
+ ctx.getObjectHandlerRegistry().parseObject(2, 2, new ObjectHeaderImpl(true, true), null);
assertNotNull(object);
assertTrue(object instanceof UnknownObject);
assertEquals(PCEPErrors.UNRECOGNIZED_OBJ_TYPE, ((UnknownObject) object).getError());
@Test
public void testUnrecognizedObjectClass() throws PCEPDeserializerException {
- final Object object = this.ctx.getObjectHandlerRegistry()
+ final Object object = ctx.getObjectHandlerRegistry()
.parseObject(35, 1, new ObjectHeaderImpl(true, true), null);
assertNotNull(object);
assertTrue(object instanceof UnknownObject);
@Test
public void testLspaObjectSerializerDefence() throws IOException {
- final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin"));
@Test
public void testEmptyEroObject() throws PCEPDeserializerException {
- final Object object = this.ctx.getObjectHandlerRegistry().parseObject(7, 1,
+ final Object object = ctx.getObjectHandlerRegistry().parseObject(7, 1,
new ObjectHeaderImpl(true, true), Unpooled.EMPTY_BUFFER);
assertNotNull(object);
assertTrue(object instanceof Ero);
assertNull(eroObject.getSubobject());
final ByteBuf buffer = Unpooled.buffer();
- this.ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
+ ctx.getObjectHandlerRegistry().serializeObject(eroObject, buffer);
final byte[] expected = {0x07, 0x13, 0x00, 0x04};
assertArrayEquals(expected, ByteArray.getAllBytes(buffer));
}
/* enterprise specific information */
0x00, 0x00, 0x00, 0x05
};
- final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(tlvRegistry, viTlvRegistry);
final ByteBuf result = Unpooled.wrappedBuffer(closeBytes);
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
/* monitoring-id=16 */
0x00, 0x00, 0x00, 0x10
};
- final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ final PCEPMonitoringObjectParser parser = new PCEPMonitoringObjectParser(tlvRegistry, viTlvRegistry);
final Monitoring monitoring = new MonitoringBuilder()
.setMonitoringId(Uint32.valueOf(16L))
.setFlags(new Flags(false, false, true, false, false))
0x0, 0x1C, 0x0, 0x4, 0x0, 0x0, 0x0, 0x0 };
final PCEPRequestParameterObjectParser parser
- = new PCEPRequestParameterObjectParser(this.tlvRegistry, this.viTlvRegistry);
+ = new PCEPRequestParameterObjectParser(tlvRegistry, viTlvRegistry);
final RpBuilder builder = new RpBuilder()
.setProcessingRule(false)
.setIgnore(false)
};
final BranchNodeListObjectParser parser
- = new BranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+ = new BranchNodeListObjectParser(ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(expected);
final BranchNodeListBuilder builder = new BranchNodeListBuilder();
};
final NonBranchNodeListObjectParser parser
- = new NonBranchNodeListObjectParser(this.ctx.getEROSubobjectHandlerRegistry());
+ = new NonBranchNodeListObjectParser(ctx.getEROSubobjectHandlerRegistry());
final ByteBuf result = Unpooled.wrappedBuffer(expected);
final NonBranchNodeListBuilder builder = new NonBranchNodeListBuilder();
builder.setProcessingRule(false);
builder.setIgnore(false);
final Ipv4DestinationCase dest = new Ipv4DestinationCaseBuilder()
- .setDestinationIpv4Address(Collections.singletonList(new Ipv4AddressNoZone("127.0.0.1")))
+ .setDestinationIpv4Address(Set.of(new Ipv4AddressNoZone("127.0.0.1")))
.build();
builder.setDestination(dest);
builder.setProcessingRule(false);
builder.setIgnore(false);
final Ipv6DestinationCase dest = new Ipv6DestinationCaseBuilder()
- .setDestinationIpv6Address(Collections.singletonList(new Ipv6AddressNoZone("::1")))
+ .setDestinationIpv6Address(Set.of(new Ipv6AddressNoZone("::1")))
.build();
builder.setDestination(dest);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.ArrayList;
-import java.util.List;
import org.junit.Test;
import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
import org.opendaylight.protocol.pcep.parser.tlv.NoPathVectorTlvParser;
@Test
public void testOFListTlv() throws PCEPDeserializerException {
final OFListTlvParser parser = new OFListTlvParser();
- final List<OfId> ids = new ArrayList<>();
- ids.add(new OfId(Uint16.valueOf(0x1234)));
- ids.add(new OfId(Uint16.valueOf(0x5678)));
- final OfList tlv = new OfListBuilder().setCodes(ids).build();
+ final OfList tlv = new OfListBuilder()
+ // Predictable order
+ .setCodes(ImmutableSet.of(new OfId(Uint16.valueOf(0x1234)), new OfId(Uint16.valueOf(0x5678))))
+ .build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(OF_LIST_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-import com.google.common.collect.Lists;
+import com.google.common.collect.ImmutableSet;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.protocol.pcep.impl.TestVendorInformationTlvParser.TestEnterpriseSpecificInformation;
@Before
public void setUp() {
- this.ctx = new SimplePCEPExtensionProviderContext();
- this.act = new BaseParserExtensionActivator();
- this.viObjAct = new TestVendorInformationActivator();
- this.act.start(this.ctx);
- this.viObjAct.start(this.ctx);
- this.objectRegistry = this.ctx.getObjectHandlerRegistry();
+ ctx = new SimplePCEPExtensionProviderContext();
+ act = new BaseParserExtensionActivator();
+ viObjAct = new TestVendorInformationActivator();
+ act.start(ctx);
+ viObjAct.start(ctx);
+ objectRegistry = ctx.getObjectHandlerRegistry();
final RpBuilder rpBuilder = new RpBuilder()
.setProcessingRule(true)
.setIgnore(false)
.setRequestId(new RequestId(Uint32.TEN))
.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.rp
.object.rp.TlvsBuilder().build());
- this.rpTrue = rpBuilder.build();
- this.rpFalse = rpBuilder.setProcessingRule(false).build();
+ rpTrue = rpBuilder.build();
+ rpFalse = rpBuilder.setProcessingRule(false).build();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object
.OpenBuilder openBuilder = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types
.rev181109.open.object.OpenBuilder()
.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
.open.object.open.TlvsBuilder().build());
// TODO get rid of previous superfluous openBuilder
- this.open = openBuilder.build();
+ open = openBuilder.build();
- this.noPath = new NoPathBuilder()
+ noPath = new NoPathBuilder()
.setProcessingRule(false)
.setIgnore(false)
.setNatureOfIssue(Uint8.ZERO)
.pcrep.message.pcrep.message.replies.result.failure._case.no.path.TlvsBuilder().build())
.build();
- this.lspa = new LspaBuilder()
+ lspa = new LspaBuilder()
.setProcessingRule(false)
.setIgnore(false)
.setLocalProtectionDesired(false)
.lspa.object.lspa.TlvsBuilder().build())
.build();
- this.metrics = new MetricsBuilder()
+ metrics = new MetricsBuilder()
.setMetric(new MetricBuilder()
.setIgnore(false)
.setProcessingRule(false)
.build())
.build();
- this.eroASSubobject = new AsNumberCaseBuilder()
+ eroASSubobject = new AsNumberCaseBuilder()
.setAsNumber(new AsNumberBuilder()
.setAsNumber(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715
.AsNumber(Uint32.valueOf(0xFFFF)))
iroBuilder.setIgnore(false);
iroBuilder.setProcessingRule(false);
final List<Subobject> iroSubs = new ArrayList<>();
- iroSubs.add(new SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
+ iroSubs.add(new SubobjectBuilder().setSubobjectType(eroASSubobject).setLoose(false).build());
iroBuilder.setSubobject(iroSubs);
- this.iro = iroBuilder.build();
+ iro = iroBuilder.build();
final EroBuilder eroBuilder = new EroBuilder();
eroBuilder.setIgnore(false);
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit.route
.object.ero.Subobject> eroSubs = new ArrayList<>();
eroSubs.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.explicit
- .route.object.ero.SubobjectBuilder().setSubobjectType(this.eroASSubobject).setLoose(false).build());
+ .route.object.ero.SubobjectBuilder().setSubobjectType(eroASSubobject).setLoose(false).build());
eroBuilder.setSubobject(eroSubs);
- this.ero = eroBuilder.build();
+ ero = eroBuilder.build();
- this.of = new OfBuilder()
+ of = new OfBuilder()
.setIgnore(false)
.setProcessingRule(false)
.setCode(new OfId(Uint16.ZERO))
.object.of.TlvsBuilder().build())
.build();
- this.endpoints = new EndpointsObjBuilder()
+ endpoints = new EndpointsObjBuilder()
.setIgnore(false)
.setProcessingRule(true)
.setAddressFamily(new Ipv4CaseBuilder()
.build())
.build();
- this.svec = new SvecBuilder()
+ svec = new SvecBuilder()
.setIgnore(false)
.setProcessingRule(false)
.setLinkDiverse(false)
.setSrlgDiverse(false)
.setLinkDirectionDiverse(false)
.setPartialPathDiverse(false)
- .setRequestsIds(Lists.newArrayList(new RequestId(Uint32.ONE)))
+ .setRequestsIds(Set.of(new RequestId(Uint32.ONE)))
.build();
- this.viObjects = new ArrayList<>();
+ viObjects = new ArrayList<>();
final TestEnterpriseSpecificInformation esInfo = new TestEnterpriseSpecificInformation(5);
final VendorInformationObject viObj = new VendorInformationObjectBuilder()
.setEnterpriseNumber(new EnterpriseNumber(Uint32.ZERO))
.setEnterpriseSpecificInformation(esInfo)
.build();
- this.viObjects.add(viObj);
+ viObjects.add(viObj);
- this.monitoring = new MonitoringBuilder()
+ monitoring = new MonitoringBuilder()
.setMonitoringId(Uint32.valueOf(100))
.setFlags(new Flags(false, false, false, false, false))
.setTlvs(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
.monitoring.object.monitoring.TlvsBuilder().build()).build();
- this.pccIdReq = new PccIdReqBuilder()
+ pccIdReq = new PccIdReqBuilder()
.setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.1")))
.build();
- this.pceId = new PceIdBuilder()
+ pceId = new PceIdBuilder()
.setIpAddress(new IpAddressNoZone(new Ipv4AddressNoZone("127.0.0.2")))
.build();
- this.procTime = new ProcTimeBuilder()
+ procTime = new ProcTimeBuilder()
.setEstimated(false)
.setCurrentProcTime(Uint32.ONE)
.setMinProcTime(Uint32.TWO)
.setAverageProcTime(Uint32.valueOf(4))
.setVarianceProcTime(Uint32.valueOf(5))
.build();
- this.overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
+ overload = new OverloadBuilder().setDuration(Uint16.valueOf(120)).build();
}
@Test
public void testOpenMsg() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin"));
- final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.ctx.getObjectHandlerRegistry());
+ final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(ctx.getObjectHandlerRegistry());
final OpenMessageBuilder builder = new OpenMessageBuilder();
final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object
builder.setOpen(b.build());
assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
@Test
public void testKeepAliveMsg() throws PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 2, 0, 4 });
- final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
+ final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(objectRegistry);
final KeepaliveBuilder builder = new KeepaliveBuilder()
.setKeepaliveMessage(new KeepaliveMessageBuilder().build());
assertEquals(
- builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
+ builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
@Test
public void testStartTLSMsg() throws Exception {
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 20, 0, 4 });
- final PCEPStartTLSMessageParser parser = new PCEPStartTLSMessageParser(this.objectRegistry);
+ final PCEPStartTLSMessageParser parser = new PCEPStartTLSMessageParser(objectRegistry);
final StarttlsBuilder builder = new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build());
- assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4),
- Collections.emptyList()));
+ assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
final ByteBuf result =
Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin"));
- final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
+ final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(objectRegistry);
final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder()
.setCClose(new CCloseBuilder()
.setIgnore(false)
.build())
.build());
- assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4),
- Collections.emptyList()));
+ assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
@Test
public void testRequestMsg() throws IOException, PCEPDeserializerException {
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder rBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder.setRp(this.rpTrue);
+ rBuilder.setRp(rpTrue);
rBuilder.setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder()
- .setEndpointsObj(this.endpoints).build()).build());
+ .setEndpointsObj(endpoints).build()).build());
reqs1.add(rBuilder.build());
builder.setRequests(reqs1);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCEPRequestMessage1.bin"));
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
.pcreq.message.RequestsBuilder rBuilder1 =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder1.setRp(this.rpTrue);
+ rBuilder1.setRp(rpTrue);
final P2pBuilder p2pBuilder = new P2pBuilder()
- .setEndpointsObj(this.endpoints)
- .setMetrics(Lists.newArrayList(this.metrics))
- .setIro(this.iro);
+ .setEndpointsObj(endpoints)
+ .setMetrics(List.of(metrics))
+ .setIro(iro);
rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
reqs2.add(rBuilder1.build());
builder.setRequests(reqs2)
- .setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
- .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
+ .setSvec(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(svec).build()));
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
.pcreq.message.RequestsBuilder rBuilder2 =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder2.setRp(new RpBuilder(this.rpTrue).setP2mp(true).build());
+ rBuilder2.setRp(new RpBuilder(rpTrue).setP2mp(true).build());
final EndpointsObjBuilder epBuilder = new EndpointsObjBuilder()
.setIgnore(false)
.setProcessingRule(true)
.setP2mpIpv4(new P2mpIpv4Builder()
.setP2mpLeaves(P2mpLeaves.NewLeavesToAdd)
.setSourceIpv4Address(new Ipv4AddressNoZone("255.255.255.255"))
- .setDestinationIpv4Address(Arrays.asList(new Ipv4AddressNoZone("255.255.255.254"),
+ .setDestinationIpv4Address(ImmutableSet.of(new Ipv4AddressNoZone("255.255.255.254"),
new Ipv4AddressNoZone("255.255.255.253")))
.build()).build());
final P2mpBuilder p2mpBuilder = new P2mpBuilder();
- p2mpBuilder.setEndpointRroPair(Collections.singletonList(new EndpointRroPairBuilder()
+ p2mpBuilder.setEndpointRroPair(List.of(new EndpointRroPairBuilder()
.setEndpointsObj(epBuilder.build())
- .setRros(Arrays.asList(new RrosBuilder()
+ .setRros(List.of(new RrosBuilder()
.setRouteObject(new ReportedRouteObjectCaseBuilder()
.setRro(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109
.reported.route.object.RroBuilder()
.setIgnore(false)
.setProcessingRule(true)
- .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .setSubobject(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.pcep.types.rev181109.reported.route.object.rro.SubobjectBuilder()
.setProtectionAvailable(false)
.setProtectionInUse(false)
.setSrro(new SrroBuilder()
.setIgnore(false)
.setProcessingRule(true)
- .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
+ .setSubobject(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns
.yang.pcep.types.rev181109.secondary.reported.route.object.srro.SubobjectBuilder()
.setProtectionInUse(false)
.setProtectionAvailable(false)
.setBranchNodeList(new BranchNodeListBuilder()
.setIgnore(false)
.setProcessingRule(true)
- .setSubobject(Arrays.asList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ .setSubobject(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.pcep.types.rev181109.bnc.SubobjectBuilder()
.setLoose(false)
.setIpPrefix(new IpPrefix(new Ipv4Prefix("255.255.255.252/32")))
builder.setRequests(reqs3).setSvec(null);
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
try {
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(new PcreqMessageBuilder()
- .setRequests(Collections.emptyList()).build()).build(), null);
+ .setRequests(List.of()).build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Requests cannot be null or empty.", e.getMessage());
public void testReplyMsg() throws IOException, PCEPDeserializerException {
// only RP
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder repliesBuilder = new RepliesBuilder();
final List<Replies> replies1 = new ArrayList<>();
- repliesBuilder.setRp(this.rpTrue);
+ repliesBuilder.setRp(rpTrue);
replies1.add(repliesBuilder.build());
builder.setReplies(replies1);
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.1.bin"));
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.2.bin"));
final List<Replies> replies2 = new ArrayList<>();
repliesBuilder = new RepliesBuilder();
- repliesBuilder.setRp(this.rpTrue);
+ repliesBuilder.setRp(rpTrue);
replies2.add(repliesBuilder.build());
final RepliesBuilder repliesBuilder2 = new RepliesBuilder();
- repliesBuilder2.setRp(this.rpTrue);
- repliesBuilder2.setResult(new FailureCaseBuilder().setNoPath(this.noPath).build());
+ repliesBuilder2.setRp(rpTrue);
+ repliesBuilder2.setResult(new FailureCaseBuilder().setNoPath(noPath).build());
replies2.add(repliesBuilder2.build());
builder.setReplies(replies2);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.3.bin"));
final List<Replies> replies3 = new ArrayList<>();
repliesBuilder = new RepliesBuilder();
- repliesBuilder.setRp(this.rpTrue);
- repliesBuilder.setResult(new FailureCaseBuilder().setNoPath(this.noPath).setLspa(this.lspa)
- .setMetrics(Lists.newArrayList(this.metrics)).setIro(this.iro).build());
+ repliesBuilder.setRp(rpTrue);
+ repliesBuilder.setResult(new FailureCaseBuilder().setNoPath(noPath).setLspa(lspa)
+ .setMetrics(List.of(metrics)).setIro(iro).build());
replies3.add(repliesBuilder.build());
builder.setReplies(replies3);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.5.bin"));
final List<Replies> replies4 = new ArrayList<>();
repliesBuilder = new RepliesBuilder();
- repliesBuilder.setRp(this.rpTrue);
+ repliesBuilder.setRp(rpTrue);
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder = new PathsBuilder()
- .setEro(this.ero)
- .setLspa(this.lspa)
- .setMetrics(Lists.newArrayList(this.metrics))
- .setIro(this.iro)
- .setOf(this.of);
+ .setEro(ero)
+ .setLspa(lspa)
+ .setMetrics(List.of(metrics))
+ .setIro(iro)
+ .setOf(of);
paths.add(paBuilder.build());
repliesBuilder.setResult(new SuccessCaseBuilder()
.setSuccess(new SuccessBuilder().setPaths(paths).build()).build()).build();
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
try {
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder()
- .setReplies(Collections.emptyList()).build()).build(), null);
+ .setReplies(List.of()).build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Replies cannot be null or empty.", e.getMessage());
innerNot.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
final List<Rps> rps = new ArrayList<>();
- rps.add(new RpsBuilder().setRp(this.rpFalse).build());
+ rps.add(new RpsBuilder().setRp(rpFalse).build());
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCNtf.5.bin"));
- final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(this.objectRegistry);
+ final PCEPNotificationMessageParser parser = new PCEPNotificationMessageParser(objectRegistry);
final PcntfMessageBuilder builder = new PcntfMessageBuilder();
final List<Notifications> nots = new ArrayList<>();
innerNot1.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf
.message.pcntf.message.notifications.NotificationsBuilder().setCNotification(cn1).build());
final List<Rps> rps1 = new ArrayList<>();
- rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
- rps1.add(new RpsBuilder().setRp(this.rpFalse).build());
+ rps1.add(new RpsBuilder().setRp(rpFalse).build());
+ rps1.add(new RpsBuilder().setRp(rpFalse).build());
b.setNotifications(innerNot1);
b.setRps(rps1);
builder.setNotifications(nots);
assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
ErrorObject error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false)
.setType(Uint8.valueOf(3)).setValue(Uint8.ONE).build();
- final PCEPErrorMessageParser parser = new PCEPErrorMessageParser(this.ctx.getObjectHandlerRegistry());
+ final PCEPErrorMessageParser parser = new PCEPErrorMessageParser(ctx.getObjectHandlerRegistry());
List<Errors> innerErr = new ArrayList<>();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message
.pcerr.message.error.type.request._case.request.Rps> rps = new ArrayList<>();
rps.add(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message
- .pcerr.message.error.type.request._case.request.RpsBuilder().setRp(this.rpFalse).build());
+ .pcerr.message.error.type.request._case.request.RpsBuilder().setRp(rpFalse).build());
innerErr.add(new ErrorsBuilder().setErrorObject(error1).build());
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCErr.5.bin"));
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
builder.setErrors(innerErr);
builder.setErrorType(
- new SessionCaseBuilder().setSession(new SessionBuilder().setOpen(this.open).build()).build());
+ new SessionCaseBuilder().setSession(new SessionBuilder().setOpen(open).build()).build());
assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
}
try {
parser.serializeMessage(new PcerrBuilder().setPcerrMessage(new PcerrMessageBuilder()
- .setErrors(Collections.emptyList()).build()).build(), null);
+ .setErrors(List.of()).build()).build(), null);
fail();
} catch (final IllegalArgumentException e) {
assertEquals("Errors should not be empty.", e.getMessage());
@Test
public void testReqMsgWithVendorInfoObjects() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.7.bin"));
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.message.RequestsBuilder rBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder.setRp(this.rpTrue);
- rBuilder.setVendorInformationObject(this.viObjects);
+ rBuilder.setRp(rpTrue);
+ rBuilder.setVendorInformationObject(viObjects);
final SegmentComputationBuilder sBuilder = new SegmentComputationBuilder();
sBuilder.setP2p(
- new P2pBuilder().setEndpointsObj(this.endpoints).setVendorInformationObject(this.viObjects).build());
+ new P2pBuilder().setEndpointsObj(endpoints).setVendorInformationObject(viObjects).build());
rBuilder.setSegmentComputation(sBuilder.build());
reqs1.add(rBuilder.build());
- builder.setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
- .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec)
- .setVendorInformationObject(this.viObjects).build()));
+ builder.setSvec(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(svec)
+ .setVendorInformationObject(viObjects).build()));
builder.setRequests(reqs1);
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
@Test
public void testRepMsgWithVendorInforObjects() throws IOException, PCEPDeserializerException {
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder repliesBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.6.bin"));
final List<Replies> replies = new ArrayList<>();
repliesBuilder = new RepliesBuilder()
- .setRp(this.rpTrue)
- .setVendorInformationObject(this.viObjects);
+ .setRp(rpTrue)
+ .setVendorInformationObject(viObjects);
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder = new PathsBuilder();
- paBuilder.setEro(this.ero);
+ paBuilder.setEro(ero);
paths.add(paBuilder.build());
repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths)
- .setVendorInformationObject(this.viObjects).build()).build()).build();
+ .setVendorInformationObject(viObjects).build()).build()).build();
replies.add(repliesBuilder.build());
builder.setReplies(replies);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
@Test
public void testMonRepMsg() throws PCEPDeserializerException, IOException {
- final PCEPMonitoringReplyMessageParser parser = new PCEPMonitoringReplyMessageParser(this.objectRegistry);
+ final PCEPMonitoringReplyMessageParser parser = new PCEPMonitoringReplyMessageParser(objectRegistry);
final PcmonrepMessageBuilder builder = new PcmonrepMessageBuilder();
- builder.setMonitoring(this.monitoring)
+ builder.setMonitoring(monitoring)
.setMonitoringMetricsList(new GeneralMetricsListBuilder()
- .setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build())).build());
+ .setMetricPce(List.of(new MetricPceBuilder().setPceId(pceId).build())).build());
final byte[] msgBytes = {
0x20, 0x09, 0x00, 0x18,
ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
assertEquals(
new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(),
- parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
+ parser.parseMessage(result.slice(4, result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
- builder.setMonitoring(this.monitoring);
- builder.setPccIdReq(this.pccIdReq);
+ builder.setMonitoring(monitoring);
+ builder.setPccIdReq(pccIdReq);
final SpecificMetricsBuilder smBuilder = new SpecificMetricsBuilder();
- smBuilder.setRp(this.rpTrue);
+ smBuilder.setRp(rpTrue);
final List<MetricPce> metricPces = new ArrayList<>();
- metricPces.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId)
- .setProcTime(this.procTime).build());
- metricPces.add(new MetricPceBuilder().setPceId(this.pceId).setProcTime(this.procTime).build());
+ metricPces.add(new MetricPceBuilder().setOverload(overload).setPceId(pceId)
+ .setProcTime(procTime).build());
+ metricPces.add(new MetricPceBuilder().setPceId(pceId).setProcTime(procTime).build());
smBuilder.setMetricPce(metricPces);
final SpecificMetricsBuilder smBuilder2 = new SpecificMetricsBuilder();
final List<MetricPce> metricPces2 = new ArrayList<>();
- smBuilder2.setRp(this.rpTrue);
- metricPces2.add(new MetricPceBuilder().setOverload(this.overload).setPceId(this.pceId).build());
+ smBuilder2.setRp(rpTrue);
+ metricPces2.add(new MetricPceBuilder().setOverload(overload).setPceId(pceId).build());
smBuilder2.setMetricPce(metricPces2);
builder.setMonitoringMetricsList(new SpecificMetricsListBuilder()
- .setSpecificMetrics(Lists.newArrayList(smBuilder.build(), smBuilder2.build())).build());
+ .setSpecificMetrics(List.of(smBuilder.build(), smBuilder2.build())).build());
result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCMonRep.bin"));
assertEquals(
new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonrepBuilder().setPcmonrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
@Test
public void testRepWithMonitoring() throws IOException, PCEPDeserializerException {
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder repliesBuilder = new RepliesBuilder();
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRepMon.5.bin"));
final List<Replies> replies4 = new ArrayList<>();
repliesBuilder = new RepliesBuilder()
- .setRp(this.rpTrue)
- .setMonitoring(this.monitoring)
- .setPccIdReq(this.pccIdReq)
- .setMetricPce(Lists.newArrayList(new MetricPceBuilder().setPceId(this.pceId).build()));
+ .setRp(rpTrue)
+ .setMonitoring(monitoring)
+ .setPccIdReq(pccIdReq)
+ .setMetricPce(List.of(new MetricPceBuilder().setPceId(pceId).build()));
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder = new PathsBuilder()
- .setEro(this.ero)
- .setLspa(this.lspa)
- .setMetrics(Lists.newArrayList(this.metrics))
- .setIro(this.iro)
- .setOf(this.of);
+ .setEro(ero)
+ .setLspa(lspa)
+ .setMetrics(List.of(metrics))
+ .setIro(iro)
+ .setOf(of);
paths.add(paBuilder.build());
repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build())
.build()).build();
builder.setReplies(replies4);
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
public void testReqWithMonitoring() throws IOException, PCEPDeserializerException {
final ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCReq.8.bin"));
- final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(this.objectRegistry);
+ final PCEPRequestMessageParser parser = new PCEPRequestMessageParser(objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.message.RequestsBuilder rBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder.setRp(this.rpTrue)
+ rBuilder.setRp(rpTrue)
.setSegmentComputation(new SegmentComputationBuilder().setP2p(new P2pBuilder()
- .setEndpointsObj(this.endpoints).build()).build());
+ .setEndpointsObj(endpoints).build()).build());
reqs1.add(rBuilder.build());
final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder()
- .setMonitoring(this.monitoring)
- .setPccIdReq(this.pccIdReq)
- .setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
+ .setMonitoring(monitoring)
+ .setPccIdReq(pccIdReq)
+ .setPceIdList(List.of(new PceIdListBuilder().setPceId(pceId).build()));
builder.setMonitoringRequest(monReqBuilder.build()).setRequests(reqs1);
assertEquals(new PcreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcreqBuilder().setPcreqMessage(builder.build()).build(), buf);
@Test
public void testMonReqMsg() throws PCEPDeserializerException, IOException {
- final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(this.objectRegistry);
+ final PCEPMonitoringRequestMessageParser parser = new PCEPMonitoringRequestMessageParser(objectRegistry);
final PcreqMessageBuilder builder = new PcreqMessageBuilder();
final MonitoringRequestBuilder monReqBuilder = new MonitoringRequestBuilder()
- .setMonitoring(this.monitoring)
- .setPceIdList(Lists.newArrayList(new PceIdListBuilder().setPceId(this.pceId).build()));
+ .setMonitoring(monitoring)
+ .setPceIdList(List.of(new PceIdListBuilder().setPceId(pceId).build()));
builder.setMonitoringRequest(monReqBuilder.build());
final byte[] msgBytes = {
0x20, 0x08, 0x00, 0x18,
};
ByteBuf result = Unpooled.wrappedBuffer(msgBytes);
assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
.message.RequestsBuilder rBuilder1 =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message
.pcreq.message.RequestsBuilder();
- rBuilder1.setRp(this.rpTrue);
+ rBuilder1.setRp(rpTrue);
final P2pBuilder p2pBuilder = new P2pBuilder()
- .setEndpointsObj(this.endpoints)
- .setMetrics(Lists.newArrayList(this.metrics))
- .setIro(this.iro);
+ .setEndpointsObj(endpoints)
+ .setMetrics(List.of(metrics))
+ .setIro(iro);
rBuilder1.setSegmentComputation(new SegmentComputationBuilder().setP2p(p2pBuilder.build()).build());
reqs2.add(rBuilder1.build());
builder.setRequests(reqs2)
- .setSvec(Lists.newArrayList(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
- .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(this.svec).build()));
- monReqBuilder.setMonitoring(this.monitoring).setPccIdReq(this.pccIdReq);
- final PceIdList pceIdList = new PceIdListBuilder().setPceId(this.pceId).build();
- monReqBuilder.setPceIdList(Lists.newArrayList(pceIdList, pceIdList));
+ .setSvec(List.of(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
+ .types.rev181109.pcreq.message.pcreq.message.SvecBuilder().setSvec(svec).build()));
+ monReqBuilder.setMonitoring(monitoring).setPccIdReq(pccIdReq);
+ final PceIdList pceIdList = new PceIdListBuilder().setPceId(pceId).build();
+ monReqBuilder.setPceIdList(List.of(pceIdList, pceIdList));
builder.setMonitoringRequest(monReqBuilder.build());
assertEquals(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcmonreqBuilder().setPcreqMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
public void testReplyMsgWithTwoEros() throws IOException, PCEPDeserializerException {
// Success Reply with two EROs: the first one is followed by Bandwidth Object and one Metric Object
- final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(this.objectRegistry);
+ final PCEPReplyMessageParser parser = new PCEPReplyMessageParser(objectRegistry);
final PcrepMessageBuilder builder = new PcrepMessageBuilder();
RepliesBuilder repliesBuilder = new RepliesBuilder();
repliesBuilder = new RepliesBuilder();
- repliesBuilder.setRp(this.rpTrue);
+ repliesBuilder.setRp(rpTrue);
final List<Paths> paths = new ArrayList<>();
final PathsBuilder paBuilder1 = new PathsBuilder()
- .setEro(this.ero)
+ .setEro(ero)
.setBandwidth(bwBuilder.build())
- .setMetrics(Lists.newArrayList(this.metrics));
+ .setMetrics(List.of(metrics));
paths.add(paBuilder1.build());
final PathsBuilder paBuilder2 = new PathsBuilder();
- paBuilder2.setEro(this.ero);
+ paBuilder2.setEro(ero);
paths.add(paBuilder2.build());
repliesBuilder.setResult(new SuccessCaseBuilder().setSuccess(new SuccessBuilder().setPaths(paths).build())
.build()).build();
ByteBuf result = Unpooled.wrappedBuffer(ByteArray.fileToBytes("src/test/resources/PCRep.7.bin"));
assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result.slice(4,
- result.readableBytes() - 4), Collections.emptyList()));
+ result.readableBytes() - 4), List.of()));
ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
assertArrayEquals(result.array(), buf.array());
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
</dependencies>
</project>
import static java.util.Objects.requireNonNull;
-import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.List;
import org.opendaylight.algo.PathComputationAlgorithm;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.Requests;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcreq.message.pcreq.message.requests.segment.computation.P2p;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private static PathConstraints getConstraints(final EndpointsObj endpoints, final Bandwidth bandwidth,
final ClassType classType, final List<Metrics> metrics, final boolean segmentRouting) {
ConstraintsBuilder ctsBuilder = new ConstraintsBuilder();
- Float convert;
/* Set Metrics if any */
if (metrics != null) {
for (Metrics metric : metrics) {
- convert = ByteBuffer.wrap(metric.getMetric().getValue().getValue()).getFloat();
+ Float convert = ByteBuffer.wrap(metric.getMetric().getValue().getValue()).getFloat();
final long value = convert.longValue();
/* Skip Metric with value equal to 0 */
if (value == 0) {
/* Set Bandwidth and Class Type */
if (bandwidth != null) {
- convert = ByteBuffer.wrap(bandwidth.getBandwidth().getValue()).getFloat();
+ Float convert = ByteBuffer.wrap(bandwidth.getBandwidth().getValue()).getFloat();
final long value = convert.longValue();
/* Skip Bandwidth with value equal to 0 */
if (value != 0) {
- ctsBuilder.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(value)));
+ // FIXME: correct rounding/truncation!
+ ctsBuilder.setBandwidth(new DecimalBandwidth(Decimal64.valueOf(2, value)));
if (classType != null) {
ctsBuilder.setClassType(classType.getClassType().getValue());
}
import static java.util.Objects.requireNonNull;
import com.google.common.collect.Iterables;
-import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Collection;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.server.rev220321.pcc.configured.lsp.configured.lsp.IntendedPathBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.server.rev220321.pcc.configured.lsp.configured.lsp.intended.path.ConstraintsBuilder;
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.ero.Subobject;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.lsp.attributes.Metrics;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.reported.route.object.Rro;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.SubobjectType;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Decimal64;
import org.opendaylight.yangtools.yang.common.Uint32;
import org.opendaylight.yangtools.yang.common.Uint8;
import org.slf4j.Logger;
private ListenerRegistration<PcepTopologyListener> listenerRegistration;
private final PathManagerProvider pathManager;
- public PcepTopologyListener(final DataBroker dataBroker, KeyedInstanceIdentifier<Topology, TopologyKey> topology,
- final PathManagerProvider pathManager) {
+ public PcepTopologyListener(final DataBroker dataBroker,
+ final KeyedInstanceIdentifier<Topology, TopologyKey> topology, final PathManagerProvider pathManager) {
requireNonNull(dataBroker);
requireNonNull(topology);
this.pathManager = requireNonNull(pathManager);
final InstanceIdentifier<Node> nodeTopology = topology.child(Node.class);
- this.listenerRegistration = dataBroker.registerDataTreeChangeListener(
+ listenerRegistration = dataBroker.registerDataTreeChangeListener(
DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, nodeTopology), this);
LOG.info("Registered PCE Server listener {} for Operational PCEP Topology {}",
listenerRegistration, topology.getKey().getTopologyId().getValue());
*/
@Override
public void close() {
- if (this.listenerRegistration != null) {
+ if (listenerRegistration != null) {
LOG.info("Unregistered PCE Server listener {} for Operational PCEP Topology", listenerRegistration);
- this.listenerRegistration.close();
- this.listenerRegistration = null;
+ listenerRegistration.close();
+ listenerRegistration = null;
}
}
* @param nodeId Node Identifier to which the modified children belongs to.
* @param lspMod List of Reported LSP modifications.
*/
- private void handleLspChange(NodeId nodeId, List<? extends DataObjectModification<? extends DataObject>> lspMod) {
- for (DataObjectModification<? extends DataObject> lsp : lspMod) {
+ private void handleLspChange(final NodeId nodeId, final List<DataObjectModification<?>> lspMod) {
+ for (DataObjectModification<?> lsp : lspMod) {
ReportedLsp rptLsp;
switch (lsp.getModificationType()) {
* @param nodeId Node Identifier to which the modified children belongs to.
* @param pccMod List of Path Computation Client modifications.
*/
- private void handlePccChange(NodeId nodeId, List<? extends DataObjectModification<? extends DataObject>> pccMod) {
- for (DataObjectModification<? extends DataObject> node : pccMod) {
+ private void handlePccChange(final NodeId nodeId, final List<DataObjectModification<?>> pccMod) {
+ for (DataObjectModification<?> node : pccMod) {
/* First, process PCC modification */
switch (node.getModificationType()) {
case DELETE:
* @param nodeId Node Identifier to which the modified children belongs to.
* @param node1Mod List of Node1 modifications.
*/
- private void handleNode1Change(NodeId nodeId, List<DataObjectModification<? extends DataObject>> node1Mod) {
- for (DataObjectModification<? extends DataObject> child : node1Mod) {
+ private void handleNode1Change(final NodeId nodeId, final List<DataObjectModification<?>> node1Mod) {
+ for (DataObjectModification<?> child : node1Mod) {
/* Then, look only to PathComputationClient.class modification */
- final List<DataObjectModification<? extends DataObject>> pccMod = child.getModifiedChildren()
+ final List<DataObjectModification<?>> pccMod = child.getModifiedChildren()
.stream().filter(mod -> mod.getDataType().equals(PathComputationClient.class))
.collect(Collectors.toList());
if (!pccMod.isEmpty()) {
: root.getDataAfter().getNodeId();
/* Look only to Node1.class modification */
- final List<DataObjectModification<? extends DataObject>> node1Mod =
- root.getModifiedChildren().stream()
+ final List<DataObjectModification<?>> node1Mod = root.getModifiedChildren().stream()
.filter(mod -> mod.getDataType().equals(Node1.class))
.collect(Collectors.toList());
if (!node1Mod.isEmpty()) {
*
* @return Path Description of the corresponding ERO SubObject.
*/
- private static PathDescription getSrPath(SrSubobject srObj, final AddressFamily af) {
+ private static PathDescription getSrPath(final SrSubobject srObj, final AddressFamily af) {
switch (af) {
case SrIpv4:
switch (srObj.getNaiType()) {
case Ipv4Adjacency:
return new PathDescriptionBuilder()
.setSid(srObj.getSid())
- .setIpv4(((IpAdjacency)(srObj).getNai()).getLocalIpAddress().getIpv4AddressNoZone())
- .setRemoteIpv4(((IpAdjacency)(srObj).getNai()).getRemoteIpAddress().getIpv4AddressNoZone())
+ .setIpv4(((IpAdjacency)srObj.getNai()).getLocalIpAddress().getIpv4AddressNoZone())
+ .setRemoteIpv4(((IpAdjacency)srObj.getNai()).getRemoteIpAddress().getIpv4AddressNoZone())
.build();
case Ipv4NodeId:
return new PathDescriptionBuilder()
.setSid(srObj.getSid())
- .setRemoteIpv4(((IpNodeId)(srObj).getNai()).getIpAddress().getIpv4AddressNoZone())
+ .setRemoteIpv4(((IpNodeId)srObj.getNai()).getIpAddress().getIpv4AddressNoZone())
.build();
default:
return null;
case Ipv6Adjacency:
return new PathDescriptionBuilder()
.setSid(srObj.getSid())
- .setIpv6(((IpAdjacency)(srObj).getNai()).getLocalIpAddress().getIpv6AddressNoZone())
- .setRemoteIpv6(((IpAdjacency)(srObj).getNai()).getRemoteIpAddress().getIpv6AddressNoZone())
+ .setIpv6(((IpAdjacency)srObj.getNai()).getLocalIpAddress().getIpv6AddressNoZone())
+ .setRemoteIpv6(((IpAdjacency)srObj.getNai()).getRemoteIpAddress().getIpv6AddressNoZone())
.build();
case Ipv6NodeId:
return new PathDescriptionBuilder()
.setSid(srObj.getSid())
- .setRemoteIpv6(((IpNodeId)(srObj).getNai()).getIpAddress().getIpv6AddressNoZone())
+ .setRemoteIpv6(((IpNodeId)srObj.getNai()).getIpAddress().getIpv6AddressNoZone())
.build();
default:
return null;
*
* @return Path Description of the corresponding ERO SubObject.
*/
- private static PathDescription getIpPath(IpPrefixCase ipc, final AddressFamily af) {
+ private static PathDescription getIpPath(final IpPrefixCase ipc, final AddressFamily af) {
switch (af) {
case Ipv4:
return new PathDescriptionBuilder().setRemoteIpv4(
*
* @return Path Description of the corresponding RRO SubObject.
*/
- private static PathDescription getIpPath(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
+ private static PathDescription getIpPath(final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang
.rsvp.rev150820._record.route.subobjects.subobject.type.IpPrefixCase ipc, final AddressFamily af) {
switch (af) {
case Ipv4:
* @return Path Description of the corresponding TE Path.
*/
private static List<PathDescription> getPathDescription(final Ero ero, final AddressFamily af) {
- final ArrayList<PathDescription> pathDesc = new ArrayList<PathDescription>();
- for (int i = 0; i < ero.getSubobject().size(); i++) {
- final SubobjectType sbt = ero.getSubobject().get(i).getSubobjectType();
+ final ArrayList<PathDescription> pathDesc = new ArrayList<>();
+ for (Subobject element : ero.getSubobject()) {
+ final SubobjectType sbt = element.getSubobjectType();
if (sbt instanceof SrSubobject) {
pathDesc.add(getSrPath((SrSubobject) sbt, af));
} else if (sbt instanceof IpPrefixCase) {
* @return Path Description of the corresponding TE Path.
*/
private static List<PathDescription> getPathDescription(final Rro rro, final AddressFamily af) {
- final ArrayList<PathDescription> pathDesc = new ArrayList<PathDescription>();
- for (int i = 0; i < rro.getSubobject().size(); i++) {
- final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820
- ._record.route.subobjects.SubobjectType sbt = rro.getSubobject().get(i).getSubobjectType();
+ final ArrayList<PathDescription> pathDesc = new ArrayList<>();
+ for (var element : rro.nonnullSubobject()) {
+ final var sbt = element.getSubobjectType();
if (sbt instanceof SrSubobject) {
pathDesc.add(getSrPath((SrSubobject) sbt, af));
} else if (sbt instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820
*
* @return new TE Path.
*/
- private static ConfiguredLsp getConfiguredLsp(ReportedLsp rl) {
+ private static ConfiguredLsp getConfiguredLsp(final ReportedLsp rl) {
/* New reported LSP is always the last Path in the List i.e. old Paths are place before */
Path path = Iterables.getLast(rl.getPath().values());
Float convert;
}
if (path.getBandwidth() != null) {
convert = ByteBuffer.wrap(path.getBandwidth().getBandwidth().getValue()).getFloat();
- cb.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(convert.longValue())));
+ cb.setBandwidth(new DecimalBandwidth(Decimal64.valueOf(2, convert.longValue())));
}
- if ((cb.getBandwidth() == null || cb.getBandwidth().getValue() == BigDecimal.ZERO)
+ if ((cb.getBandwidth() == null || cb.getBandwidth().getValue().equals(Decimal64.valueOf(2, 0)))
&& path.getReoptimizationBandwidth() != null) {
convert = ByteBuffer.wrap(path.getReoptimizationBandwidth().getBandwidth().getValue()).getFloat();
- cb.setBandwidth(new DecimalBandwidth(BigDecimal.valueOf(convert.longValue())));
+ cb.setBandwidth(new DecimalBandwidth(Decimal64.valueOf(2, convert.longValue())));
}
if (path.getMetrics() != null) {
for (Metrics metric: path.getMetrics()) {
*
* @return Path Type.
*/
- private static PathType getPathType(ReportedLsp rl) {
+ private static PathType getPathType(final ReportedLsp rl) {
/* New reported LSP is always the last Path in the List i.e. old Paths are place before */
final Path1 p1 = Iterables.getLast(rl.getPath().values()).augmentation(Path1.class);
if (!p1.getLsp().getDelegate()) {
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
import com.google.common.collect.Lists;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@Mock
private VendorInformationTlvRegistry viTlvRegistry;
- private class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
+ private static class Abs extends AbstractObjectWithTlvsParser<TlvsBuilder> {
protected Abs(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
super(tlvReg, viTlvReg, 0, 0);
@Before
public void setUp() throws PCEPDeserializerException {
- this.tlv = new OfListBuilder().setCodes(Collections.singletonList(new OfId(Uint16.TEN))).build();
- this.viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(EN).build();
- doNothing().when(this.viTlvRegistry).serializeVendorInformationTlv(any(VendorInformationTlv.class),
+ tlv = new OfListBuilder().setCodes(Set.of(new OfId(Uint16.TEN))).build();
+ viTlv = new VendorInformationTlvBuilder().setEnterpriseNumber(EN).build();
+ doNothing().when(viTlvRegistry).serializeVendorInformationTlv(any(VendorInformationTlv.class),
any(ByteBuf.class));
- doReturn(Optional.of(this.viTlv)).when(this.viTlvRegistry).parseVendorInformationTlv(EN,
+ doReturn(Optional.of(viTlv)).when(viTlvRegistry).parseVendorInformationTlv(EN,
Unpooled.wrappedBuffer(new byte[0]));
- doNothing().when(this.tlvRegistry).serializeTlv(any(Tlv.class), any(ByteBuf.class));
- doReturn(this.tlv).when(this.tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
+ doNothing().when(tlvRegistry).serializeTlv(any(Tlv.class), any(ByteBuf.class));
+ doReturn(tlv).when(tlvRegistry).parseTlv(4, Unpooled.wrappedBuffer(new byte[] { 5, 6 }));
}
@Test
public void testParseTlvs() throws PCEPDeserializerException {
- Abs abs = new Abs(this.tlvRegistry, this.viTlvRegistry);
+ Abs abs = new Abs(tlvRegistry, viTlvRegistry);
ByteBuf buffer = Unpooled.buffer();
- abs.serializeTlv(this.tlv, buffer);
+ abs.serializeTlv(tlv, buffer);
- verify(this.tlvRegistry, only()).serializeTlv(any(Tlv.class), any(ByteBuf.class));
+ verify(tlvRegistry, only()).serializeTlv(any(Tlv.class), any(ByteBuf.class));
TlvsBuilder builder = new TlvsBuilder();
abs.parseTlvs(builder, Unpooled.wrappedBuffer(new byte[] { 0, 4, 0, 2, 5, 6, 0, 0 }));
- assertEquals(this.tlv, builder.getOfList());
+ assertEquals(tlv, builder.getOfList());
}
@Test
public void testParseVendorInformationTlv() throws PCEPDeserializerException {
- final Abs parser = new Abs(this.tlvRegistry, this.viTlvRegistry);
+ final Abs parser = new Abs(tlvRegistry, viTlvRegistry);
final ByteBuf buffer = Unpooled.buffer();
- parser.serializeVendorInformationTlvs(Lists.newArrayList(this.viTlv), buffer);
- verify(this.viTlvRegistry, only()).serializeVendorInformationTlv(any(VendorInformationTlv.class),
+ parser.serializeVendorInformationTlvs(Lists.newArrayList(viTlv), buffer);
+ verify(viTlvRegistry, only()).serializeVendorInformationTlv(any(VendorInformationTlv.class),
any(ByteBuf.class));
final TlvsBuilder tlvsBuilder = new TlvsBuilder();
parser.parseTlvs(tlvsBuilder, Unpooled.wrappedBuffer(
new byte[] { 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }));
- assertEquals(this.viTlv, tlvsBuilder.getVendorInformationTlv().get(0));
+ assertEquals(viTlv, tlvsBuilder.getVendorInformationTlv().get(0));
}
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>io.netty</groupId>
- <artifactId>netty-transport-native-epoll</artifactId>
- <classifier>linux-x86_64</classifier>
+ <artifactId>netty-transport-classes-epoll</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
- </dependency>
<!-- Test dependencies -->
<dependency>
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.concurrent.FutureListener;
import java.net.InetAddress;
import java.util.ArrayList;
this.requests.add(req);
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private void notifyRequests() {
for (final PCEPRequest r : this.requests) {
r.done(OperationResults.SUCCESS);
import static com.google.common.base.Verify.verifyNotNull;
import com.google.common.annotations.VisibleForTesting;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.InetSocketAddress;
import java.util.Collection;
import java.util.Map;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
final class PCEPStatefulPeerProposal extends AbstractRegistration implements PCEPPeerProposal {
- @VisibleForTesting
private abstract static class AbstractListener<D extends DataObject, V>
implements ClusteredDataTreeChangeListener<D> {
final Map<NodeId, V> map = new ConcurrentHashMap<>();
final Registration reg;
+ @SuppressFBWarnings(value = "MC_OVERRIDABLE_METHOD_CALL_IN_CONSTRUCTOR",
+ justification = "Stateless specializations in this nest")
AbstractListener(final DataBroker dataBroker, final @NonNull LogicalDatastoreType datastore,
final @NonNull InstanceIdentifier<D> wildcard) {
reg = dataBroker.registerDataTreeChangeListener(DataTreeIdentifier.create(datastore, wildcard), this);
stopFuture = SettableFuture.create();
applyConfiguration(null);
if (asyncOperation == null) {
- stopFuture.set(Empty.getInstance());
+ stopFuture.set(Empty.value());
}
return stopFuture;
}
@Holding("this")
private void finishOperation(final SettableFuture<Empty> future) {
asyncOperation = null;
- future.set(Empty.getInstance());
+ future.set(Empty.value());
// Process next configuration change if there is one
if (nextConfig != null) {
// Check if we are shutting down
if (stopFuture != null) {
- stopFuture.set(Empty.getInstance());
+ stopFuture.set(Empty.value());
}
}
return rb.build();
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private ListenableFuture<OperationResult> redelegate(final Lsp reportedLsp, final Srp srp, final Lsp lsp,
final UpdateLspArgs input) {
// the D bit that was reported decides the type of PCE message sent
@Override
@SuppressFBWarnings(value = "NP_NULL_ON_SOME_PATH", justification = "SB does not grok TYPE_USE")
-
public synchronized ListenableFuture<OperationResult> updateLsp(final UpdateLspArgs input) {
checkArgument(input != null && input.getName() != null && input.getNode() != null
&& input.getArguments() != null, MISSING_XML_TAG);
closeFuture = null;
}
LOG.trace("Topology {} instance {} closed", topologyId(), PCEPTopologySingleton.this);
- close.set(Empty.getInstance());
+ close.set(Empty.value());
}, MoreExecutors.directExecutor());
return close;
}
ret = closeFuture = SettableFuture.create();
if (instance == null) {
// ... and there is no instance, hence we need to also compete it immediate
- closeFuture.set(Empty.getInstance());
+ closeFuture.set(Empty.value());
}
} else {
// Service close is already going on, reuse that future
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeKey;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.TopologyTypesBuilder;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcError;
+import org.opendaylight.yangtools.yang.common.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
}
return RpcResultBuilder.<Void>failed()
- .withError(RpcError.ErrorType.RPC, "Failed to find session " + nodeId)
+ .withError(ErrorType.RPC, "Failed to find session " + nodeId)
.buildFuture();
}
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
+ <artifactId>org.osgi.framework</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.tracker</artifactId>
</dependency>
<!-- Testing dependencies -->
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
-import java.util.List;
import java.util.Optional;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import org.opendaylight.bgpcep.pcep.topology.spi.AbstractInstructionExecutor;
import org.opendaylight.bgpcep.programming.topology.TopologyProgrammingUtil;
return ret.get();
}
- private static Optional<AddressFamily> findIpv4(final List<IpAddress> srcs, final List<IpAddress> dsts) {
+ private static Optional<AddressFamily> findIpv4(final Set<IpAddress> srcs, final Set<IpAddress> dsts) {
for (final IpAddress sc : srcs) {
if (sc.getIpv4Address() != null) {
for (final IpAddress dc : dsts) {
return Optional.empty();
}
- private static Optional<AddressFamily> findIpv6(final List<IpAddress> srcs, final List<IpAddress> dsts) {
+ private static Optional<AddressFamily> findIpv6(final Set<IpAddress> srcs, final Set<IpAddress> dsts) {
for (final IpAddress sc : srcs) {
if (sc.getIpv6Address() != null) {
for (final IpAddress dc : dsts) {
@Override
protected ListenableFuture<OperationResult> invokeOperation() {
- try (ReadTransaction transaction = this.dataProvider.newReadOnlyTransaction()) {
+ try (ReadTransaction transaction = dataProvider.newReadOnlyTransaction()) {
AddLspInput addLspInput = createAddLspInput(transaction);
return Futures.transform(
- this.topologyService.addLsp(addLspInput),
+ topologyService.addLsp(addLspInput),
RpcResult::getResult, MoreExecutors.directExecutor());
}
}
private AddLspInput createAddLspInput(final ReadTransaction transaction) {
- final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(this.p2pTunnelInput);
- final TpReader dr = new TpReader(transaction, tii, this.p2pTunnelInput.getDestination());
+ final InstanceIdentifier<Topology> tii = TopologyProgrammingUtil.topologyForInput(p2pTunnelInput);
+ final TpReader dr = new TpReader(transaction, tii, p2pTunnelInput.getDestination());
final TerminationPoint dp = requireNonNull(dr.getTp());
- final TpReader sr = new TpReader(transaction, tii, this.p2pTunnelInput.getSource());
+ final TpReader sr = new TpReader(transaction, tii, p2pTunnelInput.getSource());
final TerminationPoint sp = requireNonNull(sr.getTp());
final Node sn = requireNonNull(sr.getNode());
final AddLspInputBuilder ab = new AddLspInputBuilder();
ab.setNode(requireNonNull(TunelProgrammingUtil.supportingNode(sn)));
- ab.setName(this.p2pTunnelInput.getSymbolicPathName());
+ ab.setName(p2pTunnelInput.getSymbolicPathName());
checkLinkIsnotExistent(tii, ab, transaction);
private Arguments buildArguments(final TerminationPoint sp, final TerminationPoint dp) {
final ArgumentsBuilder args = new ArgumentsBuilder();
- if (this.p2pTunnelInput.getBandwidth() != null) {
- args.setBandwidth(new BandwidthBuilder().setBandwidth(this.p2pTunnelInput.getBandwidth()).build());
+ if (p2pTunnelInput.getBandwidth() != null) {
+ args.setBandwidth(new BandwidthBuilder().setBandwidth(p2pTunnelInput.getBandwidth()).build());
}
- if (this.p2pTunnelInput.getClassType() != null) {
- args.setClassType(new ClassTypeBuilder().setClassType(this.p2pTunnelInput.getClassType()).build());
+ if (p2pTunnelInput.getClassType() != null) {
+ args.setClassType(new ClassTypeBuilder().setClassType(p2pTunnelInput.getClassType()).build());
}
args.setEndpointsObj(new EndpointsObjBuilder().setAddressFamily(buildAddressFamily(sp, dp)).build());
- args.setEro(TunelProgrammingUtil.buildEro(this.p2pTunnelInput.getExplicitHops()));
- args.setLspa(new LspaBuilder(this.p2pTunnelInput).build());
+ args.setEro(TunelProgrammingUtil.buildEro(p2pTunnelInput.getExplicitHops()));
+ args.setLspa(new LspaBuilder(p2pTunnelInput).build());
- final AdministrativeStatus adminStatus = this.p2pTunnelInput.augmentation(PcepCreateP2pTunnelInput1.class)
+ final AdministrativeStatus adminStatus = p2pTunnelInput.augmentation(PcepCreateP2pTunnelInput1.class)
.getAdministrativeStatus();
if (adminStatus != null) {
args.addAugmentation(new Arguments2Builder().setLsp(new LspBuilder()
TpReader(final ReadTransaction rt, final InstanceIdentifier<Topology> topo, final TpReference ref) {
this.rt = requireNonNull(rt);
- this.nii = topo.child(Node.class, new NodeKey(ref.getNode()));
- this.tii = this.nii.child(TerminationPoint.class, new TerminationPointKey(ref.getTp()));
+ nii = topo.child(Node.class, new NodeKey(ref.getNode()));
+ tii = nii.child(TerminationPoint.class, new TerminationPointKey(ref.getTp()));
}
private DataObject read(final InstanceIdentifier<?> id) {
try {
- return this.rt.read(LogicalDatastoreType.OPERATIONAL, id).get().get();
+ return rt.read(LogicalDatastoreType.OPERATIONAL, id).get().get();
} catch (final InterruptedException | ExecutionException e) {
throw new IllegalStateException("Failed to read data.", e);
}
}
Node getNode() {
- return (Node) read(this.nii);
+ return (Node) read(nii);
}
TerminationPoint getTp() {
- return (TerminationPoint) read(this.tii);
+ return (TerminationPoint) read(tii);
}
}
}
import static java.util.Objects.requireNonNull;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
}
private InstanceIdentifier<Link> linkForLsp(final LinkId linkId) {
- return this.target.child(Link.class, new LinkKey(linkId));
+ return target.child(Link.class, new LinkKey(linkId));
}
private SupportingNode createSupportingNode(final NodeId sni, final Boolean inControl) {
return new SupportingNodeBuilder()
.setNodeRef(sni)
- .withKey(new SupportingNodeKey(sni, this.source))
+ .withKey(new SupportingNodeKey(sni, source))
.addAugmentation(new SupportingNode1Builder().setPathComputationClient(
new PathComputationClientBuilder().setControlling(inControl).build()).build())
.build();
}
if (!have) {
final SupportingNode sn = createSupportingNode(k.getNodeId(), inControl);
- trans.put(LogicalDatastoreType.OPERATIONAL, this.target.child(Node.class, node.key()).child(
+ trans.put(LogicalDatastoreType.OPERATIONAL, target.child(Node.class, node.key()).child(
SupportingNode.class, sn.key()), sn);
}
}
private InstanceIdentifier<TerminationPoint> getIpTerminationPoint(final ReadWriteTransaction trans,
final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl)
throws ExecutionException, InterruptedException {
- final Topology topo = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).get().get();
+ final Topology topo = trans.read(LogicalDatastoreType.OPERATIONAL, target).get().get();
for (final Node n : topo.nonnullNode().values()) {
for (final TerminationPoint tp : n.nonnullTerminationPoint().values()) {
final TerminationPoint1 tpa = tp.augmentation(TerminationPoint1.class);
for (final IpAddress address : ((Ip) tpt).getIpAddress()) {
if (addr.equals(address)) {
handleSni(sni, n, inControl, trans);
- return this.target.builder().child(Node.class, n.key())
+ return target.builder().child(Node.class, n.key())
.child(TerminationPoint.class, tp.key()).build();
}
}
tpb.withKey(tpk).setTpId(tpk.getTpId());
tpb.addAugmentation(new TerminationPoint1Builder()
.setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder()
- .setTerminationPointType(new IpBuilder().setIpAddress(Lists.newArrayList(addr)).build())
+ .setTerminationPointType(new IpBuilder().setIpAddress(Set.of(addr)).build())
.build())
.build());
nb.setSupportingNode(BindingMap.of(createSupportingNode(InstanceIdentifier.keyOf(sni).getNodeId(),
inControl)));
}
- final InstanceIdentifier<Node> nid = this.target.child(Node.class, nb.key());
+ final InstanceIdentifier<Node> nid = target.child(Node.class, nb.key());
trans.put(LogicalDatastoreType.OPERATIONAL, nid, nb.build());
return nid.child(TerminationPoint.class, tpb.key());
}
}
private InstanceIdentifier<TerminationPoint> tpIdentifier(final NodeId node, final TpId tp) {
- return this.target.builder().child(Node.class, new NodeKey(node)).child(TerminationPoint.class,
+ return target.builder().child(Node.class, new NodeKey(node)).child(TerminationPoint.class,
new TerminationPointKey(tp)).build();
}
private InstanceIdentifier<Node> nodeIdentifier(final NodeId node) {
- return this.target.child(Node.class, new NodeKey(node));
+ return target.child(Node.class, new NodeKey(node));
}
private void remove(final ReadWriteTransaction trans, final InstanceIdentifier<ReportedLsp> identifier,
trans.delete(LogicalDatastoreType.OPERATIONAL, li);
LOG.debug("Searching for orphan links/nodes");
- final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).get();
+ final Optional<Topology> ot = trans.read(LogicalDatastoreType.OPERATIONAL, target).get();
Preconditions.checkState(ot.isPresent());
final Topology topology = ot.get();
@Override
public void onDataTreeChanged(final Collection<DataTreeModification<Node>> changes) {
- final ReadWriteTransaction trans = this.dataProvider.newReadWriteTransaction();
+ final ReadWriteTransaction trans = dataProvider.newReadWriteTransaction();
final Set<InstanceIdentifier<ReportedLsp>> lsps = new HashSet<>();
final Set<InstanceIdentifier<Node>> nodes = new HashSet<>();
pathArguments.add(pathArgument);
}
pathArguments.add(child.getIdentifier());
- final InstanceIdentifier<?> childIID = InstanceIdentifier.create(pathArguments);
+ final InstanceIdentifier<?> childIID = InstanceIdentifier.unsafeOf(pathArguments);
handleChangedNode(child, childIID, lsps, nodes, original, updated, created);
}
}
import static org.mockito.Mockito.doReturn;
import com.google.common.util.concurrent.ListenableFuture;
-import java.util.Collections;
import java.util.List;
+import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import org.junit.Before;
.addAugmentation(new TerminationPoint1Builder()
.setIgpTerminationPointAttributes(new IgpTerminationPointAttributesBuilder()
.setTerminationPointType(new IpBuilder()
- .setIpAddress(Collections.singletonList(new IpAddress(new Ipv4Address(ipv4Address))))
+ .setIpAddress(Set.of(new IpAddress(new Ipv4Address(ipv4Address))))
.build())
.build())
.build())
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
import static java.util.Objects.requireNonNull;
import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import io.netty.util.Timeout;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import org.checkerframework.checker.lock.qual.Holding;
import org.opendaylight.bgpcep.programming.spi.ExecutionResult;
import org.opendaylight.bgpcep.programming.spi.Instruction;
InstructionImpl(final QueueInstruction queue, final SettableFuture<Instruction> future, final InstructionId id,
final List<InstructionImpl> dependencies, final Timeout timeout) {
- this.schedulingFuture = requireNonNull(future);
+ schedulingFuture = requireNonNull(future);
this.dependencies = requireNonNull(dependencies);
this.timeout = requireNonNull(timeout);
this.queue = requireNonNull(queue);
}
InstructionId getId() {
- return this.id;
+ return id;
}
synchronized InstructionStatus getStatus() {
- return this.status;
+ return status;
}
private synchronized void setStatus(final InstructionStatus newStatus, final Details details) {
// Set the status
- this.status = newStatus;
- LOG.debug("Instruction {} transitioned to status {}", this.id, newStatus);
+ status = newStatus;
+ LOG.debug("Instruction {} transitioned to status {}", id, newStatus);
// Send out a notification
- this.queue.instructionUpdated(newStatus, details);
+ queue.instructionUpdated(newStatus, details);
switch (newStatus) {
case Cancelled:
@Holding("this")
private void cancelTimeout() {
- if (this.timeout != null) {
- this.timeout.cancel();
- this.timeout = null;
+ if (timeout != null) {
+ timeout.cancel();
+ timeout = null;
}
}
public synchronized void timeout() {
- if (this.timeout == null) {
+ if (timeout == null) {
return;
}
- this.timeout = null;
- switch (this.status) {
+ timeout = null;
+ switch (status) {
case Cancelled:
case Failed:
case Successful:
- LOG.debug("Instruction {} has status {}, timeout is a no-op", this.id, this.status);
+ LOG.debug("Instruction {} has status {}, timeout is a no-op", id, status);
break;
case Unknown:
- LOG.warn("Instruction {} has status {} before timeout completed", this.id, this.status);
+ LOG.warn("Instruction {} has status {} before timeout completed", id, status);
break;
case Executing:
- LOG.info("Instruction {} timed out while executing, transitioning into Unknown", this.id);
+ LOG.info("Instruction {} timed out while executing, transitioning into Unknown", id);
setStatus(InstructionStatus.Unknown, null);
cancelDependants();
break;
case Queued:
- LOG.debug("Instruction {} timed out while Queued, cancelling it", this.id);
+ LOG.debug("Instruction {} timed out while Queued, cancelling it", id);
cancelInstrunction();
break;
case Scheduled:
- LOG.debug("Instruction {} timed out while Scheduled, cancelling it", this.id);
- cancel(this.heldUpDetails);
+ LOG.debug("Instruction {} timed out while Scheduled, cancelling it", id);
+ cancel(heldUpDetails);
break;
default:
break;
}
private synchronized void cancelInstrunction() {
- final List<InstructionId> ids = new ArrayList<>();
- for (final InstructionImpl instruction : this.dependencies) {
+ final Set<InstructionId> ids = new HashSet<>();
+ for (final InstructionImpl instruction : dependencies) {
if (instruction.getStatus() != InstructionStatus.Successful) {
ids.add(instruction.getId());
}
@Holding("this")
private void cancelDependants() {
- final Details details = new DetailsBuilder().setUnmetDependencies(ImmutableList.of(this.id)).build();
- for (final InstructionImpl instruction : this.dependants) {
+ final Details details = new DetailsBuilder().setUnmetDependencies(Set.of(id)).build();
+ for (final InstructionImpl instruction : dependants) {
instruction.tryCancel(details);
}
}
@Holding("this")
private void cancel(final Details details) {
cancelTimeout();
- this.schedulingFuture.cancel(false);
+ schedulingFuture.cancel(false);
setStatus(InstructionStatus.Cancelled, details);
}
synchronized Class<? extends CancelFailure> tryCancel(final Details details) {
- switch (this.status) {
+ switch (status) {
case Cancelled:
case Executing:
case Failed:
case Successful:
case Unknown:
- LOG.debug("Instruction {} can no longer be cancelled due to status {}", this.id, this.status);
+ LOG.debug("Instruction {} can no longer be cancelled due to status {}", id, status);
return UncancellableInstruction.class;
case Queued:
case Scheduled:
cancel(details);
return null;
default:
- throw new IllegalStateException("Unhandled instruction state " + this.status);
+ throw new IllegalStateException("Unhandled instruction state " + status);
}
}
@Override
public synchronized boolean checkedExecutionStart() {
- if (this.status != InstructionStatus.Scheduled) {
+ if (status != InstructionStatus.Scheduled) {
return false;
}
@Override
public synchronized boolean executionHeldUp(final Details details) {
- if (this.status != InstructionStatus.Scheduled) {
+ if (status != InstructionStatus.Scheduled) {
return false;
}
- this.heldUpDetails = details;
+ heldUpDetails = details;
return true;
}
final ExecutionResult<Details> result;
synchronized (this) {
- Preconditions.checkState(this.executionFuture != null);
+ Preconditions.checkState(executionFuture != null);
cancelTimeout();
// We reuse the preconditions set down in this class
result = new ExecutionResult<>(newStatus, details);
setStatus(newStatus, details);
- this.executionFuture.set(result);
+ executionFuture.set(result);
}
}
synchronized void addDependant(final InstructionImpl instruction) {
- this.dependants.add(instruction);
+ dependants.add(instruction);
}
private synchronized void removeDependant(final InstructionImpl instruction) {
- this.dependants.remove(instruction);
+ dependants.remove(instruction);
}
private synchronized void removeDependency(final InstructionImpl other) {
- this.dependencies.remove(other);
+ dependencies.remove(other);
}
synchronized Iterator<InstructionImpl> getDependants() {
- return this.dependants.iterator();
+ return dependants.iterator();
}
synchronized void clean() {
- for (final InstructionImpl dependency : this.dependencies) {
+ for (final InstructionImpl dependency : dependencies) {
dependency.removeDependant(this);
}
- this.dependencies.clear();
+ dependencies.clear();
- for (final InstructionImpl dependant : this.dependants) {
+ for (final InstructionImpl dependant : dependants) {
dependant.removeDependency(this);
}
- this.dependants.clear();
+ dependants.clear();
- this.queue.instructionRemoved();
+ queue.instructionRemoved();
}
private Boolean checkDependencies() {
boolean ready = true;
- final List<InstructionId> unmet = new ArrayList<>();
- for (final InstructionImpl instruction : this.dependencies) {
+ final Set<InstructionId> unmet = new HashSet<>();
+ for (final InstructionImpl instruction : dependencies) {
switch (instruction.getStatus()) {
case Cancelled:
case Failed:
}
if (!unmet.isEmpty()) {
LOG.warn("Instruction {} was Queued, while some dependencies were resolved unsuccessfully, cancelling it",
- this.id);
+ id);
cancel(new DetailsBuilder().setUnmetDependencies(unmet).build());
return false;
}
}
synchronized ListenableFuture<ExecutionResult<Details>> ready() {
- Preconditions.checkState(this.status == InstructionStatus.Queued);
- Preconditions.checkState(this.executionFuture == null);
+ Preconditions.checkState(status == InstructionStatus.Queued);
+ Preconditions.checkState(executionFuture == null);
/*
* Check all vertices we depend on. We start off as ready for
* scheduling. If we encounter a cancelled/failed/unknown
if (!checkDependencies()) {
return null;
}
- LOG.debug("Instruction {} is ready for execution", this.id);
+ LOG.debug("Instruction {} is ready for execution", id);
setStatus(InstructionStatus.Scheduled, null);
- this.executionFuture = SettableFuture.create();
- this.schedulingFuture.set(this);
- return this.executionFuture;
+ executionFuture = SettableFuture.create();
+ schedulingFuture.set(this);
+ return executionFuture;
}
}
import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.SettableFuture;
-import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.Timeout;
import io.netty.util.Timer;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.checkerframework.checker.lock.qual.GuardedBy;
import org.opendaylight.bgpcep.programming.NanotimeUtil;
private final InstructionBuilder builder = new InstructionBuilder();
InstructionPusher(final InstructionId id, final Nanotime deadline) {
- this.builder.setDeadline(deadline);
- this.builder.setId(id);
- this.builder.withKey(new InstructionKey(id));
- this.builder.setStatus(InstructionStatus.Queued);
+ builder.setDeadline(deadline);
+ builder.setId(id);
+ builder.withKey(new InstructionKey(id));
+ builder.setStatus(InstructionStatus.Queued);
}
@Override
public void instructionUpdated(final InstructionStatus status, final Details details) {
- if (!status.equals(this.builder.getStatus())) {
- this.builder.setStatus(status);
+ if (!status.equals(builder.getStatus())) {
+ builder.setStatus(status);
- final WriteTransaction wt = ProgrammingServiceImpl.this.dataProvider.newWriteOnlyTransaction();
+ final WriteTransaction wt = dataProvider.newWriteOnlyTransaction();
wt.put(LogicalDatastoreType.OPERATIONAL,
- ProgrammingServiceImpl.this.qid.child(
+ qid.child(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming
.rev150720.instruction.queue.Instruction.class,
- new InstructionKey(this.builder.getId())), this.builder.build());
+ new InstructionKey(builder.getId())), builder.build());
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
- LOG.debug("Instruction Queue {} updated", ProgrammingServiceImpl.this.qid);
+ LOG.debug("Instruction Queue {} updated", qid);
}
@Override
public void onFailure(final Throwable trw) {
- LOG.error("Failed to update Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
+ LOG.error("Failed to update Instruction Queue {}", qid, trw);
}
}, MoreExecutors.directExecutor());
}
try {
- ProgrammingServiceImpl.this.notifs.putNotification(new InstructionStatusChangedBuilder()
- .setId(this.builder.getId()).setStatus(status).setDetails(details).build());
+ notifs.putNotification(new InstructionStatusChangedBuilder()
+ .setId(builder.getId()).setStatus(status).setDetails(details).build());
} catch (final InterruptedException e) {
LOG.debug("Failed to publish notification", e);
}
@Override
public void instructionRemoved() {
- final WriteTransaction wt = ProgrammingServiceImpl.this.dataProvider.newWriteOnlyTransaction();
- wt.delete(LogicalDatastoreType.OPERATIONAL, ProgrammingServiceImpl.this.qid.child(
+ final WriteTransaction wt = dataProvider.newWriteOnlyTransaction();
+ wt.delete(LogicalDatastoreType.OPERATIONAL, qid.child(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.programming.rev150720.instruction
.queue.Instruction.class,
- new InstructionKey(this.builder.getId())));
+ new InstructionKey(builder.getId())));
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
- LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
+ LOG.debug("Instruction Queue {} removed", qid);
}
@Override
public void onFailure(final Throwable trw) {
- LOG.error("Failed to remove Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
+ LOG.error("Failed to remove Instruction Queue {}", qid, trw);
}
}, MoreExecutors.directExecutor());
}
this.executor = requireNonNull(executor);
this.rpcProviderRegistry = requireNonNull(rpcProviderRegistry);
this.timer = requireNonNull(timer);
- this.qid = KeyedInstanceIdentifier.builder(InstructionsQueue.class,
+ qid = KeyedInstanceIdentifier.builder(InstructionsQueue.class,
new InstructionsQueueKey(this.instructionId)).build();
- this.sgi = ServiceGroupIdentifier.create(this.instructionId + "-service-group");
- LOG.info("Creating Programming Service {}.", this.sgi.getName());
- this.csspReg = cssp.registerClusterSingletonService(this);
+ sgi = ServiceGroupIdentifier.create(this.instructionId + "-service-group");
+ LOG.info("Creating Programming Service {}.", sgi.getName());
+ csspReg = cssp.registerClusterSingletonService(this);
}
@Override
public synchronized void instantiateServiceInstance() {
- LOG.info("Instruction Queue service {} instantiated", this.sgi.getName());
- this.reg = this.rpcProviderRegistry.registerRpcImplementation(ProgrammingService.class, this);
+ LOG.info("Instruction Queue service {} instantiated", sgi.getName());
+ reg = rpcProviderRegistry.registerRpcImplementation(ProgrammingService.class, this);
- final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
- wt.put(LogicalDatastoreType.OPERATIONAL, this.qid, new InstructionsQueueBuilder()
- .withKey(new InstructionsQueueKey(this.instructionId)).setInstruction(Map.of()).build());
+ final WriteTransaction wt = dataProvider.newWriteOnlyTransaction();
+ wt.put(LogicalDatastoreType.OPERATIONAL, qid, new InstructionsQueueBuilder()
+ .withKey(new InstructionsQueueKey(instructionId)).setInstruction(Map.of()).build());
wt.commit().addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
- LOG.debug("Instruction Queue {} added", ProgrammingServiceImpl.this.qid);
+ LOG.debug("Instruction Queue {} added", qid);
}
@Override
public void onFailure(final Throwable trw) {
- LOG.error("Failed to add Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
+ LOG.error("Failed to add Instruction Queue {}", qid, trw);
}
}, MoreExecutors.directExecutor());
}
@Override
public ServiceGroupIdentifier getIdentifier() {
- return this.sgi;
+ return sgi;
}
@Override
public ListenableFuture<RpcResult<CancelInstructionOutput>> cancelInstruction(final CancelInstructionInput input) {
- return this.executor.submit(() -> realCancelInstruction(input));
+ return executor.submit(() -> realCancelInstruction(input));
}
@Override
public ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanInstructions(final CleanInstructionsInput input) {
- return this.executor.submit(() -> realCleanInstructions(input));
+ return executor.submit(() -> realCleanInstructions(input));
}
private synchronized RpcResult<CancelInstructionOutput> realCancelInstruction(final CancelInstructionInput input) {
- final InstructionImpl instruction = this.insns.get(input.getId());
+ final InstructionImpl instruction = insns.get(input.getId());
if (instruction == null) {
LOG.debug("Instruction {} not present in the graph", input.getId());
}
private synchronized RpcResult<CleanInstructionsOutput> realCleanInstructions(final CleanInstructionsInput input) {
- final List<InstructionId> failed = new ArrayList<>();
+ final Set<InstructionId> failed = new HashSet<>();
for (final InstructionId id : input.getId()) {
// Find the instruction
- final InstructionImpl instruction = this.insns.get(id);
+ final InstructionImpl instruction = insns.get(id);
if (instruction == null) {
LOG.debug("Instruction {} not present in the graph", input.getId());
failed.add(id);
// it from its dependencies and dependents
instruction.clean();
- this.insns.remove(id);
+ insns.remove(id);
LOG.debug("Instruction {} cleaned successfully", id);
}
private List<InstructionImpl> checkDependencies(final SubmitInstructionInput input) throws SchedulerException {
final List<InstructionImpl> dependencies = collectDependencies(input);
// Check if all dependencies are non-failed
- final List<InstructionId> unmet = checkIfUnfailed(dependencies);
+ final Set<InstructionId> unmet = checkIfUnfailed(dependencies);
/*
* Some dependencies have failed, declare the request dead-on-arrival
* and fail the operation.
private List<InstructionImpl> collectDependencies(final SubmitInstructionInput input) throws SchedulerException {
final List<InstructionImpl> dependencies = new ArrayList<>();
for (final InstructionId pid : input.getPreconditions()) {
- final InstructionImpl instruction = this.insns.get(pid);
+ final InstructionImpl instruction = insns.get(pid);
if (instruction == null) {
LOG.info("Instruction {} depends on {}, which is not a known instruction", input.getId(), pid);
throw new SchedulerException("Unknown dependency ID specified",
return dependencies;
}
- private static List<InstructionId> checkIfUnfailed(final List<InstructionImpl> dependencies) {
- final List<InstructionId> unmet = new ArrayList<>();
+ private static Set<InstructionId> checkIfUnfailed(final List<InstructionImpl> dependencies) {
+ final Set<InstructionId> unmet = new HashSet<>();
for (final InstructionImpl d : dependencies) {
switch (d.getStatus()) {
case Cancelled:
public synchronized ListenableFuture<Instruction> scheduleInstruction(final SubmitInstructionInput input) throws
SchedulerException {
final InstructionId id = input.getId();
- if (this.insns.get(id) != null) {
+ if (insns.get(id) != null) {
LOG.info("Instruction ID {} already present", id);
throw new SchedulerException("Instruction ID currently in use",
new FailureBuilder().setType(DuplicateInstructionId.class).build());
*/
// Schedule a timeout for the instruction
- final Timeout t = this.timer.newTimeout(timeout -> timeoutInstruction(input.getId()), left.longValue(),
+ final Timeout t = timer.newTimeout(timeout -> timeoutInstruction(input.getId()), left.longValue(),
TimeUnit.NANOSECONDS);
// Put it into the instruction list
final SettableFuture<Instruction> ret = SettableFuture.create();
final InstructionImpl instruction = new InstructionImpl(new InstructionPusher(id, input.getDeadline()), ret, id,
dependencies, t);
- this.insns.put(id, instruction);
+ insns.put(id, instruction);
// Attach it into its dependencies
for (final InstructionImpl d : dependencies) {
* This task should be ingress-weighed, so we reinsert it into the
* same execution service.
*/
- this.executor.submit(() -> tryScheduleInstruction(instruction));
+ executor.submit(() -> tryScheduleInstruction(instruction));
return ret;
}
@Override
public String getInstructionID() {
- return this.instructionId;
+ return instructionId;
}
private synchronized void timeoutInstruction(final InstructionId id) {
- final InstructionImpl instruction = this.insns.get(id);
+ final InstructionImpl instruction = insns.get(id);
if (instruction == null) {
LOG.warn("Instruction {} timed out, but not found in the queue", id);
return;
instruction.timeout();
}
- @SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD",
- justification = "https://github.com/spotbugs/spotbugs/issues/811")
private synchronized void tryScheduleDependants(final InstructionImpl instruction) {
// Walk all dependants and try to schedule them
final Iterator<InstructionImpl> it = instruction.getDependants();
@Override
public synchronized FluentFuture<? extends CommitInfo> closeServiceInstance() {
- LOG.info("Closing Instruction Queue service {}", this.sgi.getName());
+ LOG.info("Closing Instruction Queue service {}", sgi.getName());
- if (this.reg != null) {
- this.reg.close();
- this.reg = null;
+ if (reg != null) {
+ reg.close();
+ reg = null;
}
- for (final InstructionImpl instruction : this.insns.values()) {
+ for (final InstructionImpl instruction : insns.values()) {
instruction.tryCancel(null);
}
// Workaround for BUG-2283
- final WriteTransaction wt = this.dataProvider.newWriteOnlyTransaction();
- wt.delete(LogicalDatastoreType.OPERATIONAL, this.qid);
+ final WriteTransaction wt = dataProvider.newWriteOnlyTransaction();
+ wt.delete(LogicalDatastoreType.OPERATIONAL, qid);
final FluentFuture<? extends CommitInfo> future = wt.commit();
future.addCallback(new FutureCallback<CommitInfo>() {
@Override
public void onSuccess(final CommitInfo result) {
- LOG.debug("Instruction Queue {} removed", ProgrammingServiceImpl.this.qid);
+ LOG.debug("Instruction Queue {} removed", qid);
}
@Override
public void onFailure(final Throwable trw) {
- LOG.error("Failed to shutdown Instruction Queue {}", ProgrammingServiceImpl.this.qid, trw);
+ LOG.error("Failed to shutdown Instruction Queue {}", qid, trw);
}
}, MoreExecutors.directExecutor());
@Override
public synchronized void close() {
- this.csspReg.close();
+ csspReg.close();
}
}
import static org.opendaylight.protocol.util.CheckTestUtil.checkNotPresentOperational;
import static org.opendaylight.protocol.util.CheckTestUtil.checkPresentOperational;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.ListenableFuture;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.Arrays;
import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@Override
public void setUp() throws Exception {
super.setUp();
- this.mockedExecutorWrapper = new MockedExecutorWrapper();
- this.mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper();
+ mockedExecutorWrapper = new MockedExecutorWrapper();
+ mockedNotificationServiceWrapper = new MockedNotificationServiceWrapper();
- this.testedProgrammingService = new ProgrammingServiceImpl(getDataBroker(),
- this.mockedNotificationServiceWrapper.getMockedNotificationService(),
- this.mockedExecutorWrapper.getMockedExecutor(), this.rpcRegistry, this.cssp, this.timer,
+ testedProgrammingService = new ProgrammingServiceImpl(getDataBroker(),
+ mockedNotificationServiceWrapper.getMockedNotificationService(),
+ mockedExecutorWrapper.getMockedExecutor(), rpcRegistry, cssp, timer,
INSTRUCTIONS_QUEUE_KEY);
- this.singletonService.instantiateServiceInstance();
+ singletonService.instantiateServiceInstance();
}
@After
public void tearDown() throws Exception {
- this.singletonService.closeServiceInstance();
- this.testedProgrammingService.close();
+ singletonService.closeServiceInstance();
+ testedProgrammingService.close();
}
@Test
public void testScheduleInstruction() throws Exception {
final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit);
+ testedProgrammingService.scheduleInstruction(mockedSubmit);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
// assert Schedule to executor
- this.mockedExecutorWrapper.assertSubmittedTasksSize(1);
+ mockedExecutorWrapper.assertSubmittedTasksSize(1);
// assert Notification
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit.getId(),
InstructionStatus.Scheduled);
}
@Test
public void testScheduleDependingInstruction() throws Exception {
- this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit1"));
+ testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit1"));
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
"mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ testedProgrammingService.scheduleInstruction(mockedSubmit2);
- this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
+ mockedExecutorWrapper.assertSubmittedTasksSize(2);
// First is in state scheduled, so second could not be scheduled yet
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
}
@Test
public void testScheduleDependingInstructionToFail() throws Exception {
try {
- this.testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit",
+ testedProgrammingService.scheduleInstruction(getMockedSubmitInstructionInput("mockedSubmit",
"dep1"));
} catch (final SchedulerException e) {
assertThat(e.getMessage(), containsString("Unknown dependency ID"));
- this.mockedNotificationServiceWrapper.assertNotificationsCount(0);
+ mockedNotificationServiceWrapper.assertNotificationsCount(0);
return;
}
fail("Instruction schedule should fail on unresolved dependencies");
@Test
public void testCancelInstruction() throws Exception {
final SubmitInstructionInput mockedSubmit = getMockedSubmitInstructionInput("mockedSubmit");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit);
+ testedProgrammingService.scheduleInstruction(mockedSubmit);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
final CancelInstructionInput mockedCancel = getCancelInstruction("mockedSubmit");
- this.testedProgrammingService.cancelInstruction(mockedCancel);
+ testedProgrammingService.cancelInstruction(mockedCancel);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit.getId()));
- this.mockedExecutorWrapper.assertSubmittedTasksSize(2);
+ mockedExecutorWrapper.assertSubmittedTasksSize(2);
- this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(2);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit.getId(),
InstructionStatus.Cancelled);
}
@Test
public void testCancelDependantInstruction() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
"mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ testedProgrammingService.scheduleInstruction(mockedSubmit2);
final SubmitInstructionInput mockedSubmit3 = getMockedSubmitInstructionInput("mockedSubmit3",
"mockedSubmit1", "mockedSubmit2");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit3);
+ testedProgrammingService.scheduleInstruction(mockedSubmit3);
- this.testedProgrammingService.cancelInstruction(getCancelInstruction("mockedSubmit1"));
+ testedProgrammingService.cancelInstruction(getCancelInstruction("mockedSubmit1"));
- this.mockedNotificationServiceWrapper
+ mockedNotificationServiceWrapper
.assertNotificationsCount(1 /*First Scheduled*/ + 3 /*First and all dependencies cancelled*/);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(0, mockedSubmit1.getId(),
InstructionStatus.Scheduled);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
InstructionStatus.Cancelled);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit2.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit2.getId(),
InstructionStatus.Cancelled);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit3.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit3.getId(),
InstructionStatus.Cancelled);
checkPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit1.getId()));
@Test
public void testCleanInstructions() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
"mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ testedProgrammingService.scheduleInstruction(mockedSubmit2);
final CleanInstructionsInputBuilder cleanInstructionsInputBuilder = new CleanInstructionsInputBuilder();
final CleanInstructionsInput cleanInstructionsInput = cleanInstructionsInputBuilder.setId(
- Lists.newArrayList(mockedSubmit1.getId(), mockedSubmit2.getId())).build();
+ Set.of(mockedSubmit1.getId(), mockedSubmit2.getId())).build();
- ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanedInstructionOutput = this.testedProgrammingService
+ ListenableFuture<RpcResult<CleanInstructionsOutput>> cleanedInstructionOutput = testedProgrammingService
.cleanInstructions(cleanInstructionsInput);
assertCleanInstructionOutput(cleanedInstructionOutput, 2);
- this.testedProgrammingService.cancelInstruction(getCancelInstruction("mockedSubmit1"));
+ testedProgrammingService.cancelInstruction(getCancelInstruction("mockedSubmit1"));
- cleanedInstructionOutput = this.testedProgrammingService.cleanInstructions(cleanInstructionsInput);
+ cleanedInstructionOutput = testedProgrammingService.cleanInstructions(cleanInstructionsInput);
assertCleanInstructionOutput(cleanedInstructionOutput, 0);
checkNotPresentOperational(getDataBroker(), buildInstructionIID(mockedSubmit1.getId()));
cleanedInstructionOutput, final int unflushedCount) throws InterruptedException,
java.util.concurrent.ExecutionException {
if (unflushedCount == 0) {
- final List<InstructionId> unflushed = cleanedInstructionOutput.get().getResult().getUnflushed();
+ final Set<InstructionId> unflushed = cleanedInstructionOutput.get().getResult().getUnflushed();
assertTrue(unflushed == null || unflushed.isEmpty());
} else {
assertEquals(unflushedCount, cleanedInstructionOutput.get().getResult().getUnflushed().size());
@Test
public void testCloseProgrammingService() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
"mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ testedProgrammingService.scheduleInstruction(mockedSubmit2);
- this.testedProgrammingService.close();
+ testedProgrammingService.close();
- this.mockedNotificationServiceWrapper
+ mockedNotificationServiceWrapper
.assertNotificationsCount(1/* First scheduled */ + 2/* Both cancelled at close */);
}
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
- final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ final ListenableFuture<Instruction> future = testedProgrammingService.scheduleInstruction(mockedSubmit1);
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
future.get();
- this.mockedNotificationServiceWrapper.assertNotificationsCount(2);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(2);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
InstructionStatus.Cancelled);
}
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
- final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ final ListenableFuture<Instruction> future = testedProgrammingService.scheduleInstruction(mockedSubmit1);
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
final Instruction i = future.get();
i.checkedExecutionStart();
i.executionCompleted(InstructionStatus.Successful, getDetails());
- this.mockedNotificationServiceWrapper.assertNotificationsCount(3);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(3);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
InstructionStatus.Executing);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
InstructionStatus.Successful);
// Timeout in success should not do anything
}
final Optional<Nanotime> deadline = Optional.of(deadlineNano);
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1", deadline);
- final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ final ListenableFuture<Instruction> future = testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 = getMockedSubmitInstructionInput("mockedSubmit2",
"mockedSubmit1");
- this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ testedProgrammingService.scheduleInstruction(mockedSubmit2);
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
final Instruction i = future.get();
i.checkedExecutionStart();
- this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(4);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
InstructionStatus.Executing);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
InstructionStatus.Unknown);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
InstructionStatus.Cancelled);
}
@Test
public void testSuccessExecutingWithDependenciesTransaction() throws Exception {
final SubmitInstructionInput mockedSubmit1 = getMockedSubmitInstructionInput("mockedSubmit1");
- final ListenableFuture<Instruction> future = this.testedProgrammingService.scheduleInstruction(mockedSubmit1);
+ final ListenableFuture<Instruction> future = testedProgrammingService.scheduleInstruction(mockedSubmit1);
final SubmitInstructionInput mockedSubmit2 =
getMockedSubmitInstructionInput("mockedSubmit2", "mockedSubmit1");
- final ListenableFuture<Instruction> future2 = this.testedProgrammingService.scheduleInstruction(mockedSubmit2);
+ final ListenableFuture<Instruction> future2 = testedProgrammingService.scheduleInstruction(mockedSubmit2);
- this.mockedNotificationServiceWrapper.assertNotificationsCount(1);
+ mockedNotificationServiceWrapper.assertNotificationsCount(1);
Instruction instruction = future.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
- this.mockedNotificationServiceWrapper.assertNotificationsCount(4);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(4);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(1, mockedSubmit1.getId(),
InstructionStatus.Executing);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(2, mockedSubmit1.getId(),
InstructionStatus.Successful);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(3, mockedSubmit2.getId(),
InstructionStatus.Scheduled);
instruction = future2.get();
instruction.checkedExecutionStart();
instruction.executionCompleted(InstructionStatus.Successful, getDetails());
- this.mockedNotificationServiceWrapper.assertNotificationsCount(6);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(),
+ mockedNotificationServiceWrapper.assertNotificationsCount(6);
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(4, mockedSubmit2.getId(),
InstructionStatus.Executing);
- this.mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(),
+ mockedNotificationServiceWrapper.assertInstructionStatusChangedNotification(5, mockedSubmit2.getId(),
InstructionStatus.Successful);
}
final Optional<Nanotime> deadline, final String... dependencyIds) {
final SubmitInstructionInput mockedSubmitInstruction = mock(SubmitInstructionInput.class);
- final List<InstructionId> dependencies = new ArrayList<>();
- for (final String dependencyId : dependencyIds) {
- dependencies.add(new InstructionId(dependencyId));
- }
+ final Set<InstructionId> dependencies = Arrays.stream(dependencyIds)
+ .map(InstructionId::new)
+ .collect(Collectors.toUnmodifiableSet());
doReturn(dependencies).when(mockedSubmitInstruction).getPreconditions();
doReturn(new InstructionId(id)).when(mockedSubmitInstruction).getId();
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test dependencies -->
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
- <artifactId>osgi.cmpn</artifactId>
+ <artifactId>org.osgi.service.component.annotations</artifactId>
</dependency>
<!-- Test dependencies -->
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>single-feature-parent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>
<parent>
<groupId>org.opendaylight.odlparent</groupId>
<artifactId>odlparent-lite</artifactId>
- <version>9.0.13</version>
+ <version>10.0.0</version>
<relativePath/>
</parent>