Search in sources :

Example 1 with ModuleFactoryNotFoundException

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);
}
Also used : ModuleFactory(org.opendaylight.controller.config.spi.ModuleFactory) ModuleIdentifier(org.opendaylight.controller.config.api.ModuleIdentifier) AbstractModule(org.opendaylight.controller.config.spi.AbstractModule) Module(org.opendaylight.controller.config.spi.Module) ModuleFactoryNotFoundException(org.opendaylight.controller.config.api.ModuleFactoryNotFoundException) InstanceAlreadyExistsException(javax.management.InstanceAlreadyExistsException) InstanceNotFoundException(javax.management.InstanceNotFoundException) ValidationException(org.opendaylight.controller.config.api.ValidationException) ModuleFactoryNotFoundException(org.opendaylight.controller.config.api.ModuleFactoryNotFoundException) BundleContext(org.osgi.framework.BundleContext) DependencyResolver(org.opendaylight.controller.config.api.DependencyResolver)

Example 2 with ModuleFactoryNotFoundException

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;
}
Also used : ValidationException(org.opendaylight.controller.config.api.ValidationException) ConfigExecution(org.opendaylight.controller.config.facade.xml.ConfigExecution) Element(org.w3c.dom.Element) Stopwatch(com.google.common.base.Stopwatch) IOException(java.io.IOException) ConfigSubsystemFacade(org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade) ModuleFactoryNotFoundException(org.opendaylight.controller.config.api.ModuleFactoryNotFoundException) SAXException(org.xml.sax.SAXException) DocumentedException(org.opendaylight.controller.config.util.xml.DocumentedException)

Example 3 with ModuleFactoryNotFoundException

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;
}
Also used : Stopwatch(com.google.common.base.Stopwatch) ModuleFactoryNotFoundException(org.opendaylight.controller.config.api.ModuleFactoryNotFoundException)

Aggregations

ModuleFactoryNotFoundException (org.opendaylight.controller.config.api.ModuleFactoryNotFoundException)3 Stopwatch (com.google.common.base.Stopwatch)2 ValidationException (org.opendaylight.controller.config.api.ValidationException)2 IOException (java.io.IOException)1 InstanceAlreadyExistsException (javax.management.InstanceAlreadyExistsException)1 InstanceNotFoundException (javax.management.InstanceNotFoundException)1 DependencyResolver (org.opendaylight.controller.config.api.DependencyResolver)1 ModuleIdentifier (org.opendaylight.controller.config.api.ModuleIdentifier)1 ConfigExecution (org.opendaylight.controller.config.facade.xml.ConfigExecution)1 ConfigSubsystemFacade (org.opendaylight.controller.config.facade.xml.ConfigSubsystemFacade)1 AbstractModule (org.opendaylight.controller.config.spi.AbstractModule)1 Module (org.opendaylight.controller.config.spi.Module)1 ModuleFactory (org.opendaylight.controller.config.spi.ModuleFactory)1 DocumentedException (org.opendaylight.controller.config.util.xml.DocumentedException)1 BundleContext (org.osgi.framework.BundleContext)1 Element (org.w3c.dom.Element)1 SAXException (org.xml.sax.SAXException)1