Search in sources :

Example 1 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class ShutdownModuleFactory method getDefaultModules.

@Override
public Set<ShutdownModule> getDefaultModules(final DependencyResolverFactory dependencyResolverFactory, final BundleContext bundleContext) {
    ModuleIdentifier id = new ModuleIdentifier(NAME, NAME);
    DependencyResolver dependencyResolver = dependencyResolverFactory.createDependencyResolver(id);
    ShutdownModule shutdownModule = instantiateModule(NAME, dependencyResolver, bundleContext);
    return new java.util.HashSet<>(Arrays.asList(shutdownModule));
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) DependencyResolver(org.opendaylight.controller.config.api.DependencyResolver)

Example 2 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class BlueprintContainerRestartServiceImpl method restartConfigModules.

private void restartConfigModules(final List<Entry<String, ModuleIdentifier>> configModules, final ConfigSubsystemFacade configFacade) throws ParserConfigurationException, DocumentedException, ValidationException, ConflictingVersionException {
    Document document = XmlUtil.newDocument();
    Element dataElement = XmlUtil.createElement(document, XmlMappingConstants.DATA_KEY, Optional.<String>absent());
    Element modulesElement = XmlUtil.createElement(document, XmlMappingConstants.MODULES_KEY, Optional.of(XmlMappingConstants.URN_OPENDAYLIGHT_PARAMS_XML_NS_YANG_CONTROLLER_CONFIG));
    dataElement.appendChild(modulesElement);
    Config configMapping = configFacade.getConfigMapping();
    ConfigRegistry configRegistryClient = new ConfigRegistryJMXClient(ManagementFactory.getPlatformMBeanServer());
    for (Entry<String, ModuleIdentifier> entry : configModules) {
        String moduleNamespace = entry.getKey();
        ModuleIdentifier moduleId = entry.getValue();
        try {
            ObjectName instanceON = configRegistryClient.lookupConfigBean(moduleId.getFactoryName(), moduleId.getInstanceName());
            LOG.debug("Found config module instance ObjectName: {}", instanceON);
            Element moduleElement = configMapping.moduleToXml(moduleNamespace, moduleId.getFactoryName(), moduleId.getInstanceName(), instanceON, document);
            modulesElement.appendChild(moduleElement);
        } catch (final InstanceNotFoundException e) {
            LOG.warn("Error looking up config module: namespace {}, module name {}, instance {}", moduleNamespace, moduleId.getFactoryName(), moduleId.getInstanceName(), e);
        }
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Pushing config xml: {}", XmlUtil.toString(dataElement));
    }
    ConfigExecution execution = new ConfigExecution(configMapping, XmlElement.fromDomElement(dataElement), TestOption.testThenSet, EditStrategyType.recreate);
    configFacade.executeConfigExecution(execution);
    configFacade.commitSilentTransaction();
}
Also used : ConfigRegistry(org.opendaylight.controller.config.api.ConfigRegistry) Config(org.opendaylight.controller.config.facade.xml.mapping.config.Config) ConfigExecution(org.opendaylight.controller.config.facade.xml.ConfigExecution) XmlElement(org.opendaylight.controller.config.util.xml.XmlElement) Element(org.w3c.dom.Element) InstanceNotFoundException(javax.management.InstanceNotFoundException) ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) Document(org.w3c.dom.Document) ConfigRegistryJMXClient(org.opendaylight.controller.config.util.ConfigRegistryJMXClient) ObjectName(javax.management.ObjectName)

Example 3 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method removeServiceReference.

private synchronized void removeServiceReference(final ServiceReference serviceReference) throws InstanceNotFoundException {
    LOG.debug("Removing service reference {} from {}", serviceReference, this);
    assertWritable();
    // is the qName known?
    if (!allQNames.contains(serviceReference.getServiceInterfaceQName())) {
        LOG.error("Cannot find qname {} in {}", serviceReference.getServiceInterfaceQName(), allQNames);
        throw new IllegalArgumentException("Cannot find service interface " + serviceReference.getServiceInterfaceQName());
    }
    ModuleIdentifier removed = refNames.remove(serviceReference);
    if (removed == null) {
        throw new InstanceNotFoundException("Cannot find " + serviceReference.getServiceInterfaceQName());
    }
    Entry<ServiceReferenceMXBeanImpl, ServiceReferenceJMXRegistration> entry = managementBeans.remove(serviceReference);
    if (entry == null) {
        throw new IllegalStateException("Possible code error: cannot remove from mBeans: " + serviceReference);
    }
    entry.getValue().close();
}
Also used : ServiceReferenceMXBeanImpl(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl) InstanceNotFoundException(javax.management.InstanceNotFoundException) ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ServiceReferenceJMXRegistration(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceJMXRegistration)

Example 4 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method lookupConfigBeanByServiceInterfaceName.

@Override
public synchronized ObjectName lookupConfigBeanByServiceInterfaceName(final String serviceInterfaceQName, final String refName) {
    ServiceReference serviceReference = new ServiceReference(serviceInterfaceQName, refName);
    ModuleIdentifier moduleIdentifier = refNames.get(serviceReference);
    if (moduleIdentifier == null) {
        LOG.error("Cannot find qname {} and refName {} in {}", serviceInterfaceQName, refName, refName);
        throw new IllegalArgumentException("Cannot find " + serviceReference);
    }
    return getObjectName(moduleIdentifier);
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) ServiceReference(org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)

Example 5 with ModuleIdentifier

use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.

the class DependencyResolverImpl method canReuseDependency.

@Override
public boolean canReuseDependency(final ObjectName objectName, final JmxAttribute jmxAttribute) {
    Preconditions.checkNotNull(objectName);
    Preconditions.checkNotNull(jmxAttribute);
    final Module currentModule = resolveModuleInstance(objectName, jmxAttribute);
    final ModuleIdentifier identifier = currentModule.getIdentifier();
    final ModuleInternalTransactionalInfo moduleInternalTransactionalInfo = this.modulesHolder.findModuleInternalTransactionalInfo(identifier);
    if (moduleInternalTransactionalInfo.hasOldModule()) {
        final Module oldModule = moduleInternalTransactionalInfo.getOldInternalInfo().getReadableModule().getModule();
        return currentModule.canReuse(oldModule);
    }
    return false;
}
Also used : ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) Module(org.opendaylight.controller.config.spi.Module)

Aggregations

ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)30 Module (org.opendaylight.controller.config.spi.Module)11 ObjectName (javax.management.ObjectName)9 AbstractModule (org.opendaylight.controller.config.spi.AbstractModule)6 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)5 InstanceNotFoundException (javax.management.InstanceNotFoundException)5 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)5 DependencyResolver (org.opendaylight.controller.config.api.DependencyResolver)4 BundleContext (org.osgi.framework.BundleContext)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ValidationException (org.opendaylight.controller.config.api.ValidationException)3 ServiceInterfaceAnnotation (org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 ModuleFactoryNotFoundException (org.opendaylight.controller.config.api.ModuleFactoryNotFoundException)2 ModuleInternalTransactionalInfo (org.opendaylight.controller.config.manager.impl.dependencyresolver.ModuleInternalTransactionalInfo)2 RootRuntimeBeanRegistratorImpl (org.opendaylight.controller.config.manager.impl.jmx.RootRuntimeBeanRegistratorImpl)2 ServiceReference (org.opendaylight.controller.config.manager.impl.jmx.ServiceReference)2 ServiceReferenceMXBeanImpl (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl)2