Search in sources :

Example 1 with ModuleInfoBackedContext

use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.

the class ConfigManagerActivator method start.

@Override
public void start(final BundleContext context) {
    LOG.info("Config manager starting...");
    try {
        // the inner strategy is backed by thread context cl?
        final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
        final BindingContextProvider bindingContextProvider = new BindingContextProvider();
        final RefreshingSCPModuleInfoRegistry moduleInfoRegistryWrapper = new RefreshingSCPModuleInfoRegistry(moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, moduleInfoBackedContext, bindingContextProvider, context);
        final ModuleInfoBundleTracker moduleInfoBundleTracker = new ModuleInfoBundleTracker(moduleInfoRegistryWrapper);
        // start config registry
        final BundleContextBackedModuleFactoriesResolver bundleContextBackedModuleFactoriesResolver = new BundleContextBackedModuleFactoriesResolver(context);
        this.configRegistry = new ConfigRegistryImpl(bundleContextBackedModuleFactoriesResolver, this.configMBeanServer, bindingContextProvider);
        // track bundles containing factories
        final BlankTransactionServiceTracker blankTransactionServiceTracker = new BlankTransactionServiceTracker(this.configRegistry);
        final ModuleFactoryBundleTracker moduleFactoryTracker = new ModuleFactoryBundleTracker(blankTransactionServiceTracker);
        BundleTracker<Collection<ObjectRegistration<YangModuleInfo>>> moduleInfoResolvedBundleTracker = new BundleTracker<>(context, Bundle.RESOLVED | Bundle.STARTING | Bundle.STOPPING | Bundle.ACTIVE, moduleInfoBundleTracker);
        ExtensibleBundleTracker<?> moduleFactoryBundleTracker = new ExtensibleBundleTracker<>(context, moduleFactoryTracker);
        moduleInfoBundleTracker.open(moduleInfoResolvedBundleTracker);
        // start extensible tracker
        moduleFactoryBundleTracker.open();
        // Wrap config registry with JMX notification publishing adapter
        final JMXNotifierConfigRegistry notifyingConfigRegistry = new JMXNotifierConfigRegistry(this.configRegistry, this.configMBeanServer);
        // register config registry to OSGi
        final AutoCloseable clsReg = OsgiRegistrationUtil.registerService(context, moduleInfoBackedContext, ClassLoadingStrategy.class);
        final AutoCloseable configRegReg = OsgiRegistrationUtil.registerService(context, notifyingConfigRegistry, ConfigRegistry.class);
        // register config registry to jmx
        final ConfigRegistryJMXRegistrator configRegistryJMXRegistrator = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
        try {
            configRegistryJMXRegistrator.registerToJMXNoNotifications(this.configRegistry);
        } catch (final InstanceAlreadyExistsException e) {
            configRegistryJMXRegistrator.close();
            throw new IllegalStateException("Config Registry was already registered to JMX", e);
        }
        // register config registry to jmx
        final ConfigRegistryJMXRegistrator configRegistryJMXRegistratorWithNotifications = new ConfigRegistryJMXRegistrator(this.configMBeanServer);
        try {
            configRegistryJMXRegistrator.registerToJMX(notifyingConfigRegistry);
        } catch (final InstanceAlreadyExistsException e) {
            configRegistryJMXRegistrator.close();
            configRegistryJMXRegistratorWithNotifications.close();
            throw new IllegalStateException("Config Registry was already registered to JMX", e);
        }
        // TODO wire directly via moduleInfoBundleTracker
        final ServiceTracker<ModuleFactory, Object> serviceTracker = new ServiceTracker<>(context, ModuleFactory.class, blankTransactionServiceTracker);
        serviceTracker.open();
        final AutoCloseable configMgrReg = OsgiRegistrationUtil.registerService(context, this, ConfigSystemService.class);
        final List<AutoCloseable> list = Arrays.asList(bindingContextProvider, clsReg, OsgiRegistrationUtil.wrap(moduleFactoryBundleTracker), moduleInfoBundleTracker, configRegReg, configRegistryJMXRegistrator, configRegistryJMXRegistratorWithNotifications, OsgiRegistrationUtil.wrap(serviceTracker), moduleInfoRegistryWrapper, notifyingConfigRegistry, configMgrReg);
        this.autoCloseable = OsgiRegistrationUtil.aggregate(list);
        context.addBundleListener(this);
    } catch (final IllegalStateException e) {
        LOG.error("Error starting config manager", e);
    }
    LOG.info("Config manager start complete");
}
Also used : ModuleInfoBundleTracker(org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker) JMXNotifierConfigRegistry(org.opendaylight.controller.config.manager.impl.jmx.JMXNotifierConfigRegistry) ServiceTracker(org.osgi.util.tracker.ServiceTracker) BindingContextProvider(org.opendaylight.controller.config.manager.impl.osgi.mapping.BindingContextProvider) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) ConfigRegistryJMXRegistrator(org.opendaylight.controller.config.manager.impl.jmx.ConfigRegistryJMXRegistrator) ModuleInfoBundleTracker(org.opendaylight.controller.config.manager.impl.osgi.mapping.ModuleInfoBundleTracker) BundleTracker(org.osgi.util.tracker.BundleTracker) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) ModuleFactory(org.opendaylight.controller.config.spi.ModuleFactory) ConfigRegistryImpl(org.opendaylight.controller.config.manager.impl.ConfigRegistryImpl) YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) RefreshingSCPModuleInfoRegistry(org.opendaylight.controller.config.manager.impl.osgi.mapping.RefreshingSCPModuleInfoRegistry) Collection(java.util.Collection)

Example 2 with ModuleInfoBackedContext

use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.

the class BindingTestContext method getContext.

private SchemaContext getContext(final ImmutableSet<YangModuleInfo> moduleInfos) {
    final ModuleInfoBackedContext ctx = ModuleInfoBackedContext.create();
    ctx.addModuleInfos(moduleInfos);
    return ctx.tryToCreateSchemaContext().get();
}
Also used : ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)

Example 3 with ModuleInfoBackedContext

use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.

the class AbstractSchemaAwareTest method getSchemaContext.

protected SchemaContext getSchemaContext() throws Exception {
    final Iterable<YangModuleInfo> moduleInfos = getModuleInfos();
    final ModuleInfoBackedContext moduleContext = ModuleInfoBackedContext.create();
    moduleContext.addModuleInfos(moduleInfos);
    return moduleContext.tryToCreateSchemaContext().get();
}
Also used : YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)

Example 4 with ModuleInfoBackedContext

use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project controller by opendaylight.

the class SchemaUpdateForTransactionTest method loadSchemas.

public void loadSchemas(final Class<?>... classes) throws Exception {
    final ModuleInfoBackedContext context = ModuleInfoBackedContext.create();
    for (final Class<?> clz : classes) {
        YangModuleInfo moduleInfo = BindingReflections.getModuleInfo(clz);
        context.registerModuleInfo(moduleInfo);
    }
    this.schemaContext = context.tryToCreateSchemaContext().get();
    this.domStore.onGlobalContextUpdated(this.schemaContext);
}
Also used : YangModuleInfo(org.opendaylight.yangtools.yang.binding.YangModuleInfo) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)

Example 5 with ModuleInfoBackedContext

use of org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext in project bgpcep by opendaylight.

the class AbstractAddPathTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    this.ribActivator = new RIBActivator();
    this.ribExtension = new SimpleRIBExtensionProviderContext();
    this.ribActivator.startRIBExtensionProvider(this.ribExtension);
    this.bgpActivator = new BGPActivator();
    this.inetActivator = new org.opendaylight.protocol.bgp.inet.BGPActivator();
    this.context = new SimpleBGPExtensionProviderContext();
    this.bgpActivator.start(this.context);
    this.inetActivator.start(this.context);
    this.mappingService = new BindingToNormalizedNodeCodec(GeneratedClassLoadingStrategy.getTCCLClassLoadingStrategy(), new BindingNormalizedNodeCodecRegistry(StreamWriterGenerator.create(JavassistUtils.forClassPool(ClassPool.getDefault()))));
    final ModuleInfoBackedContext moduleInfoBackedContext = ModuleInfoBackedContext.create();
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpParameters.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MultiprotocolCapability.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(DestinationIpv4Case.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(AdvertizedRoutes.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(BgpRib.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(Attributes1.class));
    moduleInfoBackedContext.registerModuleInfo(BindingReflections.getModuleInfo(MpReachNlri.class));
    this.mappingService.onGlobalContextUpdated(moduleInfoBackedContext.tryToCreateSchemaContext().get());
    this.schemaContext = moduleInfoBackedContext.getSchemaContext();
    if (!Epoll.isAvailable()) {
        this.worker = new NioEventLoopGroup();
        this.boss = new NioEventLoopGroup();
    }
    this.serverRegistry = new StrictBGPPeerRegistry();
    this.serverDispatcher = new BGPDispatcherImpl(this.context.getMessageRegistry(), this.boss, this.worker, this.serverRegistry);
    doReturn(Mockito.mock(ClusterSingletonServiceRegistration.class)).when(this.clusterSingletonServiceProvider).registerClusterSingletonService(any(ClusterSingletonService.class));
    this.codecsRegistry = CodecsRegistryImpl.create(this.mappingService.getCodecFactory(), this.ribExtension.getClassLoadingStrategy());
}
Also used : RIBActivator(org.opendaylight.protocol.bgp.inet.RIBActivator) BGPActivator(org.opendaylight.protocol.bgp.parser.impl.BGPActivator) AdvertizedRoutes(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes) BindingToNormalizedNodeCodec(org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec) BindingNormalizedNodeCodecRegistry(org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry) Attributes1(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.Attributes1) BgpParameters(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters) ModuleInfoBackedContext(org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext) SimpleRIBExtensionProviderContext(org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext) SimpleBGPExtensionProviderContext(org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext) MultiprotocolCapability(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability) ClusterSingletonServiceRegistration(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration) ClusterSingletonService(org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService) MpReachNlri(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.MpReachNlri) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) DestinationIpv4Case(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case) BgpRib(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev171207.BgpRib) Before(org.junit.Before)

Aggregations

ModuleInfoBackedContext (org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext)8 YangModuleInfo (org.opendaylight.yangtools.yang.binding.YangModuleInfo)4 Before (org.junit.Before)3 ClusterSingletonService (org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService)3 RIBActivator (org.opendaylight.protocol.bgp.inet.RIBActivator)3 SimpleRIBExtensionProviderContext (org.opendaylight.protocol.bgp.rib.spi.SimpleRIBExtensionProviderContext)3 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)2 BindingToNormalizedNodeCodec (org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec)2 BindingNormalizedNodeCodecRegistry (org.opendaylight.mdsal.binding.dom.codec.impl.BindingNormalizedNodeCodecRegistry)2 ClusterSingletonServiceRegistration (org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration)2 BGPActivator (org.opendaylight.protocol.bgp.parser.impl.BGPActivator)2 SimpleBGPExtensionProviderContext (org.opendaylight.protocol.bgp.parser.spi.pojo.SimpleBGPExtensionProviderContext)2 DestinationIpv4Case (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case)2 BgpParameters (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.BgpParameters)2 MultiprotocolCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.mp.capabilities.MultiprotocolCapability)2 AdvertizedRoutes (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev171207.update.attributes.mp.reach.nlri.AdvertizedRoutes)2 InetSocketAddress (java.net.InetSocketAddress)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1