<groupId>org.opendaylight.mdsal</groupId>
<artifactId>mdsal-binding-generator-impl</artifactId>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>ietf-yang-types-20130715</artifactId>
- </dependency>
<dependency>
<groupId>org.opendaylight.mdsal.model</groupId>
<artifactId>ietf-inet-types-2013-07-15</artifactId>
* @see <a href="http://tools.ietf.org/html/rfc6793">BGP Support for 4-Octet AS Number Space</a>
*/
private static final int AS_TRANS = 23456;
-
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractBGPSessionNegotiator.class);
+ private final BGPPeerRegistry registry;
+ private final Promise<BGPSessionImpl> promise;
+ private final Channel channel;
+ @GuardedBy("this")
+ private State state = State.IDLE;
+ @GuardedBy("this")
+ private BGPSessionImpl session;
+ @GuardedBy("this")
+ private ScheduledFuture<?> pending;
@VisibleForTesting
public enum State {
/**
FINISHED,
}
- private static final Logger LOG = LoggerFactory.getLogger(AbstractBGPSessionNegotiator.class);
- private final BGPPeerRegistry registry;
- private final Promise<BGPSessionImpl> promise;
- private final Channel channel;
- @GuardedBy("this")
- private State state = State.IDLE;
- @GuardedBy("this")
- private BGPSessionImpl session;
- @GuardedBy("this")
- private ScheduledFuture<?> pending;
-
AbstractBGPSessionNegotiator(final Promise<BGPSessionImpl> promise, final Channel channel,
final BGPPeerRegistry registry) {
this.promise = requireNonNull(promise);
// Check if peer is configured in registry before retrieving preferences
if (!this.registry.isPeerConfigured(remoteIp)) {
final BGPDocumentedException cause = new BGPDocumentedException(
- String.format("BGP peer with ip: %s not configured, check configured peers in : %s", remoteIp, this.registry), BGPError.CONNECTION_REJECTED);
+ String.format("BGP peer with ip: %s not configured, check configured peers in : %s",
+ remoteIp, this.registry), BGPError.CONNECTION_REJECTED);
negotiationFailed(cause);
return;
}
as = AS_TRANS;
}
sendMessage(new OpenBuilder().setMyAsNumber(as).setHoldTimer(preferences.getHoldTime()).setBgpIdentifier(
- preferences.getBgpId()).setBgpParameters(preferences.getParams()).build());
+ preferences.getBgpId()).setBgpParameters(preferences.getParams()).build());
if (this.state != State.FINISHED) {
this.state = State.OPEN_SENT;
this.pending = this.channel.eventLoop().schedule(() -> {
AbstractBGPSessionNegotiator.this.pending = null;
if (AbstractBGPSessionNegotiator.this.state != State.FINISHED) {
AbstractBGPSessionNegotiator.this
- .sendMessage(buildErrorNotify(BGPError.HOLD_TIMER_EXPIRED));
+ .sendMessage(buildErrorNotify(BGPError.HOLD_TIMER_EXPIRED));
negotiationFailed(new BGPDocumentedException("HoldTimer expired", BGPError.FSM_ERROR));
AbstractBGPSessionNegotiator.this.state = State.FINISHED;
}
return remoteIp;
}
- protected synchronized void handleMessage(final Notification msg) {
+ synchronized void handleMessage(final Notification msg) {
LOG.debug("Channel {} handling message in state {}, msg: {}", this.channel, this.state, msg);
switch (this.state) {
- case FINISHED:
- sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
- return;
- case IDLE:
- // to avoid race condition when Open message was sent by the peer before startNegotiation could be executed
- if (msg instanceof Open) {
- startNegotiation();
- handleOpen((Open) msg);
+ case FINISHED:
+ sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
return;
- }
- sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
- break;
- case OPEN_CONFIRM:
- if (msg instanceof Keepalive) {
- negotiationSuccessful(this.session);
- LOG.info("BGP Session with peer {} established successfully.", this.channel);
- } else if (msg instanceof Notify) {
- final Notify ntf = (Notify) msg;
- negotiationFailed(new BGPDocumentedException("Peer refusal", BGPError.forValue(ntf.getErrorCode(), ntf.getErrorSubcode())));
- }
- this.state = State.FINISHED;
- return;
- case OPEN_SENT:
- if (msg instanceof Open) {
- handleOpen((Open) msg);
+ case IDLE:
+ // to avoid race condition when Open message was sent by the peer before startNegotiation could be executed
+ if (msg instanceof Open) {
+ startNegotiation();
+ handleOpen((Open) msg);
+ return;
+ }
+ sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
+ break;
+ case OPEN_CONFIRM:
+ if (msg instanceof Keepalive) {
+ negotiationSuccessful(this.session);
+ LOG.info("BGP Session with peer {} established successfully.", this.channel);
+ } else if (msg instanceof Notify) {
+ final Notify ntf = (Notify) msg;
+ negotiationFailed(new BGPDocumentedException("Peer refusal",
+ BGPError.forValue(ntf.getErrorCode(), ntf.getErrorSubcode())));
+ }
+ this.state = State.FINISHED;
return;
- }
- break;
- default:
- break;
+ case OPEN_SENT:
+ if (msg instanceof Open) {
+ handleOpen((Open) msg);
+ return;
+ }
+ break;
+ default:
+ break;
}
// Catch-all for unexpected message
LOG.warn("Channel {} state {} unexpected message {}", this.channel, this.state, msg);
sendMessage(buildErrorNotify(BGPError.FSM_ERROR));
- negotiationFailed(new BGPDocumentedException("Unexpected message channel: " + this.channel + ", state: " + this.state + ", message: " + msg, BGPError.FSM_ERROR));
+ negotiationFailed(new BGPDocumentedException("Unexpected message channel: "
+ + this.channel + ", state: " + this.state + ", message: " + msg, BGPError.FSM_ERROR));
this.state = State.FINISHED;
}
final IpAddress remoteIp = getRemoteIp();
final BGPSessionPreferences preferences = this.registry.getPeerPreferences(remoteIp);
try {
- final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences), getDestinationId(openObj, preferences), openObj);
+ final BGPSessionListener peer = this.registry.getPeer(remoteIp, getSourceId(openObj, preferences),
+ getDestinationId(openObj, preferences), openObj);
sendMessage(new KeepaliveBuilder().build());
this.state = State.OPEN_CONFIRM;
this.session = new BGPSessionImpl(peer, this.channel, openObj, preferences, this.registry);
private synchronized void negotiationFailed(final Throwable e) {
LOG.warn("Channel {} negotiation failed: {}", this.channel, e.getMessage());
if (e instanceof BGPDocumentedException) {
- // although sendMessage() can also result in calling this method, it won't create a cycle. In case sendMessage() fails to
- // deliver the message, this method gets called with different exception (definitely not with BGPDocumentedException).
- sendMessage(buildErrorNotify(((BGPDocumentedException)e).getError(), ((BGPDocumentedException) e).getData()));
+ // although sendMessage() can also result in calling this method, it won't create a cycle.
+ // In case sendMessage() fails to deliver the message, this method gets called with different
+ // exception (definitely not with BGPDocumentedException).
+ sendMessage(buildErrorNotify(((BGPDocumentedException) e).getError(),
+ ((BGPDocumentedException) e).getData()));
}
if (this.state == State.OPEN_CONFIRM) {
this.registry.removePeerSession(getRemoteIp());
* @param preferences Local BGP speaker preferences
* @return BGP Id of device that accepted the connection
*/
- protected abstract Ipv4Address getDestinationId(final Open openMsg, final BGPSessionPreferences preferences);
+ protected abstract Ipv4Address getDestinationId(Open openMsg, BGPSessionPreferences preferences);
/**
* @param openMsg Open message received from remote BGP speaker
* @param preferences Local BGP speaker preferences
* @return BGP Id of device that accepted the connection
*/
- protected abstract Ipv4Address getSourceId(final Open openMsg, final BGPSessionPreferences preferences);
+ protected abstract Ipv4Address getSourceId(Open openMsg, BGPSessionPreferences preferences);
public synchronized State getState() {
return this.state;
private void sendMessage(final Notification msg) {
this.channel.writeAndFlush(msg).addListener((ChannelFutureListener) f -> {
if (!f.isSuccess()) {
- LOG.warn("Failed to send message {} to channel {}", msg, AbstractBGPSessionNegotiator.this.channel, f.cause());
+ LOG.warn("Failed to send message {} to channel {}", msg, AbstractBGPSessionNegotiator.this.channel,
+ f.cause());
negotiationFailedCloseChannel(f.cause());
} else {
LOG.trace("Message {} sent to channel {}", msg, AbstractBGPSessionNegotiator.this.channel);
LOG.warn("No support for table type {}, skipping it", tableKey);
continue;
}
- installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey, addPathTablesType.get(tableKey), tx);
+ installAdjRibsOutTables(newPeerPath, rs, instanceIdentifierKey, tableKey,
+ addPathTablesType.get(tableKey), tx);
installAdjRibInTables(newPeerPath, tableKey, rs, instanceIdentifierKey, tx, tb);
}
return tb.build();
private static final Logger LOG = LoggerFactory.getLogger(AdjRibOutListener.class);
- static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
- static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
+ private static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
+ private static final QName PATHID_QNAME = QName.create(Ipv4Route.QNAME, "path-id").intern();
private final YangInstanceIdentifier.NodeIdentifier routeKeyPrefixLeaf = new YangInstanceIdentifier
.NodeIdentifier(PREFIX_QNAME);
private final YangInstanceIdentifier.NodeIdentifier routeKeyPathIdLeaf = new YangInstanceIdentifier
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-/**
- *
- */
final class BGPByteToMessageDecoder extends ByteToMessageDecoder {
private static final Logger LOG = LoggerFactory.getLogger(BGPByteToMessageDecoder.class);
private final MessageRegistry registry;
private final PeerSpecificParserConstraintProvider constraints;
- public BGPByteToMessageDecoder(final MessageRegistry registry) {
+ BGPByteToMessageDecoder(final MessageRegistry registry) {
this.constraints = new PeerSpecificParserConstraintImpl();
this.registry = requireNonNull(registry);
}
- public <T extends PeerConstraint> boolean addDecoderConstraint(final Class<T> classType, final T peerConstraint) {
+ <T extends PeerConstraint> boolean addDecoderConstraint(final Class<T> classType, final T peerConstraint) {
return this.constraints.addPeerConstraint(classType, peerConstraint);
}
@Override
- protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out) throws BGPDocumentedException,
- BGPParsingException {
+ protected void decode(final ChannelHandlerContext ctx, final ByteBuf in, final List<Object> out)
+ throws BGPDocumentedException, BGPParsingException {
if (in.isReadable()) {
if (LOG.isTraceEnabled()) {
LOG.trace("Received to decode: {}", ByteBufUtil.hexDump(in));
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.Open;
/**
- * Client negotiator. Validates established connections using BGPClientSessionValidator
+ * Client negotiator. Validates established connections using BGPClientSessionValidator.
*/
public final class BGPClientSessionNegotiator extends AbstractBGPSessionNegotiator {
}
public ChannelHandler[] getDecoders() {
- return new ChannelHandler[] { BGPMessageHeaderDecoder.getBGPMessageHeaderDecoder(), new BGPByteToMessageDecoder(this.registry), };
+ return new ChannelHandler[] { BGPMessageHeaderDecoder.getBGPMessageHeaderDecoder(),
+ new BGPByteToMessageDecoder(this.registry), };
}
}
/**
* @see <a href="http://tools.ietf.org/html/rfc4271#section-4.1">BGP Message Header</a>
*/
-public final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
+final class BGPMessageHeaderDecoder extends LengthFieldBasedFrameDecoder {
private static final int MARKER_SIZE = 16;
super(maxFrameSize, MARKER_SIZE, LENGTH_SIZE, -MARKER_SIZE - LENGTH_SIZE, 0);
}
- public static BGPMessageHeaderDecoder getBGPMessageHeaderDecoder() {
+ static BGPMessageHeaderDecoder getBGPMessageHeaderDecoder() {
return new BGPMessageHeaderDecoder(MAX_FRAME_SIZE);
}
- public static BGPMessageHeaderDecoder getExtendedBGPMessageHeaderDecoder() {
+ static BGPMessageHeaderDecoder getExtendedBGPMessageHeaderDecoder() {
return new BGPMessageHeaderDecoder(EXTENDED_MAX_FRAME_SIZE);
}
return;
}
LOG.info("Closing session: {}", this);
- this.channel.close().addListener((ChannelFutureListener) future -> Preconditions.checkArgument(future.isSuccess(), "Channel failed to close: %s", future.cause()));
+ this.channel.close().addListener((ChannelFutureListener) future
+ -> Preconditions.checkArgument(future.isSuccess(),
+ "Channel failed to close: %s", future.cause()));
this.state = State.IDLE;
removePeerSession();
this.sessionState.setSessionState(this.state);
synchronized void terminate(final BGPDocumentedException e) {
final BGPError error = e.getError();
final byte[] data = e.getData();
- final NotifyBuilder builder = new NotifyBuilder().setErrorCode(error.getCode()).setErrorSubcode(error.getSubcode());
+ final NotifyBuilder builder = new NotifyBuilder().setErrorCode(error.getCode())
+ .setErrorSubcode(error.getSubcode());
if (data != null && data.length != 0) {
builder.setData(data);
}
.child(Tables.class)
.build();
private static final InstanceIdentifier<MpReachNlri> MP_REACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes.class)
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path
+ .attributes.Attributes.class)
.augmentation(Attributes1.class)
.child(MpReachNlri.class);
private static final InstanceIdentifier<MpUnreachNlri> MP_UNREACH_NLRI_II = InstanceIdentifier.create(Update.class)
- .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes.class)
- .augmentation(Attributes2.class)
- .child(MpUnreachNlri.class);
+ .child(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path
+ .attributes.Attributes.class).augmentation(Attributes2.class).child(MpUnreachNlri.class);
static {
final Builder<Class<? extends DataObject>> acb = ImmutableSet.builder();
.streamChild(this.ribSupport.routesContainerClass())
.streamChild(this.ribSupport.routesListClass());
- this.attributesCodec = routeListCodec.streamChild(Attributes.class).createCachingCodec(this.cacheableAttributes);
- this.reachNlriCodec = tree.getSubtreeCodec(MP_REACH_NLRI_II).createCachingCodec(this.ribSupport.cacheableNlriObjects());
- this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II).createCachingCodec(this.ribSupport.cacheableNlriObjects());
+ this.attributesCodec = routeListCodec.streamChild(Attributes.class)
+ .createCachingCodec(this.cacheableAttributes);
+ this.reachNlriCodec = tree.getSubtreeCodec(MP_REACH_NLRI_II)
+ .createCachingCodec(this.ribSupport.cacheableNlriObjects());
+ this.unreachNlriCodec = tree.getSubtreeCodec(MP_UNREACH_NLRI_II)
+ .createCachingCodec(this.ribSupport.cacheableNlriObjects());
}
@Override
this.classContext = requireNonNull(strategy);
}
- public static CodecsRegistryImpl create(final BindingCodecTreeFactory codecFactory, final GeneratedClassLoadingStrategy classStrategy) {
+ public static CodecsRegistryImpl create(final BindingCodecTreeFactory codecFactory,
+ final GeneratedClassLoadingStrategy classStrategy) {
return new CodecsRegistryImpl(codecFactory, classStrategy);
}
import java.util.concurrent.atomic.LongAdder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.ZeroBasedCounter32;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
}
/**
- * Increments counter by 1 if supported, otherwise produce a warn
+ * Increments counter by 1 if supported, otherwise produce a warn.
*
- * @param counter counter
+ * @param counter counter
* @param tablesKey tablesKey Type
*/
static void increment(@Nullable final LongAdder counter, @Nonnull TablesKey tablesKey) {
}
/**
- * Increments counter by 1 if supported, otherwise produce a warn
- * @param counter counter
+ * Increments counter by 1 if supported, otherwise produce a warn.
+ *
+ * @param counter counter
* @param tablesKey tablesKey Type
*/
static void decrement(@Nullable final LongAdder counter, @Nonnull TablesKey tablesKey) {
}
LOG.warn("Family {} not supported", tablesKey);
}
-
- public static ZeroBasedCounter32 toZeroBasedCounter32(final LongAdder longAdder){
- return new ZeroBasedCounter32(longAdder.longValue());
- }
}
this.codecs = requireNonNull(codecs);
}
- static RIBSupportContextRegistryImpl create(final RIBExtensionConsumerContext extensions, final CodecsRegistry codecs) {
+ static RIBSupportContextRegistryImpl create(final RIBExtensionConsumerContext extensions,
+ final CodecsRegistry codecs) {
return new RIBSupportContextRegistryImpl(extensions, codecs);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.routes.route.target.constrain.routes.RouteTargetConstrainRoute;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.RouteTarget;
-/**
- * @author Claudio D. Gasparini
- */
-public final class RouteTargetMembeshipUtil {
+final class RouteTargetMembeshipUtil {
private RouteTargetMembeshipUtil() {
throw new UnsupportedOperationException();
}
- public static <R extends Route> Optional<RouteTarget> getRT(final R route) {
+ static <R extends Route> Optional<RouteTarget> getRT(final R route) {
if (!(route instanceof RouteTargetConstrainRoute)) {
return Optional.empty();
}
private final BundleContext bundleContext;
private final BGPTableTypeRegistryConsumer tableTypeRegistry;
private final ClusterSingletonServiceProvider provider;
- private final LoadingCache<InstanceIdentifier<PeerGroup>, Optional<PeerGroup>> peerGroups = CacheBuilder.newBuilder()
+ @GuardedBy("this")
+ private final Map<InstanceIdentifier<Bgp>, BGPClusterSingletonService> bgpCss = new HashMap<>();
+ private final DataBroker dataBroker;
+ private final LoadingCache<InstanceIdentifier<PeerGroup>, Optional<PeerGroup>> peerGroups
+ = CacheBuilder.newBuilder()
.build(new CacheLoader<InstanceIdentifier<PeerGroup>, Optional<PeerGroup>>() {
@Override
public Optional<PeerGroup> load(final InstanceIdentifier<PeerGroup> key)
return loadPeerGroup(key);
}
});
- private ListenerRegistration<BgpDeployerImpl> registration;
- @GuardedBy("this")
- private final Map<InstanceIdentifier<Bgp>, BGPClusterSingletonService> bgpCss = new HashMap<>();
- private final DataBroker dataBroker;
private final String networkInstanceName;
+ private ListenerRegistration<BgpDeployerImpl> registration;
@GuardedBy("this")
private boolean closed;
= rootNode.getModifiedChildren().stream()
.filter(mod -> mod.getModificationType() == DataObjectModification.ModificationType.DELETE)
.collect(Collectors.toList());
- final List<DataObjectModification<? extends DataObject>> changedConfig = rootNode.getModifiedChildren().stream()
+ final List<DataObjectModification<? extends DataObject>> changedConfig
+ = rootNode.getModifiedChildren().stream()
.filter(mod -> mod.getModificationType() != DataObjectModification.ModificationType.DELETE)
.collect(Collectors.toList());
handleDeletions(deletedConfig, rootIdentifier);
import org.opendaylight.yangtools.yang.binding.Augmentation;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-public final class OpenConfigMappingUtil {
+final class OpenConfigMappingUtil {
- public static final String APPLICATION_PEER_GROUP_NAME = "application-peers";
- public static final Optional<String> APPLICATION_PEER_GROUP_NAME_OPT = Optional.of(APPLICATION_PEER_GROUP_NAME);
+ static final String APPLICATION_PEER_GROUP_NAME = "application-peers";
+ static final Optional<String> APPLICATION_PEER_GROUP_NAME_OPT = Optional.of(APPLICATION_PEER_GROUP_NAME);
static final int HOLDTIMER = 90;
private static final AfiSafi IPV4_AFISAFI = new AfiSafiBuilder().setAfiSafiName(IPV4UNICAST.class).build();
private static final List<AfiSafi> DEFAULT_AFISAFI = ImmutableList.of(IPV4_AFISAFI);
throw new UnsupportedOperationException();
}
- public static String getRibInstanceName(final InstanceIdentifier<?> rootIdentifier) {
+ static String getRibInstanceName(final InstanceIdentifier<?> rootIdentifier) {
return rootIdentifier.firstKeyOf(Protocol.class).getName();
}
return null;
}
- public static KeyMapping getNeighborKey(final Neighbor neighbor) {
+ static KeyMapping getNeighborKey(final Neighbor neighbor) {
if (neighbor.getConfig() != null) {
final String authPassword = neighbor.getConfig().getAuthPassword();
if (authPassword != null) {
return null;
}
- public static InstanceIdentifier<Neighbor> getNeighborInstanceIdentifier(
+ static InstanceIdentifier<Neighbor> getNeighborInstanceIdentifier(
final InstanceIdentifier<Bgp> rootIdentifier,
final NeighborKey neighborKey) {
return rootIdentifier.child(Neighbors.class).child(Neighbor.class, neighborKey);
}
- public static String getNeighborInstanceName(final InstanceIdentifier<?> rootIdentifier) {
+ static String getNeighborInstanceName(final InstanceIdentifier<?> rootIdentifier) {
return Ipv4Util.toStringIP(rootIdentifier.firstKeyOf(Neighbor.class).getNeighborAddress());
}
}
//make sure IPv4 Unicast (RFC 4271) when required
- public static List<AfiSafi> getAfiSafiWithDefault(
+ static List<AfiSafi> getAfiSafiWithDefault(
final BgpCommonAfiSafiList afiSAfis, final boolean setDeafultIPv4) {
if (afiSAfis == null || afiSAfis.getAfiSafi() == null) {
return setDeafultIPv4 ? DEFAULT_AFISAFI : Collections.emptyList();
return afiSafi;
}
- public static ClusterIdentifier getGlobalClusterIdentifier(final org.opendaylight.yang.gen.v1.http.openconfig.net
+ static ClusterIdentifier getGlobalClusterIdentifier(final org.opendaylight.yang.gen.v1.http.openconfig.net
.yang.bgp.rev151009.bgp.global.base.Config globalConfig) {
final GlobalConfigAugmentation globalConfigAugmentation
= globalConfig.augmentation(GlobalConfigAugmentation.class);
}
@Nullable
- public static ClusterIdentifier getNeighborClusterIdentifier(
+ static ClusterIdentifier getNeighborClusterIdentifier(
@Nullable final RouteReflector routeReflector,
@Nullable final PeerGroup peerGroup) {
if (peerGroup != null) {
return null;
}
- public static Map<BgpTableType, PathSelectionMode> toPathSelectionMode(final List<AfiSafi> afiSafis,
+ static Map<BgpTableType, PathSelectionMode> toPathSelectionMode(final List<AfiSafi> afiSafis,
final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final Map<BgpTableType, PathSelectionMode> pathSelectionModes = new HashMap<>();
for (final AfiSafi afiSafi : afiSafis) {
return pathSelectionModes;
}
- public static boolean isApplicationPeer(final Neighbor neighbor) {
+ static boolean isApplicationPeer(final Neighbor neighbor) {
final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group
.Config config = neighbor.getConfig();
if (config != null) {
return false;
}
- public static List<AddressFamilies> toAddPathCapability(final List<AfiSafi> afiSafis,
+ static List<AddressFamilies> toAddPathCapability(final List<AfiSafi> afiSafis,
final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<AddressFamilies> addPathCapability = new ArrayList<>();
for (final AfiSafi afiSafi : afiSafis) {
return SendReceive.Receive;
}
- public static PeerRole toPeerRole(final BgpNeighborGroup neighbor) {
+ static PeerRole toPeerRole(final BgpNeighborGroup neighbor) {
if (isRrClient(neighbor)) {
return PeerRole.RrClient;
}
return false;
}
- public static List<BgpTableType> toTableTypes(final List<AfiSafi> afiSafis,
+ static List<BgpTableType> toTableTypes(final List<AfiSafi> afiSafis,
final BGPTableTypeRegistryConsumer tableTypeRegistry) {
return afiSafis.stream()
.map(afiSafi -> tableTypeRegistry.getTableType(afiSafi.getAfiSafiName()))
.collect(Collectors.toList());
}
- public static Set<TablesKey> toTableKey(final List<AfiSafi> afiSafis, final BGPTableTypeRegistryConsumer
+ static Set<TablesKey> toTableKey(final List<AfiSafi> afiSafis, final BGPTableTypeRegistryConsumer
tableTypeRegistry) {
return afiSafis.stream()
.map(afiSafi -> tableTypeRegistry.getTableKey(afiSafi.getAfiSafiName()))
.collect(Collectors.toSet());
}
- @Nonnull
- public static boolean isActive(final Neighbor neighbor, final PeerGroup peerGroup) {
+ static boolean isActive(final Neighbor neighbor, final PeerGroup peerGroup) {
Boolean activeConnection = null;
if (peerGroup != null) {
activeConnection = isActive(peerGroup.getTransport());
}
@Nonnull
- public static PeerRole toPeerRole(final Neighbor neighbor, final PeerGroup peerGroup) {
+ static PeerRole toPeerRole(final Neighbor neighbor, final PeerGroup peerGroup) {
PeerRole role = null;
if (peerGroup != null) {
role = toPeerRole(peerGroup);
return role;
}
- public static int getHoldTimer(final Neighbor neighbor, final PeerGroup peerGroup) {
+ static int getHoldTimer(final Neighbor neighbor, final PeerGroup peerGroup) {
Integer hold = null;
if (peerGroup != null) {
hold = getHoldTimer(peerGroup.getTimers());
}
@Nonnull
- public static AsNumber getRemotePeerAs(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009
+ static AsNumber getRemotePeerAs(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009
.bgp.neighbor.group.Config config, final PeerGroup peerGroup, final AsNumber localAs) {
AsNumber neighborAs = null;
if (peerGroup != null) {
}
@Nonnull
- public static AsNumber getLocalPeerAs(@Nullable final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp
+ 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) {
if (config != null) {
final AsNumber peerAs = config.getLocalAs();
return globalAs;
}
- public static int getRetryTimer(final Neighbor neighbor, final PeerGroup peerGroup) {
+ static int getRetryTimer(final Neighbor neighbor, final PeerGroup peerGroup) {
Integer retryTimer = null;
if (peerGroup != null) {
retryTimer = getRetryTimer(peerGroup.getTimers());
}
@Nonnull
- public static PortNumber getPort(final Neighbor neighbor, final PeerGroup peerGroup) {
+ static PortNumber getPort(final Neighbor neighbor, final PeerGroup peerGroup) {
PortNumber port = null;
if (peerGroup != null) {
port = getPort(peerGroup.getTransport(), PeerGroupTransportConfig.class);
}
@Nullable
- public static IpAddress getLocalAddress(@Nullable final Transport transport) {
+ static IpAddress getLocalAddress(@Nullable final Transport transport) {
if (transport != null && transport.getConfig() != null) {
final BgpNeighborTransportConfig.LocalAddress localAddress = transport.getConfig().getLocalAddress();
if (localAddress != null ) {
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
/**
- * Common interface for BgpPeer and AppPeer beans
+ * Common interface for BgpPeer and AppPeer beans.
*/
public interface PeerBean extends AutoCloseable {
this.pending.cancel(true);
}
- // Set up a client with pre-configured bootstrap, but add a closed channel handler into the pipeline to support reconnect attempts
- this.pending = connectSessionPromise(this.address, this.retryTimer, this.bootstrap, this.peerRegistry, (channel, promise) -> {
- this.initializer.initializeChannel(channel, promise);
- // add closed channel handler
- // This handler has to be added as last channel handler and the channel inactive event has to be caught by it
- // Handlers in front of it can react to channelInactive event, but have to forward the event or the reconnect will not work
- // This handler is last so all handlers in front of it can handle channel inactive (to e.g. resource cleanup) before a new connection is started
- channel.pipeline().addLast(new ClosedChannelHandler(this));
- });
+ // Set up a client with pre-configured bootstrap, but add a closed channel handler
+ // into the pipeline to support reconnect attempts
+ this.pending = connectSessionPromise(this.address, this.retryTimer, this.bootstrap, this.peerRegistry,
+ (channel, promise) -> {
+ this.initializer.initializeChannel(channel, promise);
+ // add closed channel handler
+ // This handler has to be added as last channel handler and the channel inactive event has to be
+ // caught by it
+ // Handlers in front of it can react to channelInactive event, but have to forward the event or
+ // the reconnect will not work. This handler is last so all handlers in front of it can handle
+ // channel inactive (to e.g. resource cleanup) before a new connection is started
+ channel.pipeline().addLast(new ClosedChannelHandler(this));
+ });
this.pending.addListener(future -> {
if (!future.isSuccess() && !this.isDone()) {
* @throws BGPDocumentedException if session establishment cannot be finished successfully
* @throws java.lang.IllegalStateException if there is no peer configured for provided ip address
*/
- BGPSessionListener getPeer(IpAddress ip, Ipv4Address sourceId, Ipv4Address remoteId, Open open) throws BGPDocumentedException;
+ BGPSessionListener getPeer(IpAddress ip, Ipv4Address sourceId, Ipv4Address remoteId, Open open)
+ throws BGPDocumentedException;
/**
* @param ip address of remote peer
import org.opendaylight.protocol.bgp.rib.spi.state.BGPTransportState;
/**
- * Serves to expose BGP Session, Timers, Transport, BGPErrorHandlingState Operational State
+ * Serves to expose BGP Session, Timers, Transport, BGPErrorHandlingState Operational State.
*/
public interface BGPSessionStateProvider {
/**
- * BGP Operational Session State
+ * BGP Operational Session State.
+ *
* @return BGPSessionState
*/
BGPSessionState getBGPSessionState();
/**
- * BGP Operational Timers State
+ * BGP Operational Timers State.
+ *
* @return BGPTimersState
*/
BGPTimersState getBGPTimersState();
/**
- * BGP Operational Transport State
+ * BGP Operational Transport State.
+ *
* @return BGPTransportState
*/
BGPTransportState getBGPTransportState();
/**
- * Register BGP Operational Messages State Listener
+ * Register BGP Operational Messages State Listener.
+ *
* @param bgpMessagesListener BGPMessagesListener
*/
void registerMessagesCounter(BGPMessagesListener bgpMessagesListener);
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
/**
- * Expose Prefixes Installed Count
+ * Expose Prefixes Installed Count.
*/
public interface PrefixesInstalledCounters {
/**
- * Prefixes received and installed from Peer count (EffRibIn Count) pet Table
+ * Prefixes received and installed from Peer count (EffRibIn Count) pet Table.
+ *
* @param tablesKey table
* @return count
*/
- long getPrefixedInstalledCount(@Nonnull final TablesKey tablesKey);
+ long getPrefixedInstalledCount(@Nonnull TablesKey tablesKey);
/**
- * total Prefixes received and installed from Peer count (EffRibIn Count)
+ * total Prefixes received and installed from Peer count (EffRibIn Count).
+ *
* @return count
*/
long getTotalPrefixesInstalled();
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
/**
- * Expose Prefixes Received Count
+ * Expose Prefixes Received Count.
*/
public interface PrefixesReceivedCounters {
/**
- * Prefixes received from Peer count (AdjRinIn Count) pet Table
+ * Prefixes received from Peer count (AdjRinIn Count) pet Table.
+ *
* @param tablesKey table
* @return count
*/
- long getPrefixedReceivedCount(@Nonnull final TablesKey tablesKey);
+ long getPrefixedReceivedCount(@Nonnull TablesKey tablesKey);
/**
- * list of supported tables per Peer
+ * list of supported tables per Peer.
+ *
* @return tables list
*/
Set<TablesKey> getTableKeys();
/**
- * table supported per Peer
+ * table supported per Peer.
+ *
* @param tablesKey table type
* @return true if supported
*/
- boolean isSupported(TablesKey tablesKey);
+ boolean isSupported(@Nonnull TablesKey tablesKey);
}
package org.opendaylight.protocol.bgp.rib.impl.state.peer;
/**
- * Expose Prefixes Sent Count
+ * Expose Prefixes Sent Count.
*/
public interface PrefixesSentCounters {
/**
- * Prefixes sent to peer
+ * Prefixes sent to peer.
+ *
* @return count
*/
long getPrefixesSentCount();
package org.opendaylight.protocol.bgp.rib.impl.state.rib;
/**
- * Expose Total Paths Count per RIB
+ * Expose Total Paths Count per RIB.
*/
public interface TotalPathsCounter {
/**
- * Total Paths installed on RIB
+ * Total Paths installed on RIB.
+ *
* @return count
*/
long getPathsCount();
package org.opendaylight.protocol.bgp.rib.impl.state.rib;
/**
- * Expose Total Prefixes Count per RIB
+ * Expose Total Prefixes Count per RIB.
*/
public interface TotalPrefixesCounter {
/**
- * Total Prefixes installed on RIB
+ * Total Prefixes installed on RIB.
+ *
* @return count
*/
long getPrefixesCount();
return connectPeer(peer, clientDispatcher);
}
- protected 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) {
final IpAddress ipAddress = new IpAddress(peerAddress);
- final BGPPeer bgpPeer = new BGPPeer(tableRegistry, new IpAddress(peerAddress), ribImpl, peerRole, null,
- AFI_SAFIS_ADVERTIZED, Collections.emptySet());
+ final BGPPeer bgpPeer = new BGPPeer(tableRegistry, new IpAddress(peerAddress), ribImpl, peerRole,
+ null, AFI_SAFIS_ADVERTIZED, Collections.emptySet());
final List<BgpParameters> tlvs = Lists.newArrayList(bgpParameters);
bgpPeerRegistry.addPeer(ipAddress, bgpPeer,
- new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID), AS_NUMBER, tlvs));
+ new BGPSessionPreferences(AS_NUMBER, HOLDTIMER, new BgpId(RIB_ID), AS_NUMBER, tlvs));
bgpPeer.instantiateServiceInstance();
return bgpPeer;
}
private static BGPSessionImpl connectPeer(final Ipv4Address localAddress, final BGPDispatcherImpl dispatcherImpl)
- throws InterruptedException {
- final Future<BGPSessionImpl> future = dispatcherImpl.createClient(new InetSocketAddress(localAddress.getValue(), PORT),
- new InetSocketAddress(RIB_ID, PORT), RETRY_TIMER, true);
+ throws InterruptedException {
+ final Future<BGPSessionImpl> future = dispatcherImpl
+ .createClient(new InetSocketAddress(localAddress.getValue(), PORT),
+ new InetSocketAddress(RIB_ID, PORT), RETRY_TIMER, true);
Thread.sleep(200);
waitFutureSuccess(future);
Thread.sleep(100);
return future.getNow();
}
- protected static BgpParameters createParameter(final boolean addPath) {
+ static BgpParameters createParameter(final boolean addPath) {
final OptionalCapabilities mp = new OptionalCapabilitiesBuilder().setCParameters(
new CParametersBuilder().addAugmentation(CParameters1.class,
new CParameters1Builder().setMultiprotocolCapability(
- new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class)
+ new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class)
+ .setSafi(UnicastSubsequentAddressFamily.class)
.build()).build()).build()).build();
final List<OptionalCapabilities> capabilities = Lists.newArrayList(mp);
if (addPath) {
return new BgpParametersBuilder().setOptionalCapabilities(capabilities).build();
}
- private static Update createSimpleUpdate(final Ipv4Prefix prefix, final PathId pathId, final ClusterIdentifier clusterId,
- final long localPreference) {
+ private static Update createSimpleUpdate(final Ipv4Prefix prefix, final PathId pathId,
+ final ClusterIdentifier clusterId, final long localPreference) {
final AttributesBuilder attBuilder = new AttributesBuilder();
attBuilder.setLocalPref(new LocalPrefBuilder().setPref(localPreference).build());
attBuilder.setOrigin(new OriginBuilder().setValue(BgpOrigin.Igp).build());
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(
- CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build())
- .setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build())
- .build()).build());
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
+ CParameters1.class, new CParameters1Builder()
+ .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build())
+ .setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build())
+ .build()).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final BgpId bgpId = new BgpId(new Ipv4Address(socketAddress.getAddress().getHostAddress()));
return new BGPSessionPreferences(AS_NUMBER, HOLD_TIMER, bgpId, AS_NUMBER, tlvs);
Channel createServer(final InetSocketAddress serverAddress) {
this.registry.addPeer(new IpAddress(new Ipv4Address(serverAddress.getAddress().getHostAddress())),
- this.serverListener, createPreferences(serverAddress));
+ this.serverListener, createPreferences(serverAddress));
LoggerFactory.getLogger(AbstractBGPDispatcherTest.class).info("createServer");
final ChannelFuture future = this.serverDispatcher.createServer(serverAddress);
future.addListener(future1 -> Preconditions.checkArgument(future1.isSuccess(),
public class AbstractRIBTestSetup extends DefaultRibPoliciesMockTest {
- protected static final Class<? extends AddressFamily> AFI = Ipv4AddressFamily.class;
- protected static final Class<? extends SubsequentAddressFamily> SAFI = UnicastSubsequentAddressFamily.class;
- protected static final TablesKey KEY = new TablesKey(AFI, SAFI);
- protected static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
+ static final Class<? extends AddressFamily> AFI = Ipv4AddressFamily.class;
+ static final Class<? extends SubsequentAddressFamily> SAFI = UnicastSubsequentAddressFamily.class;
+ static final TablesKey KEY = new TablesKey(AFI, SAFI);
+ static final QName PREFIX_QNAME = QName.create(Ipv4Route.QNAME, "prefix").intern();
private static final BgpId RIB_ID = new BgpId("127.0.0.1");
private RIBImpl rib;
private BindingCodecTreeFactory codecFactory;
@Mock
private ChannelPipeline pipeline;
- private final BgpTableType ipv4tt = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private final BgpTableType ipv4tt
+ = new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private final BgpTableType linkstatett = new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
+ private final BgpTableType linkstatett
+ = new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
private final List<Notification> receivedMsgs = Lists.newArrayList();
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build()).build()).build());
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(this.linkstatett.getAfi()).setSafi(this.linkstatett.getSafi()).build()).build()).build()).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
+ new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build())
+ .build()).build());
+ capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+ .addAugmentation(CParameters1.class,
+ new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(this.linkstatett.getAfi()).setSafi(this.linkstatett.getSafi())
+ .build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(
new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build()).build()).build());
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().build()).build()).build()).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
+ new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder()
+ .build()).build()).build()).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
return f;
}).when(this.speakerListener).writeAndFlush(any(Notification.class));
doReturn(this.eventLoop).when(this.speakerListener).eventLoop();
- doReturn(null).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
+ doReturn(null).when(this.eventLoop).schedule(any(Runnable.class), any(long.class),
+ any(TimeUnit.class));
doReturn("TestingChannel").when(this.speakerListener).toString();
doReturn(new InetSocketAddress(peerAddress, 179)).when(this.speakerListener).remoteAddress();
doReturn(new InetSocketAddress(peerAddress, 179)).when(this.speakerListener).localAddress();
doReturn(this.pipeline).when(this.speakerListener).pipeline();
- doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
- doReturn(null).when(this.pipeline).replace(Matchers.<Class<ChannelHandler>>any(), any(String.class), any(ChannelHandler.class));
+ doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class),
+ any(ChannelHandler.class));
+ doReturn(null).when(this.pipeline).replace(Matchers.<Class<ChannelHandler>>any(), any(String.class),
+ any(ChannelHandler.class));
doReturn(this.pipeline).when(this.pipeline).addLast(any(ChannelHandler.class));
doReturn(mock(ChannelFuture.class)).when(this.speakerListener).close();
final BGPPeerRegistry peerRegistry = new StrictBGPPeerRegistry();
- peerRegistry.addPeer(new IpAddress(new Ipv4Address(peerAddress.getHostAddress())), new SimpleSessionListener(), prefs);
+ peerRegistry.addPeer(new IpAddress(new Ipv4Address(peerAddress.getHostAddress())),
+ new SimpleSessionListener(), prefs);
- this.clientSession = new BGPClientSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.speakerListener, peerRegistry);
+ this.clientSession = new BGPClientSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
+ this.speakerListener, peerRegistry);
- this.classicOpen = new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).setBgpParameters(
+ this.classicOpen = new OpenBuilder().setMyAsNumber(30).setHoldTimer(3)
+ .setVersion(new ProtocolVersion((short) 4)).setBgpParameters(
tlvs).setBgpIdentifier(new Ipv4Address("1.1.1.2")).build();
}
@Test
public void testDenyPeer() {
- this.clientSession = new BGPClientSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), this.speakerListener, new StrictBGPPeerRegistry());
+ this.clientSession = new BGPClientSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE),
+ this.speakerListener, new StrictBGPPeerRegistry());
this.clientSession.channelActive(null);
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Notify);
this.clientSession.channelActive(null);
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Open);
- this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(1).setBgpIdentifier(new Ipv4Address("127.0.0.1")).setVersion(new ProtocolVersion((short) 4)).build());
+ this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30)
+ .setHoldTimer(1)
+ .setBgpIdentifier(new Ipv4Address("127.0.0.1")).setVersion(new ProtocolVersion((short) 4)).build());
assertEquals(2, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof Notify);
final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
- assertEquals(BGPError.UNSPECIFIC_OPEN_ERROR, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
+ assertEquals(BGPError.UNSPECIFIC_OPEN_ERROR,
+ BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
}
@Test
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build()).build()).build());
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
+ capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+ .addAugmentation(CParameters1.class,
+ new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi())
+ .build()).build()).build()).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
// Open Message without advertised four-octet AS Number capability
this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(1).setVersion(
- new ProtocolVersion((short) 4)).setBgpParameters(tlvs).setBgpIdentifier(new Ipv4Address("1.1.1.2")).build());
+ new ProtocolVersion((short) 4)).setBgpParameters(tlvs)
+ .setBgpIdentifier(new Ipv4Address("1.1.1.2")).build());
assertEquals(2, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof Notify);
final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
- assertEquals(BGPError.UNSUPPORTED_CAPABILITY, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
+ assertEquals(BGPError.UNSUPPORTED_CAPABILITY,
+ BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
assertNotNull(((Notify) m).getData());
}
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
- capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build()).build()).build());
+ capas.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
+ new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build()).build())
+ .build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(
new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).build()).build()).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(1).setVersion(
- new ProtocolVersion((short) 4)).setBgpParameters(tlvs).setBgpIdentifier(new Ipv4Address("1.1.1.2")).build());
+ new ProtocolVersion((short) 4)).setBgpParameters(tlvs)
+ .setBgpIdentifier(new Ipv4Address("1.1.1.2")).build());
assertEquals(2, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof Keepalive);
-
}
@Test
this.clientSession.handleMessage(this.classicOpen);
this.clientSession.handleMessage(new KeepaliveBuilder().build());
assertEquals(this.clientSession.getState(), BGPClientSessionNegotiator.State.FINISHED);
- this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
+ this.clientSession.handleMessage(new OpenBuilder().setMyAsNumber(30)
+ .setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).build());
assertEquals(3, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(2) instanceof Notify);
final Notification m = this.receivedMsgs.get(2);
assertEquals(1, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(0) instanceof Open);
- this.clientSession.handleMessage(new OpenBuilder(this.classicOpen).setBgpIdentifier(new Ipv4Address("1.1.1.1")).build());
+ this.clientSession.handleMessage(new OpenBuilder(this.classicOpen)
+ .setBgpIdentifier(new Ipv4Address("1.1.1.1")).build());
assertEquals(2, this.receivedMsgs.size());
assertTrue(this.receivedMsgs.get(1) instanceof Notify);
final Notification m = this.receivedMsgs.get(this.receivedMsgs.size() - 1);
- assertEquals(BGPError.BAD_BGP_ID, BGPError.forValue(((Notify) m).getErrorCode(), ((Notify) m).getErrorSubcode()));
+ assertEquals(BGPError.BAD_BGP_ID, BGPError.forValue(((Notify) m).getErrorCode(),
+ ((Notify) m).getErrorSubcode()));
}
}
private static final TablesKey TABLE_KEY
= new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
private static final InstanceIdentifier<BgpRib> BGP_IID = InstanceIdentifier.create(BgpRib.class);
+ private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
private BGPMock mock;
private AbstractRIBExtensionProviderActivator baseact, lsact;
private RIBExtensionProviderContext ext1, ext2;
- private final IpAddress localAddress = new IpAddress(new Ipv4Address("127.0.0.1"));
-
@Mock
private BGPDispatcher dispatcher;
private CodecsRegistryImpl codecsRegistry;
final RIBImpl rib = new RIBImpl(this.tableRegistry, new RibId(TEST_RIB_ID), AS_NUMBER, BGP_ID, this.ext2,
this.dispatcher, this.codecsRegistry, getDomBroker(), getDataBroker(), this.policies,
tables, Collections.singletonMap(TABLE_KEY, BasePathSelectionModeFactory
- .createBestPathSelectionStrategy()));
+ .createBestPathSelectionStrategy()));
rib.instantiateServiceInstance();
assertTablesExists(tables);
rib.onGlobalContextUpdated(this.schemaService.getGlobalContext());
assertEquals(this.neighborAddress.getIpv4Address().getValue(), this.classic.getName());
this.classic.onSessionUp(this.session);
Assert.assertArrayEquals(new byte[]{1, 1, 1, 1}, this.classic.getRawIdentifier());
- assertEquals("BGPPeer{name=127.0.0.1, tables=[TablesKey{_afi=interface org.opendaylight.yang.gen.v1.urn"
- + ".opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily,"
+ assertEquals("BGPPeer{name=127.0.0.1, tables=[TablesKey{_afi=interface org.opendaylight.yang.gen.v1"
+ + ".urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv4AddressFamily,"
+ " _safi=interface org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types"
+ ".rev180329.UnicastSubsequentAddressFamily}]}",
this.classic.toString());
ub.setNlri(nlris);
final Origin origin = new OriginBuilder().setValue(BgpOrigin.Igp).build();
final AsPath asPath = new AsPathBuilder().setSegments(Collections.emptyList()).build();
- final CNextHop nextHop = new Ipv4NextHopCaseBuilder()
- .setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
+ final CNextHop nextHop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder()
+ .setGlobal(new Ipv4Address("127.0.0.1")).build()).build();
final AttributesBuilder ab = new AttributesBuilder();
ub.setAttributes(ab.setOrigin(origin).setAsPath(asPath).setCNextHop(nextHop).build());
try {
assertEquals(3, this.routes.size());
//create new peer so that it gets advertized routes from RIB
- final BGPPeer testingPeer = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp, null,
- Collections.emptySet(), Collections.emptySet());
+ final BGPPeer testingPeer = new BGPPeer(this.tableRegistry, this.neighborAddress, getRib(), PeerRole.Ibgp,
+ null, Collections.emptySet(), Collections.emptySet());
testingPeer.instantiateServiceInstance();
testingPeer.onSessionUp(this.session);
assertEquals(3, this.routes.size());
package org.opendaylight.protocol.bgp.rib.impl;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import com.google.common.primitives.UnsignedInteger;
assertEquals(PREFIX, rk.getRouteId());
assertEquals(rk, new RouteUpdateKey(PEER_ID, PREFIX));
assertEquals(rk, rk);
- assertFalse(rk.equals(null));
assertNotEquals(rk, new RouteUpdateKey(PEER_ID_2, PREFIX));
assertNotEquals(rk, new RouteUpdateKey(PEER_ID_2, PREFIX_2));
}
.setVersion(new ProtocolVersion((short) 4)).setBgpParameters(tlvs).setBgpIdentifier(BGP_ID).build();
final List<OptionalCapabilities> capa = Lists.newArrayList();
- capa.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class,
- new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
- .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build())
- .setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().build()).build())
- .setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(AS_NUMBER).build()).build()).build());
- capa.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
+ capa.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder()
+ .addAugmentation(CParameters1.class, new CParameters1Builder()
+ .setMultiprotocolCapability(new MultiprotocolCapabilityBuilder()
+ .setAfi(this.ipv4tt.getAfi()).setSafi(this.ipv4tt.getSafi()).build())
+ .setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().build()).build())
+ .setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(AS_NUMBER).build()).build())
+ .build());
+ capa.add(new OptionalCapabilitiesBuilder()
+ .setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capa).build());
doReturn(null).when(mock(ChannelFuture.class)).addListener(any());
public class SynchronizationTest {
- private final TablesKey ipv4 = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
- private final TablesKey linkstate = new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
+ private final TablesKey ipv4
+ = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
+ private final TablesKey linkstate
+ = new TablesKey(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class);
private BGPSynchronization bs;
mpBuilder.setAfi(LinkstateAddressFamily.class);
mpBuilder.setSafi(LinkstateSubsequentAddressFamily.class);
- paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(
- mpBuilder.build()).build());
+ paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class,
+ new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
this.lsm = new UpdateBuilder().setAttributes(paBuilder.build()).build();