Reduce SchemaContext updates on shutdown 31/20931/2
authorTom Pantelis <tpanteli@brocade.com>
Mon, 18 May 2015 00:33:53 +0000 (20:33 -0400)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 22 May 2015 11:32:04 +0000 (11:32 +0000)
The GlobalBundleScanningSchemaServiceImpl sends out a ton (hundreds) of
SchemaContext updates on shutdown. This because the removedBundle method
calls tryToUpdateSchemaContext even for bundles that weren't tracked, ie
bundles w/o yang URLs. So I added a check`for # URLs > 0.

Change-Id: I203047f04ba5761c1927102b3cb0f2e309b6bf77
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java

index f7a5ea1e951b368c15df0b0c4197a4091164aa62..34c11ddc9240c3f3305ff62814d7cd59101b3985 100644 (file)
@@ -12,6 +12,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Optional;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Iterables;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -218,7 +219,15 @@ public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvi
                     LOG.warn("Failed do unregister URL {}, proceeding", url, e);
                 }
             }
-            tryToUpdateSchemaContext();
+
+            int numUrls = Iterables.size(urls);
+            if(numUrls > 0 ) {
+                if(LOG.isDebugEnabled()) {
+                    LOG.debug("removedBundle: {}, state: {}, # urls: {}", bundle.getSymbolicName(), bundle.getState(), numUrls);
+                }
+
+                tryToUpdateSchemaContext();
+            }
         }
     }