X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fconfig%2Fyang-store-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fstore%2Fimpl%2FExtenderYangTracker.java;fp=opendaylight%2Fconfig%2Fyang-store-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fstore%2Fimpl%2FExtenderYangTracker.java;h=fcdc10f109bca6289b3cc181821970430ffa6066;hp=90b94ef120c8d2e05473e76db4db7e7dd325c46a;hb=0ecc684421b03f8eb53cdd042fb3adc40f6732c7;hpb=7ec7467c79427f2ce261642920d373894dd4fe83 diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java index 90b94ef120..fcdc10f109 100644 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java +++ b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java @@ -78,7 +78,7 @@ public class ExtenderYangTracker extends BundleTracker implements YangSt } @Override - public Object addingBundle(Bundle bundle, BundleEvent event) { + public synchronized Object addingBundle(Bundle bundle, BundleEvent event) { // Ignore system bundle: // system bundle might have config-api on classpath && @@ -121,7 +121,7 @@ public class ExtenderYangTracker extends BundleTracker implements YangSt return bundle; } - private void onSnapshotFailure(Bundle bundle, List addedURLs, Exception failureReason) { + private synchronized void onSnapshotFailure(Bundle bundle, List addedURLs, Exception failureReason) { // inconsistent state inconsistentBundlesToYangURLs.putAll(bundle, addedURLs); @@ -129,9 +129,10 @@ public class ExtenderYangTracker extends BundleTracker implements YangSt consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, failureReason); logger.warn("Yang store is falling back on last consistent state containing {} files, inconsistent yang files size is {}, reason {}", consistentBundlesToYangURLs.size(), inconsistentBundlesToYangURLs.size(), failureReason.toString()); + cache.setInconsistentURLsForReporting(inconsistentBundlesToYangURLs.values()); } - private void onSnapshotSuccess(Multimap proposedNewState, YangStoreSnapshotImpl snapshot) { + private synchronized void onSnapshotSuccess(Multimap proposedNewState, YangStoreSnapshotImpl snapshot) { // consistent state // merge into consistentBundlesToYangURLs.clear(); @@ -139,12 +140,12 @@ public class ExtenderYangTracker extends BundleTracker implements YangSt inconsistentBundlesToYangURLs.clear(); updateCache(snapshot); - + cache.setInconsistentURLsForReporting(Collections. emptySet()); logger.info("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size()); logger.debug("Yang store updated to new consistent state containing {}", consistentBundlesToYangURLs); } - private void updateCache(YangStoreSnapshotImpl snapshot) { + private synchronized void updateCache(YangStoreSnapshotImpl snapshot) { cache.cacheYangStore(consistentBundlesToYangURLs, snapshot); } @@ -213,11 +214,14 @@ public class ExtenderYangTracker extends BundleTracker implements YangSt } class YangStoreCache { + private static final Logger logger = LoggerFactory.getLogger(YangStoreCache.class); @GuardedBy("this") private Set cachedUrls = null; @GuardedBy("this") private Optional cachedYangStoreSnapshot = getInitialSnapshot(); + @GuardedBy("this") + private Collection inconsistentURLsForReporting = Collections.emptySet(); synchronized Optional getSnapshotIfPossible(Multimap bundlesToYangURLs) { Set urls = setFromMultimapValues(bundlesToYangURLs); @@ -225,6 +229,9 @@ class YangStoreCache { if (cachedUrls==null || cachedUrls.equals(urls)) { Preconditions.checkState(cachedYangStoreSnapshot.isPresent()); YangStoreSnapshot freshSnapshot = new YangStoreSnapshotImpl(cachedYangStoreSnapshot.get()); + if (inconsistentURLsForReporting.size() > 0){ + logger.warn("Some yang URLs are ignored: {}", inconsistentURLsForReporting); + } return Optional.of(freshSnapshot); } @@ -239,7 +246,7 @@ class YangStoreCache { } synchronized void cacheYangStore(Multimap urls, - YangStoreSnapshot yangStoreSnapshot) { + YangStoreSnapshot yangStoreSnapshot) { this.cachedUrls = setFromMultimapValues(urls); this.cachedYangStoreSnapshot = Optional.of(yangStoreSnapshot); } @@ -252,6 +259,10 @@ class YangStoreCache { } } + public synchronized void setInconsistentURLsForReporting(Collection urls){ + inconsistentURLsForReporting = urls; + } + private Optional getInitialSnapshot() { YangStoreSnapshot initialSnapshot = new YangStoreSnapshot() { @Override