From: Tom Pantelis Date: Thu, 1 Oct 2015 21:43:24 +0000 (-0400) Subject: Speed up GlobalBundleScanningSchemaServiceImpl close X-Git-Tag: release/beryllium~254 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F81%2F27781%2F1;p=controller.git Speed up GlobalBundleScanningSchemaServiceImpl close 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 Change-Id: I9f7c05277df9bf1ffaec1c699453020312aab203 --- diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java index 34c11ddc92..ac220a830d 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/GlobalBundleScanningSchemaServiceImpl.java @@ -49,6 +49,7 @@ public class GlobalBundleScanningSchemaServiceImpl implements SchemaContextProvi private ServiceTracker listenerTracker; private BundleTracker> 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 schema = contextResolver.getSchemaContext();