Bug 9034: bgpmanager BgpUtil rm unused pendingWrTransaction 61/62661/2
authorMichael Vorburger <vorburger@redhat.com>
Wed, 23 Aug 2017 15:25:07 +0000 (17:25 +0200)
committerSam Hague <shague@redhat.com>
Tue, 5 Sep 2017 11:21:05 +0000 (07:21 -0400)
There's no set() for the pendingWrTransaction, so it's.. completely
pointless - and that retry loop in BgpConfigurationManager's
createStaleFibMap() could never have worked anyway, as
BgpUtil.getGetPendingWrTransaction() == 0, always.

Change-Id: I8644a3a9d63c5eff4106c58865cad9969d3990a2
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/BgpConfigurationManager.java
vpnservice/bgpmanager/bgpmanager-impl/src/main/java/org/opendaylight/netvirt/bgpmanager/BgpUtil.java

index 00a5f54340c44ca0ff6070125bbedd1901a8fe26..39c85cf7b703532a5769dd34606c77b7c9328b54 100755 (executable)
@@ -1878,7 +1878,7 @@ public class BgpConfigurationManager {
     }
 
     private static boolean replayNbrConfig(List<Neighbors> neighbors, BgpRouter br) {
-        if ((neighbors == null) || (neighbors.isEmpty())) {
+        if (neighbors == null || neighbors.isEmpty()) {
             LOG.error("Replaying nbr configuration, received NULL list ");
             return true;
         }
@@ -1917,7 +1917,7 @@ public class BgpConfigurationManager {
                     LOG.debug("Replaying addNbr {}, exception: ", replayNbr.getNbr().getAddress().getValue(), eNbr);
                 }
                 boolean replaySuccess = true;
-                replaySuccess = (replaySuccess && replayDone);
+                replaySuccess = replaySuccess && replayDone;
                 LOG.debug("Replay addNbr {} successful", replayNbr.getNbr().getAddress().getValue());
 
                 //Update Source handling
@@ -1935,7 +1935,7 @@ public class BgpConfigurationManager {
                                 replayNbr.getNbr().getAddress().getValue(), eUs);
                     }
                     LOG.debug("Replay updatesource {} successful", us.getSourceIp().getValue());
-                    replaySuccess = (replaySuccess && replayDone);
+                    replaySuccess = replaySuccess && replayDone;
                 }
                 //Ebgp Multihope
                 EbgpMultihop en = replayNbr.getNbr().getEbgpMultihop();
@@ -1949,7 +1949,7 @@ public class BgpConfigurationManager {
                         LOG.debug("Replaying EbgpMultihop for Nbr {}, exception: ",
                                 replayNbr.getNbr().getAddress().getValue(), eEbgpMhop);
                     }
-                    replaySuccess = (replaySuccess && replayDone);
+                    replaySuccess = replaySuccess && replayDone;
                 }
 
                 //afs
@@ -1966,7 +1966,7 @@ public class BgpConfigurationManager {
                             LOG.debug("Replaying AddressFamily for Nbr {}, exception:",
                                     replayNbr.getNbr().getAddress().getValue(), eAFs);
                         }
-                        replaySuccess = (replaySuccess && replayDone);
+                        replaySuccess = replaySuccess && replayDone;
                     }
                 }
                 //replay is success --> no need to replay this nbr in next iteration.
@@ -1975,7 +1975,7 @@ public class BgpConfigurationManager {
         } while (nbrRetry.decrementAndRetry());
         boolean replaySuccess = true;
         for (ReplayNbr replayNbr : replayNbrList) {
-            replaySuccess = (replaySuccess && (!replayNbr.isShouldRetry()));
+            replaySuccess = replaySuccess && !replayNbr.isShouldRetry();
         }
         return replaySuccess;
     }
@@ -2566,18 +2566,6 @@ public class BgpConfigurationManager {
     public static void createStaleFibMap() {
         totalStaledCount = 0;
         try {
-            /*
-            * at the time Stale FIB creation, Wait till all PENDING write transaction
-             * to complete (or)wait for max timeout value of STALE_FIB_WAIT Seconds.
-             */
-            int retry = STALE_FIB_WAIT;
-            while (BgpUtil.getGetPendingWrTransaction() != 0 && retry > 0) {
-                Thread.sleep(1000);
-                retry--;
-                if (retry == 0) {
-                    LOG.error("TimeOut occured {} seconds, in waiting stale fibDSWriter create", STALE_FIB_WAIT);
-                }
-            }
             staledFibEntriesMap.clear();
             InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
             DataBroker db = BgpUtil.getBroker();
@@ -2613,7 +2601,7 @@ public class BgpConfigurationManager {
             } else {
                 LOG.error("createStaleFibMap:: FIBentries.class is not present");
             }
-        } catch (InterruptedException | ReadFailedException e) {
+        } catch (ReadFailedException e) {
             LOG.error("createStaleFibMap:: error ", e);
         }
         LOG.error("created {} staled entries ", totalStaledCount);
@@ -2627,19 +2615,6 @@ public class BgpConfigurationManager {
         totalExternalRoutes = 0;
         totalExternalMacRoutes = 0;
         try {
-            /*
-            * at the time FIB route deletion, Wait till all PENDING write transaction
-             * to complete (or)wait for max timeout value of STALE_FIB_WAIT Seconds.
-             */
-            int retry = STALE_FIB_WAIT;
-            String rd;
-            while (BgpUtil.getGetPendingWrTransaction() != 0 && retry > 0) {
-                Thread.sleep(1000);
-                retry--;
-                if (retry == 0) {
-                    LOG.error("TimeOut occured {} seconds, while deleting external routes", STALE_FIB_WAIT);
-                }
-            }
             InstanceIdentifier<FibEntries> id = InstanceIdentifier.create(FibEntries.class);
             DataBroker db = BgpUtil.getBroker();
             if (db == null) {
@@ -2656,7 +2631,7 @@ public class BgpConfigurationManager {
                 }
                 List<VrfTables> staleVrfTables = fibEntries.get().getVrfTables();
                 for (VrfTables vrfTable : staleVrfTables) {
-                    rd = vrfTable.getRouteDistinguisher();
+                    String rd = vrfTable.getRouteDistinguisher();
                     if (vrfTable.getVrfEntry() != null) {
                         for (VrfEntry vrfEntry : vrfTable.getVrfEntry()) {
                             if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.BGP) {
@@ -2680,7 +2655,7 @@ public class BgpConfigurationManager {
             } else {
                 LOG.error("deleteExternalFibRoutes:: FIBentries.class is not present");
             }
-        } catch (InterruptedException | ReadFailedException e) {
+        } catch (ReadFailedException e) {
             LOG.error("deleteExternalFibRoutes:: error ", e);
         }
         LOG.debug("deleted {} fib entries {} mac entries", totalExternalRoutes, totalExternalMacRoutes);
index 5274bc910782166a530d124cdd2730a5bd615e94..30bd89a6274f5b61c11a7c70e56f6e02d21b1835 100755 (executable)
@@ -18,8 +18,6 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.LinkedBlockingQueue;
 import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.atomic.AtomicInteger;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.genius.mdsalutil.MDSALUtil;
@@ -54,7 +52,6 @@ public class BgpUtil {
     private static final Logger LOG = LoggerFactory.getLogger(BgpUtil.class);
     private static DataBroker dataBroker;
     public static final int PERIODICITY = 500;
-    private static AtomicInteger pendingWrTransaction = new AtomicInteger(0);
     public static final int BATCH_SIZE = 1000;
     public static Integer batchSize;
     public static Integer batchInterval;
@@ -89,11 +86,6 @@ public class BgpUtil {
         return retValue;
     }
 
-    // return number of pending Write Transactions with BGP-Util (no read)
-    public static int getGetPendingWrTransaction() {
-        return pendingWrTransaction.get();
-    }
-
     static ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
             .setNameFormat("bgp-util-mdsal-%d").build();