From: Robert Varga Date: Sat, 15 Dec 2018 10:54:30 +0000 (+0100) Subject: Fix more rib-impl checkstyle X-Git-Tag: release/neon~52 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=2d5f12e857c10f59b12f2efe8bac7761e0b25ca1;p=bgpcep.git Fix more rib-impl checkstyle This brings the number of violations below 60. Change-Id: I177545b21da1f965a6db936341223a732560d4d0 Signed-off-by: Robert Varga --- diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java index 1389359b2c..059f82a6cd 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AbstractBGPSessionNegotiator.java @@ -47,9 +47,7 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter // 4 minutes recommended in http://tools.ietf.org/html/rfc4271#section-8.2.2 private static final int INITIAL_HOLDTIMER = 4; - /** - * @see BGP Support for 4-Octet AS Number Space - */ + // BGP Support for 4-Octet AS Number Space private static final int AS_TRANS = 23456; private static final Logger LOG = LoggerFactory.getLogger(AbstractBGPSessionNegotiator.class); private final BGPPeerRegistry registry; @@ -234,6 +232,8 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter } /** + * Get destination identifier. + * * @param openMsg Open message received from remote BGP speaker * @param preferences Local BGP speaker preferences * @return BGP Id of device that accepted the connection @@ -241,6 +241,8 @@ abstract class AbstractBGPSessionNegotiator extends ChannelInboundHandlerAdapter protected abstract Ipv4Address getDestinationId(Open openMsg, BGPSessionPreferences preferences); /** + * Get source identifier. + * * @param openMsg Open message received from remote BGP speaker * @param preferences Local BGP speaker preferences * @return BGP Id of device that accepted the connection diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java index f17dbdad5c..89885ce6c4 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/AdjRibInWriter.java @@ -142,10 +142,10 @@ final class AdjRibInWriter { * method returns, the old instance must not be reasonably used. * * @param newPeerId new peer BGP identifier - * @param peerPath + * @param peerPath path of the peer in the datastore * @param registry RIB extension registry * @param tableTypes New tables, must not be null - * @param addPathTablesType + * @param addPathTablesType supported add path tables * @return New writer */ AdjRibInWriter transform(final PeerId newPeerId, final YangInstanceIdentifier peerPath, @@ -187,7 +187,7 @@ final class AdjRibInWriter { } /** - * Create new table instances, potentially creating their empty entries + * Create new table instances, potentially creating their empty entries. */ private static ImmutableMap createNewTableInstances( final YangInstanceIdentifier newPeerPath, final RIBSupportContextRegistry registry, @@ -387,7 +387,7 @@ final class AdjRibInWriter { LOG.warn("Failed to store stale routes for table {}", tablesKey, throwable); latch.countDown(); } - }, MoreExecutors.directExecutor()); + }, MoreExecutors.directExecutor()); } } diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java index 96e55c8d92..06844d17e4 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/ApplicationPeer.java @@ -70,12 +70,15 @@ import org.slf4j.LoggerFactory; * Application Peer is a special case of BGP peer. It serves as an interface * for user to advertise user routes to ODL and through ODL to other BGP peers. * + *

* This peer has it's own RIB, where it stores all user routes. This RIB is * located in configurational datastore. Routes are added through RESTCONF. * + *

* They are then processed as routes from any other peer, through AdjRib, * EffectiveRib,LocRib and if they are advertised further, through AdjRibOut. * + *

* For purposed of import policies such as Best Path Selection, application * peer needs to have a BGP-ID that is configurable. */ @@ -244,8 +247,8 @@ public class ApplicationPeer extends AbstractPeer implements ClusteredDOMDataTre // No-op break; case SUBTREE_MODIFIED: - //For be ables to use DELETE when we remove specific routes as we do when we remove the whole routes, - // we need to go deeper three levels + // For be ables to use DELETE when we remove specific routes as we do when we remove the whole + // routes, we need to go deeper three levels if (!routeTableIdentifier.equals(childIdentifier.getParent().getParent().getParent())) { processRoutesTable(child, childIdentifier, tx, routeTableIdentifier); break; diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java index e7fd673692..60d9cf0221 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPDispatcherImpl.java @@ -154,8 +154,8 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable { @Override public synchronized ChannelFuture createServer(final InetSocketAddress serverAddress) { final BGPServerSessionNegotiatorFactory snf = new BGPServerSessionNegotiatorFactory(this.bgpPeerRegistry); - final ChannelPipelineInitializer initializer = BGPChannel. - createChannelPipelineInitializer(this.handlerFactory, snf); + final ChannelPipelineInitializer initializer = BGPChannel.createChannelPipelineInitializer( + this.handlerFactory, snf); final ServerBootstrap serverBootstrap = createServerBootstrap(initializer); final ChannelFuture channelFuture = serverBootstrap.bind(serverAddress); LOG.debug("Initiated server {} at {}.", channelFuture, serverAddress); @@ -199,7 +199,7 @@ public class BGPDispatcherImpl implements BGPDispatcher, AutoCloseable { } static > ChannelPipelineInitializer - createChannelPipelineInitializer(final BGPHandlerFactory hf, final T snf) { + createChannelPipelineInitializer(final BGPHandlerFactory hf, final T snf) { return (channel, promise) -> { channel.pipeline().addLast(hf.getDecoders()); channel.pipeline().addLast(NEGOTIATOR, snf.getSessionNegotiator(channel, promise)); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageHeaderDecoder.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageHeaderDecoder.java index 308b542950..2645401c61 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageHeaderDecoder.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageHeaderDecoder.java @@ -10,6 +10,7 @@ package org.opendaylight.protocol.bgp.rib.impl; import io.netty.handler.codec.LengthFieldBasedFrameDecoder; /** + * Decoder for BGP message headers. * @see BGP Message Header */ final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder { diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageToByteEncoder.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageToByteEncoder.java index 58c35513e2..965eae8b0a 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageToByteEncoder.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPMessageToByteEncoder.java @@ -19,9 +19,6 @@ import org.opendaylight.yangtools.yang.binding.Notification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** - * - */ @Sharable final class BGPMessageToByteEncoder extends MessageToByteEncoder { private static final Logger LOG = LoggerFactory.getLogger(BGPMessageToByteEncoder.class); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java index d6a837ad4b..b2fa31e8aa 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPPeer.java @@ -110,7 +110,8 @@ import org.slf4j.LoggerFactory; */ public class BGPPeer extends AbstractPeer implements BGPSessionListener { private static final Logger LOG = LoggerFactory.getLogger(BGPPeer.class); - private static final TablesKey IPV4_UCAST_TABLE_KEY = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class); + private static final TablesKey IPV4_UCAST_TABLE_KEY = new TablesKey(Ipv4AddressFamily.class, + UnicastSubsequentAddressFamily.class); private Set tables = Collections.emptySet(); private final RIB rib; @@ -354,8 +355,9 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener { } final GracefulRestartCapability advertisedGracefulRestartCapability = session.getAdvertisedGracefulRestartCapability(); - final List advertisedTables = - advertisedGracefulRestartCapability.getTables(); + final List advertisedTables = + advertisedGracefulRestartCapability.getTables(); final List addPathTablesType = session.getAdvertisedAddPathTableTypes(); final Set advertizedTableTypes = session.getAdvertisedTableTypes(); LOG.info("Session with peer {} went up with tables {} and Add Path tables {}", this.name, @@ -386,8 +388,8 @@ public class BGPPeer extends AbstractPeer implements BGPSessionListener { new BgpPeerRpc(this, session, this.tables)); final KeyedInstanceIdentifier path = this.rib.getInstanceIdentifier() - .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp.rib - .rib.Peer.class, new PeerKey(this.peerId)); + .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.bgp + .rib.rib.Peer.class, new PeerKey(this.peerId)); this.rpcRegistration.registerPath(PeerContext.class, path); } } else { diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java index 5804ee0f9f..abf3b7f09a 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/BGPSessionImpl.java @@ -99,7 +99,7 @@ public class BGPSessionImpl extends SimpleChannelInboundHandler im private long lastMessageSentAt; /** - * System.nanoTime value about when was received the last message + * System.nanoTime value about when was received the last message. */ private long lastMessageReceivedAt; @@ -236,8 +236,6 @@ public class BGPSessionImpl extends SimpleChannelInboundHandler im * message arrived already in the channel buffer. Thus #AbstractBGPSessionNegotiator.handleMessage(..) * gets invoked again and a deadlock is caused. A BGP final state machine error will happen as BGP * negotiator is still in OPEN_SENT state as the session constructor hasn't returned yet. - * - * @param remoteOpen */ public synchronized void setChannelExtMsgCoder(final Open remoteOpen) { final boolean enableExMess = BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(remoteOpen); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java index f5179dbdcb..95c40129dc 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/EffectiveRibInWriter.java @@ -81,8 +81,10 @@ import org.slf4j.LoggerFactory; /** * Implementation of the BGP import policy. Listens on peer's Adj-RIB-In, inspects all inbound * routes in the context of the advertising peer's role and applies the inbound policy. + * *

* Inbound policy is applied as follows: + * *

* 1) if the peer is an eBGP peer, perform attribute replacement and filtering * 2) check if a route is admissible based on attributes attached to it, as well as the @@ -192,10 +194,9 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn case DELETE: final Tables removeTable = table.getDataBefore(); final TablesKey tableKey = removeTable.key(); - final KeyedInstanceIdentifier effectiveTablePath - = this.effRibTables.child(Tables.class, tableKey); - LOG.debug("Delete Effective Table {} modification type {}, " - , effectiveTablePath, modificationType); + final KeyedInstanceIdentifier effectiveTablePath = this.effRibTables + .child(Tables.class, tableKey); + LOG.debug("Delete Effective Table {} modification type {}, ", effectiveTablePath, modificationType); tx.delete(LogicalDatastoreType.OPERATIONAL, effectiveTablePath); CountersUtil.decrement(this.prefixesInstalled.get(tableKey), tableKey); break; @@ -354,7 +355,7 @@ final class EffectiveRibInWriter implements PrefixesReceivedCounters, PrefixesIn final R route, final WriteTransaction tx) { final Optional rtMembership = RouteTargetMembeshipUtil.getRT(route); if (rtMembership.isPresent()) { - if(PeerRole.Ebgp != this.peerImportParameters.getFromPeerRole()) { + if (PeerRole.Ebgp != this.peerImportParameters.getFromPeerRole()) { this.rtCache.uncacheRoute(route); } this.rtMemberships.remove(rtMembership.get()); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java index 4c6e5faf8a..d20060fb1a 100755 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/RIBImpl.java @@ -144,7 +144,8 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh this.ribPolicies = requireNonNull(ribPolicies); this.codecsRegistry = codecsRegistry; this.ribContextRegistry = RIBSupportContextRegistryImpl.create(extensions, this.codecsRegistry); - final InstanceIdentifierBuilder yangRibIdBuilder = YangInstanceIdentifier.builder().node(BgpRib.QNAME).node(Rib.QNAME); + final InstanceIdentifierBuilder yangRibIdBuilder = YangInstanceIdentifier.builder().node(BgpRib.QNAME) + .node(Rib.QNAME); this.yangRibId = yangRibIdBuilder.nodeWithKey(Rib.QNAME, RIB_ID_QNAME, ribId.getValue()).build(); this.bestPathSelectionStrategies = requireNonNull(bestPathSelectionStrategies); this.ribId = ribId; @@ -351,11 +352,11 @@ public final class RIBImpl extends BGPRIBStateImpl implements RIB, TransactionCh .addChild(ImmutableNodes.mapNodeBuilder(Tables.QNAME).build()) .build()).build(); - final DOMDataWriteTransaction trans = this.domChain.newWriteOnlyTransaction(); // merge empty BgpRib + Rib, to make sure the top-level parent structure is present - trans.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().node(BgpRib.QNAME).build(), bgpRib); + trans.merge(LogicalDatastoreType.OPERATIONAL, YangInstanceIdentifier.builder().node(BgpRib.QNAME).build(), + bgpRib); trans.put(LogicalDatastoreType.OPERATIONAL, this.yangRibId, ribInstance); try { diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java index 0426756840..748d56df76 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/StrictBGPPeerRegistry.java @@ -287,7 +287,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { /** * Session identifier that contains (source Bgp Id) -> (destination Bgp Id) AsNumber is the remoteAs coming from - * remote Open message + * remote Open message. */ private static final class BGPSessionId { @@ -302,7 +302,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { } /** - * Equals does not take direction of connection into account id1 -> id2 and id2 -> id1 are equal + * Equals does not take direction of connection into account id1 -> id2 and id2 -> id1 are equal. */ @Override public boolean equals(final Object obj) { @@ -334,7 +334,7 @@ public final class StrictBGPPeerRegistry implements BGPPeerRegistry { } /** - * Check if this connection is equal to other and if it contains higher source bgp id + * Check if this connection is equal to other and if it contains higher source bgp id. */ boolean isHigherDirection(final BGPSessionId other) { return toLong(this.from) > toLong(other.from); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtil.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtil.java index 33d459b6b3..51d7ab7f92 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtil.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/config/OpenConfigMappingUtil.java @@ -87,44 +87,6 @@ final class OpenConfigMappingUtil { return rootIdentifier.firstKeyOf(Protocol.class).getName(); } - @Nullable - private static Integer getHoldTimer(final Timers timers) { - if (timers == null) { - return null; - } - final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers - .Config config = timers.getConfig(); - if (config != null && config.getHoldTime() != null) { - return config.getHoldTime().intValue(); - } - return null; - } - - @Nullable - private static AsNumber getRemotePeerAs(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp - .rev151009.bgp.neighbor.group.Config config) { - if (config != null) { - final AsNumber peerAs = config.getPeerAs(); - if (peerAs != null) { - return peerAs; - } - } - return null; - } - - @Nullable - private static Integer getRetryTimer(final Timers timers) { - if (timers == null) { - return null; - } - final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers - .Config config = timers.getConfig(); - if (config != null && config.getConnectRetry() != null) { - return config.getConnectRetry().intValue(); - } - return null; - } - static KeyMapping getNeighborKey(final Neighbor neighbor) { if (neighbor.getConfig() != null) { final String authPassword = neighbor.getConfig().getAuthPassword(); @@ -145,21 +107,6 @@ final class OpenConfigMappingUtil { return Ipv4Util.toStringIP(rootIdentifier.firstKeyOf(Neighbor.class).getNeighborAddress()); } - @Nullable - private static > PortNumber getPort( - @Nullable final Transport transport, final Class augment) { - if (transport != null) { - final Config config = transport.getConfig(); - if (config != null) { - final T peerTc = config.augmentation(augment); - if (peerTc != null) { - return peerTc.getRemotePort(); - } - } - } - return null; - } - //make sure IPv4 Unicast (RFC 4271) when required static List getAfiSafiWithDefault( final BgpCommonAfiSafiList afiSAfis, final boolean setDeafultIPv4) { @@ -374,6 +321,19 @@ final class OpenConfigMappingUtil { return hold; } + @Nullable + private static Integer getHoldTimer(final Timers timers) { + if (timers == null) { + return null; + } + final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers + .Config config = timers.getConfig(); + if (config != null && config.getHoldTime() != null) { + return config.getHoldTime().intValue(); + } + return null; + } + static int getGracefulRestartTimer(final Neighbor neighbor, final PeerGroup peerGroup, final int holdTimer) { Integer timer = null; if (peerGroup != null) { @@ -425,6 +385,12 @@ final class OpenConfigMappingUtil { return neighborAs; } + @Nullable + private static AsNumber getRemotePeerAs(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp + .rev151009.bgp.neighbor.group.Config config) { + return config == null ? null : config.getPeerAs(); + } + @Nonnull static AsNumber getLocalPeerAs(@Nullable final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp .rev151009.bgp.neighbor.group.Config config, @Nonnull final AsNumber globalAs) { @@ -454,6 +420,19 @@ final class OpenConfigMappingUtil { return retryTimer; } + @Nullable + private static Integer getRetryTimer(final Timers timers) { + if (timers == null) { + return null; + } + final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.timers + .Config config = timers.getConfig(); + if (config != null && config.getConnectRetry() != null) { + return config.getConnectRetry().intValue(); + } + return null; + } + @Nonnull static PortNumber getPort(final Neighbor neighbor, final PeerGroup peerGroup) { PortNumber port = null; @@ -472,6 +451,21 @@ final class OpenConfigMappingUtil { return port; } + @Nullable + private static > PortNumber getPort( + @Nullable final Transport transport, final Class augment) { + if (transport != null) { + final Config config = transport.getConfig(); + if (config != null) { + final T peerTc = config.augmentation(augment); + if (peerTc != null) { + return peerTc.getRemotePort(); + } + } + } + return null; + } + @Nullable static IpAddress getLocalAddress(@Nullable final Transport transport) { if (transport != null && transport.getConfig() != null) { diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPMessagesListener.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPMessagesListener.java index 66e056ead4..3fa117d83f 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPMessagesListener.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPMessagesListener.java @@ -12,7 +12,7 @@ import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.binding.Notification; /** - * BGP Operational Messages Listener State + * BGP Operational Messages Listener State. */ public interface BGPMessagesListener { /** diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPPeerRegistry.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPPeerRegistry.java index 2bb2fcc163..05400e0fe8 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPPeerRegistry.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/BGPPeerRegistry.java @@ -5,7 +5,6 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ - package org.opendaylight.protocol.bgp.rib.impl.spi; import javax.annotation.Nonnull; @@ -68,10 +67,11 @@ public interface BGPPeerRegistry extends AutoCloseable { throws BGPDocumentedException; /** + * Get preferences for a remote peer. + * * @param ip address of remote peer * @return BGP session preferences for configured peer - * - * @throws java.lang.IllegalStateException if there is no peer configured for provided ip address + * @throws IllegalStateException if there is no peer configured for provided ip address */ BGPSessionPreferences getPeerPreferences(IpAddress ip); diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIBSupportContext.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIBSupportContext.java index 00c9152aa6..2dd8ca8fa6 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIBSupportContext.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/spi/RIBSupportContext.java @@ -25,16 +25,12 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates; /** - * * {@link RIBSupport} wrapper which provides additional functionality * such as logic to update / remove routes using Binding DTOs * for BGP messages. - * */ public abstract class RIBSupportContext { - /** - * * Create specified Rib table structure using supplied transaction. * * @param tx Transaction to to be used @@ -52,10 +48,8 @@ public abstract class RIBSupportContext { public abstract void deleteRoutes(DOMDataWriteTransaction tx, YangInstanceIdentifier tableId, MpUnreachNlri nlri); /** - * * Writes supplied routes and attributes to RIB table using supplied transaction. * - * * @param tx Transaction to be used * @param tableId Instance Identifier of table to be updated * @param nlri ReachNlri which contains routes to be written. diff --git a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/state/BGPPeerStateImpl.java b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/state/BGPPeerStateImpl.java index cbfcc17315..12d2c441cf 100644 --- a/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/state/BGPPeerStateImpl.java +++ b/bgp/rib-impl/src/main/java/org/opendaylight/protocol/bgp/rib/impl/state/BGPPeerStateImpl.java @@ -118,8 +118,8 @@ public abstract class BGPPeerStateImpl extends DefaultRibReference implements BG @Override public final synchronized boolean isAfiSafiSupported(final TablesKey tablesKey) { - return this.prefixesReceived != null && this.prefixesReceived.isSupported(tablesKey) && - this.afiSafisAdvertized.contains(tablesKey); + return this.prefixesReceived != null && this.prefixesReceived.isSupported(tablesKey) + && this.afiSafisAdvertized.contains(tablesKey); } @Override @@ -188,7 +188,7 @@ public abstract class BGPPeerStateImpl extends DefaultRibReference implements BG return this.peerRestarting; } - public synchronized final void setAfiSafiGracefulRestartState(final int peerRestartTime, + public final synchronized void setAfiSafiGracefulRestartState(final int peerRestartTime, final boolean peerRestarting, final boolean localRestarting) { this.peerRestartTime = peerRestartTime; this.peerRestarting = peerRestarting; @@ -311,11 +311,11 @@ public abstract class BGPPeerStateImpl extends DefaultRibReference implements BG } @Override - public final synchronized int getLlGracefulRestartTimer(@Nonnull TablesKey tablesKey) { - final int timerAdvertised = isLlGracefulRestartAdvertised(tablesKey) ? - this.afiSafisLlGracefulAdvertised.get(tablesKey) : 0; - final int timerReceived = isLlGracefulRestartReceived(tablesKey) ? - this.afiSafisLlGracefulReceived.get(tablesKey) : 0; + public final synchronized int getLlGracefulRestartTimer(@Nonnull final TablesKey tablesKey) { + final int timerAdvertised = isLlGracefulRestartAdvertised(tablesKey) + ? this.afiSafisLlGracefulAdvertised.get(tablesKey) : 0; + final int timerReceived = isLlGracefulRestartReceived(tablesKey) + ? this.afiSafisLlGracefulReceived.get(tablesKey) : 0; return Integer.min(timerAdvertised, timerReceived); } } diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java index 96b016f189..65ec08fdf4 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AbstractAddPathTest.java @@ -249,9 +249,9 @@ public abstract class AbstractAddPathTest extends DefaultRibPoliciesMockTest { return connectPeer(peer, clientDispatcher); } - static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, - final Ipv4Address peerAddress, final RIBImpl ribImpl, final BgpParameters bgpParameters, - final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry) { + static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, final Ipv4Address peerAddress, + final RIBImpl ribImpl, final BgpParameters bgpParameters, final PeerRole peerRole, + final BGPPeerRegistry bgpPeerRegistry) { return configurePeer(tableRegistry, peerAddress, ribImpl, bgpParameters, peerRole, bgpPeerRegistry, AFI_SAFIS_ADVERTIZED, Collections.emptySet()); } @@ -266,11 +266,10 @@ public abstract class AbstractAddPathTest extends DefaultRibPoliciesMockTest { afiSafiAdvertised, gracefulAfiSafiAdvertised, bgpPeer); } - static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, - final Ipv4Address peerAddress, final RIBImpl ribImpl, final BgpParameters bgpParameters, - final PeerRole peerRole, final BGPPeerRegistry bgpPeerRegistry, - final Set afiSafiAdvertised, final Set gracefulAfiSafiAdvertised, - final BgpPeer peer) { + static BGPPeer configurePeer(final BGPTableTypeRegistryConsumer tableRegistry, final Ipv4Address peerAddress, + final RIBImpl ribImpl, final BgpParameters bgpParameters, final PeerRole peerRole, + final BGPPeerRegistry bgpPeerRegistry, final Set afiSafiAdvertised, + final Set gracefulAfiSafiAdvertised, final BgpPeer peer) { final IpAddress ipAddress = new IpAddress(peerAddress); final BGPPeer bgpPeer = new BGPPeer(tableRegistry, new IpAddress(peerAddress), null, ribImpl, peerRole, diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java index 6b5504fa8f..d9530eaad7 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/AddPathNPathsTest.java @@ -80,7 +80,7 @@ public class AddPathNPathsTest extends AbstractAddPathTest { final BGPSessionImpl session1 = createPeerSession(PEER1, nonAddPathParams, new SimpleSessionListener()); configurePeer(this.tableRegistry, PEER2, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry); - final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener()); + final BGPSessionImpl session2 = createPeerSession(PEER2, nonAddPathParams, new SimpleSessionListener()); configurePeer(this.tableRegistry, PEER3, this.ribImpl, nonAddPathParams, PeerRole.Ibgp, this.serverRegistry); final BGPSessionImpl session3 = createPeerSession(PEER3, nonAddPathParams, new SimpleSessionListener()); diff --git a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java index 79c1d7ce90..9e74129115 100644 --- a/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java +++ b/bgp/rib-impl/src/test/java/org/opendaylight/protocol/bgp/rib/impl/PeerTest.java @@ -10,8 +10,8 @@ package org.opendaylight.protocol.bgp.rib.impl; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doCallRealMethod; import static org.mockito.Mockito.doReturn; @@ -179,8 +179,8 @@ public class PeerTest extends AbstractRIBTestSetup { assertEquals(3, this.routes.size()); //create new peer so that it gets advertized routes from RIB - final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(this.tableRegistry, this.neighborAddress.getIpv4Address(), - getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry()); + final BGPPeer testingPeer = AbstractAddPathTest.configurePeer(this.tableRegistry, + this.neighborAddress.getIpv4Address(), getRib(), null, PeerRole.Ibgp, new StrictBGPPeerRegistry()); testingPeer.instantiateServiceInstance(); testingPeer.onSessionUp(this.session); assertEquals(3, this.routes.size());