<artifactId>junit</artifactId>
</dependency>
<!-- Add Pax Exam -->
- <dependency>
- <groupId>org.ops4j.pax.exam</groupId>
- <artifactId>pax-exam-container-native</artifactId>
- <scope>test</scope>
- </dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
*/
boolean isHealthy();
+ /**
+ * @return module factory names available in the system
+ */
Set<String> getAvailableModuleNames();
+
+
/**
* Find all runtime beans
*
*/
void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException;
+ /**
+ * @return qnames of all ModuleFactory instances in the system
+ */
+ Set<String> getAvailableModuleFactoryQNames();
+
}
import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager;
import org.opendaylight.controller.config.manager.impl.osgi.BeanToOsgiServiceManager.OsgiRegistration;
import org.opendaylight.controller.config.manager.impl.util.LookupBeansUtil;
+import org.opendaylight.controller.config.manager.impl.util.ModuleQNameUtil;
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.spi.ModuleFactory;
import org.osgi.framework.BundleContext;
private final ModuleFactoriesResolver resolver;
private final MBeanServer configMBeanServer;
- @GuardedBy("this")
- private final BundleContext bundleContext;
-
@GuardedBy("this")
private long version = 0;
@GuardedBy("this")
// internal jmx server shared by all transactions
private final MBeanServer transactionsMBeanServer;
+ // Used for finding new factory instances for default module functionality
@GuardedBy("this")
private List<ModuleFactory> lastListOfFactories = Collections.emptyList();
// constructor
public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
- BundleContext bundleContext, MBeanServer configMBeanServer) {
- this(resolver, bundleContext, configMBeanServer,
+ MBeanServer configMBeanServer) {
+ this(resolver, configMBeanServer,
new BaseJMXRegistrator(configMBeanServer));
}
// constructor
public ConfigRegistryImpl(ModuleFactoriesResolver resolver,
- BundleContext bundleContext, MBeanServer configMBeanServer,
+ MBeanServer configMBeanServer,
BaseJMXRegistrator baseJMXRegistrator) {
this.resolver = resolver;
this.beanToOsgiServiceManager = new BeanToOsgiServiceManager();
- this.bundleContext = bundleContext;
this.configMBeanServer = configMBeanServer;
this.baseJMXRegistrator = baseJMXRegistrator;
this.registryMBeanServer = MBeanServerFactory
}
};
- ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(
- transactionName), factory);
Map<String, Map.Entry<ModuleFactory, BundleContext>> allCurrentFactories = Collections.unmodifiableMap(
resolver.getAllFactories());
+ ConfigTransactionLookupRegistry txLookupRegistry = new ConfigTransactionLookupRegistry(new TransactionIdentifier(
+ transactionName), factory, allCurrentFactories);
ServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
readableSRRegistry, txLookupRegistry, allCurrentFactories);
public synchronized String getServiceInterfaceName(String namespace, String localName) {
return readableSRRegistry.getServiceInterfaceName(namespace, localName);
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ return ModuleQNameUtil.getQNames(resolver.getAllFactories());
+ }
+
}
/**
Collections.sort(result);
return result;
}
+
+
}
/**
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.ArrayList;
-import java.util.Collection;
import java.util.concurrent.atomic.AtomicBoolean;
import static java.lang.String.format;
return txLookupRegistry.getTransactionIdentifier();
}
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ return txLookupRegistry.getAvailableModuleFactoryQNames();
+ }
+
}
import org.opendaylight.controller.config.manager.impl.jmx.TransactionJMXRegistrator;
import org.opendaylight.controller.config.manager.impl.jmx.TransactionModuleJMXRegistrator;
import org.opendaylight.controller.config.manager.impl.util.LookupBeansUtil;
+import org.opendaylight.controller.config.manager.impl.util.ModuleQNameUtil;
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.osgi.framework.BundleContext;
import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectName;
import java.io.Closeable;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
/**
private final TransactionJMXRegistrator transactionJMXRegistrator;
private final TransactionIdentifier transactionIdentifier;
private final TransactionModuleJMXRegistrator txModuleJMXRegistrator;
+ private final Map<String, Map.Entry<ModuleFactory, BundleContext>> allCurrentFactories;
ConfigTransactionLookupRegistry(TransactionIdentifier transactionIdentifier,
- TransactionJMXRegistratorFactory factory) {
+ TransactionJMXRegistratorFactory factory, Map<String, Entry<ModuleFactory, BundleContext>> allCurrentFactories) {
this.transactionIdentifier = transactionIdentifier;
this.transactionJMXRegistrator = factory.create();
this.txModuleJMXRegistrator = transactionJMXRegistrator.createTransactionModuleJMXRegistrator();
+ this.allCurrentFactories = allCurrentFactories;
}
private void checkTransactionName(ObjectName objectName) {
public void registerMBean(ConfigTransactionControllerInternal transactionController, ObjectName controllerObjectName) throws InstanceAlreadyExistsException {
transactionJMXRegistrator.registerMBean(transactionController, controllerObjectName);
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ return ModuleQNameUtil.getQNames(allCurrentFactories);
+ }
+
}
interface TransactionJMXRegistratorFactory {
public void checkConfigBeanExists(ObjectName objectName) throws InstanceNotFoundException {
throw new InstanceNotFoundException("Cannot find " + objectName);
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ throw new UnsupportedOperationException();
+ }
};
return new ServiceReferenceRegistryImpl(Collections.<String, ModuleFactory>emptyMap(), lookupRegistry,
Collections.<String /* qName */, Map<String /* refName */, ModuleIdentifier>>emptyMap());
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.List;
import java.util.Map;
return moduleFactories;
}
+ public Map<String, Entry<ModuleFactory, BundleContext>> getModuleNamesToConfigBeanFactories() {
+ return moduleNamesToConfigBeanFactories;
+ }
}
new BundleContextBackedModuleFactoriesResolver(context);
MBeanServer configMBeanServer = ManagementFactory.getPlatformMBeanServer();
configRegistry = new ConfigRegistryImpl(
- bundleContextBackedModuleFactoriesResolver, context,
- configMBeanServer);
+ bundleContextBackedModuleFactoriesResolver, configMBeanServer);
// register config registry to OSGi
configRegistryServiceRegistration = context.registerService(ConfigRegistryImpl.class, configRegistry, null);
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.impl.util;
+
+import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
+import org.osgi.framework.BundleContext;
+
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+
+public class ModuleQNameUtil {
+
+ public static Set<String> getQNames(Map<String, Entry<ModuleFactory, BundleContext>> resolved) {
+ Set<String> result = new HashSet<>();
+ for (Entry<ModuleFactory, BundleContext> entry : resolved.values()) {
+ Class<?> inspected = entry.getKey().getClass();
+ if (inspected.isInterface()) {
+ throw new IllegalArgumentException("Unexpected interface " + inspected);
+ }
+ ModuleQName annotation = null;
+ while(annotation == null && inspected != null) {
+ annotation = inspected.getAnnotation(ModuleQName.class);
+ inspected = inspected.getSuperclass();
+ }
+ if (annotation != null) {
+ // FIXME
+ String qName = "(" + annotation.namespace() + "?revision=" + annotation.revision() + ")" + annotation.name();
+ result.add(qName);
+ }
+ }
+ return result;
+ }
+
+}
factory, factory);
configRegistry = new ConfigRegistryImpl(resolver,
- context, ManagementFactory.getPlatformMBeanServer());
+ ManagementFactory.getPlatformMBeanServer());
configRegistry.beginConfig();
fail();
internalJmxRegistrator = new InternalJMXRegistrator(platformMBeanServer);
baseJmxRegistrator = new BaseJMXRegistrator(internalJmxRegistrator);
- configRegistry = new ConfigRegistryImpl(resolver, mockedContext,
+ configRegistry = new ConfigRegistryImpl(resolver,
platformMBeanServer, baseJmxRegistrator);
try {
configRegistryJMXRegistrator.registerToJMX(configRegistry);
@Before
public void setUp() throws Exception {
- configRegistryImpl = new ConfigRegistryImpl(null, null,
+ configRegistryImpl = new ConfigRegistryImpl(null,
ManagementFactory.getPlatformMBeanServer());
Field field = configRegistryImpl.getClass().getDeclaredField(
"baseJMXRegistrator");
public TransactionJMXRegistrator create() {
return baseJMXRegistrator.createTransactionJMXRegistrator(transactionName123);
}
- });
+ }, currentlyRegisteredFactories);
ServiceReferenceWritableRegistry writableRegistry = ServiceReferenceRegistryImpl.createSRWritableRegistry(
ServiceReferenceRegistryImpl.createInitialSRLookupRegistry(), txLookupRegistry, currentlyRegisteredFactories);
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.manager.testingservices.threadpool;
+
+import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
+
+@ModuleQName(namespace = "namespace", revision = "revision", name = "name")
+public abstract class AbstractTestingFixedThreadPoolModuleFactory {
+}
import java.util.HashSet;
import java.util.Set;
-public class TestingFixedThreadPoolModuleFactory implements ModuleFactory {
+public class TestingFixedThreadPoolModuleFactory extends AbstractTestingFixedThreadPoolModuleFactory implements ModuleFactory {
public static final String NAME = "fixed";
private static Set<Class<? extends AbstractServiceInterface>> ifc = Collections.unmodifiableSet(Sets.newHashSet(
*/
package org.opendaylight.controller.config.manager.testingservices.threadpool.test;
+import com.google.common.collect.Sets;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.ThreadPoolExecutor;
import static org.junit.Assert.assertEquals;
}
+ @Test
+ public void testQNames() {
+ Set<String> availableModuleFactoryQNames = configRegistryClient.getAvailableModuleFactoryQNames();
+ String expected = "(namespace?revision=revision)name";
+ assertEquals(Sets.newHashSet(expected), availableModuleFactoryQNames);
+ }
+
}
}
private void checkFileConsistency(){
- checkState(inCapabilities, "File {} is missing delimiters in this order: {}", fileNameForReporting,
+ checkState(inCapabilities, "File %s is missing delimiters in this order: %s", fileNameForReporting,
Arrays.asList(DirectoryPersister.MODULES_START,
DirectoryPersister.SERVICES_START,
DirectoryPersister.CAPABILITIES_START));
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>config-subsystem</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>config-persister-directory-xml-adapter</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <!-- compile dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>config-persister-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.moxy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
+ </Fragment-Host>
+ <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
+ </Provide-Capability>
+ <Import-Package>
+ com.google.common.base,
+ com.google.common.io,
+ org.apache.commons.io,
+ org.opendaylight.controller.config.persist.api,
+ org.slf4j,
+ com.google.common.collect,
+ javax.xml.bind,
+ javax.xml.bind.annotation,
+ javax.xml.transform,
+ javax.xml.transform.stream,
+ org.eclipse.persistence.jaxb,
+ org.apache.commons.lang3
+ </Import-Package>
+ <Private-Package>
+ org.opendaylight.controller.config.persist.storage.file.xml.model,
+ </Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.directory.xml;
+
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+import org.opendaylight.controller.config.persist.api.Persister;
+import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Unmarshaller;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.SortedSet;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+public class XmlDirectoryPersister implements Persister {
+ private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryPersister.class);
+
+ private final File storage;
+
+ public XmlDirectoryPersister(File storage) {
+ checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
+ this.storage = storage;
+ }
+
+ @Override
+ public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+ throw new UnsupportedOperationException("This adapter is read only. Please set readonly=true on " + getClass());
+ }
+
+ @Override
+ public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
+ File[] filesArray = storage.listFiles();
+ if (filesArray == null || filesArray.length == 0) {
+ return Collections.emptyList();
+ }
+ List<File> sortedFiles = new ArrayList<>(Arrays.asList(filesArray));
+ Collections.sort(sortedFiles);
+ // combine all found files
+ logger.debug("Reading files in following order: {}", sortedFiles);
+
+ List<ConfigSnapshotHolder> result = new ArrayList<>();
+ for (File file : sortedFiles) {
+ logger.trace("Adding file '{}' to combined result", file);
+ ConfigSnapshotHolder h = fromXmlSnapshot(file);
+ result.add(h);
+ }
+ return result;
+ }
+
+ private ConfigSnapshotHolder fromXmlSnapshot(File file) {
+ try {
+ JAXBContext jaxbContext = JAXBContext.newInstance(ConfigSnapshot.class);
+ Unmarshaller um = jaxbContext.createUnmarshaller();
+
+ return asHolder((ConfigSnapshot) um.unmarshal(file));
+ } catch (JAXBException e) {
+ logger.warn("Unable to restore configuration snapshot from {}", file, e);
+ throw new IllegalStateException("Unable to restore configuration snapshot from " + file, e);
+ }
+ }
+
+ private ConfigSnapshotHolder asHolder(final ConfigSnapshot unmarshalled) {
+ return new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return unmarshalled.getConfigSnapshot();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return unmarshalled.getCapabilities();
+ }
+
+ @Override
+ public String toString() {
+ return unmarshalled.toString();
+ }
+ };
+ }
+
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("XmlDirectoryPersister{");
+ sb.append("storage=").append(storage);
+ sb.append('}');
+ return sb.toString();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.persist.storage.directory.xml;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.config.persist.api.Persister;
+import org.opendaylight.controller.config.persist.api.PropertiesProvider;
+import org.opendaylight.controller.config.persist.api.StorageAdapter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+
+/**
+ * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
+ * required capabilities will be merged together. Writing to this persister is not supported.
+ */
+public class XmlDirectoryStorageAdapter implements StorageAdapter {
+ private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
+
+ public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
+
+
+ @Override
+ public Persister instantiate(PropertiesProvider propertiesProvider) {
+ String fileStorageProperty = propertiesProvider.getProperty(DIRECTORY_STORAGE_PROP);
+ Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(DIRECTORY_STORAGE_PROP));
+ File storage = new File(fileStorageProperty);
+ logger.debug("Using {}", storage);
+ return new XmlDirectoryPersister(storage);
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.persist.storage.directory.xml;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+
+import java.io.File;
+import java.util.Collections;
+import java.util.List;
+import java.util.SortedSet;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class DirectoryStorageAdapterTest {
+ XmlDirectoryPersister tested;
+
+ @Test
+ public void testEmptyDirectory() throws Exception {
+ File folder = new File("target/emptyFolder");
+ folder.mkdir();
+ tested = new XmlDirectoryPersister((folder));
+ assertEquals(Collections.<ConfigSnapshotHolder>emptyList(), tested.loadLastConfigs());
+
+ try {
+ tested.persistConfig(new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ throw new RuntimeException();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ throw new RuntimeException();
+ }
+ });
+ fail();
+ } catch (UnsupportedOperationException e) {
+
+ }
+ }
+
+ private File getFolder(String folderName) {
+ File result = new File(("src/test/resources/" +
+ folderName).replace("/", File.separator));
+ assertTrue(result + " is not a directory", result.isDirectory());
+ return result;
+ }
+
+ @Test
+ public void testOneFile() throws Exception {
+ File folder = getFolder("oneFile");
+ tested = new XmlDirectoryPersister((folder));
+ List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+ assertEquals(1, results.size());
+ ConfigSnapshotHolder result = results.get(0);
+ assertResult(result, "<config>1</config>", "cap1&rev", "cap2", "capa a");
+ }
+
+ private void assertResult(ConfigSnapshotHolder result, String s, String... caps) {
+ assertEquals(s, result.getConfigSnapshot().replaceAll("\\s", ""));
+ int i = 0;
+ for (String capFromSnapshot : result.getCapabilities()) {
+ assertEquals(capFromSnapshot, caps[i++]);
+ }
+ }
+
+ @Test
+ public void testTwoFiles() throws Exception {
+ File folder = getFolder("twoFiles");
+ tested = new XmlDirectoryPersister((folder));
+ List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+ assertEquals(2, results.size());
+
+ assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
+ assertResult(results.get(1), "<config>2</config>", "cap1-b", "cap2-b", "capa a-b");
+
+ }
+
+}
--- /dev/null
+<snapshot>
+ <required-capabilities>
+ <capability>cap1&rev</capability>
+ <capability>cap2</capability>
+ <capability>capa a</capability>
+ </required-capabilities>
+ <configuration>
+ <config>1</config>
+ </configuration>
+</snapshot>
\ No newline at end of file
--- /dev/null
+<snapshot>
+ <required-capabilities>
+ <capability>cap1-a</capability>
+ <capability>cap2-a</capability>
+ <capability>capa a-a</capability>
+ </required-capabilities>
+ <configuration>
+ <config>1</config>
+ </configuration>
+</snapshot>
\ No newline at end of file
--- /dev/null
+<snapshot>
+ <required-capabilities>
+ <capability>cap1-b</capability>
+ <capability>cap2-b</capability>
+ <capability>capa a-b</capability>
+ </required-capabilities>
+ <configuration>
+ <config>2</config>
+ </configuration>
+</snapshot>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>config-subsystem</artifactId>
+ <groupId>org.opendaylight.controller</groupId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>..</relativePath>
+ </parent>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>bundle</packaging>
+
+ <dependencies>
+ <!-- compile dependencies -->
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>config-persister-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.moxy</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.persistence</groupId>
+ <artifactId>org.eclipse.persistence.core</artifactId>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>org.opendaylight.bgpcep</groupId>
+ <artifactId>mockito-configuration</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <!-- workaround for creating version according to OSGi specification (major.minor.micro[.qualifier] -->
+ <plugin>
+ <groupId>org.codehaus.groovy.maven</groupId>
+ <artifactId>gmaven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <source>
+ System.setProperty("osgiversion", "${project.version}".replace('-', '.'))
+ </source>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Fragment-Host>${project.groupId}.config-persister-impl;bundle-version=${osgiversion}
+ </Fragment-Host>
+ <Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
+ </Provide-Capability>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.persist.storage.file.xml;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Lists;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+import org.opendaylight.controller.config.persist.api.Persister;
+import org.opendaylight.controller.config.persist.api.PropertiesProvider;
+import org.opendaylight.controller.config.persist.api.StorageAdapter;
+import org.opendaylight.controller.config.persist.storage.file.xml.model.Config;
+import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+import java.util.SortedSet;
+
+/**
+ * StorageAdapter that stores configuration in an xml file.
+ */
+public class XmlFileStorageAdapter implements StorageAdapter, Persister {
+ private static final Logger logger = LoggerFactory.getLogger(XmlFileStorageAdapter.class);
+
+ public static final String FILE_STORAGE_PROP = "fileStorage";
+ public static final String NUMBER_OF_BACKUPS = "numberOfBackups";
+
+ private static Integer numberOfStoredBackups;
+ private File storage;
+
+ @Override
+ public Persister instantiate(PropertiesProvider propertiesProvider) {
+ File storage = extractStorageFileFromProperties(propertiesProvider);
+ logger.debug("Using file {}", storage.getAbsolutePath());
+ // Create file if it does not exist
+ File parentFile = storage.getAbsoluteFile().getParentFile();
+ if (parentFile.exists() == false) {
+ logger.debug("Creating parent folders {}", parentFile);
+ parentFile.mkdirs();
+ }
+ if (storage.exists() == false) {
+ logger.debug("Storage file does not exist, creating empty file");
+ try {
+ boolean result = storage.createNewFile();
+ if (result == false)
+ throw new RuntimeException("Unable to create storage file " + storage);
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to create storage file " + storage, e);
+ }
+ }
+ if (numberOfStoredBackups == 0) {
+ throw new RuntimeException(NUMBER_OF_BACKUPS
+ + " property should be either set to positive value, or ommited. Can not be set to 0.");
+ }
+ setFileStorage(storage);
+ return this;
+ }
+
+ @VisibleForTesting
+ public void setFileStorage(File storage) {
+ this.storage = storage;
+ }
+
+ @VisibleForTesting
+ public void setNumberOfBackups(Integer numberOfBackups) {
+ numberOfStoredBackups = numberOfBackups;
+ }
+
+ private static File extractStorageFileFromProperties(PropertiesProvider propertiesProvider) {
+ String fileStorageProperty = propertiesProvider.getProperty(FILE_STORAGE_PROP);
+ Preconditions.checkNotNull(fileStorageProperty, "Unable to find " + propertiesProvider.getFullKeyForReporting(FILE_STORAGE_PROP));
+ File result = new File(fileStorageProperty);
+ String numberOfBackupsAsString = propertiesProvider.getProperty(NUMBER_OF_BACKUPS);
+ if (numberOfBackupsAsString != null) {
+ numberOfStoredBackups = Integer.valueOf(numberOfBackupsAsString);
+ } else {
+ numberOfStoredBackups = Integer.MAX_VALUE;
+ }
+ logger.trace("Property {} set to {}", NUMBER_OF_BACKUPS, numberOfStoredBackups);
+ return result;
+ }
+
+ @Override
+ public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+ Preconditions.checkNotNull(storage, "Storage file is null");
+
+ Config cfg = Config.fromXml(storage);
+ cfg.addConfigSnapshot(ConfigSnapshot.fromConfigSnapshot(holder), numberOfStoredBackups);
+ cfg.toXml(storage);
+ }
+
+ @Override
+ public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
+ Preconditions.checkNotNull(storage, "Storage file is null");
+
+ if (!storage.exists()) {
+ return Collections.emptyList();
+ }
+
+ Optional<ConfigSnapshot> lastSnapshot = Config.fromXml(storage).getLastSnapshot();
+
+ if (lastSnapshot.isPresent())
+ return Lists.newArrayList(toConfigSnapshot(lastSnapshot.get()));
+ else
+ return Collections.emptyList();
+ }
+
+
+ public ConfigSnapshotHolder toConfigSnapshot(final ConfigSnapshot configSnapshot) {
+ return new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return configSnapshot.getConfigSnapshot();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return configSnapshot.getCapabilities();
+ }
+
+ @Override
+ public String toString() {
+ return configSnapshot.toString();
+ }
+ };
+ }
+
+ @Override
+ public void close() {
+
+ }
+
+ @Override
+ public String toString() {
+ return "XmlFileStorageAdapter [storage=" + storage + "]";
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.file.xml.model;
+
+import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.DomHandler;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+class CapabilityHandler implements DomHandler<String, StreamResult> {
+
+ private static final String START_TAG = "<capability>";
+ private static final String END_TAG = "</capability>";
+
+ private StringWriter xmlWriter = new StringWriter();
+
+ public StreamResult createUnmarshaller(ValidationEventHandler errorHandler) {
+ xmlWriter.getBuffer().setLength(0);
+ return new StreamResult(xmlWriter);
+ }
+
+ public String getElement(StreamResult rt) {
+ String xml = rt.getWriter().toString();
+ int beginIndex = xml.indexOf(START_TAG) + START_TAG.length();
+ int endIndex = xml.indexOf(END_TAG);
+ return xml.substring(beginIndex, endIndex);
+ }
+
+ public Source marshal(String n, ValidationEventHandler errorHandler) {
+ try {
+ String xml = START_TAG + n.trim() + END_TAG;
+ StringReader xmlReader = new StringReader(xml);
+ return new StreamSource(xmlReader);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.file.xml.model;
+
+import com.google.common.base.Charsets;
+import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
+import com.google.common.collect.Lists;
+import com.google.common.io.Files;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+@XmlRootElement(name = "persisted-snapshots")
+public final class Config {
+
+ private List<ConfigSnapshot> snapshots;
+
+ Config(List<ConfigSnapshot> snapshots) {
+ this.snapshots = snapshots;
+ }
+
+ public Config() {
+ this.snapshots = Lists.newArrayList();
+ }
+
+ @XmlElement(name = "snapshot")
+ @XmlElementWrapper(name = "snapshots")
+ public List<ConfigSnapshot> getSnapshots() {
+ return snapshots;
+ }
+
+ public void setSnapshots(List<ConfigSnapshot> snapshots) {
+ this.snapshots = snapshots;
+ }
+
+ public void toXml(File to) {
+ try {
+
+ // TODO Moxy has to be used instead of default jaxb impl due to a bug
+ // default implementation has a bug that prevents from serializing xml in a string
+ JAXBContext jaxbContext = org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(new Class[]{Config.class}, null);
+
+ Marshaller marshaller = jaxbContext.createMarshaller();
+
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+
+ marshaller.marshal(this, to);
+ } catch (JAXBException e) {
+ throw new PersistException("Unable to persist configuration", e);
+ }
+ }
+
+ public static Config fromXml(File from) {
+ if(isEmpty(from))
+ return new Config();
+
+ try {
+ JAXBContext jaxbContext = JAXBContext.newInstance(Config.class);
+ Unmarshaller um = jaxbContext.createUnmarshaller();
+
+ return (Config) um.unmarshal(from);
+ } catch (JAXBException e) {
+ throw new PersistException("Unable to restore configuration", e);
+ }
+ }
+
+ private static boolean isEmpty(File from) {
+ return from.length() == 0 || isBlank(from);
+ }
+
+ private static boolean isBlank(File from) {
+ try {
+ return StringUtils.isBlank(Files.toString(from, Charsets.UTF_8));
+ } catch (IOException e) {
+ throw new IllegalStateException("Unexpected error reading file" + from, e);
+ }
+ }
+
+ public Optional<ConfigSnapshot> getLastSnapshot() {
+ ConfigSnapshot last = Iterables.getLast(snapshots, null);
+ return last == null ? Optional.<ConfigSnapshot>absent() : Optional.of(last);
+ }
+
+ public void addConfigSnapshot(ConfigSnapshot snap, int numberOfStoredBackups) {
+ if(shouldReplaceLast(numberOfStoredBackups) && snapshots.isEmpty() == false) {
+ snapshots.remove(0);
+ }
+ snapshots.add(snap);
+ }
+
+ private boolean shouldReplaceLast(int numberOfStoredBackups) {
+ return numberOfStoredBackups == snapshots.size();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.file.xml.model;
+
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.SortedSet;
+
+@XmlRootElement(name = "snapshot")
+public class ConfigSnapshot {
+
+ private String configSnapshot;
+ private SortedSet<String> capabilities;
+
+ ConfigSnapshot(String configXml, SortedSet<String> capabilities) {
+ this.configSnapshot = configXml;
+ this.capabilities = capabilities;
+ }
+
+ public ConfigSnapshot() {
+ }
+
+ public static ConfigSnapshot fromConfigSnapshot(ConfigSnapshotHolder cfg) {
+ return new ConfigSnapshot(cfg.getConfigSnapshot(), cfg.getCapabilities());
+ }
+
+ @XmlAnyElement(SnapshotHandler.class)
+ public String getConfigSnapshot() {
+ return configSnapshot;
+ }
+
+ public void setConfigSnapshot(String configSnapshot) {
+ this.configSnapshot = configSnapshot;
+ }
+
+ @XmlElement(name = "capability")
+ @XmlElementWrapper(name = "required-capabilities")
+ public SortedSet<String> getCapabilities() {
+ return capabilities;
+ }
+
+ public void setCapabilities(SortedSet<String> capabilities) {
+ this.capabilities = capabilities;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuffer sb = new StringBuffer("ConfigSnapshot{");
+ sb.append("configSnapshot='").append(configSnapshot).append('\'');
+ sb.append(", capabilities=").append(capabilities);
+ sb.append('}');
+ return sb.toString();
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.file.xml.model;
+
+final class PersistException extends RuntimeException {
+
+ public PersistException(String s, Exception e) {
+ super(s, e);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.persist.storage.file.xml.model;
+
+import javax.xml.bind.ValidationEventHandler;
+import javax.xml.bind.annotation.DomHandler;
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+class SnapshotHandler implements DomHandler<String, StreamResult> {
+
+ private static final String START_TAG = "<configuration>";
+ private static final String END_TAG = "</configuration>";
+
+ private StringWriter xmlWriter = new StringWriter();
+
+ public StreamResult createUnmarshaller(ValidationEventHandler errorHandler) {
+ xmlWriter.getBuffer().setLength(0);
+ return new StreamResult(xmlWriter);
+ }
+
+ public String getElement(StreamResult rt) {
+ String xml = rt.getWriter().toString();
+ int beginIndex = xml.indexOf(START_TAG) + START_TAG.length();
+ int endIndex = xml.indexOf(END_TAG);
+ return xml.substring(beginIndex, endIndex);
+ }
+
+ public Source marshal(String n, ValidationEventHandler errorHandler) {
+ try {
+ String xml = START_TAG + n.trim() + END_TAG;
+ StringReader xmlReader = new StringReader(xml);
+ return new StreamSource(xmlReader);
+ } catch(Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.config.persist.storage.file.xml;
+
+import com.google.common.base.Charsets;
+import junit.framework.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
+
+import static junit.framework.Assert.assertFalse;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
+
+public class FileStorageAdapterTest {
+
+ private static int i;
+ private File file;
+
+ @Before
+ public void setUp() throws Exception {
+ file = Files.createTempFile("testFilePersist", ".txt").toFile();
+ if (!file.exists())
+ return;
+ com.google.common.io.Files.write("", file, Charsets.UTF_8);
+ i = 1;
+ }
+
+ @Test
+ public void testFileAdapter() throws Exception {
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.setFileStorage(file);
+ storage.setNumberOfBackups(Integer.MAX_VALUE);
+ final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return createConfig();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return createCaps();
+ }
+ };
+ storage.persistConfig(holder);
+
+ storage.persistConfig(holder);
+
+ assertEquals(27, com.google.common.io.Files.readLines(file, Charsets.UTF_8).size());
+ List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
+ assertEquals(1, lastConf.size());
+ ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
+ assertEquals("<config>2</config>",
+ configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+ assertEquals(createCaps(), configSnapshotHolder.getCapabilities());
+
+ storage = new XmlFileStorageAdapter();
+ storage.setFileStorage(file);
+ storage.setNumberOfBackups(Integer.MAX_VALUE);
+
+ List<ConfigSnapshotHolder> last = storage.loadLastConfigs();
+ Assert.assertEquals(createCaps(), last.get(0).getCapabilities());
+ }
+
+ private SortedSet<String> createCaps() {
+ SortedSet<String> caps = new TreeSet<>();
+
+ caps.add("cap1" + i);
+ caps.add("cap2" + i);
+ caps.add("urn:opendaylight:params:xml:ns:yang:controller:netty?module=netty&revision=2013-11-19" + i);
+ caps.add("capaaaa as dasfasdf s2" + i);
+ return caps;
+ }
+
+ @Test
+ public void testFileAdapterOneBackup() throws Exception {
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.setFileStorage(file);
+ storage.setNumberOfBackups(1);
+ final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return createConfig();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return createCaps();
+ }
+ };
+ storage.persistConfig(holder);
+
+ storage.persistConfig(holder);
+
+ assertEquals(16, com.google.common.io.Files.readLines(file, Charsets.UTF_8).size());
+
+ List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
+ assertEquals(1, lastConf.size());
+ ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
+ assertEquals("<config>2</config>",
+ configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+ }
+
+ @Test
+ public void testFileAdapterOnlyTwoBackups() throws Exception {
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.setFileStorage(file);
+ storage.setNumberOfBackups(2);
+ final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return createConfig();
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return createCaps();
+ }
+ };
+ storage.persistConfig(holder);
+
+ storage.persistConfig(holder);
+ storage.persistConfig(holder);
+
+ List<String> readLines = com.google.common.io.Files.readLines(file, Charsets.UTF_8);
+ assertEquals(27, readLines.size());
+
+ List<ConfigSnapshotHolder> lastConf = storage.loadLastConfigs();
+ assertEquals(1, lastConf.size());
+ ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0);
+ assertEquals("<config>3</config>",
+ configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", ""));
+ assertFalse(readLines.contains(holder.getConfigSnapshot()));
+ }
+
+ @Test
+ public void testNoLastConfig() throws Exception {
+ File file = Files.createTempFile("testFilePersist", ".txt").toFile();
+ if (!file.exists())
+ return;
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.setFileStorage(file);
+
+ List<ConfigSnapshotHolder> elementOptional = storage.loadLastConfigs();
+ assertThat(elementOptional.size(), is(0));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNoProperties() throws Exception {
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.loadLastConfigs();
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testNoProperties2() throws Exception {
+ XmlFileStorageAdapter storage = new XmlFileStorageAdapter();
+ storage.persistConfig(new ConfigSnapshotHolder() {
+ @Override
+ public String getConfigSnapshot() {
+ return Mockito.mock(String.class);
+ }
+
+ @Override
+ public SortedSet<String> getCapabilities() {
+ return new TreeSet<>();
+ }
+ } );
+ }
+
+ static String createConfig() {
+ return "<config>" + i++ + "</config>";
+ }
+
+}
*/
package org.opendaylight.controller.config.util;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import org.opendaylight.controller.config.api.ConflictingVersionException;
+import org.opendaylight.controller.config.api.ValidationException;
+import org.opendaylight.controller.config.api.jmx.CommitStatus;
+import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
+import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
import javax.management.AttributeNotFoundException;
import javax.management.InstanceNotFoundException;
import javax.management.ObjectInstance;
import javax.management.ObjectName;
import javax.management.ReflectionException;
-
-import org.opendaylight.controller.config.api.ConflictingVersionException;
-import org.opendaylight.controller.config.api.ValidationException;
-import org.opendaylight.controller.config.api.jmx.CommitStatus;
-import org.opendaylight.controller.config.api.jmx.ConfigRegistryMXBean;
-import org.opendaylight.controller.config.api.jmx.ObjectNameUtil;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
public class ConfigRegistryJMXClient implements ConfigRegistryClient {
private final ConfigRegistryMXBean configRegistryMXBeanProxy;
}
}
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ return configRegistryMXBeanProxy.getAvailableModuleFactoryQNames();
+ }
}
+ attrName + " for " + on, e);
}
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ return configTransactionControllerMXBeanProxy.getAvailableModuleFactoryQNames();
+ }
}
public String getServiceInterfaceName(String namespace, String localName) {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ throw new UnsupportedOperationException();
+ }
}
public boolean removeServiceReferences(ObjectName objectName) throws InstanceNotFoundException {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public Set<String> getAvailableModuleFactoryQNames() {
+ throw new UnsupportedOperationException();
+ }
}
<module>config-util</module>
<module>config-persister-api</module>
<module>config-persister-file-adapter</module>
+ <module>config-persister-file-xml-adapter</module>
<module>yang-jmx-generator</module>
<module>yang-jmx-generator-plugin</module>
<module>yang-store-api</module>
<module>netty-event-executor-config</module>
<module>netty-timer-config</module>
<module>config-persister-directory-adapter</module>
+ <module>config-persister-directory-xml-adapter</module>
<module>yang-test-plugin</module>
</modules>
import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
import org.opendaylight.controller.config.spi.Module;
import org.opendaylight.controller.config.spi.ModuleFactory;
+import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
private final String globallyUniqueName, moduleInstanceType;
private final List<String> providedServices;
+ private final ModuleMXBeanEntry mbe;
public AbstractFactoryTemplate(Header header, String packageName,
- String abstractFactoryName, String globallyUniqueName,
- String moduleInstanceType, List<Field> fields,
- List<String> providedServices) {
+ String abstractFactoryName, String globallyUniqueName,
+ String moduleInstanceType, List<Field> fields,
+ List<String> providedServices, ModuleMXBeanEntry mbe) {
super(header, packageName, abstractFactoryName, Collections
.<String> emptyList(), implementedIfcs, fields, Collections
.<MethodDefinition> emptyList(), true, false, Collections
this.globallyUniqueName = globallyUniqueName;
this.moduleInstanceType = moduleInstanceType;
this.providedServices = providedServices;
+ this.mbe = mbe;
}
public String getGloballyUniqueName() {
return "factory_abs_template.ftl";
}
+ public ModuleMXBeanEntry getMbe() {
+ return mbe;
+ }
}
sieTemplate.getAnnotations().add(
Annotation.createDescriptionAnnotation(sie
.getNullableDescription()));
- sieTemplate.getAnnotations().add(Annotation.createSieAnnotation(sie.getQName(), sie.getExportedOsgiClassName
- ()));
+ sieTemplate.getAnnotations().addAll(Annotation.createSieAnnotations(sie));
return sieTemplate;
}
mbe.getPackageName(), mbe.getAbstractFactoryName(),
mbe.getGloballyUniqueName(), mbe.getFullyQualifiedName(mbe
.getStubModuleName()), attrProcessor.getFields(),
- Lists.newArrayList(transformed));
+ Lists.newArrayList(transformed), mbe);
}
public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
*/
package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
+import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
import org.opendaylight.controller.config.api.annotations.Description;
import org.opendaylight.controller.config.api.annotations.RequireInterface;
import org.opendaylight.controller.config.api.annotations.ServiceInterfaceAnnotation;
+import org.opendaylight.yangtools.yang.binding.annotations.ModuleQName;
import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
-import org.opendaylight.yangtools.yang.common.QName;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
Lists.newArrayList(new Parameter("value", q(description))));
}
- public static Annotation createSieAnnotation(QName qname,
- String exportedClassName) {
- Preconditions.checkNotNull(qname,
+ public static Collection<Annotation> createSieAnnotations(ServiceInterfaceEntry sie){
+
+ String exportedClassName = sie.getExportedOsgiClassName();
+ Preconditions.checkNotNull(sie.getQName(),
"Cannot create annotation from null qname");
Preconditions.checkNotNull(exportedClassName,
"Cannot create annotation from null exportedClassName");
+ List<Annotation> result = new ArrayList<>();
+ {
+ List<Parameter> params = Lists.newArrayList(new Parameter("value", q(sie.getQName().toString())));
+ params.add(new Parameter("osgiRegistrationType", exportedClassName + ".class"));
- List<Parameter> params = Lists.newArrayList(new Parameter("value", q(qname.toString())));
- params.add(new Parameter("osgiRegistrationType", exportedClassName + ".class"));
+ params.add(new Parameter("namespace", q(sie.getQName().getNamespace().toString())));
+ params.add(new Parameter("revision", q(sie.getQName().getFormattedRevision())));
+ params.add(new Parameter("localName", q(sie.getQName().getLocalName())));
- params.add(new Parameter("namespace", q(qname.getNamespace().toString())));
- params.add(new Parameter("revision", q(qname.getFormattedRevision())));
- params.add(new Parameter("localName", q(qname.getLocalName())));
+ Annotation sieAnnotation = new Annotation(ServiceInterfaceAnnotation.class.getCanonicalName(), params);
+ result.add(sieAnnotation);
- return new Annotation(
- ServiceInterfaceAnnotation.class.getCanonicalName(), params);
+ }
+ {
+ List<Parameter> params = new ArrayList<>();
+ params.add(new Parameter("namespace", q(sie.getYangModuleQName().getNamespace().toString())));
+ params.add(new Parameter("revision", q(sie.getYangModuleQName().getFormattedRevision())));
+ params.add(new Parameter("name", q(sie.getYangModuleQName().getLocalName())));
+
+ Annotation moduleQNameAnnotation = new Annotation(ModuleQName.class.getCanonicalName(), params);
+ result.add(moduleQNameAnnotation);
+ }
+ return result;
}
public static Annotation createRequireIfcAnnotation(
package ${packageName};
<@javadocD object=javadoc/>
+@org.opendaylight.yangtools.yang.binding.annotations.ModuleQName(namespace="${mbe.getYangModuleQName().getNamespace().toString()}",revision="${mbe.getYangModuleQName().getFormattedRevision()}",name="${mbe.getYangModuleQName().getLocalName()}")
<@typeDeclarationD object=typeDeclaration/>
{
private final Map<String, QName> providedServices;
private Collection<RuntimeBeanEntry> runtimeBeans;
+ private final QName yangModuleQName;
public ModuleMXBeanEntry(IdentitySchemaNode id,
Map<String, AttributeIfc> yangToAttributes, String packageName,
Map<String, QName> providedServices2, String javaNamePrefix,
- String namespace, Collection<RuntimeBeanEntry> runtimeBeans) {
+ String namespace, Collection<RuntimeBeanEntry> runtimeBeans,
+ QName yangModuleQName) {
this.globallyUniqueName = id.getQName().getLocalName();
this.yangToAttributes = yangToAttributes;
this.nullableDescription = id.getDescription();
this.namespace = checkNotNull(namespace);
this.providedServices = Collections.unmodifiableMap(providedServices2);
this.runtimeBeans = runtimeBeans;
+ this.yangModuleQName = yangModuleQName;
}
public String getMXBeanInterfaceName() {
moduleIdentity, yangToAttributes, packageName,
providedServices, javaNamePrefix, currentModule
.getNamespace().toString(),
- runtimeBeans);
+ runtimeBeans,
+ ModuleUtil.getQName(currentModule));
moduleMXBeanEntry.setYangModuleName(currentModule
.getName());
moduleMXBeanEntry
return nullableDescription;
}
+ public QName getYangModuleQName() {
+ return yangModuleQName;
+ }
+
@Override
public String toString() {
return "ModuleMXBeanEntry{" + "globallyUniqueName='"
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.config.yangjmxgenerator;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Module;
+
+public class ModuleUtil {
+
+ public static QName getQName(Module currentModule){
+ return new QName(currentModule.getNamespace(), currentModule.getRevision(), currentModule.getName());
+ }
+}
private final String exportedOsgiClassName;
private final QName qName;
private final String nullableDescription, packageName, typeName;
+ private final QName yangModuleQName;
- private ServiceInterfaceEntry(IdentitySchemaNode id, String packageName) {
- this(Optional.<ServiceInterfaceEntry> absent(), id, packageName);
+ private ServiceInterfaceEntry(IdentitySchemaNode id, String packageName, QName yangModuleQName) {
+ this(Optional.<ServiceInterfaceEntry> absent(), id, packageName, yangModuleQName);
}
private ServiceInterfaceEntry(Optional<ServiceInterfaceEntry> base,
- IdentitySchemaNode id, String packageName) {
+ IdentitySchemaNode id, String packageName, QName yangModuleQName) {
checkNotNull(base);
this.maybeBaseCache = base;
List<UnknownSchemaNode> unknownSchemaNodes = id.getUnknownSchemaNodes();
nullableDescription = id.getDescription();
typeName = getSimpleName(exportedOsgiClassName) + CLASS_NAME_SUFFIX;
this.packageName = packageName;
+ this.yangModuleQName = yangModuleQName;
}
private static final String getSimpleName(String fullyQualifiedName) {
* @return Map of QNames as keys and ServiceInterfaceEntry instances as
* values
*/
- public static Map<QName, ServiceInterfaceEntry> create(Module module,
+ public static Map<QName, ServiceInterfaceEntry> create(Module currentModule,
String packageName) {
logger.debug("Generating ServiceInterfaces from {} to package {}",
- module.getNamespace(), packageName);
+ currentModule.getNamespace(), packageName);
Map<IdentitySchemaNode, ServiceInterfaceEntry> identitiesToSIs = new HashMap<>();
Set<IdentitySchemaNode> notVisited = new HashSet<>(
- module.getIdentities());
+ currentModule.getIdentities());
int lastSize = notVisited.size() + 1;
while (notVisited.size() > 0) {
if (notVisited.size() == lastSize) {
} else if (identity.getBaseIdentity().getQName()
.equals(SERVICE_TYPE_Q_NAME)) {
// this is a base type
- created = new ServiceInterfaceEntry(identity, packageName);
+ created = new ServiceInterfaceEntry(identity, packageName, ModuleUtil.getQName(currentModule));
} else {
ServiceInterfaceEntry foundBase = identitiesToSIs
.get(identity.getBaseIdentity());
// derived type, did we convert the parent?
if (foundBase != null) {
created = new ServiceInterfaceEntry(
- Optional.of(foundBase), identity, packageName);
+ Optional.of(foundBase), identity, packageName, ModuleUtil.getQName(currentModule));
}
}
if (created != null) {
- created.setYangModuleName(module.getName());
+ created.setYangModuleName(currentModule.getName());
// TODO how to get local name
created.setYangModuleLocalname(identity.getQName()
.getLocalName());
return typeName;
}
+ public QName getYangModuleQName() {
+ return yangModuleQName;
+ }
+
@Override
public boolean equals(Object o) {
if (this == o)
<artifactId>config-persister-file-adapter</artifactId>
<version>${config.version}</version>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-adapter</artifactId>
- <version>${config.version}</version>
- </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-directory-adapter</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-directory-xml-adapter</artifactId>
+ <version>${config.version}</version>
+ </dependency>
<!-- Netconf -->
<dependency>
netconf.config.persister.1.properties.directoryStorage=configuration/initial/
netconf.config.persister.1.readonly=true
-netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
-netconf.config.persister.2.properties.fileStorage=configuration/current/controller.currentconfig.txt
+#netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
+#netconf.config.persister.3.properties.directoryStorage=configuration/initialXml/
+#netconf.config.persister.3.readonly=true
+
+#netconf.config.persister.4.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+#netconf.config.persister.4.properties.fileStorage=configuration/current/controller.currentconfig.txt
+#netconf.config.persister.4.properties.numberOfBackups=1
+
+netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
+netconf.config.persister.2.properties.fileStorage=configuration/current/controller.currentconfig.xml
netconf.config.persister.2.properties.numberOfBackups=1
<sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
<sonar.branch>${user.name}-private-view</sonar.branch>
<sonar.language>java</sonar.language>
+ <exam.version>3.0.0</exam.version>
</properties>
<pluginRepositories>
<developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
</scm>
-
<build>
<plugins>
<plugin>
</build>
<dependencies>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-native</artifactId>
+ <scope>test</scope>
+ <version>${exam.version}</version>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal-binding-broker-impl</artifactId>
checkArgument(!iterator.hasNext(), "Path nests inside leaf node, which is not allowed.");
return currentNode;
}
+ checkState(currentNode != null, "Current node should not be null for %s",path);
}
+ checkState(previous instanceof DataSchemaNode, "Schema node for %s should be instance of DataSchemaNode. Found %s",path,previous);
return (DataSchemaNode) previous;
}
-
private static DataSchemaNode searchInChoices(DataNodeContainer node, QName arg) {
Set<DataSchemaNode> children = node.getChildNodes();
-/**
- * @author Maros Marsalek
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
*
- * 12 2013
- *
- * Copyright (c) 2012 by Cisco Systems, Inc.
- * All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
*/
package org.opendaylight.controller.netconf.confignetconfconnector.mapping.attributes;
Preconditions.checkArgument(refNameToInstance != null, "No serviceInstances mapped to " + serviceName + " , "
+ serviceNameToRefNameToInstance.keySet());
- ServiceInstance serviceInstance = ServiceInstance.fromString(refNameToInstance.get(refName));
+ String instanceId = refNameToInstance.get(refName);
+ Preconditions.checkArgument(instanceId != null, "No serviceInstances mapped to " + serviceName + ":"
+ + refName + ", " + serviceNameToRefNameToInstance.keySet());
+
+ ServiceInstance serviceInstance = ServiceInstance.fromString(instanceId);
Preconditions.checkArgument(serviceInstance != null, "No serviceInstance mapped to " + refName
+ " under service name " + serviceName + " , " + refNameToInstance.keySet());
return serviceInstance;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import org.apache.commons.lang3.StringUtils;
import org.junit.Before;
import org.junit.Ignore;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
XmlElement modulesElement = XmlElement.fromDomElement(response).getOnlyChildElement("data")
.getOnlyChildElement("modules");
- XmlElement configAttributeType = null;
+ List<String> expectedValues = Lists.newArrayList("default-string", "configAttributeType");
+ Set<String> configAttributeType = Sets.newHashSet();
+
for (XmlElement moduleElement : modulesElement.getChildElements("module")) {
for (XmlElement type : moduleElement.getChildElements("type")) {
if (type.getAttribute(XmlUtil.XMLNS_ATTRIBUTE_KEY).equals("") == false) {
- configAttributeType = type;
+ configAttributeType.add(type.getTextContent());
}
}
}
- // TODO verify if should be default value
- assertEquals("default-string", configAttributeType.getTextContent());
+ for (String expectedValue : expectedValues) {
+ assertTrue(configAttributeType.contains(expectedValue));
+ }
}
private Map<String, Map<String, ModuleMXBeanEntry>> getMbes() throws Exception {
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-file-adapter</artifactId>
+ <artifactId>config-persister-file-xml-adapter</artifactId>
+ <scope>test</scope>
+ <version>${config.version}</version>
</dependency>
<!-- test dependencies -->
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-persister-directory-adapter</artifactId>
- <version>${parent.version}</version>
+ <artifactId>config-persister-directory-xml-adapter</artifactId>
+ <version>${config.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
* Example configuration:<pre>
netconf.config.persister.active=2,3
# read startup configuration
- netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.DirectoryStorageAdapter
+ netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
netconf.config.persister.1.properties.fileStorage=configuration/initial/
netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
import org.junit.Test;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter;
+import org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter;
import org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator;
import org.opendaylight.controller.netconf.persist.impl.osgi.PropertiesProviderBaseImpl;
List<PersisterWithConfiguration> persisters = persisterAggregator.getPersisterWithConfigurations();
assertEquals(1, persisters.size());
PersisterWithConfiguration persister = persisters.get(0);
- assertEquals(FileStorageAdapter.class.getName() ,persister.getStorage().getClass().getName());
+ assertEquals(XmlFileStorageAdapter.class.getName() ,persister.getStorage().getClass().getName());
assertFalse(persister.isReadOnly());
}
netconf.config.persister.active=2
# read startup configuration
-netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.DirectoryStorageAdapter
+netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
netconf.config.persister.1.properties.directoryStorage=target/configuration/initial/
netconf.config.persister.1.readonly=true
-netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
netconf.config.persister.2.properties.fileStorage=target/configuration/current/controller.config.2.txt
netconf.config.persister.2.properties.numberOfBackups=3
netconf.config.persister.active=3
-netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
netconf.config.persister.3.properties.fileStorage=target/configuration/current/controller.config.2.txt
netconf.config.persister.3.properties.numberOfBackups=0
<artifactId>topologymanager.integrationtest</artifactId>
<version>0.4.0-SNAPSHOT</version>
<dependencies>
+ <dependency>
+ <groupId>org.ops4j.pax.exam</groupId>
+ <artifactId>pax-exam-container-native</artifactId>
+ <version>${exam.version}</version>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>protocol_plugins.stub</artifactId>