Speed up GlobalBundleScanningSchemaServiceImpl close 81/27781/1
authorTom Pantelis <tpanteli@brocade.com>
Thu, 1 Oct 2015 21:43:24 +0000 (17:43 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Thu, 1 Oct 2015 21:52:01 +0000 (17:52 -0400)
On close, the GlobalBundleScanningSchemaServiceImpl closes the
BundleTracker which untracks all the bundles and notifies the listener
of removed bundles. This results in a call to tryToUpdateSchemaContext
which causes the remaining yang files to be re-parsed to build a new
SchemaContext. To prevent this extra processing on shutdown, I added
a "stopping" flag to elide tryToUpdateSchemaContext the same we do
with the "starting" flag.

Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
Change-Id: I9f7c05277df9bf1ffaec1c699453020312aab203

opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java

index 34c11ddc9240c3f3305ff62814d7cd59101b3985..ac220a830d2694274a53e3efb03d465061d0dbfd 100644 (file)
@@ -49,6 +49,7 @@ public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvi
     private ServiceTracker<SchemaContextListener, SchemaContextListener> listenerTracker;
     private BundleTracker<Iterable<Registration>> bundleTracker;
     private boolean starting = true;
+    private volatile boolean stopping;
     private static GlobalBundleScanningSchemaServiceImpl instance;
 
     private GlobalBundleScanningSchemaServiceImpl(final BundleContext context) {
@@ -134,6 +135,7 @@ public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvi
 
     @Override
     public void close() {
+        stopping = true;
         if (bundleTracker != null) {
             bundleTracker.close();
         }
@@ -243,7 +245,7 @@ public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvi
     }
 
     public synchronized void tryToUpdateSchemaContext() {
-        if (starting) {
+        if (starting || stopping) {
             return;
         }
         Optional<SchemaContext> schema = contextResolver.getSchemaContext();