This implements dedicated interface for LLGR state.
JIRA: BGPCEP-495
Change-Id: I54597dd6461dfed4ea655213d406d8ed8cbb5bfb
Signed-off-by: Matej Perina <matej.perina@pantheon.tech>
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.MoreExecutors;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@Nullable final AsNumber localAs,
final IpAddress neighborAddress,
final Set<TablesKey> afiSafisAdvertized,
- final Set<TablesKey> afiSafisGracefulAdvertized) {
- super(rib.getInstanceIdentifier(), groupId, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized);
+ final Set<TablesKey> afiSafisGracefulAdvertized,
+ final Map<TablesKey, Integer> afiSafisLlGracefulAdvertized) {
+ super(rib.getInstanceIdentifier(), groupId, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized,
+ afiSafisLlGracefulAdvertized);
this.name = peerName;
this.peerRole = role;
this.clusterId = clusterId;
final IpAddress neighborAddress,
final Set<TablesKey> afiSafisGracefulAdvertized) {
this(rib, peerName, groupId, role, null, null, neighborAddress,
- rib.getLocalTablesKeys(), afiSafisGracefulAdvertized);
+ rib.getLocalTablesKeys(), afiSafisGracefulAdvertized, Collections.emptyMap());
}
final synchronized FluentFuture<? extends CommitInfo> removePeer(@Nullable final YangInstanceIdentifier peerPath) {
final Set<TablesKey> afiSafisGracefulAdvertized,
final BgpPeer bgpPeer) {
super(rib, Ipv4Util.toStringIP(neighborAddress), peerGroupName, role, clusterId,
- localAs, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized);
+ localAs, neighborAddress, afiSafisAdvertized, afiSafisGracefulAdvertized, Collections.emptyMap());
this.tableTypeRegistry = requireNonNull(tableTypeRegistry);
this.rib = requireNonNull(rib);
this.rpcRegistry = rpcRegistry;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPAfiSafiState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPErrorHandlingState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPGracelfulRestartState;
+import org.opendaylight.protocol.bgp.rib.spi.state.BGPLlGracelfulRestartState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerMessagesState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerState;
import org.opendaylight.protocol.bgp.rib.spi.state.BGPPeerStateConsumer;
import org.opendaylight.yangtools.yang.binding.Notification;
public abstract class BGPPeerStateImpl extends DefaultRibReference implements BGPPeerState, BGPAfiSafiState,
- BGPGracelfulRestartState, BGPErrorHandlingState, BGPPeerMessagesState, BGPPeerStateConsumer, BGPMessagesListener {
+ BGPGracelfulRestartState, BGPLlGracelfulRestartState,BGPErrorHandlingState, BGPPeerMessagesState,
+ BGPPeerStateConsumer, BGPMessagesListener {
private static final long NONE = 0L;
private final IpAddress neighborAddress;
private final Set<TablesKey> afiSafisAdvertized;
private final Set<TablesKey> afiSafisGracefulAdvertized;
private final Set<TablesKey> afiSafisGracefulReceived = new HashSet<>();
+ private final Map<TablesKey, Integer> afiSafisLlGracefulAdvertised;
+ private final Map<TablesKey, Integer> afiSafisLlGracefulReceived = new HashMap<>();
private final LongAdder updateSentCounter = new LongAdder();
private final LongAdder notificationSentCounter = new LongAdder();
private final LongAdder updateReceivedCounter = new LongAdder();
public BGPPeerStateImpl(@Nonnull final KeyedInstanceIdentifier<Rib, RibKey> instanceIdentifier,
@Nullable final String groupId, @Nonnull final IpAddress neighborAddress,
@Nonnull final Set<TablesKey> afiSafisAdvertized,
- @Nonnull final Set<TablesKey> afiSafisGracefulAdvertized) {
+ @Nonnull final Set<TablesKey> afiSafisGracefulAdvertized,
+ @Nonnull final Map<TablesKey, Integer> afiSafisLlGracefulAdvertized) {
super(instanceIdentifier);
this.neighborAddress = requireNonNull(neighborAddress);
this.groupId = groupId;
this.afiSafisAdvertized = requireNonNull(afiSafisAdvertized);
this.afiSafisGracefulAdvertized = requireNonNull(afiSafisGracefulAdvertized);
+ this.afiSafisLlGracefulAdvertised = requireNonNull(afiSafisLlGracefulAdvertized);
}
@Override
}
return Mode.BILATERAL;
}
+
+ public final synchronized void setAdvertizedLlGracefulRestartTableTypes(
+ final Map<TablesKey, Integer> afiSafiReceived) {
+ this.afiSafisLlGracefulReceived.clear();
+ this.afiSafisLlGracefulReceived.putAll(afiSafiReceived);
+ }
+
+ @Override
+ public final synchronized boolean isLlGracefulRestartAdvertised(final TablesKey tablesKey) {
+ return this.afiSafisLlGracefulAdvertised.containsKey(tablesKey);
+ }
+
+ @Override
+ public final synchronized boolean isLlGracefulRestartReceived(final TablesKey tablesKey) {
+ return this.afiSafisLlGracefulReceived.containsKey(tablesKey);
+ }
+
+ @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;
+ return Integer.min(timerAdvertised, timerReceived);
+ }
}
/**
* BGP Operational Afi SafiS State.
*/
-public interface BGPAfiSafiState extends BGPGracelfulRestartState {
+public interface BGPAfiSafiState extends BGPLlGracelfulRestartState {
/**
* is AfiSafi Supported.
*
--- /dev/null
+/*
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.spi.state;
+
+import javax.annotation.Nonnull;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.TablesKey;
+
+/**
+ * BGP Operational Graceful Restart State.
+ */
+public interface BGPLlGracelfulRestartState extends BGPGracelfulRestartState {
+ /**
+ * is Long-lived Graceful Restart Support advertised to neighbor.
+ *
+ * @param tablesKey tables Key
+ * @return true if Afi Safi was advertised to neighbor
+ */
+ boolean isLlGracefulRestartAdvertised(@Nonnull TablesKey tablesKey);
+
+ /**
+ * is Long-lived Graceful Restart Support advertised by neighbor.
+ *
+ * @param tablesKey tables Key
+ * @return true if Afi Safi was advertised by neighbor
+ */
+ boolean isLlGracefulRestartReceived(@Nonnull TablesKey tablesKey);
+
+ /**
+ * If table is both advertised and received return timer with lower value.
+ * If table is not advertised or received return zero.
+ *
+ * @param tablesKey tables key
+ * @return effective value of timer in seconds
+ */
+ int getLlGracefulRestartTimer(@Nonnull TablesKey tablesKey);
+}