From: Robert Varga Date: Thu, 27 Apr 2017 16:20:53 +0000 (+0200) Subject: Speed up OsgiBundleScanningSchemaService close X-Git-Tag: release/boron-sr4~7 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=commitdiff_plain;h=45dfd0c8f23a157ea64a9acd5b88b6f62e324776 Speed up OsgiBundleScanningSchemaService close On close, the OsgiBundleScanningSchemaService 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. Change-Id: I9f7c05277df9bf1ffaec1c699453020312aab203 Signed-off-by: Tom Pantelis Signed-off-by: Robert Varga (cherry picked from commit b0a11d8bb72e2b74f64ca1dbd6d981cf3a70c8ea) --- diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java index 0e544a8401..bc057e74f4 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/osgi/OsgiBundleScanningSchemaService.java @@ -50,6 +50,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D private ServiceTracker listenerTracker; private BundleTracker> bundleTracker; private boolean starting = true; + private volatile boolean stopping; private static OsgiBundleScanningSchemaService instance; private OsgiBundleScanningSchemaService(final BundleContext context) { @@ -128,6 +129,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D @Override public void close() { + stopping = true; if (bundleTracker != null) { bundleTracker.close(); } @@ -241,7 +243,7 @@ public class OsgiBundleScanningSchemaService implements SchemaContextProvider, D } public synchronized void tryToUpdateSchemaContext() { - if (starting) { + if (starting || stopping) { return; } final Optional schema = contextResolver.getSchemaContext();