//disconnect the CONFIG SERVER port (which was )opened during I was Owner
bgpRouter.disconnect();
}
+ stopBgpCountersTask();
+ stopBgpAlarmsTask();
}
});
}
totalStaledCount = 0;
try {
staledFibEntriesMap.clear();
+ fibDSWriter.clearFibMap();
InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
Optional<FibEntries> fibEntries = SingleTransactionDataBroker.syncReadOptional(dataBroker,
//Create MAP from staleVrfTables.
vrfEntry.getRoutePaths()
.forEach(
- routePath -> staleFibEntMap.put(
- appendNextHopToPrefix(vrfEntry.getDestPrefix(),
- routePath.getNexthopAddress()), routePath.getLabel()));
+ routePath -> {
+ staleFibEntMap.put(
+ appendNextHopToPrefix(vrfEntry.getDestPrefix(),
+ routePath.getNexthopAddress()), routePath.getLabel());
+ fibDSWriter.addEntryToFibMap(
+ vrfTable.getRouteDistinguisher(), vrfEntry.getDestPrefix(),
+ routePath.getNexthopAddress());
+
+ });
}
staledFibEntriesMap.put(vrfTable.getRouteDistinguisher(), staleFibEntMap);
}
private static final Logger LOG = LoggerFactory.getLogger(FibDSWriter.class);
private final SingleTransactionDataBroker singleTxDB;
private final BgpUtil bgpUtil;
-
- private final Map<String,ArrayList<String>> fibMap = new HashMap<>();
+ private final Map<String, ArrayList<String>> fibMap = new HashMap<>();
@Inject
public FibDSWriter(final DataBroker dataBroker, final BgpUtil bgpUtil) {
LOG.debug("Created vrfEntry for {} nexthop {} label {}", prefix, nextHop, label);
}
+ LOG.debug("addFibEntryToDS rd {} prefix {} NH {}",
+ rd, prefix, nextHopList.get(0));
+
+ ArrayList<String> temp = new ArrayList<String>();
+ if ((fibMap.get(appendrdtoprefix(rd, prefix)) != null)) {
+ temp.addAll(fibMap.get(appendrdtoprefix(rd, prefix)));
+ }
+ if (!temp.contains(nextHopList.get(0))) {
+ temp.addAll(nextHopList);
+ fibMap.put(appendrdtoprefix(rd, prefix), temp);
+ }
+
// Looking for existing prefix in MDSAL database
InstanceIdentifier<VrfEntry> vrfEntryId =
InstanceIdentifier.builder(FibEntries.class)
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
+import org.apache.thrift.TException;
import org.opendaylight.netvirt.bgpmanager.BgpConfigurationManager;
+import org.opendaylight.netvirt.bgpmanager.thrift.client.BgpRouterException;
import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.Bgp;
import org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.bgp.neighborscontainer.Neighbors;
import org.slf4j.Logger;
return;
}
- for (Neighbors nbr : nbrs) {
- boolean alarmToRaise = true;
- if (nbrStatusMap != null && nbrStatusMap.containsKey(nbr.getAddress().getValue())) {
- String nbrshipStatus = nbrStatusMap.get(nbr.getAddress().getValue());
- LOG.trace("nbr {} status {}",
- nbr.getAddress().getValue(),
- nbrshipStatus);
- try {
- Integer.parseInt(nbrshipStatus);
- alarmToRaise = false;
- } catch (NumberFormatException e) {
- LOG.trace("Exception thrown in parsing the integers.", e);
+ LOG.debug("Fetching neighbor status' from BGP, #of neighbors: {}", nbrList.size());
+ for (Neighbors nbr : nbrList) {
+ boolean alarmToRaise = false;
+ try {
+ LOG.trace("nbr {} checking status, AS num: {}", nbr.getAddress().getValue(), nbr.getRemoteAs());
+ bgpMgr.getPeerStatus(nbr.getAddress().getValue(), nbr.getRemoteAs().longValue());
+ LOG.trace("nbr {} status is: PEER UP", nbr.getAddress().getValue());
+ } catch (BgpRouterException bre) {
+ if (bre.getErrorCode() == BgpRouterException.BGP_PEER_DOWN) {
+ LOG.error("nbr {} status is: DOWN", nbr.getAddress().getValue());
+ alarmToRaise = true;
+ } else if (bre.getErrorCode() == BgpRouterException.BGP_PEER_NOTCONFIGURED) {
+ LOG.info("nbr {} status is: NOT CONFIGURED", nbr.getAddress().getValue());
+ } else if (bre.getErrorCode() == BgpRouterException.BGP_PEER_UNKNOWN) {
+ LOG.info("nbr {} status is: Unknown", nbr.getAddress().getValue());
+ } else {
+ LOG.info("nbr {} status is: Unknown, invalid BgpRouterException: ",
+ nbr.getAddress().getValue(), bre);
}
+ } catch (TException tae) {
+ LOG.error("nbr {} status is: Unknown, received TException: ", nbr.getAddress().getValue(), tae);
+ }
- final BgpAlarmStatus alarmStatus = neighborsRaisedAlarmStatusMap.get(nbr.getAddress().getValue());
- if (alarmToRaise) {
- if (alarmStatus == null || alarmStatus != BgpAlarmStatus.RAISED) {
- LOG.trace("alarm raised for {}.", nbr.getAddress().getValue());
- raiseBgpNbrDownAlarm(nbr.getAddress().getValue());
- } else {
- LOG.trace("alarm raised already for {}", nbr.getAddress().getValue());
- }
+ final BgpAlarmStatus alarmStatus = neighborsRaisedAlarmStatusMap.get(nbr.getAddress().getValue());
+ if (alarmToRaise) {
+ if (alarmStatus == null || alarmStatus != BgpAlarmStatus.RAISED) {
+ LOG.trace("alarm raised for {}.", nbr.getAddress().getValue());
+ raiseBgpNbrDownAlarm(nbr.getAddress().getValue());
+ } else {
+ LOG.trace("alarm raised already for {}", nbr.getAddress().getValue());
+ }
+ } else {
+ if (alarmStatus == null || alarmStatus != BgpAlarmStatus.CLEARED) {
+ clearBgpNbrDownAlarm(nbr.getAddress().getValue());
+ LOG.trace("alarm cleared for {}", nbr.getAddress().getValue());
} else {
- if (alarmStatus == null || alarmStatus != BgpAlarmStatus.CLEARED) {
- clearBgpNbrDownAlarm(nbr.getAddress().getValue());
- LOG.trace("alarm cleared for {}", nbr.getAddress().getValue());
- } else {
- LOG.trace("alarm cleared already for {}", nbr.getAddress().getValue());
- }
+ LOG.trace("alarm cleared already for {}", nbr.getAddress().getValue());
}
}
}
}
+
private void raiseBgpNbrDownAlarm(String nbrIp) {
StringBuilder source = new StringBuilder();