use of org.opendaylight.controller.config.api.ModuleFactoryNotFoundException 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.ModuleFactoryNotFoundException in project controller by opendaylight.
the class ConfigPusherImpl method pushConfig.
private synchronized boolean pushConfig(final ConfigSnapshotHolder configSnapshotHolder) throws ConfigSnapshotFailureException, ConflictingVersionException {
Element xmlToBePersisted;
try {
xmlToBePersisted = XmlUtil.readXmlToElement(configSnapshotHolder.getConfigSnapshot());
} catch (SAXException | IOException e) {
throw new IllegalStateException("Cannot parse " + configSnapshotHolder, e);
}
LOG.trace("Pushing last configuration to config mapping: {}", configSnapshotHolder);
Stopwatch stopwatch = Stopwatch.createStarted();
final ConfigSubsystemFacade currentFacade = this.facade.createFacade("config-push");
try {
ConfigExecution configExecution = createConfigExecution(xmlToBePersisted, currentFacade);
executeWithMissingModuleFactoryRetries(currentFacade, configExecution);
} catch (ValidationException | DocumentedException | ModuleFactoryNotFoundException e) {
LOG.trace("Validation for config: {} failed", configSnapshotHolder, e);
throw new ConfigSnapshotFailureException(configSnapshotHolder.toString(), "edit", e);
}
try {
currentFacade.commitSilentTransaction();
} catch (ValidationException | DocumentedException e) {
throw new ConfigSnapshotFailureException(configSnapshotHolder.toString(), "commit", e);
}
LOG.trace("Last configuration loaded successfully");
LOG.trace("Total time spent {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
return true;
}
use of org.opendaylight.controller.config.api.ModuleFactoryNotFoundException in project controller by opendaylight.
the class ConfigPusherImpl method executeWithMissingModuleFactoryRetries.
private void executeWithMissingModuleFactoryRetries(final ConfigSubsystemFacade facade, final ConfigExecution configExecution) throws DocumentedException, ValidationException, ModuleFactoryNotFoundException {
Stopwatch stopwatch = Stopwatch.createStarted();
ModuleFactoryNotFoundException lastException = null;
do {
try {
facade.executeConfigExecution(configExecution);
return;
} catch (final ModuleFactoryNotFoundException e) {
LOG.debug("{} - will retry after timeout", e.toString());
lastException = e;
sleep();
}
} while (stopwatch.elapsed(TimeUnit.MILLISECONDS) < maxWaitForCapabilitiesMillis);
throw lastException;
}
Aggregations