</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
</plugins>
</build>
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public final synchronized void stopRIBExtensionProvider() {
if (this.registrations == null) {
return;
* @param safiClass SubsequentAddressFamily
* @param destinationQname destination Qname
*/
- protected AbstractRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass, final Class<? extends AddressFamily> afiClass, final Class<? extends SubsequentAddressFamily> safiClass,
+ protected AbstractRIBSupport(final Class<? extends Routes> cazeClass,
+ final Class<? extends DataObject> containerClass,
+ final Class<? extends Route> listClass, final Class<? extends AddressFamily> afiClass,
+ final Class<? extends SubsequentAddressFamily> safiClass,
final QName destinationQname) {
final QName qname = BindingReflections.findQName(containerClass).intern();
this.routesContainerIdentifier = new NodeIdentifier(qname);
- this.routeAttributesIdentifier = new NodeIdentifier(QName.create(qname, Attributes.QNAME.getLocalName().intern()));
+ this.routeAttributesIdentifier = new NodeIdentifier(QName.create(qname,
+ Attributes.QNAME.getLocalName().intern()));
this.cazeClass = requireNonNull(cazeClass);
this.containerClass = requireNonNull(containerClass);
this.listClass = requireNonNull(listClass);
this.routeQname = QName.create(qname, BindingReflections.findQName(listClass).intern().getLocalName());
this.routesListIdentifier = new NodeIdentifier(this.routeQname);
this.emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES).addChild(Builders.containerBuilder()
- .withNodeIdentifier(routesContainerIdentifier()).withChild(ImmutableNodes.mapNodeBuilder(this.routeQname).build()).build()).build();
+ .withNodeIdentifier(routesContainerIdentifier()).withChild(ImmutableNodes.mapNodeBuilder(this.routeQname)
+ .build()).build()).build();
this.afiClass = afiClass;
this.safiClass = safiClass;
this.destinationNid = new NodeIdentifier(destinationQname);
final MpUnreachNlriBuilder mb = new MpUnreachNlriBuilder();
mb.setAfi(this.getAfi());
mb.setSafi(this.getSafi());
- mb.setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(buildWithdrawnDestination(routes)).build());
+ mb.setWithdrawnRoutes(new WithdrawnRoutesBuilder()
+ .setDestinationType(buildWithdrawnDestination(routes)).build());
return mb.build();
}
@Nonnull
- protected abstract DestinationType buildDestination(@Nonnull final Collection<MapEntryNode> routes);
+ protected abstract DestinationType buildDestination(@Nonnull Collection<MapEntryNode> routes);
+
@Nonnull
- protected abstract DestinationType buildWithdrawnDestination(@Nonnull final Collection<MapEntryNode> routes);
+ protected abstract DestinationType buildWithdrawnDestination(@Nonnull Collection<MapEntryNode> routes);
/**
* Return the {@link NodeIdentifier} of the AFI/SAFI-specific container under
* Given the destination as ContainerNode, implementation needs to parse the DOM model
* from this point onward:
*
- * {@code /bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type }
- *
+ * {@code /bgp-mp:mp-unreach-nlri/bgp-mp:withdrawn-routes/bgp-mp:destination-type}
* and delete the routes from its RIBs.
*
* @param tx DOMDataWriteTransaction to be passed into implementation
* Given the destination as ContainerNode, implementation needs to parse the DOM model
* from this point onward:
*
- * {@code /bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type }
- *
+ * {@code /bgp-mp:mp-reach-nlri/bgp-mp:advertized-routes/bgp-mp:destination-type}
* and put the routes to its RIBs.
*
* @param tx DOMDataWriteTransaction to be passed into implementation
processDestination(tx, tablePath.node(routesNodeId), destination, attributes, this.putRoute);
}
- protected abstract void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination,
- final ContainerNode attributes, final ApplyRoute applyFunction);
+ protected abstract void processDestination(DOMDataWriteTransaction tx, YangInstanceIdentifier routesPath,
+ ContainerNode destination, ContainerNode attributes, ApplyRoute applyFunction);
- private static ContainerNode getDestination(final DataContainerChild<? extends PathArgument, ?> routes, final NodeIdentifier destinationId) {
+ private static ContainerNode getDestination(final DataContainerChild<? extends PathArgument, ?> routes,
+ final NodeIdentifier destinationId) {
if (routes instanceof ContainerNode) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeDestination = ((ContainerNode)routes).getChild(DESTINATION_TYPE);
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeDestination =
+ ((ContainerNode) routes).getChild(DESTINATION_TYPE);
if (maybeDestination.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> destination = maybeDestination.get();
if (destination instanceof ChoiceNode) {
- final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRet = ((ChoiceNode)destination).getChild(destinationId);
+ final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRet =
+ ((ChoiceNode) destination).getChild(destinationId);
if (maybeRet.isPresent()) {
final DataContainerChild<? extends PathArgument, ?> ret = maybeRet.get();
if (ret instanceof ContainerNode) {
- return (ContainerNode)ret;
+ return (ContainerNode) ret;
}
LOG.debug("Specified node {} is not a container, ignoring it", ret);
} else {
- LOG.debug("Specified container {} is not present in destination {}", destinationId, destination);
+ LOG.debug("Specified container {} is not present in destination {}",
+ destinationId, destination);
}
} else {
LOG.warn("Destination {} is not a choice, ignoring it", destination);
}
@Override
- public final void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath, final ContainerNode nlri) {
+ public final void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
+ final ContainerNode nlri) {
deleteRoutes(tx, tablePath, nlri, ROUTES);
}
@Override
- public final void putRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath, final ContainerNode nlri, final ContainerNode attributes) {
+ public final void putRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
+ final ContainerNode nlri, final ContainerNode attributes) {
putRoutes(tx, tablePath, nlri, attributes, ROUTES);
}
@Nonnull
@Override
- public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn, final Attributes attr) {
+ public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn,
+ final Attributes attr) {
final UpdateBuilder ub = new UpdateBuilder();
final AttributesBuilder ab = new AttributesBuilder(attr);
final CNextHop hop = ab.getCNextHop();
}
@Override
- public final void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath, final ContainerNode nlri,
- final NodeIdentifier routesNodeId) {
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
+ public final void deleteRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
+ final ContainerNode nlri, final NodeIdentifier routesNodeId) {
final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = nlri.getChild(WITHDRAWN_ROUTES);
if (maybeRoutes.isPresent()) {
final ContainerNode destination = getDestination(maybeRoutes.get(), destinationContainerIdentifier());
}
@Override
- public final void putRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath, final ContainerNode nlri,
- final ContainerNode attributes, final NodeIdentifier routesNodeId) {
+ public final void putRoutes(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tablePath,
+ final ContainerNode nlri, final ContainerNode attributes, final NodeIdentifier routesNodeId) {
final Optional<DataContainerChild<? extends PathArgument, ?>> maybeRoutes = nlri.getChild(ADVERTISED_ROUTES);
if (maybeRoutes.isPresent()) {
final ContainerNode destination = getDestination(maybeRoutes.get(), destinationContainerIdentifier());
private static final class DeleteRoute implements ApplyRoute {
@Override
- public final void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, final NodeIdentifierWithPredicates routeKey,
- final DataContainerNode<?> route, final ContainerNode attributes) {
+ public void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base,
+ final NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route,
+ final ContainerNode attributes) {
tx.delete(LogicalDatastoreType.OPERATIONAL, base.node(routeKey));
}
}
private final class PutRoute implements ApplyRoute {
@Override
- public void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base, final NodeIdentifierWithPredicates routeKey,
- final DataContainerNode<?> route, final ContainerNode attributes) {
+ public void apply(final DOMDataWriteTransaction tx, final YangInstanceIdentifier base,
+ final NodeIdentifierWithPredicates routeKey, final DataContainerNode<?> route,
+ final ContainerNode attributes) {
// Build the DataContainer data
- final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = ImmutableNodes.mapEntryBuilder();
+ final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> b =
+ ImmutableNodes.mapEntryBuilder();
b.withNodeIdentifier(routeKey);
route.getValue().forEach(b::withChild);
// Add attributes
- final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> cb = Builders.containerBuilder(attributes);
+ final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> cb =
+ Builders.containerBuilder(attributes);
cb.withNodeIdentifier(routeAttributesIdentifier());
b.withChild(cb.build());
tx.put(LogicalDatastoreType.OPERATIONAL, base.node(routeKey), b.build());
import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
-public abstract class AbstractRIBSupportRegistration<T extends RIBSupport> extends AbstractObjectRegistration<T> implements RIBSupportRegistration<T> {
+public abstract class AbstractRIBSupportRegistration<T extends RIBSupport>
+ extends AbstractObjectRegistration<T> implements RIBSupportRegistration<T> {
protected AbstractRIBSupportRegistration(final T instance) {
super(instance);
}
import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
*/
interface AddPathRibSupport {
/**
- * Extract PathId from route change received
+ * Extract PathId from route change received.
*
* @param normalizedNode Path Id Container
* @return pathId The path identifier value
*/
- default Long extractPathId(NormalizedNode<?, ?> normalizedNode) {
+ default Long extractPathId(@Nonnull NormalizedNode<?, ?> normalizedNode) {
return NON_PATH_ID;
}
/**
- * Construct a PathArgument to an AddPathRoute
+ * Construct a PathArgument to an AddPathRoute.
*
* @param pathId The path identifier
* @param routeId PathArgument leaf path
* @return routeId PathArgument + pathId or Null in case Add-path is not supported
*/
- @Nullable default PathArgument getRouteIdAddPath(long pathId, PathArgument routeId) {
+ @Nullable
+ default PathArgument getRouteIdAddPath(long pathId, @Nonnull PathArgument routeId) {
return null;
}
/**
- * Create a new Path Argument for route Key removing remove Path Id from key
- * For non extension which doesnt support Multiple Path this step is not required
- * @param routeKeyPathArgument routeKey Path Argument
+ * Create a new Path Argument for route Key removing remove Path Id from key.
+ * For non extension which doesnt support Multiple Path this step is not required.
+ *
+ * @param routeKeyPathArgument routeKey Path Argument
* @return new route Key
*/
- default PathArgument createRouteKeyPathArgument(PathArgument routeKeyPathArgument) {
+ default @Nonnull PathArgument createRouteKeyPathArgument(@Nonnull PathArgument routeKeyPathArgument) {
return routeKeyPathArgument;
}
}
import io.netty.channel.ChannelInboundHandler;
import java.util.List;
import java.util.Set;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.BgpTableType;
/**
* BGP Session represents the finite state machine in BGP, including timers and its purpose is to create a BGP
- * connection between BGP speakers. Session is automatically started, when TCP connection is created, but can be stopped
- * manually via close method of the {@link java.io.Closeable} interface.
- *
+ * connection between BGP speakers. Session is automatically started, when TCP connection is created,
+ * but can be stopped manually via close method of the {@link java.io.Closeable} interface.
* If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown requests.
*/
public interface BGPSession extends AutoCloseable, ChannelInboundHandler {
*
* @return Set of tables which it supports.
*/
+ @Nonnull
Set<BgpTableType> getAdvertisedTableTypes();
/**
*
* @return Peer's BGP Router ID.
*/
+ @Nonnull
Ipv4Address getBgpId();
/**
*
* @return Peer's AS Number
*/
+ @Nonnull
AsNumber getAsNumber();
+
/**
* Return a list with Add Path tables supported advertised and corresponding SendReceive mode.
*
* @return AddPathTables supported
*/
+ @Nonnull
List<AddressFamilies> getAdvertisedAddPathTableTypes();
/**
*
* @return Set of tables which it supports.
*/
+ @Nonnull
List<BgpTableType> getAdvertisedGracefulRestartTableTypes();
}
package org.opendaylight.protocol.bgp.rib.spi;
import java.util.EventListener;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yangtools.yang.binding.Notification;
public interface BGPSessionListener extends PeerRPCs, EventListener {
/**
- * Marks synchronization finished for given Table key
+ * Marks synchronization finished for given Table key.
*
* @param tablesKey of the table where synchronization finished
*/
- void markUptodate(final TablesKey tablesKey);
+ void markUptodate(@Nonnull TablesKey tablesKey);
/**
* Fired when the session was established successfully.
*
* @param session Peer address families which we accepted
*/
- void onSessionUp(BGPSession session);
+ void onSessionUp(@Nonnull BGPSession session);
+
/**
* Fired when the session went down because of an IO error. Implementation should take care of closing underlying
* session.
*
* @param session that went down
- * @param e Exception that was thrown as the cause of session being down
+ * @param exc Exception that was thrown as the cause of session being down
*/
- void onSessionDown(BGPSession session, Exception e);
+ void onSessionDown(@Nonnull BGPSession session, @Nonnull Exception exc);
+
/**
* Fired when the session is terminated locally. The session has already been closed and transitioned to IDLE state.
* Any outstanding queued messages were not sent. The user should not attempt to make any use of the session.
*
* @param reason the cause why the session went down
*/
- void onSessionTerminated(BGPSession session, BGPTerminationReason reason);
+ void onSessionTerminated(@Nullable BGPSession session, @Nonnull BGPTerminationReason reason);
/**
* Fired when a normal protocol message is received.
*
* @param notification Protocol message
*/
- void onMessage(BGPSession session, Notification notification) throws BGPDocumentedException;
+ void onMessage(@Nonnull BGPSession session, @Nonnull Notification notification) throws BGPDocumentedException;
}
*/
public interface ExportPolicyPeerTracker {
/**
- * Register Peer
- * @param peerId Peer Id
- * @param sendReceive send receive add ath configuration of the peer
- * @param peerPath Yii of the peer
- * @param peerRole Role of the peer
- * @param simpleRoutingPolicy
+ * Register Peer.
+ *
+ * @param peerId Peer Id
+ * @param sendReceive send receive add ath configuration of the peer
+ * @param peerPath Yii of the peer
+ * @param peerRole Role of the peer
+ * @param simpleRoutingPolicy optional
*/
+ @Nonnull
AbstractRegistration registerPeer(@Nonnull PeerId peerId, @Nullable SendReceive sendReceive,
@Nonnull YangInstanceIdentifier peerPath, @Nonnull PeerRole peerRole,
- @Nonnull Optional<SimpleRoutingPolicy> simpleRoutingPolicy);
+ @Nonnull Optional<SimpleRoutingPolicy> simpleRoutingPolicy);
/**
- * returns PeerExportGroup per role
+ * Returns PeerExportGroup per role.
+ *
* @param role of desired PeerExportGroup
* @return PeerExportGroup
*/
+ @Nonnull
PeerExportGroup getPeerGroup(@Nonnull PeerRole role);
/**
- * check whether the peer supports the table
+ * Check whether the peer supports the table.
+ *
* @param peerId of peer
* @return true if peer supports table
*/
boolean isTableSupported(@Nonnull PeerId peerId);
/**
+ * Returns roles per PeerID.
+ *
* @param peerId of peer
* @return Role of peer
*/
+ @Nullable
PeerRole getRole(@Nonnull YangInstanceIdentifier peerId);
/**
- * Check whether Peer supports Add Path
+ * Check whether Peer supports Add Path.
+ *
* @param peerId of peer
* @return true if add-path is supported
*/
/**
* Flags peers once empty structure has been created, then changes under it can
- * be applied
+ * be applied.
*
* @param peerId of peer
*/
- void registerPeerAsInitialized(PeerId peerId);
+ void registerPeerAsInitialized(@Nonnull PeerId peerId);
/**
- * check whether the peer supports the table
+ * Check whether the peer supports the table.
+ *
* @param peerId of peer
* @return true if peer supports table
*/
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
public final class IdentifierUtils {
- private static final Predicate<PathArgument> IS_PEER = input -> input instanceof NodeIdentifierWithPredicates && Peer.QNAME.equals(input.getNodeType());
- private static final Predicate<PathArgument> IS_TABLES = input -> input instanceof NodeIdentifierWithPredicates && Tables.QNAME.equals(input.getNodeType());
+ private static final Predicate<PathArgument> IS_PEER = input -> input
+ instanceof NodeIdentifierWithPredicates && Peer.QNAME.equals(input.getNodeType());
+ private static final Predicate<PathArgument> IS_TABLES = input -> input
+ instanceof NodeIdentifierWithPredicates && Tables.QNAME.equals(input.getNodeType());
private static final QName PEER_ID = QName.create(Peer.QNAME, "peer-id").intern();
private IdentifierUtils() {
}
// FIXME: implement as id.firstIdentifierOf(IS_PEER), null indicating not found
- private static NodeIdentifierWithPredicates firstKeyOf(final YangInstanceIdentifier id, final Predicate<PathArgument> match) {
+ private static NodeIdentifierWithPredicates firstKeyOf(final YangInstanceIdentifier id,
+ final Predicate<PathArgument> match) {
final PathArgument ret = id.getPathArguments().stream().filter(match::apply).findFirst().get();
- Preconditions.checkArgument(ret instanceof NodeIdentifierWithPredicates, "Non-key peer identifier %s", ret);
+ Preconditions.checkArgument(ret instanceof NodeIdentifierWithPredicates,
+ "Non-key peer identifier %s", ret);
return (NodeIdentifierWithPredicates) ret;
}
- private static YangInstanceIdentifier firstIdentifierOf(final YangInstanceIdentifier id, final Predicate<PathArgument> match) {
+ private static YangInstanceIdentifier firstIdentifierOf(final YangInstanceIdentifier id,
+ final Predicate<PathArgument> match) {
final int idx = Iterables.indexOf(id.getPathArguments(), match);
Preconditions.checkArgument(idx != -1, "Failed to find %s in %s", match, id);
// we want the element at index idx to be included in the list
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
/**
- * Implements common methods for Advertisement of Multiple Paths on ribSupport
+ * Implements common methods for Advertisement of Multiple Paths on ribSupport.
*/
public abstract class MultiPathAbstractRIBSupport extends AbstractRIBSupport {
private final QName routeKeyQname;
* the same model which populates it with route grouping instantiation, and by extension with
* the route attributes container.
*
- * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
- * @param containerClass Binding class of the container in routes choice, must not be null.
- * @param listClass Binding class of the route list, nust not be null;
+ * @param cazeClass Binding class of the AFI/SAFI-specific case statement, must not be null
+ * @param containerClass Binding class of the container in routes choice, must not be null.
+ * @param listClass Binding class of the route list, nust not be null;
* @param addressFamilyClass address Family Class
- * @param safiClass SubsequentAddressFamily
- * @param routeKeyNaming Route Key name (prefix/ route-key / etc..)
- * @param destinationQname destination Qname
+ * @param safiClass SubsequentAddressFamily
+ * @param routeKeyNaming Route Key name (prefix/ route-key / etc..)
+ * @param destinationQname destination Qname
*/
- protected MultiPathAbstractRIBSupport(final Class<? extends Routes> cazeClass, final Class<? extends DataObject> containerClass,
- final Class<? extends Route> listClass, final Class<? extends AddressFamily> addressFamilyClass,
- final Class<? extends SubsequentAddressFamily> safiClass, final String routeKeyNaming, final QName destinationQname) {
+ protected MultiPathAbstractRIBSupport(final Class<? extends Routes> cazeClass,
+ final Class<? extends DataObject> containerClass,
+ final Class<? extends Route> listClass, final Class<? extends AddressFamily> addressFamilyClass,
+ final Class<? extends SubsequentAddressFamily> safiClass, final String routeKeyNaming,
+ final QName destinationQname) {
super(cazeClass, containerClass, listClass, addressFamilyClass, safiClass, destinationQname);
this.routeKeyQname = QName.create(routeQName(), routeKeyNaming).intern();
this.pathIdQname = QName.create(routeQName(), "path-id").intern();
@Override
public final Long extractPathId(final NormalizedNode<?, ?> data) {
final Long pathId = PathIdUtil.extractPathId(data, this.routePathIdNid());
- if(pathId == null) {
+ if (pathId == null) {
return PathIdUtil.NON_PATH_ID;
}
return pathId;
@Override
public final PathArgument createRouteKeyPathArgument(final PathArgument routeKey) {
- final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(routeKeyQName(), PathIdUtil.getObjectKey(routeKey, routeKeyQName()));
+ final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(routeKeyQName(),
+ PathIdUtil.getObjectKey(routeKey, routeKeyQName()));
return new NodeIdentifierWithPredicates(routeQName(), keyValues);
}
package org.opendaylight.protocol.bgp.rib.spi;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
/**
* Marker interface identifying a BGP peer.
*
* @return symbolic name.
*/
+ @Nonnull
String getName();
/**
- * Return the peer's BGP identifier as raw bytearray
+ * Return the peer's BGP identifier as raw byte array.
+ *
* @return byte[] raw identifier
*/
byte[] getRawIdentifier();
/**
- * Close Peers and performs asynchronously DS clean up
+ * Close Peers and performs asynchronously DS clean up.
*
* @return future
*/
+ @Nonnull
ListenableFuture<?> close();
}
package org.opendaylight.protocol.bgp.rib.spi;
import java.util.function.BiConsumer;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
* A collection of peers sharing the same export policy.
*/
public interface PeerExportGroup {
+ /**
+ * Transform outgoing attributes according to policy per Peer.
+ *
+ * @param role root Peer role
+ * @param attributes attributes container
+ * @return return attributes container after apply policy
+ */
+ @Nonnull
+ ContainerNode effectiveAttributes(@Nonnull PeerRole role, @Nonnull ContainerNode attributes);
+
+ /**
+ * Returns if peer is present.
+ *
+ * @param routePeerId PeerId
+ * @return true if peer is present on this export group
+ */
+ boolean containsPeer(@Nonnull PeerId routePeerId);
+
+ /**
+ * Applies the given action for each entry in this PeerExportGroup on synchronized mode.
+ *
+ * @param action action to be applied
+ */
+ void forEach(@Nonnull BiConsumer<PeerId, YangInstanceIdentifier> action);
+
final class PeerExporTuple {
private final YangInstanceIdentifier yii;
private final PeerRole role;
return this.role;
}
}
-
- /**
- * Transform outgoing attributes according to policy per Peer
- *
- * @param role root Peer role
- * @param attributes attributes container
- * @return return attributes container after apply policy
- */
- ContainerNode effectiveAttributes(PeerRole role, ContainerNode attributes);
-
- /**
- *
- * @param routePeerId PeerId
- * @return true if peer is present on this export group
- */
- boolean containsPeer(PeerId routePeerId);
-
- /**
- * Applies the given action for each entry in this PeerExportGroup on synchronized mode
- *
- * @param action action to be applied
- */
- void forEach(BiConsumer<PeerId, YangInstanceIdentifier> action);
}
package org.opendaylight.protocol.bgp.rib.spi;
import com.google.common.util.concurrent.ListenableFuture;
+import javax.annotation.Nonnull;
/**
* Contains all Peer RPC methods related.
*/
public interface PeerRPCs {
/**
- * Release Peer session
+ * Release Peer session.
*/
+ @Nonnull
ListenableFuture<?> releaseConnection();
}
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
public final class PeerRoleUtil {
- public static final NodeIdentifier PEER_ROLE_NID = new NodeIdentifier(QName.create(Peer.QNAME, "peer-role").intern());
+ public static final NodeIdentifier PEER_ROLE_NID = new NodeIdentifier(QName.create(Peer.QNAME,
+ "peer-role").intern());
private PeerRoleUtil() {
throw new UnsupportedOperationException();
public static String roleForString(final PeerRole role) {
switch (role) {
- case Ebgp:
- return "ebgp";
- case Ibgp:
- return "ibgp";
- case RrClient:
- return "rr-client";
- case Internal:
- return "internal";
- default:
- throw new IllegalArgumentException("Unhandled role " + role);
+ case Ebgp:
+ return "ebgp";
+ case Ibgp:
+ return "ibgp";
+ case RrClient:
+ return "rr-client";
+ case Internal:
+ return "internal";
+ default:
+ throw new IllegalArgumentException("Unhandled role " + role);
}
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
/**
* Interface for acquiring AdjRIBsIn factories. In order for a model-driven RIB implementation to work correctly, it
/**
* Acquire a RIB implementation factory for a AFI/SAFI combination.
+ *
* @param key AFI/SAFI key
- * @return RIBSupport instance, or null if the AFI/SAFI is
- * not implemented.
+ * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
*/
- @Nullable RIBSupport getRIBSupport(@Nonnull TablesKey key);
+ @Nullable
+ RIBSupport getRIBSupport(@Nonnull TablesKey key);
/**
* Acquire a RIB implementation factory for a AFI/SAFI combination.
- * @param afi Address Family Identifier
+ *
+ * @param afi Address Family Identifier
* @param safi Subsequent Address Family identifier
- * @return RIBSupport instance, or null if the AFI/SAFI is
- * not implemented.
+ * @return RIBSupport instance, or null if the AFI/SAFI is not implemented.
*/
- @Nullable RIBSupport getRIBSupport(@Nonnull Class<? extends AddressFamily> afi, @Nonnull Class<? extends SubsequentAddressFamily> safi);
+ @Nullable
+ RIBSupport getRIBSupport(@Nonnull Class<? extends AddressFamily> afi,
+ @Nonnull Class<? extends SubsequentAddressFamily> safi);
/**
* Acquire a RIB implementation factory for a AFI/SAFI combination.
+ *
* @param key Tables key with AFI/SAFI
* @return RIBSupport instance, or null if the AFI/SAFI is
- * not implemented.
+ * not implemented.
*/
- @Nullable RIBSupport getRIBSupport(YangInstanceIdentifier.NodeIdentifierWithPredicates key);
+ @Nullable
+ RIBSupport getRIBSupport(@Nonnull NodeIdentifierWithPredicates key);
/**
*
* @return Class loading strategy for loading YANG modeled classes.
*/
- @Nonnull GeneratedClassLoadingStrategy getClassLoadingStrategy();
+ @Nonnull
+ GeneratedClassLoadingStrategy getClassLoadingStrategy();
}
\ No newline at end of file
*/
package org.opendaylight.protocol.bgp.rib.spi;
+import javax.annotation.Nonnull;
+
public interface RIBExtensionProviderActivator {
- void startRIBExtensionProvider(RIBExtensionProviderContext context);
+ void startRIBExtensionProvider(@Nonnull RIBExtensionProviderContext context);
void stopRIBExtensionProvider();
}
*/
package org.opendaylight.protocol.bgp.rib.spi;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
/**
* Register a RIBSupport instance for a particular AFI/SAFI combination.
*
- * @param afi Address Family identifier
- * @param safi Subsequent Address Family identifier
+ * @param afi Address Family identifier
+ * @param safi Subsequent Address Family identifier
* @param support T RIBSupport instance
* @return Registration handle. Call {@link RIBSupportRegistration#close()} method to remove it.
* @throws NullPointerException if any of the arguments is null
*/
- <T extends RIBSupport> RIBSupportRegistration<T> registerRIBSupport(Class<? extends AddressFamily> afi, Class<? extends SubsequentAddressFamily> safi, T support);
+ <T extends RIBSupport> RIBSupportRegistration<T> registerRIBSupport(
+ @Nonnull Class<? extends AddressFamily> afi,
+ @Nonnull Class<? extends SubsequentAddressFamily> safi, T support);
}
*
* @return Protocol-specific case in the routes choice, may not be null.
*/
- @Nonnull ChoiceNode emptyRoutes();
+ @Nonnull
+ ChoiceNode emptyRoutes();
/**
* Return the localized identifier of the attributes route member, as expanded
*
* @return The attributes identifier, may not be null.
*/
- @Nonnull NodeIdentifier routeAttributesIdentifier();
+ @Nonnull
+ NodeIdentifier routeAttributesIdentifier();
/**
* Return class object of the Routes Case statement.
*
* @return Class
*/
- @Nonnull Class<? extends Routes> routesCaseClass();
+ @Nonnull
+ Class<? extends Routes> routesCaseClass();
/**
* Return class object of the Routes Container statement.
*
* @return Class
*/
- @Nonnull Class<? extends DataObject> routesContainerClass();
+ @Nonnull
+ Class<? extends DataObject> routesContainerClass();
/**
* Return class object of the Routes List statement.
*
* @return Class
*/
- @Nonnull Class<? extends Route> routesListClass();
+ @Nonnull
+ Class<? extends Route> routesListClass();
- @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
- @Nonnull ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
+ @Nonnull
+ ImmutableCollection<Class<? extends DataObject>> cacheableAttributeObjects();
+
+ @Nonnull
+ ImmutableCollection<Class<? extends DataObject>> cacheableNlriObjects();
/**
* Given the NLRI as ContainerNode, this method should extract withdrawn routes
* from the DOM model and delete them from RIBs.
*
- * @param tx DOMDataWriteTransaction
+ * @param tx DOMDataWriteTransaction
* @param tablePath YangInstanceIdentifier
- * @param nlri ContainerNode DOM representation of NLRI in Update message
+ * @param nlri ContainerNode DOM representation of NLRI in Update message
*/
- void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri);
+ void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath,
+ @Nonnull ContainerNode nlri);
/**
* For default "bgp-rib" RIBs use {@link #deleteRoutes}
* </p>
*
- * @param tx DOMDataWriteTransaction
- * @param tablePath YangInstanceIdentifier
- * @param nlri ContainerNode DOM representation of NLRI in Update message
+ * @param tx DOMDataWriteTransaction
+ * @param tablePath YangInstanceIdentifier
+ * @param nlri ContainerNode DOM representation of NLRI in Update message
* @param routesNodeId NodeIdentifier of "routes" data node
*/
- void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull NodeIdentifier routesNodeId);
+ void deleteRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath,
+ @Nonnull ContainerNode nlri, @Nonnull NodeIdentifier routesNodeId);
/**
* Given the NLRI as ContainerNode, this method should extract advertised routes
* from the DOM model and put them into RIBs.
*
- * @param tx DOMDataWriteTransaction
- * @param tablePath YangInstanceIdentifier
- * @param nlri ContainerNode DOM representation of NLRI in Update message
+ * @param tx DOMDataWriteTransaction
+ * @param tablePath YangInstanceIdentifier
+ * @param nlri ContainerNode DOM representation of NLRI in Update message
* @param attributes ContainerNode
*/
- void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
+ void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath,
+ @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes);
/**
* Given the NLRI as ContainerNode, this method should extract advertised routes
* For default "bgp-rib" RIBs use {@link #putRoutes}
* </p>
*
- * @param tx DOMDataWriteTransaction
- * @param tablePath YangInstanceIdentifier
- * @param nlri ContainerNode DOM representation of NLRI in Update message
- * @param attributes ContainerNode
+ * @param tx DOMDataWriteTransaction
+ * @param tablePath YangInstanceIdentifier
+ * @param nlri ContainerNode DOM representation of NLRI in Update message
+ * @param attributes ContainerNode
* @param routesNodeId NodeIdentifier of "routes" data node
*/
- void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath, @Nonnull ContainerNode nlri,
- @Nonnull ContainerNode attributes, @Nonnull NodeIdentifier routesNodeId);
+ void putRoutes(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier tablePath,
+ @Nonnull ContainerNode nlri, @Nonnull ContainerNode attributes, @Nonnull NodeIdentifier routesNodeId);
/**
* Returns routes that were modified within this RIB support instance.
* @param routes DataTreeCandidateNode
* @return collection of modified nodes or empty collection if no node was modified
*/
- @Nonnull Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
+ @Nonnull
+ Collection<DataTreeCandidateNode> changedRoutes(@Nonnull DataTreeCandidateNode routes);
/**
* Constructs an instance identifier path to routeId.
*
* @param routesPath YangInstanceIdentifier base path
- * @param routeId PathArgument leaf path
+ * @param routeId PathArgument leaf path
* @return YangInstanceIdentifier with routesPath + specific RIB support routes path + routeId
*/
- @Nonnull YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath, @Nonnull PathArgument routeId);
+ @Nonnull
+ YangInstanceIdentifier routePath(@Nonnull YangInstanceIdentifier routesPath,
+ @Nonnull PathArgument routeId);
/**
* Indicate whether this AFI/SAFI combination is a complex route. Simple routes are those which
* binding-aware format. This needs to be done per each AFI/SAFI.
*
* @param advertised Collection of advertised routes in DOM format
- * @param withdrawn Collection of withdrawn routes in DOM format
- * @param attr Attributes MpReach is part of Attributes so we need to pass
- * it as argument, create new AttributesBuilder with existing
- * attributes and add MpReach
+ * @param withdrawn Collection of withdrawn routes in DOM format
+ * @param attr Attributes MpReach is part of Attributes so we need to pass
+ * it as argument, create new AttributesBuilder with existing
+ * attributes and add MpReach
* @return Update message ready to be sent out
*/
- @Nonnull Update buildUpdate(@Nonnull Collection<MapEntryNode> advertised, @Nonnull Collection<MapEntryNode> withdrawn, @Nonnull Attributes attr);
+ @Nonnull
+ Update buildUpdate(@Nonnull Collection<MapEntryNode> advertised,
+ @Nonnull Collection<MapEntryNode> withdrawn, @Nonnull Attributes attr);
- @Nonnull Class<? extends AddressFamily> getAfi();
+ @Nonnull
+ Class<? extends AddressFamily> getAfi();
- @Nonnull Class<? extends SubsequentAddressFamily> getSafi();
+ @Nonnull
+ Class<? extends SubsequentAddressFamily> getSafi();
interface ApplyRoute {
- void apply(DOMDataWriteTransaction tx, YangInstanceIdentifier base, NodeIdentifierWithPredicates routeKey, DataContainerNode<?> route,
- ContainerNode attributes);
+ void apply(@Nonnull DOMDataWriteTransaction tx, @Nonnull YangInstanceIdentifier base,
+ @Nonnull NodeIdentifierWithPredicates routeKey,
+ @Nonnull DataContainerNode<?> route, ContainerNode attributes);
}
}
}
/**
- * Creates Yang Instance Identifier path argument from supplied AFI and SAFI
+ * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
*
- * @param afi Class representing AFI
+ * @param afi Class representing AFI
* @param safi Class representing SAFI
* @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination.
*/
}
/**
- * Creates Yang Instance Identifier path argument from supplied AFI and SAFI
+ * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
*
- * @param id QNAME representing node
- * @param afi Class representing AFI
+ * @param id QNAME representing node
+ * @param afi Class representing AFI
* @param safi Class representing SAFI
* @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
- public static NodeIdentifierWithPredicates toYangKey(final QName id, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
+ public static NodeIdentifierWithPredicates toYangKey(final QName id, final Class<? extends AddressFamily> afi,
+ final Class<? extends SubsequentAddressFamily> safi) {
final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(
- AFI_QNAME, BindingReflections.findQName(afi),
- SAFI_QNAME, BindingReflections.findQName(safi));
+ AFI_QNAME, BindingReflections.findQName(afi),
+ SAFI_QNAME, BindingReflections.findQName(safi));
return new NodeIdentifierWithPredicates(id, keyValues);
}
/**
- * Creates Yang Instance Identifier path argument from supplied AFI and SAFI
+ * Creates Yang Instance Identifier path argument from supplied AFI and SAFI.
*
- * @param id QNAME representing node
- * @param afi Class representing AFI
+ * @param id QNAME representing node
+ * @param afi Class representing AFI
* @param safi Class representing SAFI
* @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
public static NodeIdentifierWithPredicates toYangPathKey(final QName id, final Class<? extends AddressFamily> afi,
- final Class<? extends SubsequentAddressFamily> safi) {
+ final Class<? extends SubsequentAddressFamily> safi) {
final ImmutableMap<QName, Object> keyValues = ImmutableMap.of(
- ADD_PATH_AFI_QNAME, BindingReflections.findQName(afi),
- ADD_PATH_SAFI_QNAME, BindingReflections.findQName(safi));
+ ADD_PATH_AFI_QNAME, BindingReflections.findQName(afi),
+ ADD_PATH_SAFI_QNAME, BindingReflections.findQName(safi));
return new NodeIdentifierWithPredicates(id, keyValues);
}
/**
- * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}
+ * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
*
* @param id QNAME representing node
- * @param k Tables key representing table.
+ * @param tablesKey Tables key representing table.
* @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
- public static NodeIdentifierWithPredicates toYangKey(final QName id, final TablesKey k) {
- return toYangKey(id, k.getAfi(), k.getSafi());
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
+ public static NodeIdentifierWithPredicates toYangKey(final QName id, final TablesKey tablesKey) {
+ return toYangKey(id, tablesKey.getAfi(), tablesKey.getSafi());
}
/**
- * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}
+ * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
*
* @param id QNAME representing node
- * @param k Add PAth Tables key representing table.
+ * @param tablesKey Add PAth Tables key representing table.
* @return NodeIdentifierWithPredicates of 'id' for specified AFI, SAFI combination.
*/
- public static NodeIdentifierWithPredicates toYangKey(final QName id, final SupportedTablesKey k) {
- return toYangPathKey(id, k.getAfi(), k.getSafi());
+ public static NodeIdentifierWithPredicates toYangKey(final QName id, final SupportedTablesKey tablesKey) {
+ return toYangPathKey(id, tablesKey.getAfi(), tablesKey.getSafi());
}
/**
- * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}
+ * Creates Yang Instance Identifier path argument from supplied {@link TablesKey}.
*
- * @param k Tables key representing table.
+ * @param tablesKey Tables key representing table.
* @return NodeIdentifierWithPredicates of {@link Tables} for specified AFI, SAFI combination.
*/
- public static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey k) {
- return toYangTablesKey(k.getAfi(), k.getSafi());
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
+ public static NodeIdentifierWithPredicates toYangTablesKey(final TablesKey tablesKey) {
+ return toYangTablesKey(tablesKey.getAfi(), tablesKey.getSafi());
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
public final class RouterIds {
- private static final LoadingCache<String, UnsignedInteger> ROUTER_IDS = CacheBuilder.newBuilder().weakValues().build(new CacheLoader<String, UnsignedInteger>() {
- @Override
- public UnsignedInteger load(final String key) {
- return UnsignedInteger.fromIntBits(InetAddresses.coerceToInteger(InetAddresses.forString(key)));
- }
- });
- private static final LoadingCache<PeerId, UnsignedInteger> BGP_ROUTER_IDS = CacheBuilder.newBuilder().weakValues().build(new CacheLoader<PeerId, UnsignedInteger>() {
- @Override
- public UnsignedInteger load(final PeerId key) {
- return routerIdForAddress(key.getValue().substring(BGP_PREFIX.length()));
- }
- });
+ private static final LoadingCache<String, UnsignedInteger> ROUTER_IDS =
+ CacheBuilder.newBuilder().weakValues().build(new CacheLoader<String, UnsignedInteger>() {
+ @Override
+ public UnsignedInteger load(final String key) {
+ return UnsignedInteger.fromIntBits(InetAddresses.coerceToInteger(InetAddresses.forString(key)));
+ }
+ });
private static final String BGP_PREFIX = "bgp://";
+ private static final LoadingCache<PeerId, UnsignedInteger> BGP_ROUTER_IDS =
+ CacheBuilder.newBuilder().weakValues().build(new CacheLoader<PeerId, UnsignedInteger>() {
+ @Override
+ public UnsignedInteger load(final PeerId key) {
+ return routerIdForAddress(key.getValue().substring(BGP_PREFIX.length()));
+ }
+ });
private RouterIds() {
throw new UnsupportedOperationException();
import static java.util.Objects.requireNonNull;
+import com.google.common.annotations.VisibleForTesting;
import java.util.ServiceLoader;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
-public final class ServiceLoaderRIBExtensionConsumerContext extends SimpleRIBExtensionProviderContext implements AutoCloseable {
+public final class ServiceLoaderRIBExtensionConsumerContext extends SimpleRIBExtensionProviderContext
+ implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(ServiceLoaderRIBExtensionConsumerContext.class);
private final ServiceLoader<RIBExtensionProviderActivator> loader;
}
}
- public static ServiceLoaderRIBExtensionConsumerContext createConsumerContext() {
- final ServiceLoader<RIBExtensionProviderActivator> loader = ServiceLoader.load(RIBExtensionProviderActivator.class);
- final ServiceLoaderRIBExtensionConsumerContext ctx = new ServiceLoaderRIBExtensionConsumerContext(loader);
+ @VisibleForTesting
+ static ServiceLoaderRIBExtensionConsumerContext createConsumerContext() {
+ final ServiceLoader<RIBExtensionProviderActivator> loader =
+ ServiceLoader.load(RIBExtensionProviderActivator.class);
- return ctx;
+ return new ServiceLoaderRIBExtensionConsumerContext(loader);
}
@Override
+ @SuppressWarnings("checkstyle:IllegalCatch")
public void close() {
for (RIBExtensionProviderActivator a : this.loader) {
try {
final Class<? extends SubsequentAddressFamily> safi, final T support) {
final TablesKey key = new TablesKey(afi, safi);
final RIBSupport prev = this.supports.putIfAbsent(key, support);
- Preconditions.checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
- this.domSupports.put(RibSupportUtils.toYangTablesKey(afi,safi), support);
+ Preconditions.checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s",
+ afi, safi, prev);
+ this.domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
addClassLoadingSupport(afi, safi, support);
return new AbstractRIBSupportRegistration<T>(support) {
@Override
};
}
- private void addClassLoadingSupport(final Class<?> afi, final Class<?> safi, final RIBSupport s) {
- final Set<YangModuleInfo> moduleInfos =
- getModuleInfos(afi, safi, s.routesListClass(), s.routesContainerClass(), s.routesCaseClass());
- if(!moduleInfos.isEmpty()) {
+ private void addClassLoadingSupport(final Class<?> afi, final Class<?> safi, final RIBSupport support) {
+ final Set<YangModuleInfo> moduleInfos = getModuleInfos(afi, safi, support.routesListClass(),
+ support.routesContainerClass(), support.routesCaseClass());
+ if (!moduleInfos.isEmpty()) {
this.classLoadingStrategy.addModuleInfos(moduleInfos);
}
}
+ @SuppressWarnings("checkstyle:IllegalCatch")
private static Set<YangModuleInfo> getModuleInfos(final Class<?>... clazzes) {
final Set<YangModuleInfo> moduleInfos = new HashSet<>();
- for(final Class<?> clz : clazzes) {
+ for (final Class<?> clz : clazzes) {
try {
moduleInfos.add(BindingReflections.getModuleInfo(clz));
} catch (final Exception e) {
}
@Override
- public RIBSupport getRIBSupport(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
+ public RIBSupport getRIBSupport(final Class<? extends AddressFamily> afi,
+ final Class<? extends SubsequentAddressFamily> safi) {
return getRIBSupport(new TablesKey(afi, safi));
}
}
@Override
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
public RIBSupport getRIBSupport(final NodeIdentifierWithPredicates key) {
return this.domSupports.get(key);
}
/**
* Starts and stops RIBExtensionProviderActivator instances for a RIBExtensionProviderContext.
- *
- * @author Thomas Pantelis
*/
public final class SimpleRIBExtensionProviderContextActivator implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(SimpleRIBExtensionProviderContextActivator.class);
public void start() {
LOG.info("Starting {} RIBExtensionProviderActivator instances", this.extensionActivators.size());
- for(final RIBExtensionProviderActivator e : this.extensionActivators) {
+ for (final RIBExtensionProviderActivator e : this.extensionActivators) {
e.startRIBExtensionProvider(this.providerContext);
}
}
public void close() {
LOG.info("Stopping {} RIBExtensionProviderActivator instances", this.extensionActivators.size());
- for(final RIBExtensionProviderActivator e : this.extensionActivators) {
+ for (final RIBExtensionProviderActivator e : this.extensionActivators) {
e.stopRIBExtensionProvider();
}
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
/**
- * BGP Operational Afi SafiS State
+ * BGP Operational Afi SafiS State.
*/
public interface BGPAfiSafiState extends BGPGracelfulRestartState {
/**
- * is AfiSafi Supported
+ * is AfiSafi Supported.
*
* @param tablesKey tables Key
* @return true if Afi Safi was advertized to and by the neighbor
boolean isAfiSafiSupported(@Nonnull TablesKey tablesKey);
/**
- * Prefixes installed per specific tablekey
+ * Prefixes installed per specific tablekey.
*
* @param tablesKey tables Key
* @return count
long getPrefixesInstalledCount(@Nonnull TablesKey tablesKey);
/**
- * Prefixed sent to the Peer count
+ * Prefixed sent to the Peer count.
*
* @param tablesKey tablesKey Type
* @return Prefixes sent count
long getPrefixesSentCount(@Nonnull TablesKey tablesKey);
/**
- * Prefixed received from the peer count
+ * Prefixed received from the peer count.
*
* @param tablesKey tablesKey Type
* @return Prefixed received count
long getPrefixesReceivedCount(@Nonnull TablesKey tablesKey);
/**
- * List of TablesKey - Afi Safi Advertized to the neighbor
+ * List of TablesKey - Afi Safi Advertized to the neighbor.
*
* @return TableKeys
*/
Set<TablesKey> getAfiSafisAdvertized();
/**
- * List of TablesKey - Afi Safi Advertized by neighbor
+ * List of TablesKey - Afi Safi Advertized by neighbor.
*
* @return TableKeys
*/
package org.opendaylight.protocol.bgp.rib.spi.state;
/**
- * BGP Operational Error Handling State
+ * BGP Operational Error Handling State.
*/
public interface BGPErrorHandlingState {
/**
- * Erroneous Update Received count
+ * Erroneous Update Received count.
*
* @return count
*/
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.rib.TablesKey;
/**
- * BGP Operational Graceful Restart State
+ * BGP Operational Graceful Restart State.
*/
public interface BGPGracelfulRestartState {
/**
- * is Graceful Restart Supported advertized to neighbor
+ * is Graceful Restart Supported advertized to neighbor.
*
* @param tablesKey tables Key
* @return true if Afi Safi was advertized to neighbor
boolean isGracefulRestartAdvertized(@Nonnull TablesKey tablesKey);
/**
- * is Graceful Restart Supported advertized by neighbor
+ * is Graceful Restart Supported advertized by neighbor.
*
* @param tablesKey tables Key
* @return true if Afi Safi was advertized by neighbor
*/
- boolean isGracefulRestartReceived(TablesKey tablesKey);
+ boolean isGracefulRestartReceived(@Nonnull TablesKey tablesKey);
/**
- * This flag indicates whether the local neighbor is currently restarting
+ * This flag indicates whether the local neighbor is currently restarting.
*
* @return local restarting state
*/
/**
* The period of time (advertised by the peer) that the peer expects a restart of a
- * BGP session to take
+ * BGP session to take.
*
* @return time
*/
/**
* This flag indicates whether the remote neighbor is currently in the process of
- * restarting, and hence received routes are currently stale
+ * restarting, and hence received routes are currently stale.
*
* @return peer is restarting
*/
package org.opendaylight.protocol.bgp.rib.spi.state;
/**
- * BGP Peer Messages Operational State
+ * BGP Peer Messages Operational State.
*/
public interface BGPPeerMessagesState {
/**
- * Update Messages Sent count
+ * Update Messages Sent count.
*
* @return count
*/
long getUpdateMessagesSentCount();
/**
- * Notification Messages Sent count
+ * Notification Messages Sent count.
*
* @return count
*/
long getNotificationMessagesSentCount();
/**
- * Update Messages Received count
+ * Update Messages Received count.
*
* @return count
*/
long getUpdateMessagesReceivedCount();
/**
- * Notification Update Messages Received count
+ * Notification Update Messages Received count.
*
* @return count
*/
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
/**
- * Representing operational state related to a particular BGP neighbor
+ * Representing operational state related to a particular BGP neighbor.
* - Counters for BGP messages sent and received from the neighbor
* - Operational state of timers associated with the BGP neighbor
* - Operational state of the transport session associated with the BGP neighbor
*/
public interface BGPPeerState extends RibReference {
/**
- * Indicates whether this instance is being actively managed and updated
+ * Indicates whether this instance is being actively managed and updated.
*
* @return active
*/
boolean isActive();
/**
- * PeerGroup Id
+ * PeerGroup Id.
*
* @return PeerGroup Id
*/
String getGroupId();
/**
- * Return Neighbor Key/Address
+ * Return Neighbor Key/Address.
*
* @return neighbor Address
*/
IpAddress getNeighborAddress();
/**
- * Paths installed under Effective-Rib-In for a BGP neighbor
+ * Paths installed under Effective-Rib-In for a BGP neighbor.
* Represented per Prefixes, the cost of calculate paths per each Prefix on Effective-Rib-in is not worth
* at this point, check comment under incrementPrefixesInstalled
*
}
/**
- * Prefixes installed under Effective-Rib-In for a BGP neighbor
+ * Prefixes installed under Effective-Rib-In for a BGP neighbor.
*
* @return Paths counter
*/
long getTotalPrefixes();
/**
- * Error Handling State
+ * Error Handling State.
+ *
* @return ErrorHandlingState
*/
@Nonnull
BGPErrorHandlingState getBGPErrorHandlingState();
/**
- * Afi Safi Operational State
+ * Afi Safi Operational State.
+ *
* @return AfiSafiState
*/
@Nonnull
BGPAfiSafiState getBGPAfiSafiState();
/**
- * BGP Session Operational State
+ * BGP Session Operational State.
+ *
* @return BGPSessionState
*/
- @Nullable BGPSessionState getBGPSessionState();
+ @Nullable
+ BGPSessionState getBGPSessionState();
/**
- * BGP Message Operational State
+ * BGP Message Operational State.
+ *
* @return BGPPeerMessagesState
*/
- @Nullable BGPPeerMessagesState getBGPPeerMessagesState();
+ @Nullable
+ BGPPeerMessagesState getBGPPeerMessagesState();
/**
- * BGP Operation Timers State
+ * BGP Operation Timers State.
+ *
* @return BGPTimersState
*/
- @Nullable BGPTimersState getBGPTimersState();
+ @Nullable
+ BGPTimersState getBGPTimersState();
/**
- * BGP Operational Transport State
+ * BGP Operational Transport State.
+ *
* @return BGPTransportState
*/
- @Nullable BGPTransportState getBGPTransportState();
+ @Nullable
+ BGPTransportState getBGPTransportState();
/**
- * BGP Operational GracelfulRestart State
+ * BGP Operational GracelfulRestart State.
+ *
* @return BGPGracelfulRestartState
*/
@Nonnull
import javax.annotation.Nullable;
/**
- * Interface for acquiring BGP Peer State
+ * Interface for acquiring BGP Peer State.
*/
public interface BGPPeerStateConsumer {
/**
- * Returns Peer Operational State
+ * Returns Peer Operational State.
+ *
* @return BGP Peer State
*/
@Nullable
package org.opendaylight.protocol.bgp.rib.spi.state;
+import javax.annotation.Nonnull;
import org.opendaylight.protocol.bgp.rib.spi.State;
/**
- * BGP Operational Session State
+ * BGP Operational Session State.
*/
public interface BGPSessionState {
/**
- * Internal session state
+ * Internal session state.
*
* @return Internal session state
*/
+ @Nonnull
State getSessionState();
/**
- * Additional Path capability
+ * Additional Path capability.
*
* @return true if supported
*/
boolean isAddPathCapabilitySupported();
/**
- * AS 4 Bytes capability
+ * AS 4 Bytes capability.
*
* @return true if supported
*/
boolean isAsn32CapabilitySupported();
/**
- * Graceful Restart
+ * Graceful Restart.
*
* @return true if supported
*/
boolean isGracefulRestartCapabilitySupported();
/**
- * Multiprotocol capability
+ * Multiprotocol capability.
*
* @return true if supported
*/
boolean isMultiProtocolCapabilitySupported();
/**
- * Router Refresh Capability
+ * Router Refresh Capability.
*
* @return true if supported
*/
package org.opendaylight.protocol.bgp.rib.spi.state;
import java.util.List;
+import javax.annotation.Nonnull;
/**
- * Provides list with Operational State of BGP RIBs
+ * Provides list with Operational State of BGP RIBs.
*/
public interface BGPStateConsumer {
/**
- * List of Registered BGP Rib States
+ * List of Registered BGP Rib States.
+ *
* @return ribs stats
*/
+ @Nonnull
List<BGPRIBState> getRibStats();
/**
- * List of Registered BGP Peer State
+ * List of Registered BGP Peer State.
+ *
* @return peers stats
*/
+ @Nonnull
List<BGPPeerState> getPeerStats();
}
package org.opendaylight.protocol.bgp.rib.spi.state;
+import javax.annotation.Nonnull;
+
/**
- * Provider of BGP Operational state
+ * Provider of BGP Operational state.
*/
public interface BGPStateProvider {
/**
- * register Rib state
+ * register Rib state.
+ *
* @param bgpState rib State
*/
- void bind(BGPRIBStateConsumer bgpState);
+ void bind(@Nonnull BGPRIBStateConsumer bgpState);
/**
- * Unregister Rib state
+ * Unregister Rib state.
+ *
* @param bgpState Rib/Peer State
*/
- void unbind(BGPRIBStateConsumer bgpState);
+ void unbind(@Nonnull BGPRIBStateConsumer bgpState);
/**
- * registerRib/Peer state
+ * registerRib/Peer state.
+ *
* @param bgpState rib State
*/
- void bind(BGPPeerStateConsumer bgpState);
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
+ void bind(@Nonnull BGPPeerStateConsumer bgpState);
/**
- * Unregister Peer state
+ * Unregister Peer state.
+ *
* @param bgpState Peer State
*/
- void unbind(BGPPeerStateConsumer bgpState);
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
+ void unbind(@Nonnull BGPPeerStateConsumer bgpState);
}
package org.opendaylight.protocol.bgp.rib.spi.state;
/**
- * BGP Operational Timer State
+ * BGP Operational Timer State.
*/
public interface BGPTimersState {
/**
- * Negotiated Hold Time
+ * Negotiated Hold Time.
*
* @return Hold Time
*/
long getNegotiatedHoldTime();
/**
- * The time (MILLISECONDS) for how long session has been up or on idle state
+ * The time (MILLISECONDS) for how long session has been up or on idle state.
*
* @return time
*/
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
/**
- * BGP Operational Transport State
+ * BGP Operational Transport State.
*/
public interface BGPTransportState {
/**
- * Local Port
+ * Local Port.
*
* @return port
*/
PortNumber getLocalPort();
/**
- * Remote Address
+ * Remote Address.
*
* @return IpAddress
*/
IpAddress getRemoteAddress();
/**
- * Remote Port
+ * Remote Port.
*
* @return port
*/
* execute repeated registration attempts while catching RuntimeException. If registration is not successful,
* RuntimeException is re-thrown.
*
- * @param singletonProvider
- * @param clusterSingletonService
+ * @param singletonProvider Cluster Singleton Service Provider
+ * @param clusterSingletonService Cluster Singleton Service
* @param maxAttempts Upper bound for registration retries count.
* @param sleepTime Sleep time between registration retries in milliseconds.
* @return Registration
*/
+ @SuppressWarnings("checkstyle:IllegalCatch")
public static ClusterSingletonServiceRegistration registerSingletonService(
final ClusterSingletonServiceProvider singletonProvider,
final ClusterSingletonService clusterSingletonService, final int maxAttempts, final int sleepTime) {
* RuntimeException is re-thrown. 10 registration attempts will be tried with 10 ms pause between each
* other.
*
- * @param singletonProvider
- * @param clusterSingletonService
+ * @param singletonProvider Cluster Singleton Service Provider
+ * @param clusterSingletonService Cluster Singleton Service
* @return Registration
*/
public static ClusterSingletonServiceRegistration registerSingletonService(final ClusterSingletonServiceProvider
package org.opendaylight.protocol.bgp.rib.spi;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.MockitoAnnotations.initMocks;
+
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
public abstract class AbstractRIBSupportTest {
protected static final long PATH_ID = 1;
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(Attributes2.class).child(MpUnreachNlri.class);
- private static final InstanceIdentifier<MpReachNlri> MP_REACH_IID = ATTRIBUTES_IID.augmentation(Attributes1.class).child(MpReachNlri.class);
+ 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(Attributes2.class).child(MpUnreachNlri.class);
+ private static final InstanceIdentifier<MpReachNlri> MP_REACH_IID = ATTRIBUTES_IID.augmentation(Attributes1.class)
+ .child(MpReachNlri.class);
@Mock
protected DOMDataWriteTransaction tx;
protected final void setUpTestCustomizer(final AbstractRIBSupport ribSupport) throws Exception {
this.abstractRIBSupport = ribSupport;
- this.moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport.routesContainerClass()));
+ this.moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(this.abstractRIBSupport
+ .routesContainerClass()));
this.mappingService.onGlobalContextUpdated(this.moduleInfoBackedContext.tryToCreateSchemaContext().get());
}
@Before
public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
- Mockito.doAnswer(invocation -> {
+ initMocks(this);
+ doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- AbstractRIBSupportTest.this.insertedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode<?, ?>) args[2]));
+ AbstractRIBSupportTest.this.insertedRoutes.add(AbstractRIBSupportTest.this.mappingService
+ .fromNormalizedNode((YangInstanceIdentifier) args[1], (NormalizedNode<?, ?>) args[2]));
return args[1];
- }).when(this.tx).put(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class), Mockito.any(NormalizedNode.class));
+ }).when(this.tx).put(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class),
+ any(NormalizedNode.class));
- Mockito.doAnswer(invocation -> {
+ doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
- AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService.fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
+ AbstractRIBSupportTest.this.deletedRoutes.add(AbstractRIBSupportTest.this.mappingService
+ .fromYangInstanceIdentifier((YangInstanceIdentifier) args[1]));
return args[1];
- }).when(this.tx).delete(Mockito.any(LogicalDatastoreType.class), Mockito.any(YangInstanceIdentifier.class));
+ }).when(this.tx).delete(any(LogicalDatastoreType.class), any(YangInstanceIdentifier.class));
this.deletedRoutes = new ArrayList<>();
this.insertedRoutes = new ArrayList<>();
- this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(),
- new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
+ this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy
+ .getTCCLClassLoadingStrategy(),
+ new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator
+ .create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
this.moduleInfoBackedContext = ModuleInfoBackedContext.create();
}
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.mappingService.toNormalizedNode(MP_UNREACH_IID, mpReach);
+ final MpUnreachNlri mpReach = new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder()
+ .setDestinationType(destUnreach).build()).build();
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> result = this.mappingService
+ .toNormalizedNode(MP_UNREACH_IID, mpReach);
return (ContainerNode) result.getValue();
}
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.mappingService.toNormalizedNode(MP_REACH_IID, mpReach);
+ final MpReachNlri mpReach = new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder()
+ .setDestinationType(destReach).build()).build();
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> result = this.mappingService
+ .toNormalizedNode(MP_REACH_IID, mpReach);
return (ContainerNode) result.getValue();
}
return this.mappingService.toYangInstanceIdentifier(routesIId).node(getRouteListQname());
}
+ @SuppressWarnings("checkstyle:OverloadMethodsDeclarationOrder")
protected final Collection<MapEntryNode> createRoutes(final DataObject routes) {
- Preconditions.checkArgument(routes.getImplementedInterface().equals(this.abstractRIBSupport.routesContainerClass()));
+ Preconditions.checkArgument(routes.getImplementedInterface()
+ .equals(this.abstractRIBSupport.routesContainerClass()));
final InstanceIdentifier<DataObject> routesIId = routesIId();
- final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNode = this.mappingService.toNormalizedNode(routesIId, routes);
+ final Map.Entry<YangInstanceIdentifier, NormalizedNode<?, ?>> normalizedNode = this.mappingService
+ .toNormalizedNode(routesIId, routes);
final ContainerNode container = (ContainerNode) normalizedNode.getValue();
final NodeIdentifier routeNid = new NodeIdentifier(getRouteListQname());
return ((MapNode) container.getChild(routeNid).get()).getValue();
}
private QName getRouteListQname() {
- return QName.create(BindingReflections.findQName(this.abstractRIBSupport.routesContainerClass()),
- BindingReflections.findQName(this.abstractRIBSupport.routesListClass()).intern().getLocalName());
+ return QName.create(BindingReflections.findQName(this.abstractRIBSupport.routesContainerClass()),
+ BindingReflections.findQName(this.abstractRIBSupport.routesListClass()).intern().getLocalName());
}
protected final NodeIdentifierWithPredicates createRouteNIWP(final DataObject routes) {
public class AddPathRibSupportTest {
private static final NodeIdentifier QNAME = new NodeIdentifier(QName.create("test").intern());
- private static class AddPathRibSupportLocalTest implements AddPathRibSupport{}
@Test
public void defaultAddPathRibSupport() {
assertNull(test.getRouteIdAddPath(NON_PATH_ID, null));
assertEquals(QNAME, test.createRouteKeyPathArgument(QNAME));
}
+
+ private static class AddPathRibSupportLocalTest implements AddPathRibSupport {
+ }
}
import static org.junit.Assert.assertEquals;
import com.google.common.collect.ImmutableMap;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerId;
private static final QName TABLES_KEY_QNAME = QName.create(Tables.QNAME, "tables-key").intern();
private static final TablesKey TK = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
private static final PeerId PEER_ID = new PeerId("127.0.0.1");
- private static final NodeIdentifierWithPredicates NIWP_PEER = new NodeIdentifierWithPredicates(Peer.QNAME, ImmutableMap.of(PEER_ID_QNAME, PEER_ID.getValue()));
- private static final NodeIdentifierWithPredicates NIWP_TABLE = new NodeIdentifierWithPredicates(Tables.QNAME, ImmutableMap.of(TABLES_KEY_QNAME, TK));
+ private static final NodeIdentifierWithPredicates NIWP_PEER = new NodeIdentifierWithPredicates(Peer.QNAME,
+ ImmutableMap.of(PEER_ID_QNAME, PEER_ID.getValue()));
+ private static final NodeIdentifierWithPredicates NIWP_TABLE = new NodeIdentifierWithPredicates(Tables.QNAME,
+ ImmutableMap.of(TABLES_KEY_QNAME, TK));
private static final YangInstanceIdentifier YII_PEER;
private static final YangInstanceIdentifier YII_TABLE;
static {
- YII_PEER = YangInstanceIdentifier.builder().node(BgpRib.QNAME).node(Peer.QNAME).nodeWithKey(Peer.QNAME, PEER_ID_QNAME, PEER_ID.getValue()).build();
- YII_TABLE = YangInstanceIdentifier.builder().node(LocRib.QNAME).node(Tables.QNAME).nodeWithKey(Tables.QNAME, TABLES_KEY_QNAME, TK).build();
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<IdentifierUtils> c = IdentifierUtils.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
+ YII_PEER = YangInstanceIdentifier.builder().node(BgpRib.QNAME).node(Peer.QNAME)
+ .nodeWithKey(Peer.QNAME, PEER_ID_QNAME, PEER_ID.getValue()).build();
+ YII_TABLE = YangInstanceIdentifier.builder().node(LocRib.QNAME).node(Tables.QNAME)
+ .nodeWithKey(Tables.QNAME, TABLES_KEY_QNAME, TK).build();
}
@Test
import static junit.framework.TestCase.assertFalse;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
private static final NodeIdentifierWithPredicates PREFIX_NII = new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
ImmutableMap.of(QName.create(Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
private static final MultiPathAbstractTest MULTI_PATH_ABSTRACT_TEST = new MultiPathAbstractTest();
- private static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier.create(YangInstanceIdentifier.of(BgpRib.QNAME)
+ private static final TablesKey TABLES_KEY = new TablesKey(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
+ private static final YangInstanceIdentifier LOC_RIB_TARGET = YangInstanceIdentifier
+ .create(YangInstanceIdentifier.of(BgpRib.QNAME)
.node(LocRib.QNAME).node(Tables.QNAME).node(RibSupportUtils.toYangTablesKey(TABLES_KEY)).getPathArguments());
private static final NodeIdentifier ROUTES_IDENTIFIER = new NodeIdentifier(Routes.QNAME);
private static final NodeIdentifier IPV4_ROUTES_IDENTIFIER = new NodeIdentifier(Ipv4Routes.QNAME);
this.tx = Mockito.mock(DOMDataWriteTransaction.class);
this.nlri = Mockito.mock(ContainerNode.class);
- this.attributes = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME
+ this.attributes = ImmutableContainerNodeBuilder.create()
+ .withNodeIdentifier(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME
.getLocalName().intern()))).build();
final ContainerNode destination = Mockito.mock(ContainerNode.class);
final ContainerNode route = Mockito.mock(ContainerNode.class);
final Object[] args = invocation.getArguments();
MultiPathAbstractRIBSupportTest.this.routes.remove(args[1]);
return args[1];
- }).when(this.tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.any(YangInstanceIdentifier.class));
+ }).when(this.tx).delete(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class));
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
final NormalizedNode<?, ?> node1 = (NormalizedNode<?, ?>) args[2];
MultiPathAbstractRIBSupportTest.this.routes.put((YangInstanceIdentifier) args[1], node1);
return args[1];
- }).when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), Mockito.any(YangInstanceIdentifier.class), Mockito.any(NormalizedNode.class));
+ }).when(this.tx).put(Mockito.eq(LogicalDatastoreType.OPERATIONAL), any(YangInstanceIdentifier.class),
+ any(NormalizedNode.class));
this.mapEntryNode = Mockito.mock(MapEntryNode.class);
}
@Test
public void extractPathId() {
final NodeIdentifier nii = new NodeIdentifier(PATH_ID_QNAME);
- final ContainerNode cont = ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(nii).
- addChild(new ImmutableLeafNodeBuilder<>().withNodeIdentifier(nii).withValue(PATH_ID).build()).build();
+ final ContainerNode cont = ImmutableContainerNodeSchemaAwareBuilder.create().withNodeIdentifier(nii)
+ .addChild(new ImmutableLeafNodeBuilder<>().withNodeIdentifier(nii).withValue(PATH_ID).build()).build();
assertEquals((Long) PATH_ID, MULTI_PATH_ABSTRACT_TEST.extractPathId(cont));
}
@Test
public void getRouteIdAddPath() {
final NodeIdentifierWithPredicates routeIdPa =
- new NodeIdentifierWithPredicates(Ipv4Route.QNAME, ImmutableMap.of(PATH_ID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX));
+ new NodeIdentifierWithPredicates(Ipv4Route.QNAME,
+ ImmutableMap.of(PATH_ID_QNAME, PATH_ID, PREFIX_QNAME, PREFIX));
assertEquals(routeIdPa, MULTI_PATH_ABSTRACT_TEST.getRouteIdAddPath(PATH_ID, PREFIX_NII));
}
@Test
public void emptyRoutes() throws Exception {
- final ChoiceNode emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES_IDENTIFIER).addChild(Builders.containerBuilder()
- .withNodeIdentifier(IPV4_ROUTES_IDENTIFIER).withChild(ImmutableNodes.mapNodeBuilder(MULTI_PATH_ABSTRACT_TEST.routeQName()
- ).build()).build())
- .build();
+ final ChoiceNode emptyRoutes = Builders.choiceBuilder().withNodeIdentifier(ROUTES_IDENTIFIER)
+ .addChild(Builders.containerBuilder().withNodeIdentifier(IPV4_ROUTES_IDENTIFIER)
+ .withChild(ImmutableNodes.mapNodeBuilder(MULTI_PATH_ABSTRACT_TEST.routeQName())
+ .build()).build()).build();
assertEquals(emptyRoutes, MULTI_PATH_ABSTRACT_TEST.emptyRoutes());
}
@Test
public void routeAttributesIdentifier() throws Exception {
- assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME, Attributes.QNAME.getLocalName().intern())), MULTI_PATH_ABSTRACT_TEST.routeAttributesIdentifier());
+ assertEquals(new NodeIdentifier(QName.create(Ipv4Routes.QNAME,
+ Attributes.QNAME.getLocalName().intern())), MULTI_PATH_ABSTRACT_TEST.routeAttributesIdentifier());
}
@Test
public void routePath() throws Exception {
- Assert.assertEquals(LOC_RIB_TARGET.node(ROUTES_IDENTIFIER).node(Ipv4Routes.QNAME).node(Ipv4Route.QNAME).node(PREFIX_NII),
+ Assert.assertEquals(LOC_RIB_TARGET.node(ROUTES_IDENTIFIER)
+ .node(Ipv4Routes.QNAME).node(Ipv4Route.QNAME).node(PREFIX_NII),
MULTI_PATH_ABSTRACT_TEST.routePath(LOC_RIB_TARGET.node(Routes.QNAME), PREFIX_NII));
}
@Test
public void buildUpdate() throws Exception {
- final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(
- new Ipv4Address("10.0.0.2")).build()).build();
+ final Ipv4NextHopCase nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+ .setGlobal(new Ipv4Address("10.0.0.2")).build()).build();
final Attributes attr = new AttributesBuilder().setCNextHop(nextHop).build();
final Collection<MapEntryNode> routes = new HashSet<>();
assertEquals(new UpdateBuilder().setAttributes(new AttributesBuilder().build()).build(),
- MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, routes, attr));
+ MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, routes, attr));
routes.add(this.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(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReach).build())
- .build();
- assertEquals(new UpdateBuilder().setAttributes(attMpR).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, Collections.emptySet(), attr));
-
- final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class)
- .setWithdrawnRoutes(new WithdrawnRoutesBuilder().build()).build();
-
- final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mpUnreach)
- .build()).build();
- assertEquals(new UpdateBuilder().setAttributes(attMpU).build(), MULTI_PATH_ABSTRACT_TEST.buildUpdate(Collections.emptySet(), routes, attr));
+ final MpReachNlri mpReach = new MpReachNlriBuilder().setAfi(Ipv4AddressFamily.class)
+ .setSafi(UnicastSubsequentAddressFamily.class)
+ .setCNextHop(nextHop).setAdvertizedRoutes(new AdvertizedRoutesBuilder().build()).build();
+
+ final Attributes attMpR = new AttributesBuilder().addAugmentation(Attributes1.class,
+ new Attributes1Builder().setMpReachNlri(mpReach).build()).build();
+ assertEquals(new UpdateBuilder().setAttributes(attMpR).build(),
+ MULTI_PATH_ABSTRACT_TEST.buildUpdate(routes, Collections.emptySet(), attr));
+
+ final MpUnreachNlri mpUnreach = new MpUnreachNlriBuilder().setAfi(Ipv4AddressFamily.class)
+ .setSafi(UnicastSubsequentAddressFamily.class)
+ .setWithdrawnRoutes(new WithdrawnRoutesBuilder().build()).build();
+
+ final Attributes attMpU = new AttributesBuilder().addAugmentation(Attributes2.class,
+ new Attributes2Builder().setMpUnreachNlri(mpUnreach).build()).build();
+ assertEquals(new UpdateBuilder().setAttributes(attMpU).build(),
+ MULTI_PATH_ABSTRACT_TEST.buildUpdate(Collections.emptySet(), routes, attr));
}
}
\ No newline at end of file
public class PeerExportGroupTest {
@Test
public void defaultPeerExportGroupTest() {
- final PeerExportGroup.PeerExporTuple peerExportGroup = new PeerExportGroup.PeerExporTuple(YangInstanceIdentifier.EMPTY, PeerRole.Ebgp);
+ final PeerExportGroup.PeerExporTuple peerExportGroup = new PeerExportGroup
+ .PeerExporTuple(YangInstanceIdentifier.EMPTY, PeerRole.Ebgp);
assertEquals(PeerRole.Ebgp, peerExportGroup.getRole());
assertEquals(YangInstanceIdentifier.EMPTY, peerExportGroup.getYii());
}
import static org.junit.Assert.assertNull;
import com.google.common.base.Optional;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.PeerRole;
import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafNodeBuilder;
public class PeerRoleUtilTest {
- @Test(expected = UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<PeerRoleUtil> c = PeerRoleUtil.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
@Test
public void roleForChange() {
assertNull(PeerRoleUtil.roleForChange(Optional.fromNullable(null)));
assertEquals(PeerRole.Ebgp, PeerRoleUtil.roleForChange(Optional.of(new ImmutableLeafNodeBuilder<>()
- .withNodeIdentifier(PeerRoleUtil.PEER_ROLE_NID).withValue("ebgp").build())));
+ .withNodeIdentifier(PeerRoleUtil.PEER_ROLE_NID).withValue("ebgp").build())));
}
@Test
public void roleForString() {
- assertEquals("ebgp",PeerRoleUtil.roleForString(PeerRole.Ebgp));
- assertEquals("ibgp",PeerRoleUtil.roleForString(PeerRole.Ibgp));
- assertEquals("rr-client",PeerRoleUtil.roleForString(PeerRole.RrClient));
- assertEquals("internal",PeerRoleUtil.roleForString(PeerRole.Internal));
+ assertEquals("ebgp", PeerRoleUtil.roleForString(PeerRole.Ebgp));
+ assertEquals("ibgp", PeerRoleUtil.roleForString(PeerRole.Ibgp));
+ assertEquals("rr-client", PeerRoleUtil.roleForString(PeerRole.RrClient));
+ assertEquals("internal", PeerRoleUtil.roleForString(PeerRole.Internal));
}
}
\ No newline at end of file
import static org.junit.Assert.assertTrue;
import com.google.common.collect.ImmutableMap;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import org.junit.Test;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.bgp.rib.rib.peer.SupportedTables;
public class RibSupportUtilsTest {
private static final NodeIdentifierWithPredicates NII;
private static final NodeIdentifierWithPredicates NII_PATH;
- final Class<? extends AddressFamily> AFI = Ipv4AddressFamily.class;
- final Class<? extends SubsequentAddressFamily> SAFI = UnicastSubsequentAddressFamily.class;
- private static final TablesKey TABLE_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private static final Class<? extends AddressFamily> AFI = Ipv4AddressFamily.class;
+ private static final Class<? extends SubsequentAddressFamily> SAFI = UnicastSubsequentAddressFamily.class;
+ private static final TablesKey TABLE_KEY = new TablesKey(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class);
+
static {
- final QName afi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2017-12-07", "afi");
- final QName safi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2017-12-07", "safi");
- NII = new NodeIdentifierWithPredicates(SupportedTables.QNAME, ImmutableMap.of(afi, Ipv4AddressFamily.QNAME, safi, UnicastSubsequentAddressFamily.QNAME));
+ final QName afi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2017-12-07",
+ "afi");
+ final QName safi = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-rib?revision=2017-12-07",
+ "safi");
+ NII = new NodeIdentifierWithPredicates(SupportedTables.QNAME, ImmutableMap.of(afi, Ipv4AddressFamily.QNAME,
+ safi, UnicastSubsequentAddressFamily.QNAME));
NII_PATH = new NodeIdentifierWithPredicates(SupportedTables.QNAME,
- ImmutableMap.of(
- QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2017-12-07", "afi"),
- Ipv4AddressFamily.QNAME,
- QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2017-12-07", "safi"),
- UnicastSubsequentAddressFamily.QNAME)
+ ImmutableMap.of(
+ QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2017-12-07",
+ "afi"), Ipv4AddressFamily.QNAME,
+ QName.create("urn:opendaylight:params:xml:ns:yang:bgp-multiprotocol?revision=2017-12-07",
+ "safi"), UnicastSubsequentAddressFamily.QNAME)
);
}
- @Test(expected=UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<RibSupportUtils> c = RibSupportUtils.class.getDeclaredConstructor(null);
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
@Test
public void testYangTablesKey() {
final NodeIdentifierWithPredicates p = RibSupportUtils.toYangTablesKey(TABLE_KEY);
final Map<QName, Object> m = p.getKeyValues();
assertFalse(m.isEmpty());
assertEquals(Tables.QNAME, p.getNodeType());
- assertTrue(m.containsValue(BindingReflections.findQName(this.AFI)));
- assertTrue(m.containsValue(BindingReflections.findQName(this.SAFI)));
+ assertTrue(m.containsValue(BindingReflections.findQName(AFI)));
+ assertTrue(m.containsValue(BindingReflections.findQName(SAFI)));
}
@Test
final Map<QName, Object> m = p.getKeyValues();
assertFalse(m.isEmpty());
assertEquals(SupportedTables.QNAME, p.getNodeType());
- assertTrue(m.containsValue(BindingReflections.findQName(this.AFI)));
- assertTrue(m.containsValue(BindingReflections.findQName(this.SAFI)));
+ assertTrue(m.containsValue(BindingReflections.findQName(AFI)));
+ assertTrue(m.containsValue(BindingReflections.findQName(SAFI)));
}
@Test
public void toYangPathKey() {
- final NodeIdentifierWithPredicates result = RibSupportUtils.toYangPathKey(SupportedTables.QNAME, this.AFI, this.SAFI);
+ final NodeIdentifierWithPredicates result = RibSupportUtils.toYangPathKey(SupportedTables.QNAME, AFI, SAFI);
assertEquals(NII_PATH.toString(), result.toString());
}
+
@Test
public void toYangKey() {
final NodeIdentifierWithPredicates result = RibSupportUtils.toYangKey(SupportedTables.QNAME, TABLE_KEY);
public class RouterIdsTest {
- UnsignedInteger unsignedRouterId = UnsignedInteger.valueOf(707406378);
- PeerId peerID = new PeerId("bgp://42.42.42.42");
+ private UnsignedInteger unsignedRouterId = UnsignedInteger.valueOf(707406378);
+ private PeerId peerID = new PeerId("bgp://42.42.42.42");
@Test
public void testRouterIdForAddress() throws Exception {
public class SimpleRIBExtensionProviderContextActivatorTest {
private static boolean RIBACTIVATED;
- private static class RibActivator extends AbstractRIBExtensionProviderActivator {
- @Override
- protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
- RIBACTIVATED = true;
- return Collections.singletonList(() -> RIBACTIVATED = false);
- }
- }
-
@Test
public void test() throws Exception {
final List<RIBExtensionProviderActivator> extensionActivators = Collections.singletonList(new RibActivator());
final SimpleRIBExtensionProviderContextActivator activator =
- new SimpleRIBExtensionProviderContextActivator(new SimpleRIBExtensionProviderContext(), extensionActivators);
+ new SimpleRIBExtensionProviderContextActivator(new SimpleRIBExtensionProviderContext(),
+ extensionActivators);
activator.start();
assertTrue(RIBACTIVATED);
activator.close();
assertFalse(RIBACTIVATED);
}
+
+ private static class RibActivator extends AbstractRIBExtensionProviderActivator {
+ @Override
+ protected List<AutoCloseable> startRIBExtensionProviderImpl(final RIBExtensionProviderContext context) {
+ RIBACTIVATED = true;
+ return Collections.singletonList(() -> RIBACTIVATED = false);
+ }
+ }
}
\ No newline at end of file
@Test
public void testExtensionProvider() {
- final ServiceLoaderRIBExtensionConsumerContext ctx = ServiceLoaderRIBExtensionConsumerContext.createConsumerContext();
+ final ServiceLoaderRIBExtensionConsumerContext ctx =
+ ServiceLoaderRIBExtensionConsumerContext.createConsumerContext();
Assert.assertNull(ctx.getRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
final TestActivator act = new TestActivator();
act.startRIBExtensionProvider(ctx);
Mockito.doReturn(Route.class).when(support).routesListClass();
Mockito.doReturn(DataObject.class).when(support).routesContainerClass();
Mockito.doReturn(DataObject.class).when(support).routesCaseClass();
- return Lists.newArrayList((AutoCloseable)context.registerRIBSupport(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, support));
+ return Lists.newArrayList((AutoCloseable)context.registerRIBSupport(Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, support));
}
}
}
@Test
public void testTerminationReason() {
- assertEquals(BGPError.BAD_PEER_AS.toString(), new BGPTerminationReason(BGPError.BAD_PEER_AS).getErrorMessage());
- assertEquals("BGPTerminationReason{error=BAD_PEER_AS}", new BGPTerminationReason(BGPError.BAD_PEER_AS).toString());
+ assertEquals(BGPError.BAD_PEER_AS.toString(), new BGPTerminationReason(BGPError.BAD_PEER_AS)
+ .getErrorMessage());
+ assertEquals("BGPTerminationReason{error=BAD_PEER_AS}",
+ new BGPTerminationReason(BGPError.BAD_PEER_AS).toString());
}
}
package org.opendaylight.protocol.bgp.rib.spi.util;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.mockito.MockitoAnnotations.initMocks;
import static org.opendaylight.protocol.bgp.rib.spi.util.ClusterSingletonServiceRegistrationHelper.registerSingletonService;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
@Before
public void setUp() {
- MockitoAnnotations.initMocks(this);
- Mockito.doReturn(null).when(this.singletonProvider).registerClusterSingletonService(Mockito.any());
- Mockito.when(this.singletonProvider.registerClusterSingletonService(Mockito.any()))
- .thenThrow(new RuntimeException())
- .thenReturn(this.serviceRegistration);
+ initMocks(this);
+ doReturn(null).when(this.singletonProvider).registerClusterSingletonService(any());
+ Mockito.when(this.singletonProvider.registerClusterSingletonService(any()))
+ .thenThrow(new RuntimeException())
+ .thenReturn(this.serviceRegistration);
}
- @Test(expected=UnsupportedOperationException.class)
- public void testPrivateConstructor() throws Throwable {
- final Constructor<ClusterSingletonServiceRegistrationHelper> c = ClusterSingletonServiceRegistrationHelper.class.getDeclaredConstructor();
- c.setAccessible(true);
- try {
- c.newInstance();
- } catch (final InvocationTargetException e) {
- throw e.getCause();
- }
- }
-
- @Test(expected=RuntimeException.class)
+ @Test(expected = RuntimeException.class)
public void testRegisterSingletonServiceFailure() {
registerSingletonService(this.singletonProvider, this.clusterSingletonService, 0, 1);
}
@Test
public void testRegisterSingletonServiceSuccessfulRetry() {
final ClusterSingletonServiceRegistration registerSingletonService =
- registerSingletonService(this.singletonProvider, this.clusterSingletonService, 1, 1);
- Assert.assertEquals(this.serviceRegistration, registerSingletonService);
+ registerSingletonService(this.singletonProvider, this.clusterSingletonService, 1, 1);
+ assertEquals(this.serviceRegistration, registerSingletonService);
//first reg. attempt failed, second succeeded
- Mockito.verify(this.singletonProvider, Mockito.times(2)).registerClusterSingletonService(Mockito.any());
+ verify(this.singletonProvider, Mockito.times(2)).registerClusterSingletonService(any());
}
}
import org.opendaylight.yangtools.yang.common.QName;
public interface Ipv4Prefixes {
- QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+ QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
"2015-03-05", "ipv4-prefixes").intern();
}
import org.opendaylight.yangtools.yang.common.QName;
public interface Ipv4Route extends Route {
- QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+ QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
"2015-03-05", "ipv4-route").intern();
}
import org.opendaylight.yangtools.yang.common.QName;
public interface Ipv4Routes extends DataObject {
- QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+ QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
"2015-03-05", "ipv4-routes").intern();
}
import org.opendaylight.yangtools.yang.common.QName;
public interface Ipv4RoutesCase extends Routes {
- QName QNAME = org.opendaylight.yangtools.yang.common.QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
+ QName QNAME = QName.create("urn:opendaylight:params:xml:ns:yang:bgp-inet",
"2015-03-05", "ipv4-routes-case").intern();
}
ImmutableMap.of(QName.create(Ipv4Route.QNAME, ROUTE_KEY).intern(), PREFIX));
public MultiPathAbstractTest() {
- super(Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class, Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class, ROUTE_KEY, Ipv4Prefixes.QNAME);
+ super(Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class, Ipv4AddressFamily.class,
+ UnicastSubsequentAddressFamily.class, ROUTE_KEY, Ipv4Prefixes.QNAME);
}
@Nonnull
}
@Override
- protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath, final ContainerNode destination,
- final ContainerNode attributes, final ApplyRoute applyFunction) {
+ protected void processDestination(final DOMDataWriteTransaction tx, final YangInstanceIdentifier routesPath,
+ final ContainerNode destination, final ContainerNode attributes, final ApplyRoute applyFunction) {
applyFunction.apply(tx, routesPath.node(Ipv4Route.QNAME), PREFIX_NII, destination, attributes);
}