use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.
the class DependencyResolverImpl method resolveModuleInstance.
private Module resolveModuleInstance(final ObjectName dependentReadOnlyON, final JmxAttribute jmxAttribute) {
Preconditions.checkArgument(dependentReadOnlyON != null, "dependentReadOnlyON");
Preconditions.checkArgument(jmxAttribute != null, "jmxAttribute");
final ObjectName translatedDependentReadOnlyON = translateServiceRefIfPossible(dependentReadOnlyON);
this.transactionStatus.checkCommitStarted();
this.transactionStatus.checkNotCommitted();
final ModuleIdentifier dependentModuleIdentifier = ObjectNameUtil.fromON(translatedDependentReadOnlyON, ObjectNameUtil.TYPE_MODULE);
return Preconditions.checkNotNull(this.modulesHolder.findModule(dependentModuleIdentifier, jmxAttribute));
}
use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.
the class ConfigTransactionControllerImpl method copyExistingModule.
@SuppressWarnings("IllegalCatch")
private synchronized void copyExistingModule(final ModuleInternalInfo oldConfigBeanInfo) throws InstanceAlreadyExistsException {
transactionStatus.checkNotCommitStarted();
transactionStatus.checkNotAborted();
ModuleIdentifier moduleIdentifier = oldConfigBeanInfo.getIdentifier();
dependencyResolverManager.assertNotExists(moduleIdentifier);
ModuleFactory moduleFactory;
BundleContext bc;
try {
moduleFactory = factoriesHolder.findByModuleName(moduleIdentifier.getFactoryName());
bc = getModuleFactoryBundleContext(moduleFactory.getImplementationName());
} catch (final ModuleFactoryNotFoundException e) {
throw new IllegalStateException(e);
}
Module module;
DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(moduleIdentifier);
try {
module = moduleFactory.createModule(moduleIdentifier.getInstanceName(), dependencyResolver, oldConfigBeanInfo.getReadableModule(), bc);
} catch (final Exception e) {
throw new IllegalStateException(String.format("Error while copying old configuration from %s to %s", oldConfigBeanInfo, moduleFactory), e);
}
putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, oldConfigBeanInfo, dependencyResolver, oldConfigBeanInfo.isDefaultBean(), bc);
}
use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.
the class ConfigTransactionControllerImpl method createModule.
@Override
public synchronized ObjectName createModule(final String factoryName, final String instanceName) throws InstanceAlreadyExistsException {
transactionStatus.checkNotCommitStarted();
transactionStatus.checkNotAborted();
ModuleIdentifier moduleIdentifier = new ModuleIdentifier(factoryName, instanceName);
dependencyResolverManager.assertNotExists(moduleIdentifier);
// find factory
ModuleFactory moduleFactory = factoriesHolder.findByModuleName(factoryName);
DependencyResolver dependencyResolver = dependencyResolverManager.getOrCreate(moduleIdentifier);
BundleContext bundleContext = getModuleFactoryBundleContext(moduleFactory.getImplementationName());
Module module = moduleFactory.createModule(instanceName, dependencyResolver, bundleContext);
boolean defaultBean = false;
return putConfigBeanToJMXAndInternalMaps(moduleIdentifier, module, moduleFactory, null, dependencyResolver, defaultBean, bundleContext);
}
use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.
the class ConfigTransactionControllerImpl method validateNoLocks.
@SuppressWarnings("IllegalCatch")
private void validateNoLocks() throws ValidationException {
transactionStatus.checkNotAborted();
LOG.trace("Validating transaction {}", getTransactionIdentifier());
// call validate()
List<ValidationException> collectedExceptions = new ArrayList<>();
for (Entry<ModuleIdentifier, Module> entry : dependencyResolverManager.getAllModules().entrySet()) {
ModuleIdentifier name = entry.getKey();
Module module = entry.getValue();
try {
module.validate();
} catch (final Exception e) {
LOG.warn("Validation exception in {}", getTransactionName(), e);
collectedExceptions.add(ValidationException.createForSingleException(name, e));
}
}
if (!collectedExceptions.isEmpty()) {
throw ValidationException.createFromCollectedValidationExceptions(collectedExceptions);
}
LOG.trace("Validated transaction {}", getTransactionIdentifier());
}
use of org.opendaylight.controller.config.api.ModuleIdentifier in project controller by opendaylight.
the class DependencyResolverManagerTest method mockedModule.
private static Module mockedModule() {
Module mockedModule = mock(Module.class);
doReturn(mock(AutoCloseable.class)).when(mockedModule).getInstance();
doReturn(new ModuleIdentifier("fact", "instance")).when(mockedModule).getIdentifier();
return mockedModule;
}
Aggregations