From c99a5bb839b67beefc5a339e60438894ab4037c2 Mon Sep 17 00:00:00 2001 From: Tomas Olvecky Date: Mon, 10 Mar 2014 09:56:13 +0100 Subject: [PATCH] Resolve Bug:448 - Remove yang-store api and impl. Depends on yangtools commit https://git.opendaylight.org/gerrit/#/c/5579/ . Instead of having multiple bundle trackers for config and netconf, keep only one. Each bundle containing yang files should use sal code generator, which generates YangModuleInfo objects. Using this instead of speculatively having to parse all current yang files for each adding bundle event allows not having to deal with broken yang dependencies when bundle events come in wrong order. Put SchemaContextProvider to OSGi SR in config-manager, so that any bundle working with yang can use it. This replaces too specific YangStoreService which was coupled with yang-jmx-generator. Users can listen for changes directly on OSGi SR - they receive service changed event when yang module is added or removed. Change-Id: Iabcb35929a1eeef0df328f3f948d70e1bfcbba0d Signed-off-by: Tomas Olvecky --- opendaylight/commons/opendaylight/pom.xml | 10 - ...ndingIndependentMappingServiceTracker.java | 60 ----- .../impl/osgi/ConfigManagerActivator.java | 91 +++---- .../osgi/mapping/CodecRegistryProvider.java | 46 ++++ .../osgi/mapping/ModuleInfoBundleTracker.java | 46 ++-- .../RefreshingSCPModuleInfoRegistry.java | 76 ++++++ ...ntimeGeneratedMappingServiceActivator.java | 51 ---- .../impl/util/OsgiRegistrationUtil.java | 98 ++++++++ opendaylight/config/pom.xml | 7 - opendaylight/config/yang-store-api/pom.xml | 36 --- .../config/yang-store-impl/.gitignore | 3 - opendaylight/config/yang-store-impl/pom.xml | 73 ------ .../yang/store/impl/ExtenderYangTracker.java | 222 ------------------ .../yang/store/impl/YangParserWrapper.java | 68 ------ .../yang/store/impl/YangStoreActivator.java | 46 ---- .../yang/store/impl/YangStoreCache.java | 117 --------- .../store/impl/YangStoreSnapshotImpl.java | 96 -------- .../ExtenderYangTrackerCustomizerTest.java | 171 -------------- opendaylight/config/yang-test/pom.xml | 59 ----- .../distribution/opendaylight/pom.xml | 8 - .../main/resources/configuration/config.ini | 2 - .../integrationtest/pom.xml | 10 - opendaylight/md-sal/model/pom.xml | 2 +- opendaylight/md-sal/pom.xml | 4 +- .../md-sal/sal-binding-broker/pom.xml | 12 + .../md-sal/sal-binding-config/pom.xml | 2 +- opendaylight/md-sal/sal-binding-it/pom.xml | 4 - .../test/sal/binding/it/TestHelper.java | 11 +- opendaylight/md-sal/sal-dom-api/pom.xml | 16 ++ opendaylight/md-sal/sal-dom-broker/pom.xml | 11 +- .../broker/impl/SchemaContextProvider.java | 10 +- .../md-sal/sal-netconf-connector/pom.xml | 19 -- opendaylight/md-sal/sal-remote/pom.xml | 2 +- .../implementation/pom.xml | 15 ++ .../integrationtest/test-it/pom.xml | 5 - .../md-sal/samples/toaster-consumer/pom.xml | 13 + .../md-sal/samples/toaster-provider/pom.xml | 13 + opendaylight/md-sal/samples/toaster/pom.xml | 2 +- .../md-sal/test/sal-rest-connector-it/pom.xml | 10 - .../it/ServiceProviderController.java | 2 - .../netconf/config-netconf-connector/pom.xml | 14 +- .../operations/editconfig/EditConfig.java | 2 +- .../operations/get/Get.java | 2 +- .../operations/getconfig/GetConfig.java | 2 +- .../operations/runtimerpc/RuntimeRpc.java | 2 +- .../osgi/Activator.java | 72 +++--- .../osgi/NetconfOperationProvider.java | 1 - .../NetconfOperationServiceFactoryImpl.java | 2 - .../osgi/NetconfOperationServiceImpl.java | 33 +-- .../osgi}/YangStoreException.java | 2 +- .../osgi}/YangStoreService.java | 2 +- .../osgi/YangStoreServiceImpl.java | 38 +++ .../osgi/YangStoreServiceTracker.java | 41 ---- .../osgi}/YangStoreSnapshot.java | 21 +- .../osgi/YangStoreSnapshotImpl.java} | 102 ++++---- .../confignetconfconnector/util/Util.java | 12 +- .../NetconfMappingTest.java | 79 ++++--- .../operations/editconfig/EditConfigTest.java | 2 +- .../osgi/NetconfOperationServiceImplTest.java | 1 - opendaylight/netconf/netconf-impl/pom.xml | 5 - .../mapping/operations/DefaultGetSchema.java | 9 +- .../netconf/impl/ConcurrentClientsTest.java | 70 ++---- opendaylight/netconf/netconf-it/pom.xml | 16 -- .../it}/HardcodedYangStoreService.java | 27 ++- .../it/NetconfConfigPersisterITTest.java | 45 ++-- .../netconf/it/NetconfITSecureTest.java | 3 +- .../controller/netconf/it/NetconfITTest.java | 3 +- .../netconf/it/NetconfMonitoringITTest.java | 3 +- .../it/pax/IdentityRefNetconfTest.java | 75 +++--- opendaylight/netconf/pom.xml | 16 -- 70 files changed, 683 insertions(+), 1568 deletions(-) delete mode 100644 opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java create mode 100644 opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/CodecRegistryProvider.java create mode 100644 opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RefreshingSCPModuleInfoRegistry.java delete mode 100644 opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RuntimeGeneratedMappingServiceActivator.java create mode 100644 opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java delete mode 100644 opendaylight/config/yang-store-api/pom.xml delete mode 100644 opendaylight/config/yang-store-impl/.gitignore delete mode 100644 opendaylight/config/yang-store-impl/pom.xml delete mode 100644 opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java delete mode 100644 opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangParserWrapper.java delete mode 100644 opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreActivator.java delete mode 100644 opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreCache.java delete mode 100644 opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java delete mode 100644 opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java rename opendaylight/{config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api => netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi}/YangStoreException.java (88%) rename opendaylight/{config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api => netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi}/YangStoreService.java (89%) create mode 100644 opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceImpl.java delete mode 100644 opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceTracker.java rename opendaylight/{config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api => netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi}/YangStoreSnapshot.java (69%) rename opendaylight/{config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/MbeParser.java => netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshotImpl.java} (52%) rename opendaylight/{config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl => netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it}/HardcodedYangStoreService.java (54%) diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index 77c807b0ed..2ef97a1b3d 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -1336,16 +1336,6 @@ yang-jmx-generator ${config.version} - - org.opendaylight.controller - yang-store-api - ${config.version} - - - org.opendaylight.controller - yang-store-impl - ${config.version} - org.opendaylight.controller logback-config diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java deleted file mode 100644 index dbc862a53d..0000000000 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/BindingIndependentMappingServiceTracker.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.manager.impl.osgi; - -import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; -import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTrackerCustomizer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class BindingIndependentMappingServiceTracker implements ServiceTrackerCustomizer { - private static final Logger logger = LoggerFactory.getLogger(BindingIndependentMappingServiceTracker.class); - - private final ConfigManagerActivator activator; - private final BundleContext ctx; - private BindingIndependentMappingService service; - - public BindingIndependentMappingServiceTracker(BundleContext context, ConfigManagerActivator activator) { - this.ctx = context; - this.activator = activator; - } - - @Override - public synchronized BindingIndependentMappingService addingService( - ServiceReference moduleFactoryServiceReference) { - - if (service != null) { - // FIXME - // Second registration appears from - // org.opendaylight.controller.config.yang.md.sal.binding.impl.RuntimeMappingModule - logger.debug("BindingIndependentMappingService was already added as {}" + " now added as {}", - service, ctx.getService(moduleFactoryServiceReference)); - return null; - } - - BindingIndependentMappingService service = ctx.getService(moduleFactoryServiceReference); - this.service = service; - CodecRegistry codecRegistry = service.getCodecRegistry(); - logger.debug("Codec registry acquired {}", codecRegistry); -// activator.initConfigManager(ctx, codecRegistry); - return service; - } - - @Override - public void modifiedService(ServiceReference moduleFactoryServiceReference, BindingIndependentMappingService o) { - // TODO crash - } - - @Override - public void removedService(ServiceReference moduleFactoryServiceReference, BindingIndependentMappingService o) { - // TODO crash - } -} diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java index c075b09df7..308b137403 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/ConfigManagerActivator.java @@ -7,50 +7,52 @@ */ package org.opendaylight.controller.config.manager.impl.osgi; -import java.lang.management.ManagementFactory; -import java.util.Collection; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.MBeanServer; - import org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl; import org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator; +import org.opendaylight.controller.config.manager.impl.osgi.mapping.CodecRegistryProvider; import org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker; -import org.opendaylight.controller.config.manager.impl.osgi.mapping.RuntimeGeneratedMappingServiceActivator; +import org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry; +import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil; import org.opendaylight.controller.config.spi.ModuleFactory; import org.opendaylight.yangtools.concepts.ObjectRegistration; +import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; -import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.ServiceTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -public class ConfigManagerActivator implements BundleActivator { - private static final Logger logger = LoggerFactory.getLogger(ConfigManagerActivator.class); +import javax.management.InstanceAlreadyExistsException; +import javax.management.MBeanServer; +import java.lang.management.ManagementFactory; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; +import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.registerService; +import static org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil.wrap; + +public class ConfigManagerActivator implements BundleActivator { private final MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer(); - private ExtensibleBundleTracker>> bundleTracker; - private ConfigRegistryImpl configRegistry; - private ConfigRegistryJMXRegistrator configRegistryJMXRegistrator; - private ServiceRegistration configRegistryServiceRegistration; - private RuntimeGeneratedMappingServiceActivator mappingServiceActivator; + + private AutoCloseable autoCloseable; @Override public void start(BundleContext context) { - // track bundles containing YangModuleInfo - ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(); - mappingServiceActivator = new RuntimeGeneratedMappingServiceActivator(moduleInfoBundleTracker); - CodecRegistry codecRegistry = mappingServiceActivator.startRuntimeMappingService(context).getCodecRegistry(); + ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();// the inner strategy is backed by thread context cl? + + RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry( + moduleInfoBackedContext, moduleInfoBackedContext, context); + + ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(moduleInfoRegistryWrapper); + + CodecRegistryProvider codecRegistryProvider = new CodecRegistryProvider(moduleInfoBackedContext, context); // start config registry BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver( context); - configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer, - codecRegistry); + ConfigRegistryImpl configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, configMBeanServer, + codecRegistryProvider.getCodecRegistry()); // track bundles containing factories BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker( @@ -59,53 +61,32 @@ public class ConfigManagerActivator implements BundleActivator { blankTransactionServiceTracker); // start extensible tracker - bundleTracker = new ExtensibleBundleTracker<>(context, moduleInfoBundleTracker, moduleFactoryBundleTracker); + ExtensibleBundleTracker>> bundleTracker = new ExtensibleBundleTracker<>(context, moduleInfoBundleTracker, moduleFactoryBundleTracker); bundleTracker.open(); // register config registry to OSGi - configRegistryServiceRegistration = context.registerService(ConfigRegistryImpl.class, configRegistry, null); + AutoCloseable configRegReg = registerService(context, configRegistry, ConfigRegistryImpl.class); // register config registry to jmx - configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer); + ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(configMBeanServer); try { configRegistryJMXRegistrator.registerToJMX(configRegistry); } catch (InstanceAlreadyExistsException e) { throw new IllegalStateException("Config Registry was already registered to JMX", e); } + // TODO wire directly via moduleInfoBundleTracker ServiceTracker serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, blankTransactionServiceTracker); serviceTracker.open(); + + List list = Arrays.asList( + codecRegistryProvider, configRegistry, wrap(bundleTracker), configRegReg, configRegistryJMXRegistrator, wrap(serviceTracker)); + autoCloseable = OsgiRegistrationUtil.aggregate(list); } @Override - public void stop(BundleContext context) { - try { - configRegistry.close(); - } catch (Exception e) { - logger.warn("Exception while closing config registry", e); - } - try { - bundleTracker.close(); - } catch (Exception e) { - logger.warn("Exception while closing extender", e); - } - try { - configRegistryJMXRegistrator.close(); - } catch (Exception e) { - logger.warn( - "Exception while closing config registry jmx registrator", - e); - } - try { - configRegistryServiceRegistration.unregister(); - } catch (Exception e) { - logger.warn("Exception while unregistering config registry", e); - } - try { - mappingServiceActivator.close(); - } catch (Exception e) { - logger.warn("Exception while closing mapping service", e); - } + public void stop(BundleContext context) throws Exception { + autoCloseable.close(); } } diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/CodecRegistryProvider.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/CodecRegistryProvider.java new file mode 100644 index 0000000000..9d0fbd85dc --- /dev/null +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/CodecRegistryProvider.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.config.manager.impl.osgi.mapping; + +import javassist.ClassPool; +import org.opendaylight.controller.config.manager.impl.util.OsgiRegistrationUtil; +import org.opendaylight.yangtools.sal.binding.generator.api.ClassLoadingStrategy; +import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl; +import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; +import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; +import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; +import org.osgi.framework.BundleContext; + +/** + * Creates and initializes {@link RuntimeGeneratedMappingServiceImpl}, which is used to get {@link CodecRegistry}. + * Also maintains service registrations of {@link RuntimeGeneratedMappingServiceImpl}. + */ +// TODO move to yang runtime +public class CodecRegistryProvider implements AutoCloseable { + private static final ClassPool CLASS_POOL = ClassPool.getDefault(); + + private final RuntimeGeneratedMappingServiceImpl service; + private final AutoCloseable registration; + + public CodecRegistryProvider(ClassLoadingStrategy classLoadingStrategy, BundleContext context) { + service = new RuntimeGeneratedMappingServiceImpl(classLoadingStrategy); + service.setPool(CLASS_POOL); + service.init(); + registration = OsgiRegistrationUtil.registerService(context, service, + SchemaServiceListener.class, BindingIndependentMappingService.class); + } + + public CodecRegistry getCodecRegistry() { + return service.getCodecRegistry(); + } + + @Override + public void close() throws Exception { + registration.close(); + } +} diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java index 7680f72612..8e93583e04 100644 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/ModuleInfoBundleTracker.java @@ -7,18 +7,10 @@ */ package org.opendaylight.controller.config.manager.impl.osgi.mapping; -import static java.lang.String.format; - -import java.io.InputStream; -import java.net.URL; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; - import org.apache.commons.io.IOUtils; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.sal.binding.generator.impl.GeneratedClassLoadingStrategy; -import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext; +import org.opendaylight.yangtools.concepts.Registration; +import org.opendaylight.yangtools.sal.binding.generator.api.ModuleInfoRegistry; import org.opendaylight.yangtools.yang.binding.YangModelBindingProvider; import org.opendaylight.yangtools.yang.binding.YangModuleInfo; import org.osgi.framework.Bundle; @@ -27,51 +19,57 @@ import org.osgi.util.tracker.BundleTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.InputStream; +import java.net.URL; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; + +import static java.lang.String.format; + /** - * Tracks bundles and attempts to retrieve YangModuleInfo. + * Tracks bundles and attempts to retrieve YangModuleInfo, which is then fed into ModuleInfoRegistry */ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer>> { private static final Logger logger = LoggerFactory.getLogger(ModuleInfoBundleTracker.class); - public static final String GET_MODULE_INFO_METHOD = "getModuleInfo"; public static final String MODULE_INFO_PROVIDER_PATH_PREFIX = "META-INF/services/"; - private final ModuleInfoBackedContext moduleInfoLoadingStrategy = ModuleInfoBackedContext.create(); - public GeneratedClassLoadingStrategy getModuleInfoLoadingStrategy() { - return moduleInfoLoadingStrategy; + private final ModuleInfoRegistry moduleInfoRegistry; + + public ModuleInfoBundleTracker(ModuleInfoRegistry moduleInfoRegistry) { + this.moduleInfoRegistry = moduleInfoRegistry; } @Override public Collection> addingBundle(Bundle bundle, BundleEvent event) { URL resource = bundle.getEntry(MODULE_INFO_PROVIDER_PATH_PREFIX + YangModelBindingProvider.class.getName()); - + logger.debug("Got addingBundle({}) with YangModelBindingProvider resource {}", bundle, resource); if(resource==null) { return null; } - List> registrations = new LinkedList<>(); try (InputStream inputStream = resource.openStream()) { List lines = IOUtils.readLines(inputStream); for (String moduleInfoName : lines) { + logger.trace("Retrieve ModuleInfo({}, {})", moduleInfoName, bundle); YangModuleInfo moduleInfo = retrieveModuleInfo(moduleInfoName, bundle); - registrations.add(moduleInfoLoadingStrategy.registerModuleInfo(moduleInfo)); + registrations.add(moduleInfoRegistry.registerModuleInfo(moduleInfo)); } - } catch (Exception e) { logger.error("Error while reading {}", resource, e); throw new RuntimeException(e); } - + logger.trace("Got following registrations {}", registrations); return registrations; } @Override public void modifiedBundle(Bundle bundle, BundleEvent event, Collection> object) { - // NOOP } @Override @@ -80,7 +78,7 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer reg : regs) { + for (Registration reg : regs) { try { reg.close(); } catch (Exception e) { @@ -105,7 +103,7 @@ public final class ModuleInfoBundleTracker implements BundleTrackerCustomizer osgiReg; + + public RefreshingSCPModuleInfoRegistry(ModuleInfoRegistry moduleInfoRegistry, + SchemaContextProvider schemaContextProvider, BundleContext bundleContext) { + this.moduleInfoRegistry = moduleInfoRegistry; + osgiReg = bundleContext.registerService(SchemaContextProvider.class, schemaContextProvider, new Hashtable()); + } + + private void updateService() { + osgiReg.setProperties(null); // send modifiedService event + } + + @Override + public ObjectRegistration registerModuleInfo(YangModuleInfo yangModuleInfo) { + ObjectRegistration yangModuleInfoObjectRegistration = moduleInfoRegistry.registerModuleInfo(yangModuleInfo); + ObjectRegistrationWrapper wrapper = new ObjectRegistrationWrapper(yangModuleInfoObjectRegistration); + updateService(); + return wrapper; + } + + + @Override + public void close() { + osgiReg.unregister(); + } + + private class ObjectRegistrationWrapper implements ObjectRegistration { + private final ObjectRegistration inner; + + private ObjectRegistrationWrapper(ObjectRegistration inner) { + this.inner = inner; + } + + @Override + public YangModuleInfo getInstance() { + return inner.getInstance(); + } + + @Override + public void close() throws Exception { + inner.close(); + updateService();// send modify event when a bundle disappears + } + + + @Override + public String toString() { + return inner.toString(); + } + } +} diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RuntimeGeneratedMappingServiceActivator.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RuntimeGeneratedMappingServiceActivator.java deleted file mode 100644 index a267a6b622..0000000000 --- a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/osgi/mapping/RuntimeGeneratedMappingServiceActivator.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.manager.impl.osgi.mapping; - -import javassist.ClassPool; -import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl; -import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; -import org.opendaylight.yangtools.yang.model.api.SchemaServiceListener; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import java.util.Hashtable; - -public class RuntimeGeneratedMappingServiceActivator implements AutoCloseable { - - private static final ClassPool CLASS_POOL = ClassPool.getDefault(); - - private ServiceRegistration listenerReg; - private ServiceRegistration mappingReg; - private ModuleInfoBundleTracker moduleInfoBundleTracker; - - public RuntimeGeneratedMappingServiceActivator(ModuleInfoBundleTracker moduleInfoBundleTracker) { - this.moduleInfoBundleTracker = moduleInfoBundleTracker; - } - - public RuntimeGeneratedMappingServiceImpl startRuntimeMappingService(BundleContext context) { - RuntimeGeneratedMappingServiceImpl service = new RuntimeGeneratedMappingServiceImpl(moduleInfoBundleTracker.getModuleInfoLoadingStrategy()); - service.setPool(CLASS_POOL); - service.init(); - startRuntimeMappingService(service, context); - return service; - } - - private void startRuntimeMappingService(RuntimeGeneratedMappingServiceImpl service, BundleContext context) { - Hashtable properties = new Hashtable(); - listenerReg = context.registerService(SchemaServiceListener.class, service, properties); - mappingReg = context.registerService(BindingIndependentMappingService.class, service, properties); - - } - - @Override - public void close() throws Exception { - mappingReg.unregister(); - listenerReg.unregister(); - } -} diff --git a/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java new file mode 100644 index 0000000000..8873596642 --- /dev/null +++ b/opendaylight/config/config-manager/src/main/java/org/opendaylight/controller/config/manager/impl/util/OsgiRegistrationUtil.java @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.config.manager.impl.util; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; +import org.osgi.util.tracker.BundleTracker; +import org.osgi.util.tracker.ServiceTracker; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; +import java.util.ListIterator; + +import static com.google.common.base.Preconditions.checkNotNull; + +public class OsgiRegistrationUtil { + private static final Logger logger = LoggerFactory.getLogger(OsgiRegistrationUtil.class); + + @SafeVarargs + public static AutoCloseable registerService(BundleContext bundleContext, T service, Class ... interfaces) { + checkNotNull(service); + checkNotNull(interfaces); + List autoCloseableList = new ArrayList<>(); + for (Class ifc : interfaces) { + ServiceRegistration serviceRegistration = bundleContext.registerService(ifc, service, null); + autoCloseableList.add(wrap(serviceRegistration)); + } + return aggregate(autoCloseableList); + } + + public static AutoCloseable wrap(final ServiceRegistration reg) { + checkNotNull(reg); + return new AutoCloseable() { + @Override + public void close() throws Exception { + reg.unregister(); + } + }; + } + + public static AutoCloseable wrap(final BundleTracker bundleTracker) { + checkNotNull(bundleTracker); + return new AutoCloseable() { + @Override + public void close() throws Exception { + bundleTracker.close(); + } + }; + } + + public static AutoCloseable wrap(final ServiceTracker serviceTracker) { + checkNotNull(serviceTracker); + return new AutoCloseable() { + @Override + public void close() throws Exception { + serviceTracker.close(); + } + }; + } + + /** + * Close list of auto closeables in reverse order + */ + public static AutoCloseable aggregate(final List list) { + checkNotNull(list); + + return new AutoCloseable() { + @Override + public void close() throws Exception { + Exception firstException = null; + for (ListIterator it = list.listIterator(list.size()); it.hasPrevious();) { + AutoCloseable ac = it.previous(); + try { + ac.close(); + } catch (Exception e) { + logger.warn("Exception while closing {}", ac, e); + if (firstException == null) { + firstException = e; + } else { + firstException.addSuppressed(e); + } + } + } + if (firstException != null) { + throw firstException; + } + } + }; + } +} diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 4ec7e2f64b..6b55b6ad16 100644 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -27,8 +27,6 @@ config-persister-file-xml-adapter yang-jmx-generator yang-jmx-generator-plugin - yang-store-api - yang-store-impl yang-test logback-config threadpool-config-api @@ -201,11 +199,6 @@ yang-maven-plugin-spi ${yangtools.version} - - ${project.groupId} - yang-store-api - ${config.version} - org.opendaylight.controller diff --git a/opendaylight/config/yang-store-api/pom.xml b/opendaylight/config/yang-store-api/pom.xml deleted file mode 100644 index dfd9adb23f..0000000000 --- a/opendaylight/config/yang-store-api/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - 4.0.0 - - config-subsystem - org.opendaylight.controller - 0.2.5-SNAPSHOT - .. - - yang-store-api - ${project.artifactId} - bundle - - - - ${project.groupId} - yang-jmx-generator - - - - - - - org.apache.felix - maven-bundle-plugin - - - - org.opendaylight.controller.config.yang.store.api, - - - - - - - - diff --git a/opendaylight/config/yang-store-impl/.gitignore b/opendaylight/config/yang-store-impl/.gitignore deleted file mode 100644 index fc1d35eb24..0000000000 --- a/opendaylight/config/yang-store-impl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -target -.classpath -.settings diff --git a/opendaylight/config/yang-store-impl/pom.xml b/opendaylight/config/yang-store-impl/pom.xml deleted file mode 100644 index 8a88cd04f9..0000000000 --- a/opendaylight/config/yang-store-impl/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - 4.0.0 - - config-subsystem - org.opendaylight.controller - 0.2.5-SNAPSHOT - .. - - yang-store-impl - ${project.artifactId} - bundle - - - - ${project.groupId} - yang-store-api - - - org.osgi - org.osgi.core - - - org.slf4j - slf4j-api - - - ${project.groupId} - yang-jmx-generator - - - org.opendaylight.yangtools - binding-type-provider - - - commons-io - commons-io - - - com.google.guava - guava - - - org.opendaylight.yangtools - mockito-configuration - - - com.google.code.findbugs - jsr305 - - - - - - - org.apache.felix - maven-bundle-plugin - - - org.opendaylight.controller.config.yang.store.impl.YangStoreActivator - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - 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 deleted file mode 100644 index 889d246784..0000000000 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTracker.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Collections2; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleEvent; -import org.osgi.util.tracker.BundleTracker; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.concurrent.GuardedBy; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Note on consistency: - * When this bundle is activated after other bundles containing yang files, the resolving order - * is not preserved. We thus maintain two maps, one containing consistent snapshot, other inconsistent. The - * container should eventually send all events and thus making the inconsistent map redundant. - */ -public class ExtenderYangTracker extends BundleTracker implements YangStoreService, AutoCloseable { - - private static final Logger logger = LoggerFactory.getLogger(ExtenderYangTracker.class); - - private final Multimap consistentBundlesToYangURLs = HashMultimap.create(); - - /* - Map of currently problematic yang files that should get fixed eventually after all events are received. - */ - private final Multimap inconsistentBundlesToYangURLs = HashMultimap.create(); - - private final YangStoreCache cache = new YangStoreCache(); - private final MbeParser mbeParser; - - - public ExtenderYangTracker(Optional maybeBlacklist, BundleContext bundleContext) { - this(new MbeParser(), maybeBlacklist, bundleContext); - } - - @GuardedBy("this") - private Optional maybeBlacklist; - - @VisibleForTesting - ExtenderYangTracker(MbeParser mbeParser, Optional maybeBlacklist, BundleContext bundleContext) { - super(bundleContext, BundleEvent.RESOLVED | BundleEvent.UNRESOLVED, null); - this.mbeParser = mbeParser; - this.maybeBlacklist = maybeBlacklist; - open(); - } - - @Override - public synchronized Object addingBundle(Bundle bundle, BundleEvent event) { - - // Ignore system bundle: - // system bundle might have config-api on classpath && - // config-api contains yang files => - // system bundle might contain yang files from that bundle - if (bundle.getBundleId() == 0) - return bundle; - - if (maybeBlacklist.isPresent()) { - Matcher m = maybeBlacklist.get().matcher(bundle.getSymbolicName()); - if (m.matches()) { - logger.debug("Ignoring {} because it is in blacklist {}", bundle, maybeBlacklist); - return bundle; - } - } - - Enumeration enumeration = bundle.findEntries("META-INF/yang", "*.yang", false); - if (enumeration != null && enumeration.hasMoreElements()) { - synchronized (this) { - List addedURLs = new ArrayList<>(); - while (enumeration.hasMoreElements()) { - URL url = enumeration.nextElement(); - addedURLs.add(url); - } - logger.trace("Bundle {} has event {}, bundle state {}, URLs {}", bundle, event, bundle.getState(), addedURLs); - // test that yang store is consistent - Multimap proposedNewState = HashMultimap.create(consistentBundlesToYangURLs); - proposedNewState.putAll(inconsistentBundlesToYangURLs); - proposedNewState.putAll(bundle, addedURLs); - - Preconditions.checkArgument(addedURLs.size() > 0, "No change can occur when no URLs are changed"); - - try(YangStoreSnapshotImpl snapshot = createSnapshot(mbeParser, proposedNewState)) { - onSnapshotSuccess(proposedNewState, snapshot); - } catch(YangStoreException e) { - onSnapshotFailure(bundle, addedURLs, e); - } - } - } - return bundle; - } - - private synchronized void onSnapshotFailure(Bundle bundle, List addedURLs, Exception failureReason) { - // inconsistent state - inconsistentBundlesToYangURLs.putAll(bundle, addedURLs); - - logger.debug("Yang store is falling back to last consistent state containing {}, inconsistent yang files {}", - consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, failureReason); - logger.info("Yang store is falling back to last consistent state containing {} files, keeping {} inconsistent yang files due to {}", - consistentBundlesToYangURLs.size(), inconsistentBundlesToYangURLs.size(), failureReason.toString()); - cache.setInconsistentURLsForReporting(inconsistentBundlesToYangURLs.values()); - } - - private synchronized void onSnapshotSuccess(Multimap proposedNewState, YangStoreSnapshotImpl snapshot) { - // consistent state - // merge into - consistentBundlesToYangURLs.clear(); - consistentBundlesToYangURLs.putAll(proposedNewState); - - logger.debug("Yang store updated to new consistent state containing {}", consistentBundlesToYangURLs); - - // If we cleared up some inconsistent models, report that - if (!inconsistentBundlesToYangURLs.isEmpty()) { - inconsistentBundlesToYangURLs.clear(); - logger.info("Yang store updated to new consistent state containing {} yang files", consistentBundlesToYangURLs.size()); - } - - updateCache(snapshot); - cache.setInconsistentURLsForReporting(Collections. emptySet()); - } - - private synchronized void updateCache(YangStoreSnapshotImpl snapshot) { - cache.cacheYangStore(consistentBundlesToYangURLs, snapshot); - } - - @Override - public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) { - logger.debug("Modified bundle {} {} {}", bundle, event, object); - } - - /** - * If removing YANG files makes yang store inconsistent, method {@link #getYangStoreSnapshot()} - * will throw exception. There is no rollback. - */ - @Override - public synchronized void removedBundle(Bundle bundle, BundleEvent event, Object object) { - logger.debug("Removed bundle {} {} {}", bundle, event, object); - inconsistentBundlesToYangURLs.removeAll(bundle); - consistentBundlesToYangURLs.removeAll(bundle); - } - - @Override - public synchronized YangStoreSnapshot getYangStoreSnapshot() - throws YangStoreException { - Optional yangStoreOpt = cache.getSnapshotIfPossible(consistentBundlesToYangURLs); - if (yangStoreOpt.isPresent()) { - logger.debug("Returning cached yang store {}", yangStoreOpt.get()); - return yangStoreOpt.get(); - } - - YangStoreSnapshotImpl snapshot = createSnapshot(mbeParser, consistentBundlesToYangURLs); - updateCache(snapshot); - return snapshot; - } - - private static YangStoreSnapshotImpl createSnapshot(MbeParser mbeParser, Multimap multimap) throws YangStoreException { - try { - YangStoreSnapshotImpl yangStoreSnapshot = mbeParser.parseYangFiles(fromUrlsToInputStreams(multimap)); - logger.trace("{} module entries parsed successfully from {} yang files", - yangStoreSnapshot.countModuleMXBeanEntries(), multimap.values().size()); - return yangStoreSnapshot; - } catch (RuntimeException e) { - StringBuffer causeStr = new StringBuffer(); - Throwable cause = e; - while (cause != null) { - causeStr.append(e.getMessage()); - causeStr.append("\n"); - cause = e.getCause(); - } - throw new YangStoreException("Unable to parse yang files. \n" + causeStr.toString() + - "URLs: " + multimap, e); - } - } - - private static Collection fromUrlsToInputStreams(Multimap multimap) { - return Collections2.transform(multimap.values(), - new Function() { - - @Override - public InputStream apply(URL url) { - try { - return url.openStream(); - } catch (IOException e) { - logger.warn("Unable to open stream from {}", url); - throw new IllegalStateException( - "Unable to open stream from " + url, e); - } - } - }); - } - - public synchronized void setMaybeBlacklist(Optional maybeBlacklistPattern) { - maybeBlacklist = maybeBlacklistPattern; - cache.invalidate(); - } -} diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangParserWrapper.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangParserWrapper.java deleted file mode 100644 index 7c428181aa..0000000000 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangParserWrapper.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import com.google.common.collect.Sets; -import org.apache.commons.io.IOUtils; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Map; - -public class YangParserWrapper { - - /** - * throw IllegalStateException if it is unable to parse yang files - */ - public static SchemaContext parseYangFiles(Collection yangFilesAsInputStreams) { - YangParserImpl parser = getYangParserInstance(); - Map mappedYangModules = null; - try { - mappedYangModules = parseYangFiles(parser, yangFilesAsInputStreams); - } catch (YangStoreException e) { - throw new IllegalStateException("Unable to parse yang files", e); - } - return getSchemaContextFromModules(parser, mappedYangModules); - } - - static YangParserImpl getYangParserInstance() { - return new YangParserImpl(); - } - - static SchemaContext getSchemaContextFromModules(YangModelParser parser, Map allYangModules) { - return parser.resolveSchemaContext(Sets - .newHashSet(allYangModules.values())); - } - - static Map parseYangFiles(YangModelParser parser, Collection allInput) throws YangStoreException { - List bufferedInputStreams = new ArrayList<>(); - for (InputStream is : allInput) { - String content; - try { - content = IOUtils.toString(is); - } catch (IOException e) { - throw new YangStoreException("Can not get yang as String from " - + is, e); - } - InputStream buf = new ByteArrayInputStream(content.getBytes()); - bufferedInputStreams.add(buf); - } - - return parser - .parseYangModelsFromStreamsMapped(bufferedInputStreams); - } -} diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreActivator.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreActivator.java deleted file mode 100644 index a25b05ab8a..0000000000 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreActivator.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import com.google.common.base.Optional; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Dictionary; -import java.util.Hashtable; -import java.util.regex.Pattern; - -public class YangStoreActivator implements BundleActivator { - private static final Logger logger = LoggerFactory.getLogger(YangStoreActivator.class); - - @Override - public void start(BundleContext context) throws Exception { - // get blacklist - Optional maybeBlacklistPattern = Optional.absent(); - String blacklist = context.getProperty("yangstore.blacklist"); - if (blacklist != null) { - try { - maybeBlacklistPattern = Optional.of(Pattern.compile(blacklist)); - } catch (RuntimeException e) { - logger.error("Cannot parse blacklist regex " + blacklist, e); - throw e; - } - } - ExtenderYangTracker extenderYangTracker = new ExtenderYangTracker(maybeBlacklistPattern, context); - Dictionary properties = new Hashtable<>(); - context.registerService(YangStoreService.class, extenderYangTracker, properties); - } - - @Override - public void stop(BundleContext context) throws Exception { - - } -} diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreCache.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreCache.java deleted file mode 100644 index 48bce78378..0000000000 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreCache.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Multimap; -import com.google.common.collect.Sets; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; -import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.osgi.framework.Bundle; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.annotation.concurrent.GuardedBy; -import java.net.URL; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -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); - - if (cachedUrls==null || cachedUrls.equals(urls)) { - Preconditions.checkState(cachedYangStoreSnapshot.isPresent()); - YangStoreSnapshot freshSnapshot = YangStoreSnapshotImpl.copy(cachedYangStoreSnapshot.get()); - if (inconsistentURLsForReporting.size() > 0){ - logger.warn("Some yang URLs are ignored: {}", inconsistentURLsForReporting); - } - return Optional.of(freshSnapshot); - } - - return Optional.absent(); - } - - private static Set setFromMultimapValues( - Multimap bundlesToYangURLs) { - Set urls = Sets.newHashSet(bundlesToYangURLs.values()); - Preconditions.checkState(bundlesToYangURLs.size() == urls.size()); - return urls; - } - - synchronized void cacheYangStore(Multimap urls, - YangStoreSnapshot yangStoreSnapshot) { - this.cachedUrls = setFromMultimapValues(urls); - this.cachedYangStoreSnapshot = Optional.of(yangStoreSnapshot); - } - - synchronized void invalidate() { - cachedUrls.clear(); - if (cachedYangStoreSnapshot.isPresent()){ - cachedYangStoreSnapshot.get().close(); - cachedYangStoreSnapshot = Optional.absent(); - } - } - - public synchronized void setInconsistentURLsForReporting(Collection urls){ - inconsistentURLsForReporting = urls; - } - - private Optional getInitialSnapshot() { - YangStoreSnapshot initialSnapshot = new YangStoreSnapshot() { - @Override - public Map> getModuleMXBeanEntryMap() { - return Collections.emptyMap(); - } - - @Override - public Map> getQNamesToIdentitiesToModuleMXBeanEntries() { - return Collections.emptyMap(); - } - - @Override - public Set getModules() { - return Collections.emptySet(); - } - - @Override - public Map getModulesToSources() { - return Collections.emptyMap(); - } - - @Override - public String getModuleSource(Module module) { - throw new IllegalArgumentException("Cannot get sources in empty snapshot"); - } - - @Override - public int countModuleMXBeanEntries() { - return 0; - } - - @Override - public void close() { - } - }; - return Optional.of(initialSnapshot); - } -} diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java b/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java deleted file mode 100644 index 474d754798..0000000000 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/YangStoreSnapshotImpl.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; -import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; -import org.opendaylight.yangtools.yang.common.QName; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Collections; -import java.util.Map; -import java.util.Set; - -public class YangStoreSnapshotImpl implements YangStoreSnapshot { - private static final Logger logger = LoggerFactory.getLogger(YangStoreSnapshotImpl.class); - - @Deprecated - private final Map> moduleMXBeanEntryMap; - - private final Map modulesToSources; - private final Map> qNamesToIdentitiesToModuleMXBeanEntries; - - public YangStoreSnapshotImpl(Map> moduleMXBeanEntryMap, - Map modulesToSources, - Map> qNamesToIdentitiesToModuleMXBeanEntries) { - - this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntryMap); - this.modulesToSources = Collections.unmodifiableMap(modulesToSources); - this.qNamesToIdentitiesToModuleMXBeanEntries = Collections.unmodifiableMap(qNamesToIdentitiesToModuleMXBeanEntries); - } - - public static YangStoreSnapshotImpl copy(YangStoreSnapshot yangStoreSnapshot) { - return new YangStoreSnapshotImpl( - yangStoreSnapshot.getModuleMXBeanEntryMap(), - yangStoreSnapshot.getModulesToSources(), - yangStoreSnapshot.getQNamesToIdentitiesToModuleMXBeanEntries()); - } - - /** - * @return all loaded config modules. Key of outer map is namespace of yang file. - * Key of inner map is name of module entry. Value is module entry. - */ - @Override - public Map> getModuleMXBeanEntryMap() { - return moduleMXBeanEntryMap; - } - - @Override - public Map> getQNamesToIdentitiesToModuleMXBeanEntries() { - return qNamesToIdentitiesToModuleMXBeanEntries; - } - - @Override - public Set getModules() { - return modulesToSources.keySet(); - } - - @Override - public String getModuleSource(Module module) { - String result = modulesToSources.get(module); - if (result == null) { - logger.trace("Cannot find module {} in {}", module, modulesToSources); - throw new IllegalArgumentException("Module not found in this snapshot:" + module); - } - return result; - } - - @Override - public Map getModulesToSources() { - return modulesToSources; - } - - @Override - public int countModuleMXBeanEntries() { - int i = 0; - for (Map value : moduleMXBeanEntryMap - .values()) { - i += value.keySet().size(); - } - return i; - } - - @Override - public void close() { - // TODO: reference counting - } - -} diff --git a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java b/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java deleted file mode 100644 index 8a7b95ff3e..0000000000 --- a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/ExtenderYangTrackerCustomizerTest.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ -package org.opendaylight.controller.config.yang.store.impl; - -import com.google.common.base.Optional; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; -import org.opendaylight.yangtools.yang.model.api.Module; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.BundleListener; - -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; -import java.util.Map; -import java.util.regex.Pattern; - -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyCollectionOf; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -public class ExtenderYangTrackerCustomizerTest { - - - private ExtenderYangTracker tested; - @Mock - private MbeParser parser; - @Mock - private YangStoreSnapshotImpl yangStoreSnapshot; - @Mock - private BundleContext bundleContext; - - private Map> moduleMap = Maps.newHashMap(); - - @Before - public void setUp() throws YangStoreException { - - moduleMap.put("1", new Map.Entry() { - @Override - public Module getKey() { - return mock(Module.class); - } - - @Override - public String getValue() { - return "v"; - } - - @Override - public String setValue(String value) { - return "v"; - } - }); - - MockitoAnnotations.initMocks(this); - doNothing().when(bundleContext).addBundleListener(any(BundleListener.class)); - doReturn(new Bundle[0]).when(bundleContext).getBundles(); - tested = new ExtenderYangTracker(parser, Optional.absent(), bundleContext); - doReturn(yangStoreSnapshot).when(parser).parseYangFiles( - anyCollectionOf(InputStream.class)); - doReturn(22).when(yangStoreSnapshot).countModuleMXBeanEntries(); - doReturn("mock yang store").when(yangStoreSnapshot).toString(); - doNothing().when(yangStoreSnapshot).close(); - doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getModuleMXBeanEntryMap(); - doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getModulesToSources(); - doReturn(Collections.emptyMap()).when(yangStoreSnapshot).getQNamesToIdentitiesToModuleMXBeanEntries(); - } - - @Test - public void testCache() throws MalformedURLException, YangStoreException, - InterruptedException { - Bundle bundle = getMockedBundle(5, false); - tested.addingBundle(bundle, null); - bundle = getMockedBundle(2, false); - tested.addingBundle(bundle, null); - bundle = getMockedBundle(10, false); - tested.addingBundle(bundle, null); - YangStoreSnapshot returnedStore; - - returnedStore = tested.getYangStoreSnapshot(); - - - tested.removedBundle(bundle, null, null); - tested.getYangStoreSnapshot(); - - bundle = getMockedBundle(10, false); - tested.addingBundle(bundle, null); - - for(int i = 0; i< 20; i++){ - tested.getYangStoreSnapshot(); - } - - verify(parser, times(5)).parseYangFiles(anyCollectionOf(InputStream.class)); - - returnedStore = tested.getYangStoreSnapshot(); - - verifyNoMoreInteractions(parser); - } - - int bundleCounter = 1; - - private Bundle getMockedBundle(int sizeOfUrls, boolean system) - throws MalformedURLException { - Bundle mock = mock(Bundle.class); - doReturn(32).when(mock).getState();//mock just for logging - - List urls = Lists.newArrayList(); - for (int i = 0; i < sizeOfUrls; i++) { - urls.add(new URL("http://127.0." + bundleCounter++ + "." + i)); - } - Enumeration abc = new TestEnumeration(urls); - - doReturn(abc).when(mock).findEntries("META-INF/yang", "*.yang", false); - if (system) - doReturn(0L).when(mock).getBundleId(); - else - doReturn(1L).when(mock).getBundleId(); - - doReturn("mockedBundle").when(mock).toString(); - doReturn("mockedBundle").when(mock).getSymbolicName(); - - return mock; - } - - private static final class TestEnumeration implements Enumeration { - - private final List urls; - int currentPos = 0; - - public TestEnumeration(List urls) { - this.urls = urls; - } - - @Override - public boolean hasMoreElements() { - try { - urls.get(currentPos); - } catch (IndexOutOfBoundsException e) { - return false; - } - return true; - } - - @Override - public URL nextElement() { - URL url = urls.get(currentPos++); - return url; - } - - } -} diff --git a/opendaylight/config/yang-test/pom.xml b/opendaylight/config/yang-test/pom.xml index 6caee4108a..3e75d00943 100644 --- a/opendaylight/config/yang-test/pom.xml +++ b/opendaylight/config/yang-test/pom.xml @@ -106,65 +106,6 @@ org.opendaylight.yangtools yang-maven-plugin - - - config - - generate-sources - - - src/main/yang - - - - org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator - - ${jmxGeneratorPath} - - - urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang - - - - - true - - - - - types - - generate-sources - - - src/main/yang/types - - - - org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - - - ${project.build.directory}/generated-sources/sal - - - - true - - - - - - org.opendaylight.controller - yang-jmx-generator-plugin - ${config.version} - - - - org.opendaylight.yangtools - maven-sal-api-gen-plugin - ${yangtools.version} - - org.opendaylight.controller diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index 38dc454ac3..c993435614 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -190,14 +190,6 @@ org.opendaylight.controller yang-jmx-generator - - org.opendaylight.controller - yang-store-api - - - org.opendaylight.controller - yang-store-impl - org.opendaylight.controller logback-config diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini index 7d45c82935..0d223b8df2 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini @@ -46,8 +46,6 @@ netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.confi netconf.config.persister.2.properties.fileStorage=configuration/current/controller.currentconfig.xml netconf.config.persister.2.properties.numberOfBackups=1 -yangstore.blacklist=.*controller.model.* - # Set Default start level for framework osgi.bundles.defaultStartLevel=4 # Extra packages to import from the boot class loader diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml index b4f71764d3..74e7d1afe7 100644 --- a/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml +++ b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml @@ -153,11 +153,6 @@ - - org.opendaylight.controller - yang-store-impl - ${config.version} - org.opendaylight.controller logback-config @@ -252,11 +247,6 @@ ${netconf.version} test - - org.opendaylight.controller - yang-store-impl - ${config.version} - org.opendaylight.yangtools diff --git a/opendaylight/md-sal/model/pom.xml b/opendaylight/md-sal/model/pom.xml index 1ea0a3e132..4c8a74c62b 100644 --- a/opendaylight/md-sal/model/pom.xml +++ b/opendaylight/md-sal/model/pom.xml @@ -60,7 +60,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - target/generated-sources/sal + ${salGeneratorPath} diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index d05e8b0e61..a45cadab7c 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -36,7 +36,7 @@ sal-binding-broker sal-binding-util - sal-binding-dom-it + samples @@ -79,6 +79,7 @@ sal-binding-it + sal-binding-dom-it @@ -101,6 +102,7 @@ + ${project.build.directory}/generated-sources/sal UTF-8 diff --git a/opendaylight/md-sal/sal-binding-broker/pom.xml b/opendaylight/md-sal/sal-binding-broker/pom.xml index ad4a1ee200..dea455bfa1 100644 --- a/opendaylight/md-sal/sal-binding-broker/pom.xml +++ b/opendaylight/md-sal/sal-binding-broker/pom.xml @@ -37,6 +37,17 @@ + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl target/site/models @@ -101,6 +112,7 @@ org.opendaylight.controller.sal.binding.codegen.*, org.opendaylight.controller.sal.binding.osgi.*, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.binding.impl.rev131028 diff --git a/opendaylight/md-sal/sal-binding-config/pom.xml b/opendaylight/md-sal/sal-binding-config/pom.xml index a58df8435b..145dc37552 100644 --- a/opendaylight/md-sal/sal-binding-config/pom.xml +++ b/opendaylight/md-sal/sal-binding-config/pom.xml @@ -36,7 +36,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - target/generated-sources/sal + ${salGeneratorPath} diff --git a/opendaylight/md-sal/sal-binding-it/pom.xml b/opendaylight/md-sal/sal-binding-it/pom.xml index 213e4f47f7..520935ca90 100644 --- a/opendaylight/md-sal/sal-binding-it/pom.xml +++ b/opendaylight/md-sal/sal-binding-it/pom.xml @@ -160,10 +160,6 @@ org.opendaylight.controller config-netconf-connector - - org.opendaylight.controller - yang-store-impl - org.opendaylight.controller logback-config diff --git a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java index e8a52d069d..0a71ef5315 100644 --- a/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java +++ b/opendaylight/md-sal/sal-binding-it/src/main/java/org/opendaylight/controller/test/sal/binding/it/TestHelper.java @@ -7,15 +7,15 @@ */ package org.opendaylight.controller.test.sal.binding.it; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.options.DefaultCompositeOption; +import org.ops4j.pax.exam.util.PathUtils; + import static org.ops4j.pax.exam.CoreOptions.frameworkProperty; import static org.ops4j.pax.exam.CoreOptions.junitBundles; import static org.ops4j.pax.exam.CoreOptions.mavenBundle; import static org.ops4j.pax.exam.CoreOptions.systemProperty; -import org.ops4j.pax.exam.Option; -import org.ops4j.pax.exam.options.DefaultCompositeOption; -import org.ops4j.pax.exam.util.PathUtils; - public class TestHelper { public static final String CONTROLLER = "org.opendaylight.controller"; @@ -50,8 +50,6 @@ public class TestHelper { mavenBundle("commons-io", "commons-io").versionAsInProject(), // mavenBundle(CONTROLLER, "config-manager").versionAsInProject(), // mavenBundle(CONTROLLER, "yang-jmx-generator").versionAsInProject(), // - mavenBundle(CONTROLLER, "yang-store-api").versionAsInProject(), // - mavenBundle(CONTROLLER, "yang-store-impl").versionAsInProject(), // mavenBundle(CONTROLLER, "logback-config").versionAsInProject(), // mavenBundle(CONTROLLER, "config-persister-api").versionAsInProject(), // mavenBundle(CONTROLLER, "netconf-api").versionAsInProject(), // @@ -129,7 +127,6 @@ public class TestHelper { systemProperty("netconf.config.persister.1.properties.fileStorage") .value(PathUtils.getBaseDir() + "/src/test/resources/controller.xml"), // systemProperty("netconf.config.persister.1.properties.numberOfBackups").value("1") // - //systemProperty("yangstore.blacklist").value(".*controller.model.*") // ); diff --git a/opendaylight/md-sal/sal-dom-api/pom.xml b/opendaylight/md-sal/sal-dom-api/pom.xml index 9eadce3ed7..15932d56ce 100644 --- a/opendaylight/md-sal/sal-dom-api/pom.xml +++ b/opendaylight/md-sal/sal-dom-api/pom.xml @@ -40,6 +40,22 @@ + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl target/site/models diff --git a/opendaylight/md-sal/sal-dom-broker/pom.xml b/opendaylight/md-sal/sal-dom-broker/pom.xml index 225281e7a4..d192bea540 100644 --- a/opendaylight/md-sal/sal-dom-broker/pom.xml +++ b/opendaylight/md-sal/sal-dom-broker/pom.xml @@ -81,6 +81,14 @@ + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl target/site/models @@ -124,7 +132,8 @@ org.opendaylight.controller.sal.dom.broker.util, org.opendaylight.controller.config.yang.md.sal.dom.impl, org.opendaylight.controller.config.yang.md.sal.dom.statistics, - org.opendaylight.yangtools.yang.util + org.opendaylight.yangtools.yang.util, + org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.dom.impl.rev131028.* * diff --git a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java index fc8ccd6746..e49a28d8e0 100644 --- a/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java +++ b/opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaContextProvider.java @@ -7,10 +7,10 @@ */ package org.opendaylight.controller.sal.dom.broker.impl; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; - -public interface SchemaContextProvider { - - SchemaContext getSchemaContext(); +/** + * @deprecated Use org.opendaylight.yangtools.yang.model.api.SchemaContextProvider instead + */ +@Deprecated +public interface SchemaContextProvider extends org.opendaylight.yangtools.yang.model.api.SchemaContextProvider{ } diff --git a/opendaylight/md-sal/sal-netconf-connector/pom.xml b/opendaylight/md-sal/sal-netconf-connector/pom.xml index 33cd94d6a8..2105e2e71d 100644 --- a/opendaylight/md-sal/sal-netconf-connector/pom.xml +++ b/opendaylight/md-sal/sal-netconf-connector/pom.xml @@ -70,12 +70,6 @@ ${netconf.version} test - - ${project.groupId} - yang-store-api - ${netconf.version} - test - ${project.groupId} netconf-client @@ -125,19 +119,6 @@ test-jar ${netconf.version} - - ${project.groupId} - yang-store-impl - test - ${netconf.version} - - - ${project.groupId} - yang-store-impl - test - test-jar - ${netconf.version} - org.opendaylight.controller logback-config diff --git a/opendaylight/md-sal/sal-remote/pom.xml b/opendaylight/md-sal/sal-remote/pom.xml index 090c56f67d..15bd2e7a30 100644 --- a/opendaylight/md-sal/sal-remote/pom.xml +++ b/opendaylight/md-sal/sal-remote/pom.xml @@ -43,7 +43,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - target/generated-sources/ + ${salGeneratorPath} diff --git a/opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml index e06363d385..4515357476 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml @@ -165,6 +165,21 @@ + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + + + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl + + target/site/models + + org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl target/site/models diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml index 8813ee9613..3e73f161c2 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml @@ -443,11 +443,6 @@ ${netconf.version} test - - org.opendaylight.controller - yang-store-impl - ${config.version} - org.opendaylight.controller logback-config diff --git a/opendaylight/md-sal/samples/toaster-consumer/pom.xml b/opendaylight/md-sal/samples/toaster-consumer/pom.xml index 07a7d41ee7..67fc824a7b 100644 --- a/opendaylight/md-sal/samples/toaster-consumer/pom.xml +++ b/opendaylight/md-sal/samples/toaster-consumer/pom.xml @@ -57,6 +57,14 @@ + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + true @@ -68,6 +76,11 @@ yang-jmx-generator-plugin ${config.version} + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.version} + diff --git a/opendaylight/md-sal/samples/toaster-provider/pom.xml b/opendaylight/md-sal/samples/toaster-provider/pom.xml index 1a540fe949..4e4cfeda2a 100644 --- a/opendaylight/md-sal/samples/toaster-provider/pom.xml +++ b/opendaylight/md-sal/samples/toaster-provider/pom.xml @@ -56,6 +56,14 @@ + + + org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl + + + ${salGeneratorPath} + + true @@ -67,6 +75,11 @@ yang-jmx-generator-plugin ${config.version} + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.version} + diff --git a/opendaylight/md-sal/samples/toaster/pom.xml b/opendaylight/md-sal/samples/toaster/pom.xml index ad6d814c1b..59f8955d4b 100644 --- a/opendaylight/md-sal/samples/toaster/pom.xml +++ b/opendaylight/md-sal/samples/toaster/pom.xml @@ -32,7 +32,7 @@ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl - target/generated-sources/sal + ${salGeneratorPath} diff --git a/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml b/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml index 1c723eecca..15fee781ef 100644 --- a/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml +++ b/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml @@ -655,16 +655,6 @@ yang-jmx-generator ${config.version} - - org.opendaylight.controller - yang-store-api - ${config.version} - - - org.opendaylight.controller - yang-store-impl - ${config.version} - org.opendaylight.controller logback-config diff --git a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java index 08aeea2678..8400bc1835 100644 --- a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java +++ b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java @@ -213,8 +213,6 @@ public class ServiceProviderController { mavenBundle(ODL, "config-manager").versionAsInProject(), mavenBundle(ODL, "config-util").versionAsInProject(), mavenBundle(ODL, "yang-jmx-generator").versionAsInProject(), - mavenBundle(ODL, "yang-store-api").versionAsInProject(), - mavenBundle(ODL, "yang-store-impl").versionAsInProject(), mavenBundle(ODL, "logback-config").versionAsInProject(), mavenBundle(ODL, "config-persister-api").versionAsInProject(), // mavenBundle(ODL,"config-persister-file-adapter").versionAsInProject(), diff --git a/opendaylight/netconf/config-netconf-connector/pom.xml b/opendaylight/netconf/config-netconf-connector/pom.xml index f8993a09e7..b37b5babdd 100644 --- a/opendaylight/netconf/config-netconf-connector/pom.xml +++ b/opendaylight/netconf/config-netconf-connector/pom.xml @@ -40,10 +40,6 @@ ${project.groupId} netconf-util - - ${project.groupId} - yang-store-api - ${project.groupId} netconf-mapping-api @@ -81,11 +77,6 @@ netconf-impl test - - ${project.groupId} - yang-store-impl - test - org.opendaylight.yangtools mockito-configuration @@ -121,7 +112,6 @@ javax.management.openmbean, org.opendaylight.controller.config.api, org.opendaylight.controller.config.api.jmx, - org.opendaylight.controller.config.yang.store.api, org.opendaylight.controller.config.yangjmxgenerator, org.opendaylight.controller.config.yangjmxgenerator.attribute, org.opendaylight.controller.netconf.api, @@ -135,7 +125,9 @@ org.slf4j, org.w3c.dom, com.google.common.io, - org.opendaylight.yangtools.yang.model.api.type + org.opendaylight.yangtools.yang.model.api.type, + org.opendaylight.yangtools.sal.binding.generator.spi, + org.opendaylight.yangtools.sal.binding.yang.types diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java index bb19dc207e..01ced4cb9a 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfig.java @@ -20,7 +20,7 @@ import javax.management.ObjectName; import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java index 73f9ecd6fa..f7fc029fcc 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/get/Get.java @@ -17,7 +17,7 @@ import javax.management.ObjectName; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java index 7cf6e17e9d..bf7f9f0f24 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/getconfig/GetConfig.java @@ -16,7 +16,7 @@ import javax.management.ObjectName; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorSeverity; import org.opendaylight.controller.netconf.api.NetconfDocumentedException.ErrorTag; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java index 5b7c575e2f..a7b42889b6 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/runtimerpc/RuntimeRpc.java @@ -14,7 +14,7 @@ import javax.management.ObjectName; import javax.management.openmbean.OpenType; import org.opendaylight.controller.config.util.ConfigRegistryClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java index 5642cc7188..b39549ed5b 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/Activator.java @@ -8,19 +8,20 @@ package org.opendaylight.controller.netconf.confignetconfconnector.osgi; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; import org.osgi.framework.ServiceRegistration; +import org.osgi.util.tracker.ServiceTracker; +import org.osgi.util.tracker.ServiceTrackerCustomizer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.Hashtable; - import static com.google.common.base.Preconditions.checkState; -public class Activator implements BundleActivator, YangStoreServiceTracker.YangStoreTrackerListener { +public class Activator implements BundleActivator { private static final Logger logger = LoggerFactory.getLogger(Activator.class); @@ -29,10 +30,43 @@ public class Activator implements BundleActivator, YangStoreServiceTracker.YangS private ConfigRegistryLookupThread configRegistryLookup = null; @Override - public void start(BundleContext context) throws Exception { + public void start(final BundleContext context) throws Exception { this.context = context; - YangStoreServiceTracker tracker = new YangStoreServiceTracker(context, this); - tracker.open(); + + ServiceTrackerCustomizer customizer = new ServiceTrackerCustomizer() { + @Override + public ConfigRegistryLookupThread addingService(ServiceReference reference) { + logger.debug("Got addingService(SchemaContextProvider) event, starting ConfigRegistryLookupThread"); + checkState(configRegistryLookup == null, "More than one onYangStoreAdded received"); + + SchemaContextProvider schemaContextProvider = reference.getBundle().getBundleContext().getService(reference); + + YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(schemaContextProvider); + configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService); + configRegistryLookup.start(); + return configRegistryLookup; + } + + @Override + public void modifiedService(ServiceReference reference, ConfigRegistryLookupThread configRegistryLookup) { + logger.debug("Got modifiedService(SchemaContextProvider) event"); + configRegistryLookup.yangStoreService.refresh(); + + } + + @Override + public void removedService(ServiceReference reference, ConfigRegistryLookupThread configRegistryLookup) { + configRegistryLookup.interrupt(); + if (osgiRegistration != null) { + osgiRegistration.unregister(); + } + osgiRegistration = null; + Activator.this.configRegistryLookup = null; + } + }; + + ServiceTracker listenerTracker = new ServiceTracker<>(context, SchemaContextProvider.class, customizer); + listenerTracker.open(); } @Override @@ -42,27 +76,10 @@ public class Activator implements BundleActivator, YangStoreServiceTracker.YangS } } - @Override - public synchronized void onYangStoreAdded(YangStoreService yangStoreService) { - checkState(configRegistryLookup == null, "More than one onYangStoreAdded received"); - configRegistryLookup = new ConfigRegistryLookupThread(yangStoreService); - configRegistryLookup.start(); - } - - @Override - public synchronized void onYangStoreRemoved() { - configRegistryLookup.interrupt(); - if (osgiRegistration != null) { - osgiRegistration.unregister(); - } - osgiRegistration = null; - configRegistryLookup = null; - } - private class ConfigRegistryLookupThread extends Thread { - private final YangStoreService yangStoreService; + private final YangStoreServiceImpl yangStoreService; - private ConfigRegistryLookupThread(YangStoreService yangStoreService) { + private ConfigRegistryLookupThread(YangStoreServiceImpl yangStoreService) { super("config-registry-lookup"); this.yangStoreService = yangStoreService; } @@ -71,8 +88,7 @@ public class Activator implements BundleActivator, YangStoreServiceTracker.YangS public void run() { NetconfOperationServiceFactoryImpl factory = new NetconfOperationServiceFactoryImpl(yangStoreService); logger.debug("Registering into OSGi"); - osgiRegistration = context.registerService(new String[]{NetconfOperationServiceFactory.class.getName()}, factory, - new Hashtable()); + osgiRegistration = context.registerService(NetconfOperationServiceFactory.class, factory, null); } } } diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java index 77c58501cd..09966b8c3b 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationProvider.java @@ -11,7 +11,6 @@ package org.opendaylight.controller.netconf.confignetconfconnector.osgi; import com.google.common.base.Optional; import com.google.common.collect.Sets; import org.opendaylight.controller.config.util.ConfigRegistryClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.netconf.confignetconfconnector.operations.Commit; import org.opendaylight.controller.netconf.confignetconfconnector.operations.DiscardChanges; import org.opendaylight.controller.netconf.confignetconfconnector.operations.Validate; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java index 034b39a806..4ca71ae288 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceFactoryImpl.java @@ -9,8 +9,6 @@ package org.opendaylight.controller.netconf.confignetconfconnector.osgi; import org.opendaylight.controller.config.util.ConfigRegistryJMXClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationServiceFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java index 444500d5dd..95659ddf91 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImpl.java @@ -8,16 +8,12 @@ package org.opendaylight.controller.netconf.confignetconfconnector.osgi; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.Sets; import org.opendaylight.controller.config.api.LookupRegistry; import org.opendaylight.controller.config.util.ConfigRegistryJMXClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider; import org.opendaylight.controller.netconf.confignetconfconnector.util.Util; @@ -26,10 +22,10 @@ import org.opendaylight.controller.netconf.mapping.api.NetconfOperation; import org.opendaylight.controller.netconf.mapping.api.NetconfOperationService; import org.opendaylight.yangtools.yang.model.api.Module; -import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Sets; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; /** * Manages life cycle of {@link YangStoreSnapshot}. @@ -155,7 +151,7 @@ public class NetconfOperationServiceImpl implements NetconfOperationService { private final String moduleNamespace; public YangStoreCapability(Module module, String moduleContent) { - super(getAsString(module)); + super(toCapabilityURI(module)); this.content = moduleContent; this.moduleName = module.getName(); this.moduleNamespace = module.getNamespace().toString(); @@ -167,14 +163,9 @@ public class NetconfOperationServiceImpl implements NetconfOperationService { return Optional.of(content); } - private static String getAsString(Module module) { - final StringBuffer capabilityContent = new StringBuffer(); - capabilityContent.append(module.getNamespace()); - capabilityContent.append("?module="); - capabilityContent.append(module.getName()); - capabilityContent.append("&revision="); - capabilityContent.append(Util.writeDate(module.getRevision())); - return capabilityContent.toString(); + private static String toCapabilityURI(Module module) { + return String.valueOf(module.getNamespace()) + "?module=" + + module.getName() + "&revision=" + Util.writeDate(module.getRevision()); } @Override diff --git a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreException.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreException.java similarity index 88% rename from opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreException.java rename to opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreException.java index 68d62f896a..18558b39ca 100644 --- a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreException.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreException.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.config.yang.store.api; +package org.opendaylight.controller.netconf.confignetconfconnector.osgi; public class YangStoreException extends Exception { diff --git a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreService.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java similarity index 89% rename from opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreService.java rename to opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java index 15619a88cc..969d7cfdb3 100644 --- a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreService.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreService.java @@ -5,7 +5,7 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.config.yang.store.api; +package org.opendaylight.controller.netconf.confignetconfconnector.osgi; /** * Yang store OSGi service diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceImpl.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceImpl.java new file mode 100644 index 0000000000..1102f342bd --- /dev/null +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceImpl.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.controller.netconf.confignetconfconnector.osgi; + +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; + +import javax.annotation.concurrent.GuardedBy; + +public class YangStoreServiceImpl implements YangStoreService { + private final SchemaContextProvider service; + @GuardedBy("this") + private YangStoreSnapshotImpl cache = null; + + public YangStoreServiceImpl(SchemaContextProvider service) { + this.service = service; + } + + @Override + public synchronized YangStoreSnapshotImpl getYangStoreSnapshot() throws YangStoreException { + if (cache == null) { + cache = new YangStoreSnapshotImpl(service.getSchemaContext()); + } + return cache; + } + + /** + * Called when schema context changes, invalidates cache. + */ + public synchronized void refresh() { + cache = null; + } +} diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceTracker.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceTracker.java deleted file mode 100644 index 3b1e89d7df..0000000000 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreServiceTracker.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v1.0 which accompanies this distribution, - * and is available at http://www.eclipse.org/legal/epl-v10.html - */ - -package org.opendaylight.controller.netconf.confignetconfconnector.osgi; - -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -class YangStoreServiceTracker extends ServiceTracker { - private final YangStoreTrackerListener listener; - - YangStoreServiceTracker(BundleContext context, final YangStoreTrackerListener listener) { - super(context, YangStoreService.class, null); - this.listener = listener; - } - - @Override - public synchronized YangStoreService addingService(final ServiceReference reference) { - final YangStoreService yangStoreService = super.addingService(reference); - listener.onYangStoreAdded(yangStoreService); - return yangStoreService; - } - - @Override - public synchronized void removedService(final ServiceReference reference, - final YangStoreService service) { - listener.onYangStoreRemoved(); - } - - static interface YangStoreTrackerListener { - void onYangStoreAdded(YangStoreService yangStoreService); - void onYangStoreRemoved(); - } -} diff --git a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreSnapshot.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java similarity index 69% rename from opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreSnapshot.java rename to opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java index b912b0c7af..0454bad4ba 100644 --- a/opendaylight/config/yang-store-api/src/main/java/org/opendaylight/controller/config/yang/store/api/YangStoreSnapshot.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshot.java @@ -5,11 +5,12 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.config.yang.store.api; +package org.opendaylight.controller.netconf.confignetconfconnector.osgi; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; import java.util.Map; import java.util.Set; @@ -27,29 +28,13 @@ public interface YangStoreSnapshot extends AutoCloseable { Map> getQNamesToIdentitiesToModuleMXBeanEntries(); - /** - * Get number of parsed ModuleMXBeanEntry instances. - */ - int countModuleMXBeanEntries(); - /** * Get all modules discovered when this snapshot was created. * @return all modules discovered. If one module exists with two different revisions, return both. */ Set getModules(); - /** - * Get all modules together with their yang sources. - */ - Map getModulesToSources(); - - /** - * Retrieve source of module as it appeared during creation of this snapshot. - * @param module - * @return yang source of given module - * @throws java.lang.IllegalArgumentException if module does not belong to this snapshot - */ - String getModuleSource(Module module); + String getModuleSource(ModuleIdentifier moduleIdentifier); @Override void close(); diff --git a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/MbeParser.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshotImpl.java similarity index 52% rename from opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/MbeParser.java rename to opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshotImpl.java index dd07c5a84f..782998067f 100644 --- a/opendaylight/config/yang-store-impl/src/main/java/org/opendaylight/controller/config/yang/store/impl/MbeParser.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/YangStoreSnapshotImpl.java @@ -5,12 +5,10 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.config.yang.store.impl; -import com.google.common.collect.Lists; +package org.opendaylight.controller.netconf.confignetconfconnector.osgi; + import com.google.common.collect.Maps; -import org.apache.commons.io.IOUtils; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.controller.config.yangjmxgenerator.PackageTranslator; import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry; @@ -20,69 +18,62 @@ import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.io.InputStream; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; + +public class YangStoreSnapshotImpl implements YangStoreSnapshot { + private static final Logger logger = LoggerFactory.getLogger(YangStoreSnapshotImpl.class); + + + private final Map> moduleMXBeanEntryMap; + -public class MbeParser { - private static final Logger logger = LoggerFactory.getLogger(MbeParser.class); + private final Map> qNamesToIdentitiesToModuleMXBeanEntries; - public YangStoreSnapshotImpl parseYangFiles(Collection allInput) throws YangStoreException { - YangParserImpl parser = YangParserWrapper.getYangParserInstance(); + private final SchemaContext schemaContext; - Map allYangModules = YangParserWrapper.parseYangFiles(parser, allInput); - SchemaContext resolveSchemaContext = YangParserWrapper.getSchemaContextFromModules(parser, allYangModules); + public YangStoreSnapshotImpl(SchemaContext resolveSchemaContext) { logger.trace("Resolved modules:{}", resolveSchemaContext.getModules()); + this.schemaContext = resolveSchemaContext; // JMX generator Map namespaceToPackageMapping = Maps.newHashMap(); - PackageTranslator packageTranslator = new PackageTranslator( - namespaceToPackageMapping); - + PackageTranslator packageTranslator = new PackageTranslator(namespaceToPackageMapping); Map qNamesToSIEs = new HashMap<>(); - Map knownSEITracker = new HashMap<>(); // create SIE structure qNamesToSIEs for (Module module : resolveSchemaContext.getModules()) { String packageName = packageTranslator.getPackageName(module); Map namesToSIEntries = ServiceInterfaceEntry - .create(module, packageName,knownSEITracker); - - for (Entry sieEntry : namesToSIEntries - .entrySet()) { - + .create(module, packageName, knownSEITracker); + for (Entry sieEntry : namesToSIEntries.entrySet()) { // merge value into qNamesToSIEs if (qNamesToSIEs.containsKey(sieEntry.getKey()) == false) { qNamesToSIEs.put(sieEntry.getKey(), sieEntry.getValue()); } else { - throw new IllegalStateException( - "Cannot add two SIE with same qname " + throw new IllegalStateException("Cannot add two SIE with same qname " + sieEntry.getValue()); } } } Map> moduleMXBeanEntryMap = Maps.newHashMap(); - Map modulesToSources = new HashMap<>(); - Map> - qNamesToIdentitiesToModuleMXBeanEntries = new HashMap<>(); + + Map> qNamesToIdentitiesToModuleMXBeanEntries = new HashMap<>(); - for (Entry moduleEntry : allYangModules.entrySet()) { - Module module = moduleEntry.getValue(); + for (Module module : schemaContext.getModules()) { String packageName = packageTranslator.getPackageName(module); TypeProviderWrapper typeProviderWrapper = new TypeProviderWrapper( new TypeProviderImpl(resolveSchemaContext)); - String yangAsString = reReadInputStream(moduleEntry); QName qName = new QName(module.getNamespace(), module.getRevision(), module.getName()); @@ -90,43 +81,36 @@ public class MbeParser { Collections.unmodifiableMap(ModuleMXBeanEntry.create(module, qNamesToSIEs, resolveSchemaContext, typeProviderWrapper, packageName)); moduleMXBeanEntryMap.put(module.getNamespace().toString(), namesToMBEs); - modulesToSources.put(module, yangAsString); + qNamesToIdentitiesToModuleMXBeanEntries.put(qName, namesToMBEs); } + this.moduleMXBeanEntryMap = Collections.unmodifiableMap(moduleMXBeanEntryMap); + this.qNamesToIdentitiesToModuleMXBeanEntries = Collections.unmodifiableMap(qNamesToIdentitiesToModuleMXBeanEntries); - return new YangStoreSnapshotImpl(moduleMXBeanEntryMap, modulesToSources, qNamesToIdentitiesToModuleMXBeanEntries); } - private String reReadInputStream(Entry moduleEntry) { - String yangAsString; - try { - moduleEntry.getKey().reset(); - yangAsString = IOUtils.toString(moduleEntry.getKey()); - } catch (IOException e) { - throw new IllegalStateException("Cannot reread " + moduleEntry.getValue(), e); - } - return yangAsString; + @Override + public Map> getModuleMXBeanEntryMap() { + return moduleMXBeanEntryMap; } - @Deprecated - public Map parseYangFilesToString(Collection allYangs) { - - logger.error("Using deprecated method that will be removed soon", new UnsupportedOperationException("Deprecated")); - YangParserImpl parser = YangParserWrapper.getYangParserInstance(); + @Override + public Map> getQNamesToIdentitiesToModuleMXBeanEntries() { + return qNamesToIdentitiesToModuleMXBeanEntries; + } - Map allYangModules = parser - .parseYangModelsFromStreamsMapped(Lists.newArrayList(allYangs)); - Map retVal = new HashMap<>(); + @Override + public Set getModules() { + return schemaContext.getModules(); + } - for (Entry entry : allYangModules.entrySet()) { - try { - retVal.put(entry.getValue(), IOUtils.toString(entry.getKey())); - } catch (IOException e) { - throw new IllegalStateException( - "Can not create string from yang file."); - } - } - return retVal; + @Override + public String getModuleSource(org.opendaylight.yangtools.yang.model.api.ModuleIdentifier moduleIdentifier) { + return schemaContext.getModuleSource(moduleIdentifier).get(); } + @Override + public void close() { + + } } diff --git a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/util/Util.java b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/util/Util.java index fc8ddc01bd..d7f352af36 100644 --- a/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/util/Util.java +++ b/opendaylight/netconf/config-netconf-connector/src/main/java/org/opendaylight/controller/netconf/confignetconfconnector/util/Util.java @@ -11,22 +11,18 @@ package org.opendaylight.controller.netconf.confignetconfconnector.util; import com.google.common.base.Preconditions; import java.text.ParseException; -import java.text.SimpleDateFormat; import java.util.Date; -public final class Util { +import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat; - /** - * Used for date <-> xml serialization - */ - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); +public final class Util { public static String writeDate(final Date date) { - return dateFormat.format(date); + return getRevisionFormat().format(date); } public static Date readDate(final String s) throws ParseException { - return dateFormat.parse(s); + return getRevisionFormat().parse(s); } public static void checkType(final Object value, final Class clazz) { diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java index 41d91819a6..b52328f631 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/NetconfMappingTest.java @@ -8,33 +8,11 @@ package org.opendaylight.controller.netconf.confignetconfconnector; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.verifyNoMoreInteractions; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.math.BigInteger; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.ObjectName; -import javax.xml.parsers.ParserConfigurationException; - +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import org.apache.commons.lang3.StringUtils; import org.junit.Before; import org.junit.Ignore; @@ -49,8 +27,6 @@ import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnota import org.opendaylight.controller.config.manager.impl.AbstractConfigTest; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; -import org.opendaylight.controller.config.yang.store.impl.MbeParser; import org.opendaylight.controller.config.yang.test.impl.ComplexDtoBInner; import org.opendaylight.controller.config.yang.test.impl.ComplexList; import org.opendaylight.controller.config.yang.test.impl.Deep; @@ -72,6 +48,8 @@ import org.opendaylight.controller.netconf.confignetconfconnector.operations.edi import org.opendaylight.controller.netconf.confignetconfconnector.operations.get.Get; import org.opendaylight.controller.netconf.confignetconfconnector.operations.getconfig.GetConfig; import org.opendaylight.controller.netconf.confignetconfconnector.operations.runtimerpc.RuntimeRpc; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreServiceImpl; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.netconf.confignetconfconnector.transactions.TransactionProvider; import org.opendaylight.controller.netconf.impl.mapping.operations.DefaultCloseSession; import org.opendaylight.controller.netconf.impl.osgi.NetconfOperationRouterImpl; @@ -88,6 +66,7 @@ import org.opendaylight.yangtools.yang.data.impl.codec.CodecRegistry; import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec; import org.opendaylight.yangtools.yang.model.api.Module; import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -96,11 +75,32 @@ import org.w3c.dom.Element; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import com.google.common.collect.Sets; +import javax.management.InstanceAlreadyExistsException; +import javax.management.InstanceNotFoundException; +import javax.management.ObjectName; +import javax.xml.parsers.ParserConfigurationException; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigInteger; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; public class NetconfMappingTest extends AbstractConfigTest { @@ -590,7 +590,16 @@ public class NetconfMappingTest extends AbstractConfigTest { final List yangDependencies = getYangs(); final Map> mBeanEntries = Maps.newHashMap(); - mBeanEntries.putAll(new MbeParser().parseYangFiles(yangDependencies).getModuleMXBeanEntryMap()); + + YangParserImpl yangParser = new YangParserImpl(); + final SchemaContext schemaContext = yangParser.resolveSchemaContext(new HashSet<>(yangParser.parseYangModelsFromStreamsMapped(yangDependencies).values())); + YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(new SchemaContextProvider() { + @Override + public SchemaContext getSchemaContext() { + return schemaContext ; + } + }); + mBeanEntries.putAll(yangStoreService.getYangStoreSnapshot().getModuleMXBeanEntryMap()); return mBeanEntries; } diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java index b70a66f5ef..ae5a9930d2 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/operations/editconfig/EditConfigTest.java @@ -20,7 +20,7 @@ import org.opendaylight.controller.config.api.ServiceReferenceReadableRegistry; import org.opendaylight.controller.config.api.ValidationException; import org.opendaylight.controller.config.util.ConfigRegistryClient; import org.opendaylight.controller.config.util.ConfigTransactionClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes.fromxml.AttributeConfigElement; import org.opendaylight.controller.netconf.confignetconfconnector.mapping.config.InstanceConfigElementResolved; diff --git a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java index 13f8cad968..a063f5786a 100644 --- a/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java +++ b/opendaylight/netconf/config-netconf-connector/src/test/java/org/opendaylight/controller/netconf/confignetconfconnector/osgi/NetconfOperationServiceImplTest.java @@ -14,7 +14,6 @@ import org.junit.Assert; import org.junit.Test; import org.junit.matchers.JUnitMatchers; import org.opendaylight.controller.config.api.LookupRegistry; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry; import org.opendaylight.yangtools.yang.common.QName; diff --git a/opendaylight/netconf/netconf-impl/pom.xml b/opendaylight/netconf/netconf-impl/pom.xml index 85fff89777..76a0bd9908 100644 --- a/opendaylight/netconf/netconf-impl/pom.xml +++ b/opendaylight/netconf/netconf-impl/pom.xml @@ -72,11 +72,6 @@ test - - ${project.groupId} - yang-store-api - test - xmlunit xmlunit diff --git a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java index a81bbd62a0..7134f5c580 100644 --- a/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java +++ b/opendaylight/netconf/netconf-impl/src/main/java/org/opendaylight/controller/netconf/impl/mapping/operations/DefaultGetSchema.java @@ -8,9 +8,8 @@ package org.opendaylight.controller.netconf.impl.mapping.operations; -import java.util.HashMap; -import java.util.Map; - +import com.google.common.base.Optional; +import com.google.common.collect.Maps; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.impl.mapping.CapabilityProvider; import org.opendaylight.controller.netconf.util.mapping.AbstractLastNetconfOperation; @@ -22,8 +21,8 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; import org.w3c.dom.Element; -import com.google.common.base.Optional; -import com.google.common.collect.Maps; +import java.util.HashMap; +import java.util.Map; public final class DefaultGetSchema extends AbstractLastNetconfOperation { public static final String GET_SCHEMA = "get-schema"; diff --git a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java index 43854374a0..07da7f990a 100644 --- a/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java +++ b/opendaylight/netconf/netconf-impl/src/test/java/org/opendaylight/controller/netconf/impl/ConcurrentClientsTest.java @@ -8,36 +8,17 @@ package org.opendaylight.controller.netconf.impl; -import static com.google.common.base.Preconditions.checkNotNull; -import static org.junit.Assert.fail; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; - -import java.io.DataOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.management.ManagementFactory; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import javax.management.ObjectName; - +import com.google.common.base.Optional; +import com.google.common.collect.Sets; +import io.netty.channel.ChannelFuture; +import io.netty.channel.EventLoopGroup; +import io.netty.channel.nio.NioEventLoopGroup; +import io.netty.util.HashedWheelTimer; import org.apache.commons.io.IOUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.config.util.ConfigRegistryJMXClient; -import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; import org.opendaylight.controller.netconf.api.NetconfDocumentedException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.client.NetconfClient; @@ -57,13 +38,22 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.w3c.dom.Document; -import com.google.common.base.Optional; -import com.google.common.collect.Sets; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.lang.management.ManagementFactory; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Set; -import io.netty.channel.ChannelFuture; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.util.HashedWheelTimer; +import static com.google.common.base.Preconditions.checkNotNull; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.doNothing; +import static org.mockito.MockitoAnnotations.initMocks; public class ConcurrentClientsTest { @@ -71,11 +61,6 @@ public class ConcurrentClientsTest { private EventLoopGroup nettyGroup; private NetconfClientDispatcher netconfClientDispatcher; - @Mock - private YangStoreService yangStoreService; - @Mock - private ConfigRegistryJMXClient jmxClient; - private final InetSocketAddress netconfAddress = new InetSocketAddress("127.0.0.1", 8303); static final Logger logger = LoggerFactory.getLogger(ConcurrentClientsTest.class); @@ -90,18 +75,7 @@ public class ConcurrentClientsTest { @Before public void setUp() throws Exception { - { // init mocks - MockitoAnnotations.initMocks(this); - final YangStoreSnapshot yStore = mock(YangStoreSnapshot.class); - doReturn(yStore).when(this.yangStoreService).getYangStoreSnapshot(); - doReturn(Collections.emptyMap()).when(yStore).getModuleMXBeanEntryMap(); - - final ConfigTransactionJMXClient mockedTCl = mock(ConfigTransactionJMXClient.class); - doReturn(mockedTCl).when(this.jmxClient).getConfigTransactionClient(any(ObjectName.class)); - - doReturn(Collections.emptySet()).when(jmxClient).lookupConfigBeans(); - } - + initMocks(this); nettyGroup = new NioEventLoopGroup(); NetconfHelloMessageAdditionalHeader additionalHeader = new NetconfHelloMessageAdditionalHeader("uname", "10.10.10.1", "830", "tcp", "client"); netconfClientDispatcher = new NetconfClientDispatcher( nettyGroup, nettyGroup, additionalHeader, 5000); diff --git a/opendaylight/netconf/netconf-it/pom.xml b/opendaylight/netconf/netconf-it/pom.xml index 57067f47ec..aab939e8d9 100644 --- a/opendaylight/netconf/netconf-it/pom.xml +++ b/opendaylight/netconf/netconf-it/pom.xml @@ -23,11 +23,6 @@ config-util test - - ${project.groupId} - yang-store-api - test - ${project.groupId} netconf-api @@ -103,17 +98,6 @@ ${config.version} test - - ${project.groupId} - yang-store-impl - test - - - ${project.groupId} - yang-store-impl - test - test-jar - org.opendaylight.controller logback-config diff --git a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/HardcodedYangStoreService.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/HardcodedYangStoreService.java similarity index 54% rename from opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/HardcodedYangStoreService.java rename to opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/HardcodedYangStoreService.java index 6221682147..d7f77148e8 100644 --- a/opendaylight/config/yang-store-impl/src/test/java/org/opendaylight/controller/config/yang/store/impl/HardcodedYangStoreService.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/HardcodedYangStoreService.java @@ -5,24 +5,30 @@ * terms of the Eclipse Public License v1.0 which accompanies this distribution, * and is available at http://www.eclipse.org/legal/epl-v10.html */ -package org.opendaylight.controller.config.yang.store.impl; +package org.opendaylight.controller.netconf.it; import org.apache.commons.io.IOUtils; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.api.YangStoreService; -import org.opendaylight.controller.config.yang.store.api.YangStoreSnapshot; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreService; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreServiceImpl; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreSnapshot; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.api.SchemaContextProvider; +import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; +import java.util.List; import static org.junit.Assert.assertNotNull; public class HardcodedYangStoreService implements YangStoreService { - private final Collection byteArrayInputStreams; + private final List byteArrayInputStreams; public HardcodedYangStoreService( Collection inputStreams) @@ -46,6 +52,15 @@ public class HardcodedYangStoreService implements YangStoreService { throw new RuntimeException(e); } } - return new MbeParser().parseYangFiles(byteArrayInputStreams); + + YangParserImpl yangParser = new YangParserImpl(); + final SchemaContext schemaContext = yangParser.resolveSchemaContext(new HashSet<>(yangParser.parseYangModelsFromStreamsMapped(byteArrayInputStreams).values())); + YangStoreServiceImpl yangStoreService = new YangStoreServiceImpl(new SchemaContextProvider() { + @Override + public SchemaContext getSchemaContext() { + return schemaContext ; + } + }); + return yangStoreService.getYangStoreSnapshot(); } } diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java index 1035c9f9fe..19007cd037 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfConfigPersisterITTest.java @@ -7,27 +7,9 @@ */ package org.opendaylight.controller.netconf.it; -import static junit.framework.Assert.assertEquals; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.anyLong; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; +import com.google.common.collect.Lists; +import com.google.common.collect.Sets; import io.netty.channel.ChannelFuture; - -import java.io.IOException; -import java.io.InputStream; -import java.net.InetSocketAddress; -import java.util.Collection; -import java.util.List; -import java.util.Set; -import java.util.regex.Pattern; - -import javax.management.InstanceNotFoundException; -import javax.management.Notification; -import javax.management.NotificationListener; - import org.apache.commons.lang3.StringUtils; import org.junit.After; import org.junit.Assert; @@ -40,8 +22,7 @@ import org.opendaylight.controller.config.manager.impl.factoriesresolver.Hardcod import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder; import org.opendaylight.controller.config.persist.api.Persister; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.api.jmx.CommitJMXNotification; import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession; @@ -64,8 +45,24 @@ import org.opendaylight.controller.netconf.util.test.XmlFileLoader; import org.opendaylight.controller.netconf.util.xml.XmlUtil; import org.w3c.dom.Element; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; +import javax.management.InstanceNotFoundException; +import javax.management.Notification; +import javax.management.NotificationListener; +import java.io.IOException; +import java.io.InputStream; +import java.net.InetSocketAddress; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.regex.Pattern; + +import static junit.framework.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Matchers.anyLong; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; public class NetconfConfigPersisterITTest extends AbstractNetconfConfigTest { diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index 44775fdf93..6989bf512f 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -14,8 +14,7 @@ import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException; import org.opendaylight.controller.netconf.client.NetconfClient; import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; import org.opendaylight.controller.netconf.confignetconfconnector.osgi.NetconfOperationServiceFactoryImpl; diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java index fce3f70e73..677d0dff8c 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITTest.java @@ -42,8 +42,7 @@ import org.junit.Test; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.spi.ModuleFactory; import org.opendaylight.controller.config.util.ConfigTransactionJMXClient; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException; import org.opendaylight.controller.config.yang.test.impl.DepTestImplModuleFactory; import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleFactory; import org.opendaylight.controller.config.yang.test.impl.NetconfTestImplModuleMXBean; diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java index 7a840be02a..4af66532a1 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfMonitoringITTest.java @@ -30,8 +30,7 @@ import org.junit.matchers.JUnitMatchers; import org.mockito.Mock; import org.opendaylight.controller.config.manager.impl.factoriesresolver.HardcodedModuleFactoriesResolver; import org.opendaylight.controller.config.spi.ModuleFactory; -import org.opendaylight.controller.config.yang.store.api.YangStoreException; -import org.opendaylight.controller.config.yang.store.impl.HardcodedYangStoreService; +import org.opendaylight.controller.netconf.confignetconfconnector.osgi.YangStoreException; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.api.monitoring.NetconfManagementSession; import org.opendaylight.controller.netconf.client.NetconfClient; diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java index 4e536c43bd..5fd9f2fcd1 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/pax/IdentityRefNetconfTest.java @@ -7,20 +7,8 @@ */ package org.opendaylight.controller.netconf.it.pax; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles; -import static org.ops4j.pax.exam.CoreOptions.mavenBundle; -import static org.ops4j.pax.exam.CoreOptions.options; -import static org.ops4j.pax.exam.CoreOptions.systemProperty; - -import javax.inject.Inject; -import javax.xml.parsers.ParserConfigurationException; - import com.google.common.base.Preconditions; +import com.google.common.base.Throwables; import io.netty.channel.nio.NioEventLoopGroup; import org.junit.Assert; import org.junit.Test; @@ -39,16 +27,29 @@ import org.ops4j.pax.exam.util.Filter; import org.w3c.dom.Document; import org.xml.sax.SAXException; +import javax.inject.Inject; +import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.InputStream; import java.net.InetSocketAddress; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; +import static org.junit.Assert.fail; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; + @RunWith(PaxExam.class) public class IdentityRefNetconfTest { - public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 5000; + public static final int CLIENT_CONNECTION_TIMEOUT_MILLIS = 15000; // Wait for controller to start @Inject @@ -84,31 +85,37 @@ public class IdentityRefNetconfTest { private static final InetSocketAddress tcpAddress = new InetSocketAddress("127.0.0.1", 18383); + @Test public void testIdRef() throws Exception { - Preconditions.checkNotNull(broker, "Controller not initialized"); - - NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup(); - NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup, - CLIENT_CONNECTION_TIMEOUT_MILLIS); - - NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml"); - NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml"); - NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml"); - - try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) { - sendMessage(edit, netconfClient); - sendMessage(commit, netconfClient); - sendMessage(getConfig, netconfClient, "id-test", - "prefix:test-identity1", - "prefix:test-identity2", - "prefix:test-identity2", - "prefix:test-identity1"); - } + try { + Preconditions.checkNotNull(broker, "Controller not initialized"); + + NioEventLoopGroup nettyThreadgroup = new NioEventLoopGroup(); + NetconfClientDispatcher clientDispatcher = new NetconfClientDispatcher(nettyThreadgroup, nettyThreadgroup, + CLIENT_CONNECTION_TIMEOUT_MILLIS); + + NetconfMessage edit = xmlFileToNetconfMessage("netconfMessages/editConfig_identities.xml"); + NetconfMessage commit = xmlFileToNetconfMessage("netconfMessages/commit.xml"); + NetconfMessage getConfig = xmlFileToNetconfMessage("netconfMessages/getConfig.xml"); + + try (NetconfClient netconfClient = new NetconfClient("client", tcpAddress, CLIENT_CONNECTION_TIMEOUT_MILLIS, clientDispatcher)) { + sendMessage(edit, netconfClient); + sendMessage(commit, netconfClient); + sendMessage(getConfig, netconfClient, "id-test", + "prefix:test-identity1", + "prefix:test-identity2", + "prefix:test-identity2", + "prefix:test-identity1"); + } - clientDispatcher.close(); + clientDispatcher.close(); + } catch (Exception e) { + fail(Throwables.getStackTraceAsString(e)); + } } + private void sendMessage(NetconfMessage edit, NetconfClient netconfClient, String... containingResponse) throws ExecutionException, InterruptedException, TimeoutException { NetconfMessage response = netconfClient.sendRequest(edit).get(); diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index ae75657e5a..e7b9a02552 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -97,22 +97,6 @@ config-util ${config.version} - - ${project.groupId} - yang-store-api - ${config.version} - - - ${project.groupId} - yang-store-impl - ${config.version} - - - ${project.groupId} - yang-store-impl - ${config.version} - test-jar - ${project.groupId} yang-test -- 2.36.6