use of org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade in project controller by opendaylight.
the class BlueprintContainerRestartServiceImpl method restartConfigModules.
private void restartConfigModules(final BundleContext bundleContext, final List<Entry<String, ModuleIdentifier>> configModules) {
if (configModules.isEmpty()) {
return;
}
ServiceReference<ConfigSubsystemFacadeFactory> configFacadeFactoryRef = bundleContext.getServiceReference(ConfigSubsystemFacadeFactory.class);
if (configFacadeFactoryRef == null) {
LOG.debug("ConfigSubsystemFacadeFactory service reference not found");
return;
}
ConfigSubsystemFacadeFactory configFacadeFactory = bundleContext.getService(configFacadeFactoryRef);
if (configFacadeFactory == null) {
LOG.debug("ConfigSubsystemFacadeFactory service not found");
return;
}
try (ConfigSubsystemFacade configFacade = configFacadeFactory.createFacade("BlueprintContainerRestartService")) {
restartConfigModules(configModules, configFacade);
} catch (ParserConfigurationException | DocumentedException | ValidationException | ConflictingVersionException e) {
LOG.error("Error restarting config modules", e);
} finally {
bundleContext.ungetService(configFacadeFactoryRef);
}
}
use of org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade 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;
}
Aggregations