Search in sources :

Example 1 with PersisterAggregator

use of org.opendaylight.controller.config.persist.impl.PersisterAggregator 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)1 ConfigSnapshotHolder (org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder)1 PersisterAggregator (org.opendaylight.controller.config.persist.impl.PersisterAggregator)1 ServiceReference (org.osgi.framework.ServiceReference)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1 ServiceTrackerCustomizer (org.osgi.util.tracker.ServiceTrackerCustomizer)1