Remove static VrfEntryListener.isOpenStackVniSemanticsEnforced 31/65531/4
authorTom Pantelis <tompantelis@gmail.com>
Wed, 15 Nov 2017 07:44:44 +0000 (02:44 -0500)
committerSam Hague <shague@redhat.com>
Mon, 20 Nov 2017 12:15:26 +0000 (12:15 +0000)
VrfEntryListener defines a static isOpenStackVniSemanticsEnforced
which is set in the ctor via the IElanService. FindBugs flags this
as a violation although it technically is safe b/c VrfEntryListener
is a singleton. However statics in this manner aren't good practice.
Users of the static flag should instead inject and obtain the flag
from IElanService.

One user was the static FibUtil class. FibUtil was converted to a
singleton. It also had static methods that take the DataBroker
and IdManagerService. Thee services are now injected and the methods
changed to non-static to make it cleaner. All users of these methods
now inject the FibUtil instance.

Change-Id: Ifecd9511568e263545ca7ce1c486483f67f9fe85
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/BaseVrfEntryHandler.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/BgpRouteVrfEntryHandler.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/EvpnVrfEntryHandler.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibConstants.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibManagerImpl.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/FibUtil.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/NexthopManager.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/RouterInterfaceVrfEntryHandler.java
vpnservice/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/netvirt/fibmanager/VrfEntryListener.java

index 0e1fb0d2ebed0254463023e7c6e4e3098209b3ad..ff56c8eaa9ffd54f7f5d5777bd9f57d69c70180f 100644 (file)
@@ -92,23 +92,34 @@ public class BaseVrfEntryHandler implements AutoCloseable {
     private static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
 
     private final DataBroker dataBroker;
-    final NexthopManager nextHopManager;
+    private final NexthopManager nextHopManager;
     private final IMdsalApiManager mdsalManager;
+    private final FibUtil fibUtil;
 
     @Inject
     public BaseVrfEntryHandler(final DataBroker dataBroker,
                                final NexthopManager nexthopManager,
-                               final IMdsalApiManager mdsalManager) {
+                               final IMdsalApiManager mdsalManager,
+                               final FibUtil fibUtil) {
         this.dataBroker = dataBroker;
         this.nextHopManager = nexthopManager;
         this.mdsalManager = mdsalManager;
+        this.fibUtil = fibUtil;
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() {
         LOG.info("{} closed", getClass().getSimpleName());
     }
 
+    protected FibUtil getFibUtil() {
+        return fibUtil;
+    }
+
+    protected NexthopManager getNextHopManager() {
+        return nextHopManager;
+    }
+
     private void addAdjacencyResultToList(List<AdjacencyResult> adjacencyList, AdjacencyResult adjacencyResult) {
         if (adjacencyResult != null && !adjacencyList.contains(adjacencyResult)) {
             adjacencyList.add(adjacencyResult);
@@ -138,9 +149,9 @@ public class BaseVrfEntryHandler implements AutoCloseable {
             if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
                 List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
                 List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
-                        FibUtil.getVpnNameFromId(dataBroker, vpnId), usedRds, vrfEntry.getDestPrefix());
+                        fibUtil.getVpnNameFromId(vpnId), usedRds, vrfEntry.getDestPrefix());
                 if (vpnExtraRoutes.isEmpty()) {
-                    Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+                    Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
                     // We don't want to provide an adjacencyList for an extra-route-prefix.
                     if (prefixInfo == null) {
                         LOG.debug("The extra route {} in rd {} for vpn {} has been removed from all the next hops",
@@ -281,7 +292,7 @@ public class BaseVrfEntryHandler implements AutoCloseable {
             return;
         }
         if (prefixInfo == null) {
-            prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+            prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
             //Checking PrefixtoInterface again as it is populated later in some cases
             if (prefixInfo == null) {
                 LOG.debug("No prefix info found for prefix {}", vrfEntry.getDestPrefix());
@@ -294,7 +305,7 @@ public class BaseVrfEntryHandler implements AutoCloseable {
             LOG.debug("Failed to get VPN interface for prefix {}", ipPrefix);
             return;
         }
-        String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipPrefix);
+        String macAddress = fibUtil.getMacAddressFromPrefix(ifName, ipPrefix);
         if (macAddress == null) {
             LOG.warn("No MAC address found for VPN interface {} prefix {}", ifName, ipPrefix);
             return;
@@ -326,10 +337,10 @@ public class BaseVrfEntryHandler implements AutoCloseable {
         // FIXME vxlan vni bit set is not working properly with OVS.need to
         // revisit
         if (tunnelType.equals(TunnelTypeVxlan.class)) {
-            prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+            prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
             //For extra route, the prefixInfo is fetched from the primary adjacency
             if (prefixInfo == null) {
-                prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, adjacencyResult.getPrefix());
+                prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
             }
             // Internet VPN VNI will be used as tun_id for NAT use-cases
             if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
@@ -337,10 +348,9 @@ public class BaseVrfEntryHandler implements AutoCloseable {
                     tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
                 }
             } else {
-                if (FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker, prefixInfo.getSubnetId(),
-                        vpnId, rd)) {
-                    java.util.Optional<Long> optionalVni = FibUtil.getVniForVxlanNetwork(dataBroker,
-                            prefixInfo.getSubnetId());
+                if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId,
+                        rd)) {
+                    java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
                     if (!optionalVni.isPresent()) {
                         LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp,
                                 vrfEntry, prefixInfo.getSubnetId());
@@ -452,7 +462,7 @@ public class BaseVrfEntryHandler implements AutoCloseable {
     }
 
     public Routes getVpnToExtraroute(Long vpnId, String vpnRd, String destPrefix) {
-        String optVpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+        String optVpnName = fibUtil.getVpnNameFromId(vpnId);
         if (optVpnName != null) {
             InstanceIdentifier<Routes> vpnExtraRoutesId = getVpnToExtrarouteIdentifier(
                     optVpnName, vpnRd, destPrefix);
index d322178a21e8b96197d51668402fd3e858e25d58..f7527a304d1179942f9e857a9bd16ba741a2d444 100644 (file)
@@ -64,18 +64,19 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
         implements ResourceHandler, IVrfEntryHandler {
 
     private static final Logger LOG = LoggerFactory.getLogger(BgpRouteVrfEntryHandler.class);
-    private final DataBroker dataBroker;
-
     private static final int BATCH_INTERVAL = 500;
     private static final int BATCH_SIZE = 1000;
+
+    private final DataBroker dataBroker;
     private final BlockingQueue<ActionableResource> vrfEntryBufferQ = new LinkedBlockingQueue<>();
     private final ResourceBatchingManager resourceBatchingManager;
     private final NexthopManager nexthopManager;
 
     @Inject
     public BgpRouteVrfEntryHandler(final DataBroker dataBroker,
-                                   final NexthopManager nexthopManager) {
-        super(dataBroker, nexthopManager, null);
+                                   final NexthopManager nexthopManager,
+                                   final FibUtil fibUtil) {
+        super(dataBroker, nexthopManager, null, fibUtil);
         this.dataBroker = dataBroker;
         this.nexthopManager = nexthopManager;
 
@@ -89,7 +90,7 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() {
         LOG.info("{} close", getClass().getSimpleName());
     }
 
@@ -175,7 +176,7 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
         final VrfTablesKey vrfTableKey = vrfEntryIid.firstKeyOf(VrfTables.class);
 
         final VpnInstanceOpDataEntry vpnInstance =
-                FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+                getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
         Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
         Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId()
                 + " has null vpnId!");
@@ -201,12 +202,12 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
         final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
         String rd = vrfTableKey.getRouteDistinguisher();
         final VpnInstanceOpDataEntry vpnInstance =
-                FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+                getFibUtil().getVpnInstance(vrfTableKey.getRouteDistinguisher());
         if (vpnInstance == null) {
             LOG.debug("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
             return;
         }
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+        String vpnName = getFibUtil().getVpnNameFromId(vpnInstance.getVpnId());
         final Collection<VpnToDpnList> vpnToDpnList = vpnInstance.getVpnToDpnList();
         if (vpnToDpnList != null) {
             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker,
@@ -387,7 +388,7 @@ public class BgpRouteVrfEntryHandler extends BaseVrfEntryHandler
     protected void addTunnelInterfaceActions(NexthopManager.AdjacencyResult adjacencyResult, long vpnId,
             VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
         Class<? extends TunnelTypeBase> tunnelType =
-                VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(),
+                VpnExtraRouteHelper.getTunnelType(getNextHopManager().getInterfaceManager(),
                         adjacencyResult.getInterfaceName());
         if (tunnelType == null) {
             LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
index d56af9ceb95292624fd7849fb57df7dbe3d1c69d..76a52adf21d526edafb327eeb7d42d25bd330350 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId;
 import org.opendaylight.genius.mdsalutil.instructions.InstructionApplyActions;
 import org.opendaylight.genius.utils.batching.SubTransaction;
 import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
@@ -49,23 +50,25 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
     private final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler;
     private final NexthopManager nexthopManager;
     private final JobCoordinator jobCoordinator;
+    private final IElanService elanManager;
 
     EvpnVrfEntryHandler(DataBroker broker, VrfEntryListener vrfEntryListener,
-                          BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler,
-                          NexthopManager nexthopManager, JobCoordinator jobCoordinator) {
-        super(broker, nexthopManager, null);
+            BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler, NexthopManager nexthopManager,
+            JobCoordinator jobCoordinator, IElanService elanManager, FibUtil fibUtil) {
+        super(broker, nexthopManager, null, fibUtil);
         this.dataBroker = broker;
         this.vrfEntryListener = vrfEntryListener;
         this.bgpRouteVrfEntryHandler = bgpRouteVrfEntryHandler;
         this.nexthopManager = nexthopManager;
         this.jobCoordinator = jobCoordinator;
+        this.elanManager = elanManager;
     }
 
     @Override
     public void createFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
         LOG.info("Initiating creation of Evpn Flows");
         final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstanceOpData(dataBroker,
+        final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(
                 vrfTableKey.getRouteDistinguisher()).get();
         Long vpnId = vpnInstance.getVpnId();
         Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
@@ -94,8 +97,7 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
             }
             return;
         }
-        Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnInstance.getVpnId(),
-                vrfEntry.getDestPrefix());
+        Prefixes localNextHopInfo = getFibUtil().getPrefixToInterface(vpnInstance.getVpnId(), vrfEntry.getDestPrefix());
         List<BigInteger> localDpnId = new ArrayList<>();
         boolean isNatPrefix = false;
         if (Prefixes.PrefixCue.Nat.equals(localNextHopInfo.getPrefixCue())) {
@@ -113,7 +115,7 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
     @Override
     public void removeFlows(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
         final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstanceOpData(dataBroker,
+        final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstanceOpData(
                 vrfTableKey.getRouteDistinguisher()).get();
         if (vpnInstance == null) {
             LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
@@ -142,7 +144,7 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
                 for (String nextHopIp : extraRoute.getNexthopIpList()) {
                     LOG.info("NextHop IP for destination {} is {}", vrfEntry.getDestPrefix(), nextHopIp);
                     if (nextHopIp != null) {
-                        localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, nextHopIp + "/32");
+                        localNextHopInfo = getFibUtil().getPrefixToInterface(vpnId, nextHopIp + "/32");
                         if (localNextHopInfo != null) {
                             localNextHopIP = nextHopIp + "/32";
                             BigInteger dpnId = checkCreateLocalEvpnFlows(localNextHopInfo, localNextHopIP, vpnId,
@@ -233,21 +235,20 @@ public class EvpnVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntr
             List<ActionInfo> actionInfos = new ArrayList<>();
             BigInteger tunnelId;
             String prefix = adjacencyResult.getPrefix();
-            Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, prefix);
+            Prefixes prefixInfo = getFibUtil().getPrefixToInterface(vpnId, prefix);
             String interfaceName = prefixInfo.getVpnInterfaceName();
             if (vrfEntry.getOrigin().equals(RouteOrigin.BGP.getValue()) || isNatPrefix) {
                 tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
-            } else if (VrfEntryListener.isOpenStackVniSemanticsEnforced) {
-                tunnelId = BigInteger.valueOf(FibUtil.getVniForVxlanNetwork(dataBroker,
-                        prefixInfo.getSubnetId()).get());
+            } else if (elanManager.isOpenStackVniSemanticsEnforced()) {
+                tunnelId = BigInteger.valueOf(getFibUtil().getVniForVxlanNetwork(prefixInfo.getSubnetId()).get());
             } else {
-                Interface interfaceState = FibUtil.getInterfaceStateFromOperDS(dataBroker, interfaceName);
+                Interface interfaceState = getFibUtil().getInterfaceStateFromOperDS(interfaceName);
                 tunnelId = BigInteger.valueOf(interfaceState.getIfIndex());
             }
             LOG.debug("adding set tunnel id action for label {}", tunnelId);
             String macAddress = null;
             if (interfaceName != null) {
-                macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, interfaceName, prefix);
+                macAddress = getFibUtil().getMacAddressFromPrefix(interfaceName, prefix);
                 actionInfos.add(new ActionSetFieldEthernetDestination(new MacAddress(macAddress)));
             }
             actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
index 7f202ffc8a2dd6ccaa7513252bda36d74c8e03e4..a40a4e75bfc1c9e9a5b4965e4ade99547a86d232 100644 (file)
@@ -7,27 +7,22 @@
  */
 package org.opendaylight.netvirt.fibmanager;
 
+import com.google.common.collect.ImmutableMap;
 import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg0;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.NxmNxReg1;
 
-public final class FibConstants {
-    static final int DEFAULT_FIB_FLOW_PRIORITY = 10;
-    static final int DEFAULT_PREFIX_LENGTH = 32;
-    static final int DEFAULT_IPV6_PREFIX_LENGTH = 128;
-    static final String PREFIX_SEPARATOR = "/";
-    static final String FLOWID_PREFIX = "L3.";
-    static final String VPN_IDPOOL_NAME = "vpnservices";
-    static final String SEPARATOR = ".";
-    static final String DEFAULT_NEXTHOP_IP = "0.0.0.0";
-    public static final long INVALID_GROUP_ID = -1;
-    public static final Map<Integer, Class<? extends NxmNxReg>> NXM_REG_MAPPING = new ConcurrentHashMap<>();
+public interface FibConstants {
+    int DEFAULT_FIB_FLOW_PRIORITY = 10;
+    int DEFAULT_PREFIX_LENGTH = 32;
+    int DEFAULT_IPV6_PREFIX_LENGTH = 128;
+    String PREFIX_SEPARATOR = "/";
+    String FLOWID_PREFIX = "L3.";
+    String VPN_IDPOOL_NAME = "vpnservices";
+    String SEPARATOR = ".";
+    String DEFAULT_NEXTHOP_IP = "0.0.0.0";
+    long INVALID_GROUP_ID = -1;
 
-    static {
-        NXM_REG_MAPPING.put(0, NxmNxReg0.class);
-        NXM_REG_MAPPING.put(1, NxmNxReg1.class);
-    }
+    Map<Integer, Class<? extends NxmNxReg>> NXM_REG_MAPPING = ImmutableMap.of(0, NxmNxReg0.class, 1, NxmNxReg1.class);
 }
index cd91d2080f0e6297e259f0b5a84b7e2c9e0e49a0..adb5f0955bd0edc711dc454020d89e457d0f8f8b 100755 (executable)
@@ -36,15 +36,18 @@ public class FibManagerImpl implements IFibManager {
     private final VrfEntryListener vrfEntryListener;
     private IVpnManager vpnmanager;
     private final DataBroker dataBroker;
+    private final FibUtil fibUtil;
 
     @Inject
     public FibManagerImpl(final DataBroker dataBroker,
                           final NexthopManager nexthopManager,
                           final VrfEntryListener vrfEntryListener,
-                          final BundleContext bundleContext) {
+                          final BundleContext bundleContext,
+                          final FibUtil fibUtil) {
         this.dataBroker = dataBroker;
         this.nexthopManager = nexthopManager;
         this.vrfEntryListener = vrfEntryListener;
+        this.fibUtil = fibUtil;
 
         GlobalEventExecutor.INSTANCE.execute(() -> {
             final WaitingServiceTracker<IVpnManager> tracker = WaitingServiceTracker.create(
@@ -128,37 +131,37 @@ public class FibManagerImpl implements IFibManager {
                                     List<String> nextHopList, VrfEntry.EncapType encapType, long label,
                                     long l3vni, String gwMacAddress, String parentVpnRd, RouteOrigin origin,
                                     WriteTransaction writeConfigTxn) {
-        FibUtil.addOrUpdateFibEntry(broker, rd, macAddress, prefix , nextHopList, encapType, label, l3vni,
-                gwMacAddress, parentVpnRd, origin, writeConfigTxn);
+        fibUtil.addOrUpdateFibEntry(rd, macAddress, prefix, nextHopList , encapType, label, l3vni, gwMacAddress,
+                parentVpnRd, origin, writeConfigTxn);
     }
 
     @Override
     public void addFibEntryForRouterInterface(DataBroker broker, String rd, String prefix,
                                               RouterInterface routerInterface, long label,
                                               WriteTransaction writeConfigTxn) {
-        FibUtil.addFibEntryForRouterInterface(broker, rd, prefix, routerInterface, label, writeConfigTxn);
+        fibUtil.addFibEntryForRouterInterface(rd, prefix, routerInterface, label, writeConfigTxn);
     }
 
     @Override
     public void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix,
                                        String nextHopToRemove, WriteTransaction writeConfigTxn) {
-        FibUtil.removeOrUpdateFibEntry(broker, rd, prefix, nextHopToRemove, writeConfigTxn);
+        fibUtil.removeOrUpdateFibEntry(rd, prefix, nextHopToRemove, writeConfigTxn);
     }
 
     @Override
     public void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn) {
-        FibUtil.removeFibEntry(broker, rd, prefix, writeConfigTxn);
+        fibUtil.removeFibEntry(rd, prefix, writeConfigTxn);
     }
 
     @Override
     public void updateRoutePathForFibEntry(DataBroker broker, String rd, String prefix, String nextHop,
                                long label, boolean nextHopAdd, WriteTransaction writeConfigTxn) {
-        FibUtil.updateRoutePathForFibEntry(broker, rd, prefix, nextHop, label, nextHopAdd, writeConfigTxn);
+        fibUtil.updateRoutePathForFibEntry(rd, prefix, nextHop, label, nextHopAdd, writeConfigTxn);
     }
 
     @Override
     public void removeVrfTable(DataBroker broker, String rd, WriteTransaction writeConfigTxn) {
-        FibUtil.removeVrfTable(broker, rd, writeConfigTxn);
+        fibUtil.removeVrfTable(rd, writeConfigTxn);
     }
 
     @Override
@@ -177,7 +180,7 @@ public class FibManagerImpl implements IFibManager {
             return;
         }
         InterVpnLinkDataComposite interVpnLink = optInterVpnLink.get();
-        String vpnName = (isVpnFirstEndPoint) ? interVpnLink.getFirstEndpointVpnUuid().get()
+        String vpnName = isVpnFirstEndPoint ? interVpnLink.getFirstEndpointVpnUuid().get()
                                               : interVpnLink.getSecondEndpointVpnUuid().get();
 
         vrfEntryListener.removeInterVPNLinkRouteFlows(interVpnLink, vpnName, vrfEntry);
index 3cdb3b75f823f3f596e209c742e77fca3626fc39..cdfd8455a32d9b16503aac2c91546d3efe614b44 100644 (file)
@@ -10,12 +10,10 @@ package org.opendaylight.netvirt.fibmanager;
 
 import static java.util.stream.Collectors.joining;
 import static java.util.stream.Collectors.toList;
-import static org.opendaylight.netvirt.fibmanager.VrfEntryListener.isOpenStackVniSemanticsEnforced;
 
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.net.InetAddresses;
-
 import java.math.BigInteger;
 import java.net.InetAddress;
 import java.util.ArrayList;
@@ -23,13 +21,15 @@ import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
-
+import javax.inject.Inject;
+import javax.inject.Singleton;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.BucketInfo;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
 import org.opendaylight.genius.mdsalutil.NwConstants;
+import org.opendaylight.netvirt.elanmanager.api.IElanService;
 import org.opendaylight.netvirt.fibmanager.NexthopManager.AdjacencyResult;
 import org.opendaylight.netvirt.fibmanager.api.FibHelper;
 import org.opendaylight.netvirt.fibmanager.api.RouteOrigin;
@@ -99,11 +99,20 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public final class FibUtil {
+@Singleton
+public class FibUtil {
     private static final Logger LOG = LoggerFactory.getLogger(FibUtil.class);
     private static final String FLOWID_PREFIX = "L3.";
 
-    private FibUtil() {
+    private final DataBroker dataBroker;
+    private final IElanService elanManager;
+    private final IdManagerService idManager;
+
+    @Inject
+    public FibUtil(DataBroker dataBroker, IElanService elanManager, IdManagerService idManager) {
+        this.dataBroker = dataBroker;
+        this.elanManager = elanManager;
+        this.idManager = idManager;
     }
 
     static InstanceIdentifier<Adjacency> getAdjacencyIdentifier(String vpnInterfaceName, String ipAddress) {
@@ -157,12 +166,12 @@ public final class FibUtil {
             .child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd)).build();
     }
 
-    static Optional<VpnInstanceOpDataEntry> getVpnInstanceOpData(DataBroker broker, String rd) {
+    Optional<VpnInstanceOpDataEntry> getVpnInstanceOpData(String rd) {
         InstanceIdentifier<VpnInstanceOpDataEntry> id = getVpnInstanceOpDataIdentifier(rd);
-        return MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL, id);
+        return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
     }
 
-    static VpnInstanceOpDataEntry getVpnInstance(DataBroker dataBroker, String rd) {
+    VpnInstanceOpDataEntry getVpnInstance(String rd) {
         InstanceIdentifier<VpnInstanceOpDataEntry> id =
                 InstanceIdentifier.create(VpnInstanceOpData.class)
                         .child(VpnInstanceOpDataEntry.class, new VpnInstanceOpDataEntryKey(rd));
@@ -175,19 +184,19 @@ public final class FibUtil {
         return rd + FibConstants.SEPARATOR + prefix;
     }
 
-    static Prefixes getPrefixToInterface(DataBroker broker, Long vpnId, String ipPrefix) {
-        Optional<Prefixes> localNextHopInfoData = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+    Prefixes getPrefixToInterface(Long vpnId, String ipPrefix) {
+        Optional<Prefixes> localNextHopInfoData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
             getPrefixToInterfaceIdentifier(vpnId, ipPrefix));
         return localNextHopInfoData.isPresent() ? localNextHopInfoData.get() : null;
     }
 
-    static String getMacAddressFromPrefix(DataBroker broker, String ifName, String ipPrefix) {
-        Optional<Adjacency> adjacencyData = MDSALUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+    String getMacAddressFromPrefix(String ifName, String ipPrefix) {
+        Optional<Adjacency> adjacencyData = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL,
             getAdjacencyIdentifier(ifName, ipPrefix));
         return adjacencyData.isPresent() ? adjacencyData.get().getMacAddress() : null;
     }
 
-    static void releaseId(IdManagerService idManager, String poolName, String idKey) {
+    void releaseId(String poolName, String idKey) {
         ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(poolName).setIdKey(idKey).build();
         try {
             Future<RpcResult<Void>> result = idManager.releaseId(idInput);
@@ -209,28 +218,27 @@ public final class FibUtil {
                     .VpnInstanceKey(vpnName)).build();
     }
 
-    public static long getVpnId(DataBroker broker, String vpnName) {
+    public long getVpnId(String vpnName) {
 
         InstanceIdentifier<VpnInstance> id = getVpnInstanceToVpnIdIdentifier(vpnName);
-        return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
+        return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
                 VpnInstance::getVpnId).orElse(-1L);
     }
 
     /**
      * Retrieves the VpnInstance name (typically the VPN Uuid) out from the route-distinguisher.
-     *
-     * @param broker The DataBroker
      * @param rd The route-distinguisher
+     *
      * @return The vpn instance
      */
-    public static Optional<String> getVpnNameFromRd(DataBroker broker, String rd) {
+    public Optional<String> getVpnNameFromRd(String rd) {
         return Optional.fromJavaUtil(
-                getVpnInstanceOpData(broker, rd).toJavaUtil().map(VpnInstanceOpDataEntry::getVpnInstanceName));
+                getVpnInstanceOpData(rd).toJavaUtil().map(VpnInstanceOpDataEntry::getVpnInstanceName));
     }
 
-    public static String getVpnNameFromId(DataBroker broker, long vpnId) {
+    public String getVpnNameFromId(long vpnId) {
         InstanceIdentifier<VpnIds> id = getVpnIdToVpnInstanceIdentifier(vpnId);
-        return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
+        return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id).toJavaUtil().map(
                 VpnIds::getVpnInstanceName).orElse(null);
     }
 
@@ -241,10 +249,9 @@ public final class FibUtil {
 
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    public static void addOrUpdateFibEntry(DataBroker broker, String rd, String macAddress, String prefix,
-                                           List<String> nextHopList, VrfEntry.EncapType encapType, long label,
-                                           long l3vni, String gwMacAddress, String parentVpnRd, RouteOrigin origin,
-                                           WriteTransaction writeConfigTxn) {
+    public void addOrUpdateFibEntry(String rd, String macAddress, String prefix, List<String> nextHopList,
+            VrfEntry.EncapType encapType, long label, long l3vni, String gwMacAddress, String parentVpnRd,
+            RouteOrigin origin, WriteTransaction writeConfigTxn) {
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
             return;
@@ -259,7 +266,7 @@ public final class FibUtil {
                     .child(VrfEntry.class, new VrfEntryKey(prefix)).build();
 
             writeFibEntryToDs(vrfEntryId, prefix, nextHopList, label, l3vni, encapType, origin, macAddress,
-                    gwMacAddress, parentVpnRd, writeConfigTxn, broker);
+                    gwMacAddress, parentVpnRd, writeConfigTxn);
             LOG.debug("Created/Updated vrfEntry for {} nexthop {} label {}", prefix, nextHopList, label);
         } catch (Exception e) {
             LOG.error("addOrUpdateFibEntry: Prefix {} rd {} label {} error ", prefix, rd, label, e);
@@ -268,11 +275,9 @@ public final class FibUtil {
 
     // TODO Clean up the exception handling
     @SuppressWarnings("checkstyle:IllegalCatch")
-    public static void writeFibEntryToDs(InstanceIdentifier<VrfEntry> vrfEntryId, String prefix,
-                                         List<String> nextHopList, long label, Long l3vni,
-                                         VrfEntry.EncapType encapType, RouteOrigin origin, String macAddress,
-                                         String gatewayMacAddress, String parentVpnRd,
-                                         WriteTransaction writeConfigTxn, DataBroker broker) {
+    public void writeFibEntryToDs(InstanceIdentifier<VrfEntry> vrfEntryId, String prefix, List<String> nextHopList,
+            long label, Long l3vni, VrfEntry.EncapType encapType, RouteOrigin origin, String macAddress,
+            String gatewayMacAddress, String parentVpnRd, WriteTransaction writeConfigTxn) {
         VrfEntryBuilder vrfEntryBuilder = new VrfEntryBuilder().setDestPrefix(prefix).setOrigin(origin.getValue());
         if (parentVpnRd != null) {
             vrfEntryBuilder.setParentVpnRd(parentVpnRd);
@@ -281,17 +286,13 @@ public final class FibUtil {
         if (writeConfigTxn != null) {
             writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build(), true);
         } else {
-            MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build());
+            MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntryBuilder.build());
         }
     }
 
     @SuppressWarnings("checkstyle:IllegalCatch")
-    public static void addFibEntryForRouterInterface(DataBroker broker,
-                                                     String rd,
-                                                     String prefix,
-                                                     RouterInterface routerInterface,
-                                                     long label,
-                                                     WriteTransaction writeConfigTxn) {
+    public void addFibEntryForRouterInterface(String rd, String prefix, RouterInterface routerInterface, long label,
+            WriteTransaction writeConfigTxn) {
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
             return;
@@ -311,7 +312,7 @@ public final class FibUtil {
             if (writeConfigTxn != null) {
                 writeConfigTxn.merge(LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry, true);
             } else {
-                MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
+                MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId, vrfEntry);
             }
             LOG.debug("Created vrfEntry for router-interface-prefix {} rd {} label {}", prefix, rd, label);
         } catch (Exception e) {
@@ -340,7 +341,7 @@ public final class FibUtil {
         builder.setRoutePaths(routePaths);
     }
 
-    public static void removeFibEntry(DataBroker broker, String rd, String prefix, WriteTransaction writeConfigTxn) {
+    public void removeFibEntry(String rd, String prefix, WriteTransaction writeConfigTxn) {
 
         if (rd == null || rd.isEmpty()) {
             LOG.error("Prefix {} not associated with vpn", prefix);
@@ -355,22 +356,20 @@ public final class FibUtil {
         if (writeConfigTxn != null) {
             writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
         } else {
-            MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+            MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
         }
     }
 
     /**
      * Removes a specific Nexthop from a VrfEntry. If Nexthop to remove is the
      * last one in the VrfEntry, then the VrfEntry is removed too.
-     *
-     * @param broker          dataBroker service reference
      * @param rd              Route-Distinguisher to which the VrfEntry belongs to
      * @param prefix          Destination of the route
      * @param nextHopToRemove Specific nexthop within the Route to be removed.
      *                        If null or empty, then the whole VrfEntry is removed
      */
-    public static void removeOrUpdateFibEntry(DataBroker broker, String rd, String prefix, String nextHopToRemove,
-                                              WriteTransaction writeConfigTxn) {
+    public void removeOrUpdateFibEntry(String rd, String prefix, String nextHopToRemove,
+            WriteTransaction writeConfigTxn) {
 
         LOG.debug("Removing fib entry with destination prefix {} from vrf table for rd {}", prefix, rd);
 
@@ -378,7 +377,7 @@ public final class FibUtil {
         InstanceIdentifier<VrfEntry> vrfEntryId =
             InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd))
                 .child(VrfEntry.class, new VrfEntryKey(prefix)).build();
-        Optional<VrfEntry> entry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+        Optional<VrfEntry> entry = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
         if (entry.isPresent()) {
             final List<RoutePaths> routePaths = entry.get().getRoutePaths();
             if (routePaths == null || routePaths.isEmpty()) {
@@ -399,14 +398,14 @@ public final class FibUtil {
                 if (writeConfigTxn != null) {
                     writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfEntryId);
                 } else {
-                    MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+                    MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
                 }
                 LOG.info("Removed Fib Entry rd {} prefix {}", rd, prefix);
             } else {
                 InstanceIdentifier<RoutePaths> routePathsId =
                         FibHelper.buildRoutePathId(rd, prefix, routePath.getNexthopAddress());
                 // Remove route
-                MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routePathsId);
+                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathsId);
 
                 LOG.info("Removed Route Path rd {} prefix {}, nextHop {}, label {}", rd, prefix,
                         routePath.getNexthopAddress(), routePath.getLabel());
@@ -419,8 +418,8 @@ public final class FibUtil {
     /**
      * Adds or removes nextHop from routePath based on the flag nextHopAdd.
      */
-    public static void updateRoutePathForFibEntry(DataBroker broker, String rd, String prefix, String nextHop,
-            long label, boolean nextHopAdd, WriteTransaction writeConfigTxn) {
+    public void updateRoutePathForFibEntry(String rd, String prefix, String nextHop, long label,
+            boolean nextHopAdd, WriteTransaction writeConfigTxn) {
 
         LOG.debug("Updating fib entry for prefix {} with nextHop {} for rd {}.", prefix, nextHop, rd);
 
@@ -433,11 +432,11 @@ public final class FibUtil {
                     writeConfigTxn.put(LogicalDatastoreType.CONFIGURATION, routePathId, routePaths,
                             WriteTransaction.CREATE_MISSING_PARENTS);
                 } else {
-                    MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, routePathId, routePaths);
+                    MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathId, routePaths);
                 }
                 LOG.debug("Added routepath with nextHop {} for prefix {} and label {}.", nextHop, prefix, label);
             } else {
-                Optional<RoutePaths> routePath = MDSALUtil.read(broker,
+                Optional<RoutePaths> routePath = MDSALUtil.read(dataBroker,
                         LogicalDatastoreType.CONFIGURATION, routePathId);
                 if (!routePath.isPresent()) {
                     LOG.warn("Couldn't find RoutePath with rd {}, prefix {} and nh {} for deleting",
@@ -447,14 +446,14 @@ public final class FibUtil {
                 if (writeConfigTxn != null) {
                     writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, routePathId);
                 } else {
-                    MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routePathId);
+                    MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routePathId);
                 }
                 LOG.info("Removed routepath with nextHop {} for prefix {} and rd {}.", nextHop, prefix, rd);
             }
         }
     }
 
-    public static void removeVrfTable(DataBroker broker, String rd, WriteTransaction writeConfigTxn) {
+    public void removeVrfTable(String rd, WriteTransaction writeConfigTxn) {
         LOG.debug("Removing vrf table for rd {}", rd);
         InstanceIdentifier.InstanceIdentifierBuilder<VrfTables> idBuilder =
             InstanceIdentifier.builder(FibEntries.class).child(VrfTables.class, new VrfTablesKey(rd));
@@ -463,10 +462,10 @@ public final class FibUtil {
         if (writeConfigTxn != null) {
             writeConfigTxn.delete(LogicalDatastoreType.CONFIGURATION, vrfTableId);
         } else {
-            Optional<VrfTables> ifStateOptional = MDSALUtil.read(broker,
+            Optional<VrfTables> ifStateOptional = MDSALUtil.read(dataBroker,
                     LogicalDatastoreType.CONFIGURATION, vrfTableId);
             if (ifStateOptional.isPresent()) {
-                MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
+                MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfTableId);
             }
         }
     }
@@ -510,8 +509,8 @@ public final class FibUtil {
         return id;
     }
 
-    public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
-        .state.Interface getInterfaceStateFromOperDS(DataBroker dataBroker, String interfaceName) {
+    public org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces
+        .state.Interface getInterfaceStateFromOperDS(String interfaceName) {
         InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508
             .interfaces.state.Interface> ifStateId = buildStateInterfaceId(interfaceName);
         Optional<Interface> ifStateOptional = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, ifStateId);
@@ -534,34 +533,33 @@ public final class FibUtil {
         return "FIB-" + vpnId.toString() + "-" + dpnId.toString() ;
     }
 
-    public static void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeOperTxn, DataBroker broker,
-                                                      String tunnelIpRemoved, String primaryRd, String prefix) {
-        Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(broker, primaryRd);
+    public void updateUsedRdAndVpnToExtraRoute(WriteTransaction writeOperTxn, String tunnelIpRemoved, String primaryRd,
+            String prefix) {
+        Optional<VpnInstanceOpDataEntry> optVpnInstance = getVpnInstanceOpData(primaryRd);
         if (!optVpnInstance.isPresent()) {
             return;
         }
         VpnInstanceOpDataEntry vpnInstance = optVpnInstance.get();
         String vpnName = vpnInstance.getVpnInstanceName();
         long vpnId = vpnInstance.getVpnId();
-        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(broker, vpnId, prefix);
+        List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, prefix);
         // To identify the rd to be removed, iterate through the allocated rds for the prefix and check
         // which rd is allocated for the particular OVS.
         for (String usedRd : usedRds) {
             Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper
-                    .getVpnExtraroutes(broker, vpnName, usedRd, prefix);
+                    .getVpnExtraroutes(dataBroker, vpnName, usedRd, prefix);
             if (vpnExtraRoutes.isPresent()) {
                 // Since all the nexthops under one OVS will be present under one rd, only 1 nexthop is read
                 // to identify the OVS
                 String nextHopRemoved = vpnExtraRoutes.get().getNexthopIpList().get(0);
-                Prefixes prefixToInterface = getPrefixToInterface(broker, vpnId, getIpPrefix(nextHopRemoved));
+                Prefixes prefixToInterface = getPrefixToInterface(vpnId, getIpPrefix(nextHopRemoved));
                 if (prefixToInterface != null && tunnelIpRemoved
-                        .equals(getEndpointIpAddressForDPN(broker, prefixToInterface.getDpnId()))) {
+                        .equals(getEndpointIpAddressForDPN(prefixToInterface.getDpnId()))) {
                     InstanceIdentifier<Adjacency> adjId = getAdjacencyIdentifier(
                             prefixToInterface.getVpnInterfaceName(), prefix);
-                    Interface ifState = FibUtil.getInterfaceStateFromOperDS(
-                            broker, prefixToInterface.getVpnInterfaceName());
+                    Interface ifState = getInterfaceStateFromOperDS(prefixToInterface.getVpnInterfaceName());
                     //Delete datastore only if extra route is deleted or VM interface is deleted/down
-                    if (!MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, adjId).isPresent()
+                    if (!MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, adjId).isPresent()
                             || ifState == null || ifState.getOperStatus() == OperStatus.Down) {
                         writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL,
                                 getAdjacencyIdentifier(prefixToInterface.getVpnInterfaceName(), prefix));
@@ -576,12 +574,12 @@ public final class FibUtil {
         }
     }
 
-    private static String getEndpointIpAddressForDPN(DataBroker broker, BigInteger dpnId) {
+    private String getEndpointIpAddressForDPN(BigInteger dpnId) {
         //TODO: Move it to a common place for vpn and fib
         String nextHopIp = null;
         InstanceIdentifier<DPNTEPsInfo> tunnelInfoId =
             InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(dpnId)).build();
-        Optional<DPNTEPsInfo> tunnelInfo = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId);
+        Optional<DPNTEPsInfo> tunnelInfo = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, tunnelInfoId);
         if (tunnelInfo.isPresent()) {
             List<TunnelEndPoints> nexthopIpList = tunnelInfo.get().getTunnelEndPoints();
             if (nexthopIpList != null && !nexthopIpList.isEmpty()) {
@@ -608,9 +606,9 @@ public final class FibUtil {
                 .child(VrfTables.class,new VrfTablesKey(rd)).child(VrfEntry.class,new VrfEntryKey(prefix)).build();
     }
 
-    public static List<String> getNextHopAddresses(DataBroker broker, String rd, String prefix) {
+    public List<String> getNextHopAddresses(String rd, String prefix) {
         InstanceIdentifier<VrfEntry> vrfEntryId = getNextHopIdentifier(rd, prefix);
-        Optional<VrfEntry> vrfEntry = MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
+        Optional<VrfEntry> vrfEntry = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vrfEntryId);
         if (vrfEntry.isPresent()) {
             return FibHelper.getNextHopListFromRoutePaths(vrfEntry.get());
         } else {
@@ -618,10 +616,10 @@ public final class FibUtil {
         }
     }
 
-    public static Subnetmap getSubnetMap(DataBroker broker, Uuid subnetId) {
+    public Subnetmap getSubnetMap(Uuid subnetId) {
         InstanceIdentifier<Subnetmap> subnetmapId = InstanceIdentifier.builder(Subnetmaps.class)
             .child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
-        return MDSALUtil.read(broker, LogicalDatastoreType.CONFIGURATION, subnetmapId).orNull();
+        return MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetmapId).orNull();
     }
 
     public static String getGreLbGroupKey(List<String> availableDcGws) {
@@ -686,24 +684,23 @@ public final class FibUtil {
                 .setNexthopKey(Collections.singletonList(groupIdKey)).build();
     }
 
-    public static Optional<Nexthops> getNexthops(DataBroker dataBroker, String nextHopKey) {
+    public Optional<Nexthops> getNexthops(String nextHopKey) {
         InstanceIdentifier<Nexthops> nextHopsId = InstanceIdentifier.builder(L3vpnLbNexthops.class)
                 .child(Nexthops.class, new NexthopsKey(nextHopKey)).build();
         return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, nextHopsId);
     }
 
-    public static Optional<DpnLbNexthops> getDpnLbNexthops(DataBroker dataBroker, BigInteger dpnId,
-            String destinationIp) {
+    public Optional<DpnLbNexthops> getDpnLbNexthops(BigInteger dpnId, String destinationIp) {
         InstanceIdentifier<DpnLbNexthops> id = InstanceIdentifier.builder(DpidL3vpnLbNexthops.class)
                 .child(DpnLbNexthops.class, new DpnLbNexthopsKey(destinationIp, dpnId))
                 .build();
         return MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
     }
 
-    protected static boolean isVxlanNetworkAndInternalRouterVpn(DataBroker dataBroker, Uuid subnetId, String
+    boolean isVxlanNetworkAndInternalRouterVpn(Uuid subnetId, String
             vpnInstanceName, String rd) {
         if (rd.equals(vpnInstanceName)) {
-            Subnetmap subnetmap = getSubnetMap(dataBroker, subnetId);
+            Subnetmap subnetmap = getSubnetMap(subnetId);
             if (subnetmap != null) {
                 return subnetmap.getNetworkType() == NetworkAttributes.NetworkType.VXLAN;
             }
@@ -711,24 +708,22 @@ public final class FibUtil {
         return false;
     }
 
-    protected static java.util.Optional<Long> getVniForVxlanNetwork(DataBroker dataBroker, Uuid subnetId) {
-        Subnetmap subnetmap = getSubnetMap(dataBroker, subnetId);
+    java.util.Optional<Long> getVniForVxlanNetwork(Uuid subnetId) {
+        Subnetmap subnetmap = getSubnetMap(subnetId);
         if (subnetmap != null && subnetmap.getNetworkType() == NetworkAttributes.NetworkType.VXLAN) {
             return java.util.Optional.of(subnetmap.getSegmentationId());
         }
         return java.util.Optional.empty();
     }
 
-    protected static boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(DataBroker dataBroker, Uuid subnetId,
-                                                                               long vpnId, String rd) {
-        return isOpenStackVniSemanticsEnforced
-                && isVxlanNetworkAndInternalRouterVpn(dataBroker, subnetId, getVpnNameFromId(dataBroker, vpnId), rd);
+    boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(Uuid subnetId, long vpnId, String rd) {
+        return elanManager.isOpenStackVniSemanticsEnforced()
+                && isVxlanNetworkAndInternalRouterVpn(subnetId, getVpnNameFromId(vpnId), rd);
     }
 
-    protected static boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(DataBroker dataBroker, Uuid subnetId,
-                                                                               String vpnName, String rd) {
-        return isOpenStackVniSemanticsEnforced
-                && isVxlanNetworkAndInternalRouterVpn(dataBroker, subnetId, vpnName, rd);
+    boolean enforceVxlanDatapathSemanticsforInternalRouterVpn(Uuid subnetId, String vpnName, String rd) {
+        return elanManager.isOpenStackVniSemanticsEnforced()
+                && isVxlanNetworkAndInternalRouterVpn(subnetId, vpnName, rd);
     }
 
     static NodeRef buildNodeRef(BigInteger dpId) {
index 16864f3ad286138b0e5659f7065d2acea2ff56ff..cecd28f7fd5c6b88caac33ac4d60b2910cb7e156 100644 (file)
@@ -127,6 +127,9 @@ import org.slf4j.LoggerFactory;
 @Singleton
 public class NexthopManager implements AutoCloseable {
     private static final Logger LOG = LoggerFactory.getLogger(NexthopManager.class);
+    private static final String NEXTHOP_ID_POOL_NAME = "nextHopPointerPool";
+    private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
+
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalApiManager;
     private final OdlInterfaceRpcService interfaceManager;
@@ -135,8 +138,7 @@ public class NexthopManager implements AutoCloseable {
     private final IElanService elanService;
     private final SalGroupService salGroupService;
     private final JobCoordinator jobCoordinator;
-    private static final String NEXTHOP_ID_POOL_NAME = "nextHopPointerPool";
-    private static final long WAIT_TIME_FOR_SYNC_INSTALL = Long.getLong("wait.time.sync.install", 300L);
+    private final FibUtil fibUtil;
     private L3VPNTransportTypes configuredTransportTypeL3VPN = L3VPNTransportTypes.Invalid;
 
     /**
@@ -157,7 +159,8 @@ public class NexthopManager implements AutoCloseable {
                           final ItmRpcService itmManager,
                           final IElanService elanService,
                           final SalGroupService salGroupService,
-                          final JobCoordinator jobCoordinator) {
+                          final JobCoordinator jobCoordinator,
+                          final FibUtil fibUtil) {
         this.dataBroker = dataBroker;
         this.mdsalApiManager = mdsalApiManager;
         this.idManager = idManager;
@@ -166,6 +169,7 @@ public class NexthopManager implements AutoCloseable {
         this.elanService = elanService;
         this.salGroupService = salGroupService;
         this.jobCoordinator = jobCoordinator;
+        this.fibUtil = fibUtil;
         createIdPool();
     }
 
@@ -325,7 +329,7 @@ public class NexthopManager implements AutoCloseable {
 
     public long createLocalNextHop(long vpnId, BigInteger dpnId, String ifName,
             String ipNextHopAddress, String ipPrefixAddress, String gwMacAddress, String jobKey) {
-        String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipPrefixAddress);
+        String macAddress = fibUtil.getMacAddressFromPrefix(ifName, ipPrefixAddress);
         String ipAddress = macAddress != null ? ipPrefixAddress : ipNextHopAddress;
 
         long groupId = createNextHopPointer(getNextHopKey(vpnId, ipAddress));
@@ -342,7 +346,7 @@ public class NexthopManager implements AutoCloseable {
                         ipAddress, ifName, dpnId);
                 if (nexthop == null) {
                     String encMacAddress = macAddress == null
-                            ? FibUtil.getMacAddressFromPrefix(dataBroker, ifName, ipAddress) : macAddress;
+                            ? fibUtil.getMacAddressFromPrefix(ifName, ipAddress) : macAddress;
                     List<BucketInfo> listBucketInfo = new ArrayList<>();
                     List<ActionInfo> listActionInfo = new ArrayList<>();
                     int actionKey = 0;
@@ -698,11 +702,11 @@ public class NexthopManager implements AutoCloseable {
 
     private ElanInstance getElanInstanceForPrefix(long vpnId, String prefixIp) {
         ElanInstance elanInstance = null;
-        Prefixes prefix = FibUtil.getPrefixToInterface(dataBroker, vpnId, prefixIp);
+        Prefixes prefix = fibUtil.getPrefixToInterface(vpnId, prefixIp);
         if (prefix != null) {
             Uuid subnetId = prefix.getSubnetId();
             if (subnetId != null) {
-                Subnetmap subnetMap = FibUtil.getSubnetMap(dataBroker, subnetId);
+                Subnetmap subnetMap = fibUtil.getSubnetMap(subnetId);
                 if (subnetMap != null && subnetMap.getNetworkId() != null) {
                     elanInstance = elanService.getElanInstance(subnetMap.getNetworkId().getValue());
                 }
@@ -812,7 +816,7 @@ public class NexthopManager implements AutoCloseable {
             } else {
                 localNextHopIP = nextHopIp + NwConstants.IPV6PREFIX;
             }
-            Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, localNextHopIP);
+            Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
             if (localNextHopInfo != null) {
                 long groupId = getLocalNextHopGroup(vpnId, localNextHopIP);
                 if (groupId == FibConstants.INVALID_GROUP_ID) {
@@ -842,7 +846,7 @@ public class NexthopManager implements AutoCloseable {
             } else {
                 nextHopPrefixIp = nextHopIp + NwConstants.IPV6PREFIX;
             }
-            List<String> tepIpAddresses = FibUtil.getNextHopAddresses(dataBroker, rd, nextHopPrefixIp);
+            List<String> tepIpAddresses = fibUtil.getNextHopAddresses(rd, nextHopPrefixIp);
             if (tepIpAddresses.isEmpty()) {
                 return;
             }
@@ -860,7 +864,7 @@ public class NexthopManager implements AutoCloseable {
             Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper
                     .getTunnelType(interfaceManager,
                             egressInterface);
-            Interface ifState = FibUtil.getInterfaceStateFromOperDS(dataBroker, egressInterface);
+            Interface ifState = fibUtil.getInterfaceStateFromOperDS(egressInterface);
             if (ifState == null || ifState.getOperStatus() != OperStatus.Up) {
                 LOG.trace("Tunnel not up {}", egressInterface);
                 return;
@@ -869,12 +873,11 @@ public class NexthopManager implements AutoCloseable {
                 return;
             }
             Long label = FibUtil.getLabelFromRoutePaths(vrfEntry).get();
-            Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, nextHopPrefixIp);
+            Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, nextHopPrefixIp);
             BigInteger tunnelId;
-            if (FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker, prefixInfo.getSubnetId(),
-                    vpnId, rd)) {
-                java.util.Optional<Long> optionalVni = FibUtil.getVniForVxlanNetwork(dataBroker,
-                        prefixInfo.getSubnetId());
+            if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId,
+                    rd)) {
+                java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
                 if (!optionalVni.isPresent()) {
                     LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp,
                             vrfEntry, prefixInfo.getSubnetId());
@@ -887,7 +890,7 @@ public class NexthopManager implements AutoCloseable {
             List<ActionInfo> actionInfos = new ArrayList<>();
             actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
             String ifName = prefixInfo.getVpnInterfaceName();
-            String macAddress = FibUtil.getMacAddressFromPrefix(dataBroker, ifName, nextHopPrefixIp);
+            String macAddress = fibUtil.getMacAddressFromPrefix(ifName, nextHopPrefixIp);
             actionInfos.add(new ActionSetFieldEthernetDestination(actionInfos.size(),
                     new MacAddress(macAddress)));
             List<ActionInfo> egressActions;
@@ -989,13 +992,13 @@ public class NexthopManager implements AutoCloseable {
         }
         // TODO : Place the logic to construct all possible DC-GW combination here.
         int bucketId = availableDcGws.indexOf(destinationIp);
-        Optional<DpnLbNexthops> dpnLbNextHops = FibUtil.getDpnLbNexthops(dataBroker, dpnId, destinationIp);
+        Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
         if (!dpnLbNextHops.isPresent()) {
             return;
         }
         List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
         nextHopKeys.forEach(nextHopKey -> {
-            Optional<Nexthops> optionalNextHops = FibUtil.getNexthops(dataBroker, nextHopKey);
+            Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
             if (!optionalNextHops.isPresent()) {
                 return;
             }
@@ -1032,13 +1035,13 @@ public class NexthopManager implements AutoCloseable {
         WriteTransaction configTx = dataBroker.newWriteOnlyTransaction();
         // TODO : Place the logic to construct all possible DC-GW combination here.
         int bucketId = availableDcGws.indexOf(destinationIp);
-        Optional<DpnLbNexthops> dpnLbNextHops = FibUtil.getDpnLbNexthops(dataBroker, dpnId, destinationIp);
+        Optional<DpnLbNexthops> dpnLbNextHops = fibUtil.getDpnLbNexthops(dpnId, destinationIp);
         if (!dpnLbNextHops.isPresent()) {
             return;
         }
         List<String> nextHopKeys = dpnLbNextHops.get().getNexthopKey();
         nextHopKeys.forEach(nextHopKey -> {
-            Optional<Nexthops> optionalNextHops = FibUtil.getNexthops(dataBroker, nextHopKey);
+            Optional<Nexthops> optionalNextHops = fibUtil.getNexthops(nextHopKey);
             if (!optionalNextHops.isPresent()) {
                 return;
             }
index 32a298640d2fb2d713bb9d5f359f14981fd7d74a..a1eed62557b3685b93443ab12a0b0c34b7219c5b 100644 (file)
@@ -33,21 +33,19 @@ import org.slf4j.LoggerFactory;
 public class RouterInterfaceVrfEntryHandler extends BaseVrfEntryHandler implements IVrfEntryHandler {
 
     private static final Logger LOG = LoggerFactory.getLogger(RouterInterfaceVrfEntryHandler.class);
-    private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalManager;
     private final IPv6Handler ipv6Handler;
 
     @Inject
     public RouterInterfaceVrfEntryHandler(final DataBroker dataBroker, final NexthopManager nexthopManager,
-            final IMdsalApiManager mdsalManager, final IPv6Handler ipv6Handler) {
-        super(dataBroker, nexthopManager, mdsalManager);
-        this.dataBroker = dataBroker;
+            final IMdsalApiManager mdsalManager, final IPv6Handler ipv6Handler, final FibUtil fibUtil) {
+        super(dataBroker, nexthopManager, mdsalManager, fibUtil);
         this.mdsalManager = mdsalManager;
         this.ipv6Handler = ipv6Handler;
     }
 
     @Override
-    public void close() throws Exception {
+    public void close() {
         LOG.info("{} close", getClass().getSimpleName());
     }
 
@@ -70,7 +68,7 @@ public class RouterInterfaceVrfEntryHandler extends BaseVrfEntryHandler implemen
 
     private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove,
             RouterInterface routerInterface) {
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
         Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
         Preconditions.checkNotNull(vpnInstance.getVpnId(),
                 "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
@@ -79,7 +77,7 @@ public class RouterInterfaceVrfEntryHandler extends BaseVrfEntryHandler implemen
             if (vrfEntry.getParentVpnRd() != null
                     && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
                 VpnInstanceOpDataEntry parentVpnInstance =
-                        FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+                        getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
                 vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList()
                         : vpnInstance.getVpnToDpnList();
             } else {
index ddfb717c30b7e589e60a6883cf6309d5351064ee..1720a07509d431614cc855ad77cb5e6fb0b30dfc 100755 (executable)
@@ -75,7 +75,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
@@ -119,36 +118,33 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
     private final DataBroker dataBroker;
     private final IMdsalApiManager mdsalManager;
     private final NexthopManager nextHopManager;
-    private final IdManagerService idManager;
     private final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler;
     private final BaseVrfEntryHandler baseVrfEntryHandler;
     private final RouterInterfaceVrfEntryHandler routerInterfaceVrfEntryHandler;
     private final JobCoordinator jobCoordinator;
+    private final IElanService elanManager;
+    private final FibUtil fibUtil;
     private final List<AutoCloseable> closeables = new CopyOnWriteArrayList<>();
 
-    // FXIME: This should not be a static here - will be fixed later
-    @SuppressFBWarnings("ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
-    static boolean isOpenStackVniSemanticsEnforced;
-
     @Inject
     public VrfEntryListener(final DataBroker dataBroker, final IMdsalApiManager mdsalApiManager,
-                            final NexthopManager nexthopManager, final IdManagerService idManager,
+                            final NexthopManager nexthopManager,
                             final IElanService elanManager,
                             final BaseVrfEntryHandler vrfEntryHandler,
                             final BgpRouteVrfEntryHandler bgpRouteVrfEntryHandler,
                             final RouterInterfaceVrfEntryHandler routerInterfaceVrfEntryHandler,
-                            final JobCoordinator jobCoordinator) {
+                            final JobCoordinator jobCoordinator,
+                            final FibUtil fibUtil) {
         super(VrfEntry.class, VrfEntryListener.class);
         this.dataBroker = dataBroker;
         this.mdsalManager = mdsalApiManager;
         this.nextHopManager = nexthopManager;
-        this.idManager = idManager;
+        this.elanManager = elanManager;
         this.baseVrfEntryHandler = vrfEntryHandler;
         this.bgpRouteVrfEntryHandler = bgpRouteVrfEntryHandler;
         this.routerInterfaceVrfEntryHandler = routerInterfaceVrfEntryHandler;
         this.jobCoordinator = jobCoordinator;
-
-        isOpenStackVniSemanticsEnforced = elanManager.isOpenStackVniSemanticsEnforced();
+        this.fibUtil = fibUtil;
     }
 
     @Override
@@ -200,9 +196,10 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         }
         if (VrfEntry.EncapType.Vxlan.equals(vrfEntry.getEncapType())) {
             LOG.info("EVPN flows need to be programmed.");
-            EvpnVrfEntryHandler evpnVrfEntryHandler =
-                    new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler, nextHopManager, jobCoordinator);
+            EvpnVrfEntryHandler evpnVrfEntryHandler = new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler,
+                    nextHopManager, jobCoordinator, elanManager, fibUtil);
             evpnVrfEntryHandler.createFlows(identifier, vrfEntry, rd);
+            closeables.add(evpnVrfEntryHandler);
             return;
         }
         RouterInterface routerInt = vrfEntry.getAugmentation(RouterInterface.class);
@@ -233,8 +230,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
     private void removeFibEntries(InstanceIdentifier<VrfEntry> identifier, VrfEntry vrfEntry, String rd) {
         if (VrfEntry.EncapType.Vxlan.equals(vrfEntry.getEncapType())) {
             LOG.info("EVPN flows to be deleted");
-            EvpnVrfEntryHandler evpnVrfEntryHandler =
-                    new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler, nextHopManager, jobCoordinator);
+            EvpnVrfEntryHandler evpnVrfEntryHandler = new EvpnVrfEntryHandler(dataBroker, this, bgpRouteVrfEntryHandler,
+                    nextHopManager, jobCoordinator, elanManager, fibUtil);
             evpnVrfEntryHandler.removeFlows(identifier, vrfEntry, rd);
             closeables.add(evpnVrfEntryHandler);
             return;
@@ -283,7 +280,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
 
             //Updates need to be handled for extraroute even if original vrf entry route path is null or
             //updated vrf entry route path is null. This can happen during tunnel events.
-            Optional<VpnInstanceOpDataEntry> optVpnInstance = FibUtil.getVpnInstanceOpData(dataBroker, rd);
+            Optional<VpnInstanceOpDataEntry> optVpnInstance = fibUtil.getVpnInstanceOpData(rd);
             List<String> usedRds = new ArrayList<>();
             if (optVpnInstance.isPresent()) {
                 usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker,optVpnInstance.get().getVpnId(),
@@ -313,9 +310,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             nextHopsRemoved.removeAll(FibHelper.getNextHopListFromRoutePaths(update));
             WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
             nextHopsRemoved.parallelStream()
-                    .forEach(nextHopRemoved -> FibUtil.updateUsedRdAndVpnToExtraRoute(
-                             writeOperTxn, dataBroker, nextHopRemoved, rd,
-                             update.getDestPrefix()));
+                    .forEach(nextHopRemoved -> fibUtil.updateUsedRdAndVpnToExtraRoute(
+                             writeOperTxn, nextHopRemoved, rd, update.getDestPrefix()));
             CheckedFuture<Void, TransactionCommitFailedException> operFuture = writeOperTxn.submit();
             try {
                 operFuture.get();
@@ -341,7 +337,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         final VrfTablesKey vrfTableKey = vrfEntryIid.firstKeyOf(VrfTables.class);
         List<SubTransaction> txnObjects =  new ArrayList<>();
         final VpnInstanceOpDataEntry vpnInstance =
-                FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+                fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
         Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + vrfTableKey.getRouteDistinguisher());
         Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId()
                 + " has null vpnId!");
@@ -349,7 +345,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         if (vrfEntry.getParentVpnRd() != null
                 && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
             // This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
-            VpnInstanceOpDataEntry parentVpnInstance = FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+            VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
             vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() :
                 vpnInstance.getVpnToDpnList();
             LOG.info("createFibEntries: Processing creation of PNF FIB entry with rd {} prefix {}",
@@ -412,7 +408,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             }, DJC_MAX_RETRIES);
         }
 
-        Optional<String> optVpnUuid = FibUtil.getVpnNameFromRd(dataBroker, rd);
+        Optional<String> optVpnUuid = fibUtil.getVpnNameFromRd(rd);
         if (optVpnUuid.isPresent()) {
             String vpnUuid = optVpnUuid.get();
             InterVpnLinkDataComposite interVpnLink = InterVpnLinkCache.getInterVpnLinkByVpnId(vpnUuid).orNull();
@@ -477,7 +473,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
 
                     if (RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.SELF_IMPORTED) {
                         Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
-                                FibUtil.getVpnInstanceOpData(dataBroker, rd);
+                                fibUtil.getVpnInstanceOpData(rd);
                         if (vpnInstanceOpDataEntryOptional.isPresent()) {
                             String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
                             if (!lri.getVpnInstanceList().contains(vpnInstanceName)) {
@@ -701,8 +697,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
     private List<BigInteger> createLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
         List<BigInteger> returnLocalDpnId = new ArrayList<>();
         String localNextHopIP = vrfEntry.getDestPrefix();
-        Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, localNextHopIP);
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+        Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, localNextHopIP);
+        String vpnName = fibUtil.getVpnNameFromId(vpnId);
         if (localNextHopInfo == null) {
             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, localNextHopIP);
             List<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getAllVpnExtraRoutes(dataBroker,
@@ -716,8 +712,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                 } else {
                     ipPrefix = vpnExtraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
                 }
-                Prefixes localNextHopInfoLocal = FibUtil.getPrefixToInterface(dataBroker,
-                    vpnId, ipPrefix);
+                Prefixes localNextHopInfoLocal = fibUtil.getPrefixToInterface(vpnId,
+                    ipPrefix);
                 if (localNextHopInfoLocal != null) {
                     localNextHopSeen = true;
                     BigInteger dpnId =
@@ -735,7 +731,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         LabelRouteInfo lri = getLabelRouteInfo(label);
                         if (isPrefixAndNextHopPresentInLri(localNextHopIP, nextHopAddressList, lri)) {
                             Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
-                                    FibUtil.getVpnInstanceOpData(dataBroker, rd);
+                                    fibUtil.getVpnInstanceOpData(rd);
                             if (vpnInstanceOpDataEntryOptional.isPresent()) {
                                 String vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
                                 if (lri.getVpnInstanceList().contains(vpnInstanceName)) {
@@ -784,7 +780,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                                                 final Long vpnId, final String rd,
                                                 final VrfEntry vrfEntry, Long parentVpnId,
                                                 Routes routes, List<Routes> vpnExtraRoutes) {
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+        String vpnName = fibUtil.getVpnNameFromId(vpnId);
         if (localNextHopInfo != null) {
             long groupId;
             long localGroupId;
@@ -845,8 +841,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                 WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
                 baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions,
                         NwConstants.ADD_FLOW, tx, null);
-                if (!FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker,
-                        localNextHopInfo.getSubnetId(), vpnName, rd)) {
+                if (!fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(localNextHopInfo.getSubnetId(),
+                        vpnName, rd)) {
                     optLabel.ifPresent(label -> {
                         if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
                             LOG.debug("Installing LFIB and tunnel table entry on dpn {} for interface {} with label "
@@ -989,8 +985,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
 
     public List<BigInteger> deleteLocalFibEntry(Long vpnId, String rd, VrfEntry vrfEntry) {
         List<BigInteger> returnLocalDpnId = new ArrayList<>();
-        Prefixes localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+        Prefixes localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
+        String vpnName = fibUtil.getVpnNameFromId(vpnId);
         boolean isExtraroute = false;
         if (localNextHopInfo == null) {
             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
@@ -1012,7 +1008,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                 } else {
                     ipPrefix = extraRoute.getNexthopIpList().get(0) + NwConstants.IPV6PREFIX;
                 }
-                localNextHopInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, ipPrefix);
+                localNextHopInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
                 if (localNextHopInfo != null) {
                     String localNextHopIP = localNextHopInfo.getIpAddress();
                     BigInteger dpnId = checkDeleteLocalFibEntry(localNextHopInfo, localNextHopIP,
@@ -1083,8 +1079,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                     WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
                     baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, null,
                             NwConstants.DEL_FLOW, tx, null);
-                    if (!FibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(dataBroker,
-                            localNextHopInfo.getSubnetId(), vpnId, rd)) {
+                    if (!fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(localNextHopInfo.getSubnetId(),
+                            vpnId, rd)) {
                         if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
                             FibUtil.getLabelFromRoutePaths(vrfEntry).ifPresent(label -> {
                                 makeLFibTableEntry(dpnId, label, null /* instructions */, DEFAULT_FIB_FLOW_PRIORITY,
@@ -1115,7 +1111,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             tx = dataBroker.newWriteOnlyTransaction();
         }
 
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnId);
+        String vpnName = fibUtil.getVpnNameFromId(vpnId);
         LOG.debug("createremotefibentry: adding route {} for rd {} on remoteDpnId {}",
                 vrfEntry.getDestPrefix(), rd, remoteDpnId);
 
@@ -1139,8 +1135,8 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             java.util.Optional<Routes> routes = vpnExtraRoutes
                     .stream()
                     .filter(route -> {
-                        Prefixes prefixToInterface = FibUtil.getPrefixToInterface(dataBroker,
-                                vpnId, FibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
+                        Prefixes prefixToInterface = fibUtil.getPrefixToInterface(vpnId,
+                                fibUtil.getIpPrefix(route.getNexthopIpList().get(0)));
                         if (prefixToInterface == null) {
                             return false;
                         }
@@ -1178,7 +1174,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
          - vpn interface op DS
      */
         LOG.debug("Cleanup of prefix {} in VPN {}", vrfEntry.getDestPrefix(), vpnId);
-        Prefixes prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+        Prefixes prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
         if (prefixInfo == null) {
             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
             String usedRd = usedRds.isEmpty() ? primaryRd : usedRds.get(0);
@@ -1193,7 +1189,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         } else {
                             ipPrefix = nextHopIp + NwConstants.IPV6PREFIX;
                         }
-                        prefixInfo = FibUtil.getPrefixToInterface(dataBroker, vpnId, ipPrefix);
+                        prefixInfo = fibUtil.getPrefixToInterface(vpnId, ipPrefix);
                         checkCleanUpOpDataForFib(prefixInfo, vpnId, primaryRd, vrfEntry, extraRoute);
                     }
                 }
@@ -1274,7 +1270,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         if (lri != null && lri.getPrefix().equals(vrfEntry.getDestPrefix())
                                 && nextHopAddressList.contains(lri.getNextHopIpList().get(0))) {
                             Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
-                                    FibUtil.getVpnInstanceOpData(dataBroker, rd);
+                                    fibUtil.getVpnInstanceOpData(rd);
                             String vpnInstanceName = "";
                             if (vpnInstanceOpDataEntryOptional.isPresent()) {
                                 vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
@@ -1282,12 +1278,12 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                             boolean lriRemoved = deleteLabelRouteInfo(lri, vpnInstanceName, writeOperTxn);
                             if (lriRemoved) {
                                 String parentRd = lri.getParentVpnRd();
-                                FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
-                                        FibUtil.getNextHopLabelKey(parentRd, vrfEntry.getDestPrefix()));
+                                fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+                                        parentRd, vrfEntry.getDestPrefix()));
                             }
                         } else {
-                            FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
-                                    FibUtil.getNextHopLabelKey(rd, vrfEntry.getDestPrefix()));
+                            fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+                                    rd, vrfEntry.getDestPrefix()));
                         }
                     }
                 });
@@ -1298,13 +1294,13 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             if (Prefixes.PrefixCue.PhysNetFunc.equals(prefixInfo.getPrefixCue())) {
                 /*Get vpnId for rd = networkId since op vpnInterface will be pointing to rd = networkId
                 * */
-                Optional<String> vpnName = FibUtil.getVpnNameFromRd(dataBroker, vrfEntry.getParentVpnRd());
+                Optional<String> vpnName = fibUtil.getVpnNameFromRd(vrfEntry.getParentVpnRd());
                 if (vpnName.isPresent()) {
-                    vpnId = FibUtil.getVpnId(dataBroker, vpnName.get());
+                    vpnId = fibUtil.getVpnId(vpnName.get());
                 }
             }
             if (optvpnInterface.isPresent()) {
-                long associatedVpnId = FibUtil.getVpnId(dataBroker, optvpnInterface.get().getVpnInstanceName());
+                long associatedVpnId = fibUtil.getVpnId(optvpnInterface.get().getVpnInstanceName());
                 if (vpnId != associatedVpnId) {
                     LOG.warn("Prefixes {} are associated with different vpn instance with id : {} rather than {}",
                         vrfEntry.getDestPrefix(), associatedVpnId, vpnId);
@@ -1316,7 +1312,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                 }
             }
             if (extraRoute != null) {
-                Optional<String> optVpnName = FibUtil.getVpnNameFromRd(dataBroker, rd);
+                Optional<String> optVpnName = fibUtil.getVpnNameFromRd(rd);
                 List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnId, vrfEntry.getDestPrefix());
                 //Only one used Rd present in case of removal event
                 String usedRd = usedRds.get(0);
@@ -1355,8 +1351,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
     private void deleteFibEntries(final InstanceIdentifier<VrfEntry> identifier, final VrfEntry vrfEntry) {
         final VrfTablesKey vrfTableKey = identifier.firstKeyOf(VrfTables.class);
         final String rd = vrfTableKey.getRouteDistinguisher();
-        final VpnInstanceOpDataEntry vpnInstance =
-                FibUtil.getVpnInstance(dataBroker, vrfTableKey.getRouteDistinguisher());
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(vrfTableKey.getRouteDistinguisher());
         if (vpnInstance == null) {
             LOG.error("VPN Instance for rd {} is not available from VPN Op Instance Datastore", rd);
             return;
@@ -1365,7 +1360,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         if (vrfEntry.getParentVpnRd() != null
                 && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
             // This block MUST BE HIT only for PNF (Physical Network Function) FIB Entries.
-            VpnInstanceOpDataEntry parentVpnInstance = FibUtil.getVpnInstance(dataBroker, vrfEntry.getParentVpnRd());
+            VpnInstanceOpDataEntry parentVpnInstance = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
             vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() :
                     vpnInstance.getVpnToDpnList();
             LOG.info("deleteFibEntries: Processing deletion of PNF FIB entry with rd {} prefix {}",
@@ -1377,7 +1372,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         SubnetRoute subnetRoute = vrfEntry.getAugmentation(SubnetRoute.class);
         final java.util.Optional<Long> optionalLabel = FibUtil.getLabelFromRoutePaths(vrfEntry);
         List<String> nextHopAddressList = FibHelper.getNextHopListFromRoutePaths(vrfEntry);
-        String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+        String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
         if (subnetRoute != null) {
             long elanTag = subnetRoute.getElantag();
             LOG.trace("SUBNETROUTE: deleteFibEntries: SubnetRoute augmented vrfentry found for rd {} prefix {}"
@@ -1409,7 +1404,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                     LabelRouteInfo lri = getLabelRouteInfo(label);
                     if (isPrefixAndNextHopPresentInLri(vrfEntry.getDestPrefix(), nextHopAddressList, lri)) {
                         Optional<VpnInstanceOpDataEntry> vpnInstanceOpDataEntryOptional =
-                                FibUtil.getVpnInstanceOpData(dataBroker, rd);
+                                fibUtil.getVpnInstanceOpData(rd);
                         String vpnInstanceName = "";
                         if (vpnInstanceOpDataEntryOptional.isPresent()) {
                             vpnInstanceName = vpnInstanceOpDataEntryOptional.get().getVpnInstanceName();
@@ -1417,14 +1412,14 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         boolean lriRemoved = this.deleteLabelRouteInfo(lri, vpnInstanceName, null);
                         if (lriRemoved) {
                             String parentRd = lri.getParentVpnRd();
-                            FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
-                                    FibUtil.getNextHopLabelKey(parentRd, vrfEntry.getDestPrefix()));
+                            fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+                                    parentRd, vrfEntry.getDestPrefix()));
                             LOG.trace("SUBNETROUTE: deleteFibEntries: Released subnetroute label {} for rd {} prefix {}"
                                     + " as labelRouteInfo cleared", label, rd, vrfEntry.getDestPrefix());
                         }
                     } else {
-                        FibUtil.releaseId(idManager, FibConstants.VPN_IDPOOL_NAME,
-                                FibUtil.getNextHopLabelKey(rd, vrfEntry.getDestPrefix()));
+                        fibUtil.releaseId(FibConstants.VPN_IDPOOL_NAME, FibUtil.getNextHopLabelKey(
+                                rd, vrfEntry.getDestPrefix()));
                         LOG.trace("SUBNETROUTE: deleteFibEntries: Released subnetroute label {} for rd {} prefix {}",
                                 label, rd, vrfEntry.getDestPrefix());
                     }
@@ -1488,7 +1483,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
 
         // Remove all fib entries configured due to interVpnLink, when nexthop is the opposite endPoint
         // of the interVpnLink.
-        Optional<String> optVpnUuid = FibUtil.getVpnNameFromRd(this.dataBroker, rd);
+        Optional<String> optVpnUuid = fibUtil.getVpnNameFromRd(rd);
         if (optVpnUuid.isPresent()) {
             String vpnUuid = optVpnUuid.get();
             FibUtil.getFirstNextHopAddress(vrfEntry).ifPresent(routeNexthop -> {
@@ -1550,7 +1545,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                                     final FutureCallback<List<Void>> callback) {
         LOG.trace("New dpn {} for vpn {} : populateFibOnNewDpn", dpnId, rd);
         InstanceIdentifier<VrfTables> id = buildVrfId(rd);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
         final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
         List<SubTransaction> txnObjects =  new ArrayList<>();
         if (!vrfTable.isPresent()) {
@@ -1630,7 +1625,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
         LOG.trace("populateExternalRoutesOnDpn : dpn {}, vpn {}, rd {}, localNexthopIp {} , remoteNextHopIp {} ",
             dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
         InstanceIdentifier<VrfTables> id = buildVrfId(rd);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
         List<SubTransaction> txnObjects =  new ArrayList<>();
         final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
         if (vrfTable.isPresent()) {
@@ -1657,7 +1652,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                                        final String destPrefix,
                                        final String destTepIp,
                                        final long label) {
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
 
         if (vpnInstance == null) {
             LOG.error("VpnInstance for rd {} not present for prefix {}", rd, destPrefix);
@@ -1703,7 +1698,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                         Optional<Routes> extraRouteOptional = Optional.absent();
                         if (usedRds.size() != 0) {
                             extraRouteOptional = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker,
-                                    FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId()),
+                                    fibUtil.getVpnNameFromId(vpnInstance.getVpnId()),
                                     usedRds.get(0), vrfEntry.getDestPrefix());
                         }
                         baseVrfEntryHandler.deleteRemoteRoute(null, localDpnId, vpnId, vrfTablesKey, modVrfEntry,
@@ -1719,7 +1714,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                                  final FutureCallback<List<Void>> callback) {
         LOG.trace("cleanUpDpnForVpn: Remove dpn {} for vpn {} : cleanUpDpnForVpn", dpnId, rd);
         InstanceIdentifier<VrfTables> id = buildVrfId(rd);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
         List<SubTransaction> txnObjects =  new ArrayList<>();
         final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
         jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId),
@@ -1765,7 +1760,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                             // to which prefix is attached at this point
                             List<String> usedRds = VpnExtraRouteHelper.getUsedRds(dataBroker, vpnInstance.getVpnId(),
                                     vrfEntry.getDestPrefix());
-                            String vpnName = FibUtil.getVpnNameFromId(dataBroker, vpnInstance.getVpnId());
+                            String vpnName = fibUtil.getVpnNameFromId(vpnInstance.getVpnId());
                             Optional<Routes> extraRouteOptional;
                             //Is this fib route an extra route? If yes, get the nexthop which would be
                             //an adjacency in the vpn
@@ -1807,7 +1802,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
                 + " localNexthopIp {} , remoteNexhtHopIp {}",
             dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
         InstanceIdentifier<VrfTables> id = buildVrfId(rd);
-        final VpnInstanceOpDataEntry vpnInstance = FibUtil.getVpnInstance(dataBroker, rd);
+        final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
         List<SubTransaction> txnObjects =  new ArrayList<>();
         final Optional<VrfTables> vrfTable = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
         if (vrfTable.isPresent()) {
@@ -1913,7 +1908,7 @@ public class VrfEntryListener extends AsyncDataTreeChangeListenerBase<VrfEntry,
             return true;
         }
 
-        Prefixes prefix = FibUtil.getPrefixToInterface(dataBroker, vpnId, vrfEntry.getDestPrefix());
+        Prefixes prefix = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
         if (prefix != null) {
             BigInteger prefixDpnId = prefix.getDpnId();
             if (dpnId.equals(prefixDpnId)) {