Search in sources :

Example 1 with ConfigSubsystemFacadeFactory

use of org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory 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);
    }
}
Also used : ConflictingVersionException(org.opendaylight.controller.config.api.ConflictingVersionException) ValidationException(org.opendaylight.controller.config.api.ValidationException) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException) ConfigSubsystemFacade(org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) ConfigSubsystemFacadeFactory(org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory)

Example 2 with ConfigSubsystemFacadeFactory

use of org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory in project controller by opendaylight.

the class ConfigPersisterActivator method start.

@Override
public void start(final BundleContext context) throws Exception {
    LOG.debug("ConfigPersister starting");
    this.context = context;
    PropertiesProviderBaseImpl propertiesProvider = new PropertiesProviderBaseImpl(context);
    final PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(propertiesProvider);
    autoCloseables.add(persisterAggregator);
    final long maxWaitForCapabilitiesMillis = getMaxWaitForCapabilitiesMillis(propertiesProvider);
    final List<ConfigSnapshotHolder> configs = persisterAggregator.loadLastConfigs();
    final long conflictingVersionTimeoutMillis = getConflictingVersionTimeoutMillis(propertiesProvider);
    LOG.debug("Following configs will be pushed: {}", configs);
    ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory> schemaServiceTrackerCustomizer = new ServiceTrackerCustomizer<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory>() {

        @Override
        public ConfigSubsystemFacadeFactory addingService(final ServiceReference<ConfigSubsystemFacadeFactory> reference) {
            LOG.debug("Got addingService(SchemaContextProvider) event");
            // Yang store service should not be registered multiple times
            ConfigSubsystemFacadeFactory configSubsystemFacadeFactory = reference.getBundle().getBundleContext().getService(reference);
            startPusherThread(configs, maxWaitForCapabilitiesMillis, configSubsystemFacadeFactory, conflictingVersionTimeoutMillis, persisterAggregator);
            return configSubsystemFacadeFactory;
        }

        @Override
        public void modifiedService(final ServiceReference<ConfigSubsystemFacadeFactory> reference, final ConfigSubsystemFacadeFactory service) {
            LOG.warn("Config manager facade was modified unexpectedly");
        }

        @Override
        public void removedService(final ServiceReference<ConfigSubsystemFacadeFactory> reference, final ConfigSubsystemFacadeFactory service) {
            LOG.warn("Config manager facade was removed unexpectedly");
        }
    };
    ServiceTracker<ConfigSubsystemFacadeFactory, ConfigSubsystemFacadeFactory> schemaContextProviderServiceTracker = new ServiceTracker<>(context, ConfigSubsystemFacadeFactory.class, schemaServiceTrackerCustomizer);
    schemaContextProviderServiceTracker.open();
}
Also used : ConfigSnapshotHolder(org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder) ServiceTracker(org.osgi.util.tracker.ServiceTracker) ServiceTrackerCustomizer(org.osgi.util.tracker.ServiceTrackerCustomizer) ConfigSubsystemFacadeFactory(org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory) PersisterAggregator(org.opendaylight.controller.config.persist.impl.PersisterAggregator) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

ConfigSubsystemFacadeFactory (org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacadeFactory)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 ConflictingVersionException (org.opendaylight.controller.config.api.ConflictingVersionException)1 ValidationException (org.opendaylight.controller.config.api.ValidationException)1 ConfigSubsystemFacade (org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade)1 ConfigSnapshotHolder (org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder)1 PersisterAggregator (org.opendaylight.controller.config.persist.impl.PersisterAggregator)1 DocumentedException (org.opendaylight.controller.config.util.xml.DocumentedException)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)1