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));
}
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();
}
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();
}
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);
}
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;
}
Aggregations