Merge "Bug 639, Bug 641, Bug 642: This is MD-SAL based sample implementation of a...
authorTony Tkacik <ttkacik@cisco.com>
Tue, 8 Apr 2014 09:55:33 +0000 (09:55 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Tue, 8 Apr 2014 09:55:33 +0000 (09:55 +0000)
57 files changed:
opendaylight/commons/opendaylight/pom.xml
opendaylight/config/config-persister-directory-adapter/pom.xml [deleted file]
opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryPersister.java [deleted file]
opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapter.java [deleted file]
opendaylight/config/config-persister-directory-adapter/src/main/resources/footer.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/main/resources/header.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/main/resources/middle.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapterTest.java [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFile/controller.config.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedCapabilities.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedSnapshot.xml [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config1.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config2.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedCapabilities.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedSnapshot.xml [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedCapabilities.txt [deleted file]
opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedSnapshot.xml [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/pom.xml [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersister.java [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryStorageAdapter.java [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileType.java [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileTypeTest.java [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/bad_controller.xml.config [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/1controller.txt.config [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/2controller.xml.config [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.txt.config [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.xml.config [deleted file]
opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/unknown.config [deleted file]
opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryPersister.java
opendaylight/config/config-persister-directory-xml-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/xml/XmlDirectoryStorageAdapter.java
opendaylight/config/config-persister-directory-xml-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/xml/DirectoryStorageAdapterTest.java
opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles/controller.config2.xml2 [moved from opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles/controller.config2.xml with 100% similarity]
opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config1.xml [new file with mode: 0644]
opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config2.xml [new file with mode: 0644]
opendaylight/config/config-persister-file-adapter/pom.xml [deleted file]
opendaylight/config/config-persister-file-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapter.java [deleted file]
opendaylight/config/config-persister-file-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapterTest.java [deleted file]
opendaylight/config/pom.xml
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini
opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/ChangeListenerNotifyTask.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/DataChangeEventResolver.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/InMemoryDOMDataStore.java
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/md/sal/dom/store/impl/tree/ListenerRegistrationNode.java
opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml
opendaylight/md-sal/sal-rest-connector/src/main/java/org/opendaylight/controller/sal/restconf/impl/RestconfImpl.xtend
opendaylight/md-sal/sal-rest-connector/src/test/java/org/opendaylight/controller/sal/restconf/impl/test/RestGetOperationTest.java
opendaylight/md-sal/sal-rest-connector/src/test/resources/full-versions/test-module/test-module
opendaylight/md-sal/test/sal-rest-connector-it/pom.xml
opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java
opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java
opendaylight/netconf/pom.xml
opendaylight/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/NeutronSubnet.java
opendaylight/northbound/networkconfiguration/neutron/src/main/java/org/opendaylight/controller/networkconfig/neutron/northbound/NeutronSubnetsNorthbound.java
opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/DiscoveryService.java

index e7c7bbe6370c1750d88d454c8faffdd4ac2eadae..1e06679a3b9e929dc77ba5061db02c6aa3dcda11 100644 (file)
           <artifactId>config-persister-api</artifactId>
           <version>${config.version}</version>
         </dependency>
-        <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>config-persister-file-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>
-        <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>config-persister-directory-autodetect-adapter</artifactId>
-          <version>${config.version}</version>
-        </dependency>
 
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
diff --git a/opendaylight/config/config-persister-directory-adapter/pom.xml b/opendaylight/config/config-persister-directory-adapter/pom.xml
deleted file mode 100644 (file)
index 86b8c4d..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?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.5-SNAPSHOT</version>
-        <relativePath>..</relativePath>
-    </parent>
-    <artifactId>config-persister-directory-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>commons-io</groupId>
-            <artifactId>commons-io</artifactId>
-        </dependency>
-
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>mockito-configuration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>config-persister-api</artifactId>
-            <type>test-jar</type>
-            <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
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryPersister.java b/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryPersister.java
deleted file mode 100644 (file)
index eb8ef8c..0000000
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * 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;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import org.apache.commons.io.IOUtils;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolderImpl;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkState;
-
-public class DirectoryPersister implements Persister {
-    private static final Logger logger = LoggerFactory.getLogger(DirectoryPersister.class);
-    private static final Charset ENCODING = Charsets.UTF_8;
-
-    public static final String MODULES_START = "//MODULES START";
-    static final String SERVICES_START = "//SERVICES START";
-    static final String CAPABILITIES_START = "//CAPABILITIES START";
-
-
-    private final File storage;
-    private static final String header, middle, footer;
-
-    static {
-        header = readResource("header.txt");
-        middle = readResource("middle.txt");
-        footer = readResource("footer.txt");
-    }
-
-    public DirectoryPersister(File storage) {
-        checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
-        this.storage = storage;
-    }
-
-    private static String readResource(String resource) {
-        try {
-            return IOUtils.toString(DirectoryPersister.class.getResourceAsStream("/" + resource));
-        } catch (IOException e) {
-            throw new IllegalStateException("Cannot load " + resource, e);
-        }
-    }
-
-    @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 configSnapshotHolder = loadLastConfig(file);
-            result.add(configSnapshotHolder);
-        }
-        return result;
-    }
-
-    public static ConfigSnapshotHolder loadLastConfig(File file) throws IOException {
-        final MyLineProcessor lineProcessor = new MyLineProcessor(file.getAbsolutePath());
-        Files.readLines(file, ENCODING, lineProcessor);
-        return lineProcessor.getConfigSnapshotHolder(header, middle, footer);
-    }
-
-
-    @Override
-    public void close() {
-
-    }
-
-    @Override
-    public String toString() {
-        return "FileStorageAdapter [storage=" + storage + "]";
-    }
-}
-
-class MyLineProcessor implements com.google.common.io.LineProcessor<String> {
-    private final String fileNameForReporting;
-
-    private boolean inModules, inServices, inCapabilities;
-    private final StringBuffer modulesBuffer = new StringBuffer(), servicesBuilder = new StringBuffer();
-    private final SortedSet<String> caps = new TreeSet<>();
-
-    MyLineProcessor(String fileNameForReporting) {
-        this.fileNameForReporting = fileNameForReporting;
-    }
-
-    @Override
-    public String getResult() {
-        return null;
-    }
-
-    @Override
-    public boolean processLine(String line) throws IOException {
-
-        String lineWithNewLine = line + System.lineSeparator();
-        if (line.equals(DirectoryPersister.MODULES_START)) {
-            checkState(inModules == false && inServices == false && inCapabilities == false);
-            inModules = true;
-        } else if (line.equals(DirectoryPersister.SERVICES_START)) {
-            checkState(inModules == true && inServices == false && inCapabilities == false);
-            inModules = false;
-            inServices = true;
-        } else if (line.equals(DirectoryPersister.CAPABILITIES_START)) {
-            checkState(inModules == false && inServices == true && inCapabilities == false);
-            inServices = false;
-            inCapabilities = true;
-        } else if (inModules) {
-            modulesBuffer.append(lineWithNewLine);
-        } else if (inServices) {
-            servicesBuilder.append(lineWithNewLine);
-        } else {
-            caps.add(line);
-        }
-        return true;
-    }
-
-    private void checkFileConsistency(){
-        checkState(inCapabilities, "File %s is missing delimiters in this order: %s", fileNameForReporting,
-                Arrays.asList(DirectoryPersister.MODULES_START,
-                        DirectoryPersister.SERVICES_START,
-                        DirectoryPersister.CAPABILITIES_START));
-    }
-
-    String getModules() {
-        checkFileConsistency();
-        return modulesBuffer.toString();
-    }
-
-    String getServices() {
-        checkFileConsistency();
-        return servicesBuilder.toString();
-    }
-
-    SortedSet<String> getCapabilities() {
-        checkFileConsistency();
-        return caps;
-    }
-
-    ConfigSnapshotHolder getConfigSnapshotHolder(String header, String middle, String footer) {
-        String combinedSnapshot = header + getModules() + middle + getServices() + footer;
-        ConfigSnapshotHolder result = new ConfigSnapshotHolderImpl(combinedSnapshot, getCapabilities(), fileNameForReporting);
-        return result;
-    }
-
-}
-
diff --git a/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapter.java b/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapter.java
deleted file mode 100644 (file)
index 69c8fba..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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;
-
-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 DirectoryStorageAdapter implements StorageAdapter {
-    private static final Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapter.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 DirectoryPersister(storage);
-    }
-
-}
diff --git a/opendaylight/config/config-persister-directory-adapter/src/main/resources/footer.txt b/opendaylight/config/config-persister-directory-adapter/src/main/resources/footer.txt
deleted file mode 100644 (file)
index d4dcc62..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-    </services>
-</data>
diff --git a/opendaylight/config/config-persister-directory-adapter/src/main/resources/header.txt b/opendaylight/config/config-persister-directory-adapter/src/main/resources/header.txt
deleted file mode 100644 (file)
index 90ed41c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
diff --git a/opendaylight/config/config-persister-directory-adapter/src/main/resources/middle.txt b/opendaylight/config/config-persister-directory-adapter/src/main/resources/middle.txt
deleted file mode 100644 (file)
index f728cfd..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-    </modules>
-    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapterTest.java b/opendaylight/config/config-persister-directory-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapterTest.java
deleted file mode 100644 (file)
index 278d0d2..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.commons.io.IOUtils;
-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.test.PropertiesProviderTest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-public class DirectoryStorageAdapterTest {
-    Persister tested;
-
-    private Persister instantiatePersisterFromAdapter(File file){
-        PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("directoryStorage",file.getPath());
-        DirectoryStorageAdapter dsa = new DirectoryStorageAdapter();
-        return dsa.instantiate(pp);
-    }
-    @Test
-    public void testEmptyDirectory() throws Exception {
-        File folder = new File("target/emptyFolder");
-        folder.mkdir();
-
-        tested =  instantiatePersisterFromAdapter(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 = instantiatePersisterFromAdapter(folder);
-
-        List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
-        assertEquals(1, results.size());
-        ConfigSnapshotHolder result = results.get(0);
-        assertSnapshot(result, "oneFileExpected");
-    }
-
-
-    @Test
-    public void testTwoFiles() throws Exception {
-        File folder = getFolder("twoFiles");
-        tested = instantiatePersisterFromAdapter(folder);
-
-        List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
-        assertEquals(2, results.size());
-        assertSnapshot(results.get(0), "twoFilesExpected1");
-        assertSnapshot(results.get(1), "twoFilesExpected2");
-    }
-
-    private void assertSnapshot(ConfigSnapshotHolder result, String directory) throws Exception {
-        SortedSet<String> expectedCapabilities = new TreeSet<>(IOUtils.readLines(getClass().getResourceAsStream("/" + directory + "/expectedCapabilities.txt")));
-        String expectedSnapshot = IOUtils.toString(getClass().getResourceAsStream("/" + directory + "/expectedSnapshot.xml"));
-        expectedSnapshot = expectedSnapshot.replaceAll("\r","");
-        String _snapshot = result.getConfigSnapshot();
-        _snapshot = _snapshot.replaceAll("\r","");
-        assertEquals(expectedCapabilities, result.getCapabilities());
-        assertEquals(expectedSnapshot, _snapshot);
-    }
-
-}
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFile/controller.config.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFile/controller.config.txt
deleted file mode 100644 (file)
index 99b4cb9..0000000
+++ /dev/null
@@ -1,120 +0,0 @@
-//MODULES START
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
-            <name>yang-schema-service</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
-            <name>hash-map-data-store</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
-            <name>dom-broker</name>
-            <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-                <name>ref_hash-map-data-store</name>
-            </data-store>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
-            <name>binding-broker-impl</name>
-            <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-                <name>ref_binding-notification-broker</name>
-            </notification-service>
-            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-                <name>ref_binding-data-broker</name>
-            </data-broker>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
-            <name>runtime-mapping-singleton</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
-            <name>binding-notification-broker</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
-            <name>binding-data-broker</name>
-            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                <name>ref_dom-broker</name>
-            </dom-broker>
-            <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                <name>ref_runtime-mapping-singleton</name>
-            </mapping-service>
-        </module>
-//SERVICES START
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-            <instance>
-                <name>ref_yang-schema-service</name>
-                <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-            <instance>
-                <name>ref_binding-notification-broker</name>
-                <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-            <instance>
-                <name>ref_hash-map-data-store</name>
-                <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <instance>
-                <name>ref_binding-broker-impl</name>
-                <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
-            <instance>
-                <name>ref_runtime-mapping-singleton</name>
-                <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <instance>
-                <name>ref_dom-broker</name>
-                <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-            <instance>
-                <name>ref_binding-data-broker</name>
-                <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
-            </instance>
-        </service>
-//CAPABILITIES START
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedCapabilities.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedCapabilities.txt
deleted file mode 100644 (file)
index 84c85b7..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedSnapshot.xml b/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedSnapshot.xml
deleted file mode 100644 (file)
index a6a57d7..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
-            <name>yang-schema-service</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
-            <name>hash-map-data-store</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
-            <name>dom-broker</name>
-            <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-                <name>ref_hash-map-data-store</name>
-            </data-store>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
-            <name>binding-broker-impl</name>
-            <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-                <name>ref_binding-notification-broker</name>
-            </notification-service>
-            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-                <name>ref_binding-data-broker</name>
-            </data-broker>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
-            <name>runtime-mapping-singleton</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
-            <name>binding-notification-broker</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
-            <name>binding-data-broker</name>
-            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                <name>ref_dom-broker</name>
-            </dom-broker>
-            <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                <name>ref_runtime-mapping-singleton</name>
-            </mapping-service>
-        </module>
-    </modules>
-    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-            <instance>
-                <name>ref_yang-schema-service</name>
-                <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-            <instance>
-                <name>ref_binding-notification-broker</name>
-                <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-            <instance>
-                <name>ref_hash-map-data-store</name>
-                <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <instance>
-                <name>ref_binding-broker-impl</name>
-                <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
-            <instance>
-                <name>ref_runtime-mapping-singleton</name>
-                <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <instance>
-                <name>ref_dom-broker</name>
-                <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-            <instance>
-                <name>ref_binding-data-broker</name>
-                <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
-            </instance>
-        </service>
-    </services>
-</data>
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config1.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config1.txt
deleted file mode 100644 (file)
index 6ae48fb..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-//MODULES START
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
-            <name>yang-schema-service</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
-            <name>hash-map-data-store</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
-            <name>dom-broker</name>
-            <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-                <name>ref_hash-map-data-store</name>
-            </data-store>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
-            <name>binding-broker-impl</name>
-            <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-                <name>ref_binding-notification-broker</name>
-            </notification-service>
-            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-                <name>ref_binding-data-broker</name>
-            </data-broker>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
-            <name>runtime-mapping-singleton</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
-            <name>binding-notification-broker</name>
-        </module>
-//SERVICES START
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-            <instance>
-                <name>ref_yang-schema-service</name>
-                <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-            <instance>
-                <name>ref_binding-notification-broker</name>
-                <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-            <instance>
-                <name>ref_hash-map-data-store</name>
-                <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <instance>
-                <name>ref_binding-broker-impl</name>
-                <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
-            <instance>
-                <name>ref_runtime-mapping-singleton</name>
-                <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <instance>
-                <name>ref_dom-broker</name>
-                <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
-            </instance>
-        </service>
-//CAPABILITIES START
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config2.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config2.txt
deleted file mode 100644 (file)
index ad9138f..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-//MODULES START
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
-            <name>binding-data-broker</name>
-            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                <name>ref_dom-broker</name>
-            </dom-broker>
-            <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                <name>ref_runtime-mapping-singleton</name>
-            </mapping-service>
-        </module>
-//SERVICES START
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-            <instance>
-                <name>ref_binding-data-broker</name>
-                <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
-            </instance>
-        </service>
-//CAPABILITIES START
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedCapabilities.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedCapabilities.txt
deleted file mode 100644 (file)
index ef35fdd..0000000
+++ /dev/null
@@ -1 +0,0 @@
-urn:opendaylight:l2:types?module=opendaylight-l2-types&revision=2013-08-27
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedSnapshot.xml b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedSnapshot.xml
deleted file mode 100644 (file)
index 2b1d06e..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:schema-service-singleton</type>
-            <name>yang-schema-service</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:hash-map-data-store</type>
-            <name>hash-map-data-store</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">prefix:dom-broker-impl</type>
-            <name>dom-broker</name>
-            <data-store xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-                <name>ref_hash-map-data-store</name>
-            </data-store>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-broker-impl</type>
-            <name>binding-broker-impl</name>
-            <notification-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-                <name>ref_binding-notification-broker</name>
-            </notification-service>
-            <data-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-                <name>ref_binding-data-broker</name>
-            </data-broker>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:runtime-generated-mapping</type>
-            <name>runtime-mapping-singleton</name>
-        </module>
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-notification-broker</type>
-            <name>binding-notification-broker</name>
-        </module>
-    </modules>
-    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:schema-service</type>
-            <instance>
-                <name>ref_yang-schema-service</name>
-                <provider>/config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-notification-service</type>
-            <instance>
-                <name>ref_binding-notification-broker</name>
-                <provider>/config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-data-store</type>
-            <instance>
-                <name>ref_hash-map-data-store</name>
-                <provider>/config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
-            <instance>
-                <name>ref_binding-broker-impl</name>
-                <provider>/config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:binding-impl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding-impl:binding-dom-mapping-service</type>
-            <instance>
-                <name>ref_runtime-mapping-singleton</name>
-                <provider>/config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton']</provider>
-            </instance>
-        </service>
-        <service>
-            <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-            <instance>
-                <name>ref_dom-broker</name>
-                <provider>/config/modules/module[name='dom-broker-impl']/instance[name='dom-broker']</provider>
-            </instance>
-        </service>
-    </services>
-</data>
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedCapabilities.txt b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedCapabilities.txt
deleted file mode 100644 (file)
index 9924111..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:threadpool?module=threadpool&revision=2013-04-09
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
-urn:ietf:params:netconf:capability:candidate:1.0
-urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
-urn:opendaylight:params:xml:ns:yang:controller:netty:eventexecutor?module=netty-event-executor&revision=2013-11-12
-urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28
-urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
-urn:ietf:params:netconf:capability:rollback-on-error:1.0
-urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
-urn:opendaylight:params:xml:ns:yang:controller:threadpool:impl?module=threadpool-impl&revision=2013-04-05
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:controller:logback:config?module=config-logging&revision=2013-07-16
-urn:opendaylight:yang:extension:yang-ext?module=yang-ext&revision=2013-07-09
-urn:opendaylight:params:xml:ns:yang:iana?module=iana&revision=2013-08-16
-urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
-urn:opendaylight:params:xml:ns:yang:ieee754?module=ieee754&revision=2013-08-19
diff --git a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedSnapshot.xml b/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedSnapshot.xml
deleted file mode 100644 (file)
index 887cb2c..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
-    <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <module>
-            <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">prefix:binding-data-broker</type>
-            <name>binding-data-broker</name>
-            <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:dom="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">dom:dom-broker-osgi-registry</type>
-                <name>ref_dom-broker</name>
-            </dom-broker>
-            <mapping-service xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">
-                <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">binding:binding-dom-mapping-service</type>
-                <name>ref_runtime-mapping-singleton</name>
-            </mapping-service>
-        </module>
-    </modules>
-    <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
-        <service>
-            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
-            <instance>
-                <name>ref_binding-data-broker</name>
-                <provider>/config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker']</provider>
-            </instance>
-        </service>
-    </services>
-</data>
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/pom.xml b/opendaylight/config/config-persister-directory-autodetect-adapter/pom.xml
deleted file mode 100644 (file)
index 5e556c0..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-<?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.5-SNAPSHOT</version>
-        <relativePath>..</relativePath>
-    </parent>
-    <artifactId>config-persister-directory-autodetect-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-directory-adapter</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-directory-xml-adapter</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.yangtools</groupId>
-            <artifactId>mockito-configuration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>config-persister-api</artifactId>
-            <type>test-jar</type>
-            <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,
-                            org.opendaylight.controller.config.persist.storage.directory,
-                            org.opendaylight.controller.config.persist.storage.directory.xml,
-                        </Private-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-</project>
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersister.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersister.java
deleted file mode 100644 (file)
index 2028d62..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.autodetect;
-
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.storage.directory.DirectoryPersister;
-import org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryPersister;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.xml.bind.JAXBException;
-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 static com.google.common.base.Preconditions.checkArgument;
-
-public class AutodetectDirectoryPersister implements Persister {
-    private static final Logger logger = LoggerFactory.getLogger(AutodetectDirectoryPersister.class);
-
-    private final File storage;
-
-    public AutodetectDirectoryPersister(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);
-
-            FileType fileType = FileType.getFileType(file);
-            logger.trace("File '{}' detected as {} storage", file, fileType);
-
-            ConfigSnapshotHolder snapshot = loadLastConfig(file, fileType);
-            result.add(snapshot);
-        }
-        return result;
-    }
-
-    private ConfigSnapshotHolder loadLastConfig(File file, FileType fileType) throws IOException {
-        switch (fileType) {
-        case plaintext:
-            logger.warn("Plaintext configuration files are deprecated, and will not be supported in future versions. " +
-                    "Use xml files instead");
-            return DirectoryPersister.loadLastConfig(file);
-        case xml:
-            try {
-                return XmlDirectoryPersister.loadLastConfig(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);
-            }
-        default:
-            throw new IllegalStateException("Unknown storage type " + fileType);
-        }
-    }
-
-    @Override
-    public void close() {
-
-    }
-
-    @Override
-    public String toString() {
-        final StringBuffer sb = new StringBuffer("AutodetectDirectoryPersister{");
-        sb.append("storage=").append(storage);
-        sb.append('}');
-        return sb.toString();
-    }
-}
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryStorageAdapter.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryStorageAdapter.java
deleted file mode 100644 (file)
index f856ddd..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * 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.autodetect;
-
-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 AutodetectDirectoryStorageAdapter implements StorageAdapter {
-    private static final Logger logger = LoggerFactory.getLogger(AutodetectDirectoryStorageAdapter.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 AutodetectDirectoryPersister(storage);
-    }
-
-}
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileType.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileType.java
deleted file mode 100644 (file)
index 779a887..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.autodetect;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.controller.config.persist.storage.directory.DirectoryPersister;
-import org.opendaylight.controller.config.persist.storage.file.xml.model.ConfigSnapshot;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Arrays;
-
-enum FileType {
-
-    plaintext, xml;
-
-    public static final String XML_STORAGE_FIRST_LINE = "<" + ConfigSnapshot.SNAPSHOT_ROOT_ELEMENT_NAME + ">";
-    private static final String XML_FILE_DEFINITION_LINE = "<?xml";
-
-    static FileType getFileType(File file) {
-        String firstLine = readFirstLine(file);
-        if(isPlaintextStorage(firstLine)) {
-            return plaintext;
-        } else if(isXmlStorage(firstLine))
-            return xml;
-
-        throw new IllegalArgumentException("File " + file + " is not of permitted storage type: " + Arrays.toString(FileType.values()));
-    }
-
-    private static boolean isXmlStorage(String firstLine) {
-        boolean isXml = false;
-        isXml |= firstLine.startsWith(XML_STORAGE_FIRST_LINE);
-        isXml |= firstLine.startsWith(XML_FILE_DEFINITION_LINE);
-        return isXml;
-    }
-
-    private static boolean isPlaintextStorage(String firstLine) {
-        return firstLine.startsWith(DirectoryPersister.MODULES_START);
-
-    }
-
-    @VisibleForTesting
-    static String readFirstLine(File file) {
-        FirstLineReadingProcessor callback = new FirstLineReadingProcessor();
-        try {
-            return Files.readLines(file, Charsets.UTF_8, callback);
-        } catch (IOException e) {
-            throw new IllegalArgumentException("Unable to detect file type of file " + file, e);
-        }
-    }
-
-
-    private static class FirstLineReadingProcessor implements com.google.common.io.LineProcessor<String> {
-        private String firstNonBlankLine;
-
-        @Override
-        public boolean processLine(String line) throws IOException {
-            if(isEmptyLine(line)) {
-                return true;
-            } else {
-                firstNonBlankLine = line.trim();
-                return false;
-            }
-        }
-
-        private boolean isEmptyLine(String line) {
-            return StringUtils.isBlank(line);
-        }
-
-        @Override
-        public String getResult() {
-            return firstNonBlankLine;
-        }
-    }
-}
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java
deleted file mode 100644 (file)
index bcade93..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * 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.autodetect;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import junit.framework.Assert;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-
-public class AutodetectDirectoryPersisterTest {
-
-    @Test
-    public void testCombined() throws Exception {
-        File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
-        File parentFile = resourcePath.getParentFile();
-
-        AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
-        PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("directoryStorage",parentFile.getPath());
-        AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
-        List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
-
-        Assert.assertEquals(2, configs.size());
-        String snapFromTxt = configs.get(0).getConfigSnapshot();
-        org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<config>txt</config>"));
-        org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("<service>txt</service>"));
-
-        String snapFromXml = configs.get(1).getConfigSnapshot();
-        org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("<config>xml</config>"));
-
-        Assert.assertEquals(configs.get(0).getCapabilities(), configs.get(1).getCapabilities());
-    }
-
-    @Test
-    public void testInvalidXml() throws Exception {
-        File resourcePath = FileTypeTest.getResourceAsFile("/bad_controller.xml.config");
-        File parentFile = resourcePath.getParentFile();
-
-        AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
-        PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("directoryStorage",parentFile.getPath());
-        AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
-        try {
-            List<ConfigSnapshotHolder> configs = persister.loadLastConfigs();
-            fail("An exception of type " + IllegalStateException.class + " was expected");
-        } catch (IllegalStateException ise){
-            String message = ise.getMessage();
-            assertThat(message, JUnitMatchers.containsString("Unable to restore configuration snapshot from "));
-        }
-
-    }
-
-    @Test
-    public void testPersistConfig() throws Exception {
-        File resourcePath = FileTypeTest.getResourceAsFile("/combined/1controller.txt.config");
-        File parentFile = resourcePath.getParentFile();
-
-        AutodetectDirectoryStorageAdapter adapter = new AutodetectDirectoryStorageAdapter();
-
-        PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("directoryStorage",parentFile.getPath());
-        AutodetectDirectoryPersister persister = (AutodetectDirectoryPersister) adapter.instantiate(pp);
-        List<ConfigSnapshotHolder> configs = null;
-        try {
-            configs = persister.loadLastConfigs();
-        } catch (IOException e) {
-            fail("An exception of type " + UnsupportedOperationException.class + " was expected");
-        }
-        Assert.assertEquals(2, configs.size());
-        try {
-            persister.persistConfig(configs.get(0));
-        } catch (UnsupportedOperationException uoe){
-            String message = uoe.getMessage();
-            assertThat(message,JUnitMatchers.containsString("This adapter is read only. Please set readonly=true on class"));
-        }
-    }
-
-}
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileTypeTest.java b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileTypeTest.java
deleted file mode 100644 (file)
index bbc272d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.autodetect;
-
-import junit.framework.Assert;
-import org.junit.Test;
-import org.junit.matchers.JUnitMatchers;
-
-import java.io.File;
-
-public class FileTypeTest {
-
-    @Test
-    public void testPlaintext() throws Exception {
-        File file = getResourceAsFile("/test.txt.config");
-
-        FileType type = FileType.getFileType(file);
-        Assert.assertEquals(FileType.plaintext, type);
-
-    }
-
-    @Test
-    public void testXml() throws Exception {
-        File file = getResourceAsFile("/test.xml.config");
-
-        FileType type = FileType.getFileType(file);
-        Assert.assertEquals(FileType.xml, type);
-    }
-
-    @Test(expected = IllegalArgumentException.class)
-    public void testUnknown() throws Exception {
-        File file = getResourceAsFile("/unknown.config");
-
-        try {
-            FileType.getFileType(file);
-        } catch (IllegalArgumentException e) {
-            org.junit.Assert.assertThat(e.getMessage(), JUnitMatchers.containsString("File " + file + " is not of permitted storage type"));
-            throw e;
-        }
-    }
-
-    static File getResourceAsFile(String resource) {
-        String f = FileTypeTest.class.getResource(resource).getFile();
-        return new File(f);
-    }
-
-}
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/bad_controller.xml.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/bad_controller.xml.config
deleted file mode 100644 (file)
index 3f6a337..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<snapshot>
-    <required-capabilities>
-        <capability
-        <capability>cap2</capability>
-        <capability>capa a</capability>
-    </required-capabilities>
-    <configuration>
-        <config>xml</config>
-    </configuration>
-</snapshot>
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/1controller.txt.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/1controller.txt.config
deleted file mode 100644 (file)
index f72cd1c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-//MODULES START
-        <config>txt</config>
-//SERVICES START
-        <service>txt</service>
-//CAPABILITIES START
-cap1&rev
-cap2
-capa a
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/2controller.xml.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/2controller.xml.config
deleted file mode 100644 (file)
index 988f866..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-<snapshot>
-    <required-capabilities>
-        <capability>cap1&amp;rev</capability>
-        <capability>cap2</capability>
-        <capability>capa a</capability>
-    </required-capabilities>
-    <configuration>
-        <config>xml</config>
-    </configuration>
-</snapshot>
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.txt.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.txt.config
deleted file mode 100644 (file)
index edf37ca..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-//MODULES START
-configuration
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.xml.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.xml.config
deleted file mode 100644 (file)
index fe94299..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-<snapshot>
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/unknown.config b/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/unknown.config
deleted file mode 100644 (file)
index c4218c8..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-unknown
-file type
\ No newline at end of file
index 0ca47edf0e5540cef5db8c2bcbb8f0d8f9dde611..7f8ebd7fddf8e7ee93a665106040ef4c83c5fb96 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.controller.config.persist.storage.directory.xml;
 
+import com.google.common.base.Optional;
+import com.google.common.io.Files;
 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;
@@ -17,11 +19,13 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBException;
 import javax.xml.bind.Unmarshaller;
 import java.io.File;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
+import java.util.Set;
 import java.util.SortedSet;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -30,10 +34,26 @@ public class XmlDirectoryPersister implements Persister {
     private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryPersister.class);
 
     private final File storage;
+    private final Optional<FilenameFilter> extensionsFilter;
 
+    /**
+     * Creates XmlDirectoryPersister that picks up all files in specified folder
+     */
     public XmlDirectoryPersister(File storage) {
+        this(storage, Optional.<FilenameFilter>absent());
+    }
+
+    /**
+     * Creates XmlDirectoryPersister that picks up files only with specified file extension
+     */
+    public XmlDirectoryPersister(File storage, Set<String> fileExtensions) {
+        this(storage, Optional.of(getFilter(fileExtensions)));
+    }
+
+    private XmlDirectoryPersister(File storage, Optional<FilenameFilter> extensionsFilter) {
         checkArgument(storage.exists() && storage.isDirectory(), "Storage directory does not exist: " + storage);
         this.storage = storage;
+        this.extensionsFilter = extensionsFilter;
     }
 
     @Override
@@ -43,7 +63,7 @@ public class XmlDirectoryPersister implements Persister {
 
     @Override
     public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
-        File[] filesArray = storage.listFiles();
+        File[] filesArray = extensionsFilter.isPresent() ? storage.listFiles(extensionsFilter.get()) : storage.listFiles();
         if (filesArray == null || filesArray.length == 0) {
             return Collections.emptyList();
         }
@@ -55,19 +75,30 @@ public class XmlDirectoryPersister implements Persister {
         List<ConfigSnapshotHolder> result = new ArrayList<>();
         for (File file : sortedFiles) {
             logger.trace("Adding file '{}' to combined result", file);
-            ConfigSnapshotHolder h = fromXmlSnapshot(file);
-            result.add(h);
+            Optional<ConfigSnapshotHolder> h = fromXmlSnapshot(file);
+            // Ignore non valid snapshot
+            if(h.isPresent() == false) {
+                continue;
+            }
+
+            result.add(h.get());
         }
         return result;
     }
 
-    private ConfigSnapshotHolder fromXmlSnapshot(File file) {
+    private Optional<ConfigSnapshotHolder> fromXmlSnapshot(File file) {
         try {
-            return loadLastConfig(file);
+            return Optional.of(loadLastConfig(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);
+            // In case of parse error, issue a warning, ignore and continue
+            logger.warn(
+                    "Unable to parse configuration snapshot from {}. Initial config from {} will be IGNORED in this run. " +
+                    "Note that subsequent config files may fail due to this problem. " +
+                    "Xml markup in this file needs to be fixed, for detailed information see enclosed exception.",
+                    file, file, e);
         }
+
+        return Optional.absent();
     }
 
     public static ConfigSnapshotHolder loadLastConfig(File file) throws JAXBException {
@@ -96,6 +127,17 @@ public class XmlDirectoryPersister implements Persister {
         };
     }
 
+    private static FilenameFilter getFilter(final Set<String>fileExtensions) {
+        checkArgument(fileExtensions.isEmpty() == false, "No file extension provided", fileExtensions);
+
+        return new FilenameFilter() {
+            @Override
+            public boolean accept(File dir, String name) {
+                String ext = Files.getFileExtension(name);
+                return fileExtensions.contains(ext);
+            }
+        };
+    }
 
     @Override
     public void close() {
index ab6fb1577cc49261b134b2db57ad15dd76c63938..40f8c283ddd5a8e49ff7eb2c8464bddd65178a98 100644 (file)
@@ -9,6 +9,8 @@
 package org.opendaylight.controller.config.persist.storage.directory.xml;
 
 import com.google.common.base.Preconditions;
+import com.google.common.base.Splitter;
+import com.google.common.collect.Sets;
 import org.opendaylight.controller.config.persist.api.Persister;
 import org.opendaylight.controller.config.persist.api.PropertiesProvider;
 import org.opendaylight.controller.config.persist.api.StorageAdapter;
@@ -16,6 +18,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.io.File;
+import java.util.Set;
 
 /**
  * StorageAdapter that retrieves initial configuration from a directory. If multiple files are present, snapshot and
@@ -25,6 +28,8 @@ public class XmlDirectoryStorageAdapter implements StorageAdapter {
     private static final Logger logger = LoggerFactory.getLogger(XmlDirectoryStorageAdapter.class);
 
     public static final String DIRECTORY_STORAGE_PROP = "directoryStorage";
+    public static final String INCLUDE_EXT_PROP = "includeExtensions";
+    private static final char EXTENSIONS_SEPARATOR = ',';
 
 
     @Override
@@ -32,8 +37,21 @@ public class XmlDirectoryStorageAdapter implements StorageAdapter {
         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);
+        String fileExtensions = propertiesProvider.getProperty(INCLUDE_EXT_PROP);
+
+        logger.debug("Using storage: {}", storage);
+
+        if(fileExtensions != null) {
+            logger.debug("Using extensions: {}", fileExtensions);
+            return new XmlDirectoryPersister(storage, splitExtensions(fileExtensions));
+        } else {
+            return new XmlDirectoryPersister(storage);
+        }
+    }
+
+    private Set<String> splitExtensions(String fileExtensions) {
+        return Sets.newHashSet(Splitter.on(EXTENSIONS_SEPARATOR).trimResults().omitEmptyStrings()
+                .split(fileExtensions));
     }
 
 }
index 8e34bc79903bcb54c712416afa906246c2ef3a5e..da442ef4b2fb669b5b1bd0e9a389616cc6755b97 100644 (file)
@@ -12,6 +12,8 @@ import java.io.File;
 import java.util.Collections;
 import java.util.List;
 import java.util.SortedSet;
+
+import com.google.common.base.Optional;
 import org.junit.Test;
 import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
 import org.opendaylight.controller.config.persist.api.Persister;
@@ -26,13 +28,21 @@ public class DirectoryStorageAdapterTest {
     Persister tested;
     Logger logger = LoggerFactory.getLogger(DirectoryStorageAdapterTest.class.toString());
 
-    private Persister instantiatePersisterFromAdapter(File file){
+    private Persister instantiatePersisterFromAdapter(File file, Optional<String> extensions){
         PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("directoryStorage",file.getPath());
+        pp.addProperty(XmlDirectoryStorageAdapter.DIRECTORY_STORAGE_PROP,file.getPath());
+        if(extensions.isPresent()) {
+            pp.addProperty(XmlDirectoryStorageAdapter.INCLUDE_EXT_PROP, extensions.get());
+        }
+
         XmlDirectoryStorageAdapter dsa = new XmlDirectoryStorageAdapter();
         return dsa.instantiate(pp);
     }
 
+    private Persister instantiatePersisterFromAdapter(File file){
+        return instantiatePersisterFromAdapter(file, Optional.<String>absent());
+    }
+
     @Test
     public void testEmptyDirectory() throws Exception {
         File folder = new File("target/emptyFolder");
@@ -69,15 +79,22 @@ public class DirectoryStorageAdapterTest {
     @Test
     public void testOneFile() throws Exception {
         File folder = getFolder("oneFile");
-        tested = instantiatePersisterFromAdapter(folder);
+        tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
 
-        logger.info("Testing : "+tested.toString());
+        logger.info("Testing : " + tested.toString());
         List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
         assertEquals(1, results.size());
         ConfigSnapshotHolder result = results.get(0);
         assertResult(result, "<config>1</config>", "cap1&rev", "cap2", "capa a");
     }
 
+    @Test
+    public void testOneFileWrongExtension() throws Exception {
+        File folder = getFolder("oneFile");
+        tested = instantiatePersisterFromAdapter(folder, Optional.of("aa, bb"));
+        logger.info("Testing : " + tested.toString());
+    }
+
     private void assertResult(ConfigSnapshotHolder result, String s, String... caps) {
         assertEquals(s, result.getConfigSnapshot().replaceAll("\\s", ""));
         int i = 0;
@@ -87,16 +104,45 @@ public class DirectoryStorageAdapterTest {
     }
 
     @Test
-    public void testTwoFiles() throws Exception {
+    public void testTwoFilesAllExtensions() throws Exception {
         File folder = getFolder("twoFiles");
         tested = instantiatePersisterFromAdapter(folder);
-        logger.info("Testing : "+tested.toString());
+        logger.info("Testing : " + tested.toString());
         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");
+    }
+
+    @Test
+    public void testTwoFilesTwoExtensions() throws Exception {
+        File folder = getFolder("twoFiles");
+        tested = instantiatePersisterFromAdapter(folder, Optional.of("xml, xml2"));
+        logger.info("Testing : " + tested.toString());
+        assertEquals(2, tested.loadLastConfigs().size());
+    }
+
+    @Test
+    public void testTwoFilesOnlyOneExtension() throws Exception {
+        File folder = getFolder("twoFiles");
+        tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
+        logger.info("Testing : " + tested.toString());
+        List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+        assertEquals(1, results.size());
 
+        assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
+    }
+
+    @Test
+    public void testTwoFilesOneInvalid() throws Exception {
+        File folder = getFolder("twoFiles_corrupt");
+        tested = instantiatePersisterFromAdapter(folder, Optional.of("xml"));
+        logger.info("Testing : " + tested.toString());
+        List<ConfigSnapshotHolder> results = tested.loadLastConfigs();
+        assertEquals(1, results.size());
+
+        assertResult(results.get(0), "<config>1</config>", "cap1-a", "cap2-a", "capa a-a");
     }
 
 }
diff --git a/opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config1.xml b/opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config1.xml
new file mode 100644 (file)
index 0000000..28f112e
--- /dev/null
@@ -0,0 +1,10 @@
+<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
diff --git a/opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config2.xml b/opendaylight/config/config-persister-directory-xml-adapter/src/test/resources/twoFiles_corrupt/controller.config2.xml
new file mode 100644 (file)
index 0000000..ed781d5
--- /dev/null
@@ -0,0 +1,10 @@
+<snapshotInvalid>
+    <required-capabilities>
+        <capability>cap1-b</capability>
+        <capability>cap2-b</capability>
+        <capability>capa a-b</capability>
+    </required-capabilities>
+    <configuration>
+        <config>2</config>
+    </configuration>
+</snapshotInvalid>
\ No newline at end of file
diff --git a/opendaylight/config/config-persister-file-adapter/pom.xml b/opendaylight/config/config-persister-file-adapter/pom.xml
deleted file mode 100644 (file)
index a8ea93e..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-<?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.5-SNAPSHOT</version>
-        <relativePath>..</relativePath>
-    </parent>
-    <artifactId>config-persister-file-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>
-
-        <!-- test dependencies -->
-        <dependency>
-            <groupId>org.opendaylight.yangtools</groupId>
-            <artifactId>mockito-configuration</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${project.groupId}</groupId>
-            <artifactId>config-persister-api</artifactId>
-            <type>test-jar</type>
-            <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>
diff --git a/opendaylight/config/config-persister-file-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapter.java b/opendaylight/config/config-persister-file-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapter.java
deleted file mode 100644 (file)
index 1b9948b..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Charsets;
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.io.Files;
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.apache.commons.lang3.StringUtils;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolderImpl;
-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;
-
-/**
- * StorageAdapter that stores configuration in a plain file.
- */
-public class FileStorageAdapter implements StorageAdapter, Persister {
-    private static final Logger logger = LoggerFactory.getLogger(FileStorageAdapter.class);
-
-
-    private static final Charset ENCODING = Charsets.UTF_8;
-
-    public static final String FILE_STORAGE_PROP = "fileStorage";
-    public static final String NUMBER_OF_BACKUPS = "numberOfBackups";
-
-
-    private static final String SEPARATOR_E_PURE = "//END OF CONFIG";
-    private static final String SEPARATOR_E = newLine(SEPARATOR_E_PURE);
-
-    private static final String SEPARATOR_M_PURE = "//END OF SNAPSHOT";
-    private static final String SEPARATOR_M = newLine(SEPARATOR_M_PURE);
-
-    private static final String SEPARATOR_S = newLine("//START OF CONFIG");
-
-    private static final String SEPARATOR_SL_PURE = "//START OF CONFIG-LAST";
-    private static final String SEPARATOR_SL = newLine(SEPARATOR_SL_PURE);
-
-    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
-    void setFileStorage(File storage) {
-        this.storage = storage;
-    }
-
-    @VisibleForTesting
-    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;
-    }
-
-    private static String newLine(String string) {
-        return string + "\n";
-    }
-
-    @Override
-    public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
-        Preconditions.checkNotNull(storage, "Storage file is null");
-
-        String content = Files.toString(storage, ENCODING);
-        if (numberOfStoredBackups == Integer.MAX_VALUE) {
-            resetLastConfig(content);
-            persistLastConfig(holder);
-        } else {
-            if (numberOfStoredBackups == 1) {
-                Files.write("", storage, ENCODING);
-                persistLastConfig(holder);
-            } else {
-                int count = StringUtils.countMatches(content, SEPARATOR_S);
-                if ((count + 1) < numberOfStoredBackups) {
-                    resetLastConfig(content);
-                    persistLastConfig(holder);
-                } else {
-                    String contentSubString = StringUtils.substringBefore(content, SEPARATOR_E);
-                    contentSubString = contentSubString.concat(SEPARATOR_E_PURE);
-                    content = StringUtils.substringAfter(content, contentSubString);
-                    resetLastConfig(content);
-                    persistLastConfig(holder);
-                }
-            }
-        }
-    }
-
-    private void resetLastConfig(String content) throws IOException {
-        content = content.replaceFirst(SEPARATOR_SL, SEPARATOR_S);
-        Files.write(content, storage, ENCODING);
-    }
-
-    private void persistLastConfig(ConfigSnapshotHolder holder) throws IOException {
-        Files.append(SEPARATOR_SL, storage, ENCODING);
-        String snapshotAsString = holder.getConfigSnapshot();
-        Files.append(newLine(snapshotAsString), storage, ENCODING);
-        Files.append(SEPARATOR_M, storage, ENCODING);
-        Files.append(toStringCaps(holder.getCapabilities()), storage, ENCODING);
-        Files.append(SEPARATOR_E, storage, ENCODING);
-    }
-
-    private CharSequence toStringCaps(Set<String> capabilities) {
-        StringBuilder b = new StringBuilder();
-        for (String capability : capabilities) {
-            b.append(newLine(capability));
-        }
-        return b.toString();
-    }
-
-    @Override
-    public List<ConfigSnapshotHolder> loadLastConfigs() throws IOException {
-        Preconditions.checkNotNull(storage, "Storage file is null");
-
-        if (!storage.exists()) {
-            return Collections.emptyList();
-        }
-
-        final LineProcessor lineProcessor = new LineProcessor();
-        Files.readLines(storage, ENCODING, lineProcessor);
-
-        if (lineProcessor.getConfigSnapshot().isPresent() == false) {
-            return Collections.emptyList();
-        } else {
-            return Arrays.<ConfigSnapshotHolder>asList(new ConfigSnapshotHolderImpl(lineProcessor.getConfigSnapshot().get(),
-                    lineProcessor.getCapabilities(), storage.getAbsolutePath()));
-        }
-
-    }
-
-    private static final class LineProcessor implements com.google.common.io.LineProcessor<String> {
-
-        private boolean inLastConfig, inLastSnapshot;
-        private final StringBuffer snapshotBuffer = new StringBuffer();
-        private final SortedSet<String> caps = new TreeSet<>();
-
-        @Override
-        public String getResult() {
-            return null;
-        }
-
-        @Override
-        public boolean processLine(String line) throws IOException {
-            if (inLastConfig && line.equals(SEPARATOR_E_PURE)) {
-                inLastConfig = false;
-                return false;
-            }
-
-            if (inLastConfig && line.equals(SEPARATOR_M_PURE)) {
-                inLastSnapshot = false;
-                return true;
-            }
-
-            if (inLastConfig) {
-                if (inLastSnapshot) {
-                    snapshotBuffer.append(line);
-                    snapshotBuffer.append(System.lineSeparator());
-                } else {
-                    caps.add(line);
-                }
-            }
-
-            if (line.equals(SEPARATOR_SL_PURE)) {
-                inLastConfig = true;
-                inLastSnapshot = true;
-            }
-
-            return true;
-        }
-
-        Optional<String> getConfigSnapshot() {
-            final String xmlContent = snapshotBuffer.toString();
-            if (xmlContent.equals("")) {
-                return Optional.absent();
-            } else {
-                return Optional.of(xmlContent);
-            }
-        }
-
-        SortedSet<String> getCapabilities() {
-            return caps;
-        }
-
-    }
-
-    @Override
-    public void close() {
-
-    }
-
-    @Override
-    public String toString() {
-        return "FileStorageAdapter [storage=" + storage + "]";
-    }
-
-}
diff --git a/opendaylight/config/config-persister-file-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapterTest.java b/opendaylight/config/config-persister-file-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapterTest.java
deleted file mode 100644 (file)
index 0366dbc..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * 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;
-
-import com.google.common.base.Charsets;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import java.io.File;
-import java.nio.file.Files;
-import java.util.Collection;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.TreeSet;
-import org.junit.Before;
-import org.junit.Test;
-import org.mockito.Mockito;
-import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
-import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.test.PropertiesProviderTest;
-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 testFileAdapterAsPersister() throws Exception {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        PropertiesProviderTest pp = new PropertiesProviderTest();
-        pp.addProperty("fileStorage",file.getPath());
-        pp.addProperty("numberOfBackups",Integer.toString(Integer.MAX_VALUE));
-
-        Persister configPersister = storage.instantiate(pp);
-        final ConfigSnapshotHolder holder = new ConfigSnapshotHolder() {
-            @Override
-            public String getConfigSnapshot() {
-                return createConfig();
-            }
-
-            @Override
-            public SortedSet<String> getCapabilities() {
-                return createCaps();
-            }
-        };
-        configPersister.persistConfig(holder);
-
-        configPersister.persistConfig(holder);
-
-        Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
-                new Predicate<String>() {
-
-                    @Override
-                    public boolean apply(String input) {
-                        if (input.equals(""))
-                            return false;
-                        return true;
-                    }
-                });
-        assertEquals(14, readLines.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());
-    }
-    @Test
-    public void testFileAdapter() throws Exception {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        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);
-
-        Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
-                new Predicate<String>() {
-
-                    @Override
-                    public boolean apply(String input) {
-                        if (input.equals(""))
-                            return false;
-                        return true;
-                    }
-                });
-        assertEquals(14, readLines.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());
-    }
-
-    private SortedSet<String> createCaps() {
-        SortedSet<String> caps = new TreeSet<>();
-
-        caps.add("cap1");
-        caps.add("cap2");
-        caps.add("capaaaa as dasfasdf s2");
-        return caps;
-    }
-
-    @Test
-    public void testFileAdapterOneBackup() throws Exception {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        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);
-
-        Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
-                new Predicate<String>() {
-
-                    @Override
-                    public boolean apply(String input) {
-                        if (input.equals(""))
-                            return false;
-                        return true;
-                    }
-                });
-        assertEquals(7, readLines.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 {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        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);
-
-        Collection<String> readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8),
-                new Predicate<String>() {
-
-                    @Override
-                    public boolean apply(String input) {
-                        if (input.equals(""))
-                            return false;
-                        return true;
-                    }
-                });
-
-        assertEquals(14, 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;
-        FileStorageAdapter storage = new FileStorageAdapter();
-        storage.setFileStorage(file);
-
-        List<ConfigSnapshotHolder> elementOptional = storage.loadLastConfigs();
-        assertThat(elementOptional.size(), is(0));
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testNoProperties() throws Exception {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        storage.loadLastConfigs();
-    }
-
-    @Test(expected = NullPointerException.class)
-    public void testNoProperties2() throws Exception {
-        FileStorageAdapter storage = new FileStorageAdapter();
-        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>";
-    }
-
-}
index 6b55b6ad16ab85e6f15dd30eb96e2dbc9ed1ad44..d700075e950030e77856de1b84a2382878653055 100644 (file)
@@ -23,7 +23,6 @@
         <module>config-plugin-parent</module>
         <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>
@@ -35,9 +34,7 @@
         <module>netty-threadgroup-config</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>config-persister-directory-autodetect-adapter</module>
         <module>yang-test-plugin</module>
         <module>shutdown-api</module>
         <module>shutdown-impl</module>
index a38a9b4f935cd401428dd2c0b86f3e24024fd01c..a6d1019c42f03da052a5012047d83c201059bfa1 100644 (file)
                     <groupId>org.opendaylight.controller</groupId>
                     <artifactId>config-persister-api</artifactId>
                 </dependency>
-                <dependency>
-                    <groupId>org.opendaylight.controller</groupId>
-                    <artifactId>config-persister-file-adapter</artifactId>
-                </dependency>
                 <dependency>
                     <groupId>org.opendaylight.controller</groupId>
                     <artifactId>config-persister-file-xml-adapter</artifactId>
                 </dependency>
-                <dependency>
-                    <groupId>org.opendaylight.controller</groupId>
-                    <artifactId>config-persister-directory-adapter</artifactId>
-                </dependency>
                 <dependency>
                     <groupId>org.opendaylight.controller</groupId>
                     <artifactId>config-persister-directory-xml-adapter</artifactId>
                 </dependency>
-                <dependency>
-                    <groupId>org.opendaylight.controller</groupId>
-                    <artifactId>config-persister-directory-autodetect-adapter</artifactId>
-                </dependency>
 
                 <dependency>
                     <groupId>org.opendaylight.controller</groupId>
index 4598bac593269d026bdcf32dd295ecaf5eb2af37..e91a13b9f2dda31dc53860ea9c1563316d3f896b 100644 (file)
@@ -26,22 +26,12 @@ netconf.ssh.pk.path = ./configuration/RSA.pk
 
 netconf.config.persister.active=1,2
 # read startup configuration
-#netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.DirectoryStorageAdapter
-#netconf.config.persister.1.properties.directoryStorage=configuration/initial/
-#netconf.config.persister.1.readonly=true
-
-netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.autodetect.AutodetectDirectoryStorageAdapter
+netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.xml.XmlDirectoryStorageAdapter
 netconf.config.persister.1.properties.directoryStorage=configuration/initial/
+# include only xml files, files with other extensions will be skipped, multiple extensions are permitted e.g. netconf.config.persister.1.properties.includeExtensions=xml,cfg,config
+netconf.config.persister.1.properties.includeExtensions=xml
 netconf.config.persister.1.readonly=true
 
-#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
index 74e7d1afe74910bcc55a3a1e1a3b9c52a546060c..01e5ae0372b06d6bf54138dd9bb9df948f1d551b 100644 (file)
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-file-adapter</artifactId>
+            <artifactId>config-persister-file-xml-adapter</artifactId>
             <version>${config.version}</version>
         </dependency>
         <dependency>
             <artifactId>config-persister-impl</artifactId>
             <version>${config.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-file-adapter</artifactId>
-            <version>${config.version}</version>
-        </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>netconf-impl</artifactId>
index 72ae24e007ba847ba882c291b24092073a75aff7..306dc2390b9a4381067baa62506112ad42d071c7 100644 (file)
@@ -9,10 +9,10 @@ import org.slf4j.LoggerFactory;
 class ChangeListenerNotifyTask implements Runnable {
 
     private static final Logger LOG = LoggerFactory.getLogger(ChangeListenerNotifyTask.class);
-    private final Iterable<DataChangeListenerRegistration<?>> listeners;
+    private final Iterable<? extends DataChangeListenerRegistration<?>> listeners;
     private final AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> event;
 
-    public ChangeListenerNotifyTask(final Iterable<DataChangeListenerRegistration<?>> listeners,
+    public ChangeListenerNotifyTask(final Iterable<? extends DataChangeListenerRegistration<?>> listeners,
             final AsyncDataChangeEvent<InstanceIdentifier, NormalizedNode<?, ?>> event) {
         this.listeners = listeners;
         this.event = event;
index a032c798c62d8fbe0151ab5406a23dab54b0af02..0948f6d3e56f9bd285240c39dc9a6b2f80039b6f 100644 (file)
@@ -184,6 +184,9 @@ public class DataChangeEventResolver {
                 subtree.merge(resolveSubtreeChangeEvent(childPath, childListen, childMod, childBefore.get(),
                         childAfter.get()));
                 break;
+            case UNMODIFIED:
+                // no-op
+                break;
             }
         }
         DOMImmutableDataChangeEvent oneChangeEvent = one.build();
index 0cd00cad7e6ec9609a03bac044f1ac613edf32c2..2091913f24949106aae128e07083a4354b992b70 100644 (file)
@@ -11,12 +11,15 @@ import static com.google.common.base.Preconditions.checkNotNull;
 import static com.google.common.base.Preconditions.checkState;
 import static org.opendaylight.controller.md.sal.dom.store.impl.StoreUtils.increase;
 
+import java.util.Collections;
 import java.util.concurrent.Callable;
 import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerRegistrationNode;
+import org.opendaylight.controller.md.sal.dom.store.impl.tree.ListenerRegistrationNode.DataChangeListenerRegistration;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.ModificationType;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.NodeModification;
 import org.opendaylight.controller.md.sal.dom.store.impl.tree.StoreMetadataNode;
@@ -37,6 +40,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
 import com.google.common.primitives.UnsignedLong;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -51,41 +55,39 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
     private final ListeningExecutorService executor;
     private final String name;
     private final AtomicLong txCounter = new AtomicLong(0);
-
-    private DataAndMetadataSnapshot snapshot;
-    private ModificationApplyOperation operationTree;
     private final ListenerRegistrationNode listenerTree;
+    private final AtomicReference<DataAndMetadataSnapshot> snapshot;
 
-
+    private ModificationApplyOperation operationTree;
 
     private SchemaContext schemaContext;
 
     public InMemoryDOMDataStore(final String name, final ListeningExecutorService executor) {
-        this.executor = executor;
-        this.name = name;
-        this.operationTree = new AllwaysFailOperation();
-        this.snapshot = DataAndMetadataSnapshot.createEmpty();
+        this.name = Preconditions.checkNotNull(name);
+        this.executor = Preconditions.checkNotNull(executor);
         this.listenerTree = ListenerRegistrationNode.createRoot();
+        this.snapshot = new AtomicReference<DataAndMetadataSnapshot>(DataAndMetadataSnapshot.createEmpty());
+        this.operationTree = new AlwaysFailOperation();
     }
 
     @Override
-    public String getIdentifier() {
+    public final String getIdentifier() {
         return name;
     }
 
     @Override
     public DOMStoreReadTransaction newReadOnlyTransaction() {
-        return new SnapshotBackedReadTransaction(nextIdentifier(), snapshot);
+        return new SnapshotBackedReadTransaction(nextIdentifier(), snapshot.get());
     }
 
     @Override
     public DOMStoreReadWriteTransaction newReadWriteTransaction() {
-        return new SnapshotBackedReadWriteTransaction(nextIdentifier(), snapshot, this, operationTree);
+        return new SnapshotBackedReadWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree);
     }
 
     @Override
     public DOMStoreWriteTransaction newWriteOnlyTransaction() {
-        return new SnaphostBackedWriteTransaction(nextIdentifier(), snapshot, this, operationTree);
+        return new SnaphostBackedWriteTransaction(nextIdentifier(), snapshot.get(), this, operationTree);
     }
 
     @Override
@@ -99,31 +101,34 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
             final InstanceIdentifier path, final L listener, final DataChangeScope scope) {
         LOG.debug("{}: Registering data change listener {} for {}",name,listener,path);
         ListenerRegistrationNode listenerNode = listenerTree;
-        for(PathArgument arg :path.getPath()) {
+        for(PathArgument arg : path.getPath()) {
             listenerNode = listenerNode.ensureChild(arg);
         }
-        synchronized (listener) {
-            notifyInitialState(path, listener);
-        }
-        return listenerNode.registerDataChangeListener(path,listener, scope);
-    }
 
-    private void notifyInitialState(final InstanceIdentifier path,
-            final AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>> listener) {
-        Optional<StoreMetadataNode> currentState = snapshot.read(path);
-        try {
+        /*
+         * Make sure commit is not occurring right now. Listener has to be registered and its
+         * state capture enqueued at a consistent point.
+         *
+         * FIXME: improve this to read-write lock, such that multiple listener registrations
+         *        can occur simultaneously
+         */
+        final DataChangeListenerRegistration<L> reg;
+        synchronized (this) {
+            reg = listenerNode.registerDataChangeListener(path, listener, scope);
+
+            Optional<StoreMetadataNode> currentState = snapshot.get().read(path);
             if (currentState.isPresent()) {
-                NormalizedNode<?, ?> data = currentState.get().getData();
-                listener.onDataChanged(DOMImmutableDataChangeEvent.builder() //
+                final NormalizedNode<?, ?> data = currentState.get().getData();
+
+                final DOMImmutableDataChangeEvent event = DOMImmutableDataChangeEvent.builder() //
                         .setAfter(data) //
                         .addCreated(path, data) //
-                        .build() //
-                );
+                        .build();
+                executor.submit(new ChangeListenerNotifyTask(Collections.singletonList(reg), event));
             }
-        } catch (Exception e) {
-            LOG.error("Unhandled exception encountered when invoking listener {}", listener, e);
         }
 
+        return reg;
     }
 
     private synchronized DOMStoreThreePhaseCommitCohort submit(
@@ -136,23 +141,30 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
         return name + "-" + txCounter.getAndIncrement();
     }
 
-    private synchronized void commit(final DataAndMetadataSnapshot currentSnapshot,
+    private void commit(final DataAndMetadataSnapshot currentSnapshot,
             final StoreMetadataNode newDataTree, final Iterable<ChangeListenerNotifyTask> listenerTasks) {
         LOG.debug("Updating Store snaphot version: {} with version:{}",currentSnapshot.getMetadataTree().getSubtreeVersion(),newDataTree.getSubtreeVersion());
 
         if(LOG.isTraceEnabled()) {
             LOG.trace("Data Tree is {}",StoreUtils.toStringTree(newDataTree));
         }
-        checkState(snapshot == currentSnapshot, "Store snapshot and transaction snapshot differs");
-        snapshot = DataAndMetadataSnapshot.builder() //
+
+        final DataAndMetadataSnapshot newSnapshot = DataAndMetadataSnapshot.builder() //
                 .setMetadataTree(newDataTree) //
                 .setSchemaContext(schemaContext) //
                 .build();
 
-        for(ChangeListenerNotifyTask task : listenerTasks) {
-            executor.submit(task);
-        }
+        /*
+         * The commit has to occur atomically with regard to listener registrations.
+         */
+        synchronized (this) {
+            final boolean success = snapshot.compareAndSet(currentSnapshot, newSnapshot);
+            checkState(success, "Store snapshot and transaction snapshot differ. This should never happen.");
 
+            for (ChangeListenerNotifyTask task : listenerTasks) {
+                executor.submit(task);
+            }
+        }
     }
 
     private static class SnapshotBackedReadTransaction implements DOMStoreReadTransaction {
@@ -293,7 +305,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
 
         @Override
         public ListenableFuture<Boolean> canCommit() {
-            final DataAndMetadataSnapshot snapshotCapture = snapshot;
+            final DataAndMetadataSnapshot snapshotCapture = snapshot.get();
             final ModificationApplyOperation snapshotOperation = operationTree;
 
             return executor.submit(new Callable<Boolean>() {
@@ -310,7 +322,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
 
         @Override
         public ListenableFuture<Void> preCommit() {
-            storeSnapshot = snapshot;
+            storeSnapshot = snapshot.get();
             if(modification.getModificationType() == ModificationType.UNMODIFIED) {
                 return Futures.immediateFuture(null);
             }
@@ -360,7 +372,7 @@ public class InMemoryDOMDataStore implements DOMStore, Identifiable<String>, Sch
 
     }
 
-    private class AllwaysFailOperation implements ModificationApplyOperation {
+    private static final class AlwaysFailOperation implements ModificationApplyOperation {
 
         @Override
         public Optional<StoreMetadataNode> apply(final NodeModification modification,
index e48438d6fa63aa1888fe8ab0df580ca7881d5650..2528d383b95a0c9f6534ad0f01627f56dbc26c5c 100644 (file)
@@ -9,7 +9,6 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataCh
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeListener;
 import org.opendaylight.yangtools.concepts.AbstractObjectRegistration;
 import org.opendaylight.yangtools.concepts.Identifiable;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
@@ -20,7 +19,7 @@ import com.google.common.base.Optional;
 
 public class ListenerRegistrationNode implements StoreTreeNode<ListenerRegistrationNode>, Identifiable<PathArgument> {
 
-    private final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationNode.class);
+    private static final Logger LOG = LoggerFactory.getLogger(ListenerRegistrationNode.class);
 
     private final ListenerRegistrationNode parent;
     private final Map<PathArgument, ListenerRegistrationNode> children;
@@ -49,6 +48,7 @@ public class ListenerRegistrationNode implements StoreTreeNode<ListenerRegistrat
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
     public Collection<org.opendaylight.controller.md.sal.dom.store.impl.DataChangeListenerRegistration<?>> getListeners() {
+        // FIXME: this is not thread-safe and races with listener (un)registration!
         return (Collection) listeners;
     }
 
@@ -75,7 +75,7 @@ public class ListenerRegistrationNode implements StoreTreeNode<ListenerRegistrat
      * @param scope Scope of triggering event.
      * @return
      */
-    public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> ListenerRegistration<L> registerDataChangeListener(final InstanceIdentifier path,
+    public <L extends AsyncDataChangeListener<InstanceIdentifier, NormalizedNode<?, ?>>> DataChangeListenerRegistration<L> registerDataChangeListener(final InstanceIdentifier path,
             final L listener, final DataChangeScope scope) {
 
         DataChangeListenerRegistration<L> listenerReg = new DataChangeListenerRegistration<L>(path,listener, scope, this);
index 3e73f161c28df060f33e9f658b8eb4d60d30f5ac..ffdcda31eb7b4916bc96b3ceca017da177648ab3 100644 (file)
@@ -50,7 +50,7 @@
         </plugins>
         <pluginManagement>
             <plugins>
-                <!--This plugin's configuration is used to store Eclipse 
+                <!--This plugin's configuration is used to store Eclipse
                     m2e settings only. It has no influence on the Maven build itself. -->
                 <plugin>
                     <groupId>org.eclipse.m2e</groupId>
             <groupId>org.opendaylight.yangtools</groupId>
             <artifactId>yang-data-api</artifactId>
         </dependency>
-        <!--dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-impl</artifactId> 
+        <!--dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>yang-data-impl</artifactId>
             <version>${yangtools.version}</version> </dependency -->
         <dependency>
             <groupId>org.opendaylight.yangtools</groupId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-file-adapter</artifactId>
+            <artifactId>config-persister-file-xml-adapter</artifactId>
             <version>${config.version}</version>
         </dependency>
         <dependency>
             <groupId>org.ops4j.pax.exam</groupId>
             <artifactId>pax-exam</artifactId>
             <version>${exam.version}</version>
-            <!-- Compile scope here is intentional, it is used in TestHelper 
-                class which could be downloaded via nexus and reused in other integration 
+            <!-- Compile scope here is intentional, it is used in TestHelper
+                class which could be downloaded via nexus and reused in other integration
                 tests. -->
             <scope>compile</scope>
         </dependency>
index 8ebf28f35f1771ec778fc6e1a5b16088f6aafe16..fa478ac72e398ae928c619004023b8aae6cc68fe 100644 (file)
@@ -305,7 +305,7 @@ class RestconfImpl implements RestconfService {
         return callRpc(rpc, null)
     }
 
-    def resolveIdentifierInInvokeRpc(String identifier) {
+    private def resolveIdentifierInInvokeRpc(String identifier) {
         if (identifier.indexOf("/") === -1) {
             val identifierDecoded = identifier.urlPathArgDecode
             val rpc = identifierDecoded.rpcDefinition
@@ -314,8 +314,8 @@ class RestconfImpl implements RestconfService {
             }
             throw new ResponseException(NOT_FOUND, "RPC does not exist.");
         }
-        val slashErrorMsg  = String.format("Identifier %n%s%ncan't contain slash character (/). +
-            If slash is part of identifier name then use %2F placeholder.",identifier)
+        val slashErrorMsg = String.format(
+            "Identifier %n%s%ncan't contain slash character (/).%nIf slash is part of identifier name then use %%2F placeholder.", identifier)
         throw new ResponseException(NOT_FOUND, slashErrorMsg);
     }
 
index dff9d65db3f043b3b264ad50bb83687dbb9bba10..320a7f9d08b1f80d3465e7a9570df2044831563a 100644 (file)
@@ -7,20 +7,34 @@
  */
 package org.opendaylight.controller.sal.restconf.impl.test;
 
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 import java.io.FileNotFoundException;
 import java.io.UnsupportedEncodingException;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+
 import javax.ws.rs.core.Application;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+
 import org.glassfish.jersey.server.ResourceConfig;
 import org.glassfish.jersey.test.JerseyTest;
 import org.junit.BeforeClass;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.sal.core.api.mount.MountInstance;
 import org.opendaylight.controller.sal.core.api.mount.MountService;
@@ -33,16 +47,12 @@ import org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper;
 import org.opendaylight.controller.sal.restconf.impl.ControllerContext;
 import org.opendaylight.controller.sal.restconf.impl.RestconfImpl;
 import org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.Node;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
 
 public class RestGetOperationTest extends JerseyTest {
 
@@ -133,6 +143,52 @@ public class RestGetOperationTest extends JerseyTest {
         assertEquals(200, get(uri, MediaType.APPLICATION_XML));
     }
 
+    /**
+     * MountPoint test. URI represents mount point.
+     * 
+     * Slashes in URI behind mount point. lst1 element with key
+     * GigabitEthernet0%2F0%2F0%2F0 (GigabitEthernet0/0/0/0) is requested via
+     * GET HTTP operation. It is tested whether %2F character is replaced with
+     * simple / in InstanceIdentifier parameter in method
+     * {@link BrokerFacade#readConfigurationDataBehindMountPoint(MountInstance, InstanceIdentifier)}
+     * which is called in method {@link RestconfImpl#readConfigurationData}
+     * 
+     * 
+     * @throws ParseException
+     */
+    @Test
+    public void getDataWithSlashesBehindMountPoint() throws UnsupportedEncodingException, URISyntaxException,
+            ParseException {
+        InstanceIdentifier awaitedInstanceIdentifier = prepareInstanceIdentifierForList();
+        when(
+                brokerFacade.readConfigurationDataBehindMountPoint(any(MountInstance.class),
+                        eq(awaitedInstanceIdentifier))).thenReturn(prepareCnDataForMountPointTest());
+        MountInstance mountInstance = mock(MountInstance.class);
+        when(mountInstance.getSchemaContext()).thenReturn(schemaContextTestModule);
+        MountService mockMountService = mock(MountService.class);
+        when(mockMountService.getMountPoint(any(InstanceIdentifier.class))).thenReturn(mountInstance);
+
+        ControllerContext.getInstance().setMountService(mockMountService);
+
+        String uri = "/config/ietf-interfaces:interfaces/interface/0/yang-ext:mount/test-module:cont/lst1/GigabitEthernet0%2F0%2F0%2F0";
+        assertEquals(200, get(uri, MediaType.APPLICATION_XML));
+    }
+
+    private InstanceIdentifier prepareInstanceIdentifierForList() throws URISyntaxException, ParseException {
+        List<PathArgument> parameters = new ArrayList<>();
+
+        Date revision = new SimpleDateFormat("yyyy-MM-dd").parse("2014-01-09");
+        URI uri = new URI("test:module");
+        QName qNameCont = QName.create(uri, revision, "cont");
+        QName qNameList = QName.create(uri, revision, "lst1");
+        QName qNameKeyList = QName.create(uri, revision, "lf11");
+
+        parameters.add(new InstanceIdentifier.NodeIdentifier(qNameCont));
+        parameters.add(new InstanceIdentifier.NodeIdentifierWithPredicates(qNameList, qNameKeyList,
+                "GigabitEthernet0/0/0/0"));
+        return new InstanceIdentifier(parameters);
+    }
+
     @Test
     public void getDataMountPointIntoHighestElement() throws UnsupportedEncodingException, URISyntaxException {
         when(
@@ -162,6 +218,7 @@ public class RestGetOperationTest extends JerseyTest {
         response = target(uri).request("application/yang.api+xml").get();
         validateModulesResponseXml(response);
     }
+
     // /streams/
     @Test
     public void getStreamsTest() throws UnsupportedEncodingException, FileNotFoundException {
@@ -193,7 +250,7 @@ public class RestGetOperationTest extends JerseyTest {
         assertTrue("Module2 in xml wasn't found", prepareXmlRegex("module2", "2014-01-02", "module:2", responseBody)
                 .find());
         String[] split = responseBody.split("<module");
-        assertEquals("<module element is returned more then once",2,split.length);
+        assertEquals("<module element is returned more then once", 2, split.length);
 
         response = target(uri).request("application/yang.api+json").get();
         assertEquals(200, response.getStatus());
@@ -201,7 +258,7 @@ public class RestGetOperationTest extends JerseyTest {
         assertTrue("Module2 in json wasn't found", prepareJsonRegex("module2", "2014-01-02", "module:2", responseBody)
                 .find());
         split = responseBody.split("\"module\"");
-        assertEquals("\"module\" element is returned more then once",2,split.length);
+        assertEquals("\"module\" element is returned more then once", 2, split.length);
 
     }
 
@@ -395,8 +452,7 @@ public class RestGetOperationTest extends JerseyTest {
                 prepareJsonRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point",
                         responseBody).find());
         String[] split = responseBody.split("\"module\"");
-        assertEquals("\"module\" element is returned more then once",2,split.length);
-
+        assertEquals("\"module\" element is returned more then once", 2, split.length);
 
         response = target(uri).request("application/yang.api+xml").get();
         assertEquals(200, response.getStatus());
@@ -406,10 +462,7 @@ public class RestGetOperationTest extends JerseyTest {
                 prepareXmlRegex("module1-behind-mount-point", "2014-02-03", "module:1:behind:mount:point", responseBody)
                         .find());
         split = responseBody.split("<module");
-        assertEquals("<module element is returned more then once",2,split.length);
-
-
-
+        assertEquals("<module element is returned more then once", 2, split.length);
 
     }
 
index 93342ead54f27a633973a965c3ee48e16c238445..2e533e720e0760f6abca5b84663c52ce170a4899 100644 (file)
@@ -28,7 +28,13 @@ module test-module {
             type string;
         }
     }
-  } 
+    list lst1 {
+        key "lf11";
+        leaf lf11 {
+            type string;
+        }
+    }
+  }   
   
   
   rpc rpc-test {
index a9fc739456b95740c3ab9c00313c31711e7ebba9..f0a8584730955a76514824494d02de82f66ded54 100644 (file)
@@ -43,7 +43,7 @@
         </plugins>
         <pluginManagement>
             <plugins>
-                <!--This plugin's configuration is used to store Eclipse 
+                <!--This plugin's configuration is used to store Eclipse
                     m2e settings only. It has no influence on the Maven build itself. -->
                 <plugin>
                     <groupId>org.eclipse.m2e</groupId>
             <artifactId>jersey-core</artifactId>
             <version>${jersey.version}</version>
         </dependency>
-        <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId> 
+        <!-- <dependency> <groupId>com.sun.jersey</groupId> <artifactId>jersey-servlet</artifactId>
             <version>${jersey.version}</version> </dependency> -->
         <dependency>
             <groupId>com.sun.jersey</groupId>
         </dependency>
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
-            <artifactId>config-persister-file-adapter</artifactId>
+            <artifactId>config-persister-file-xml-adapter</artifactId>
             <version>${config.version}</version>
         </dependency>
         <dependency>
index 8400bc18353fc765da09cf6f84831085875fbb44..4a43e0cf8266c1ae5c56dbb6a77c9bdc7018bb73 100644 (file)
@@ -75,9 +75,9 @@ public class ServiceProviderController {
         InstanceIdentifier path = InstanceIdentifier.builder(InventoryUtils.INVENTORY_PATH)
                 .nodeWithKey(InventoryUtils.INVENTORY_NODE, InventoryUtils.INVENTORY_ID, "foo").toInstance();
 
-        
+
         InstanceIdentifier mountPointPath = path;
-        
+
         /** We retrive a mountpoint **/
         MountProvisionInstance mountPoint = mountService.getMountPoint(mountPointPath);
         CompositeNode data = mountPoint.readOperationalData(InstanceIdentifier.builder().node(CONFIG_MODULES)
@@ -215,7 +215,7 @@ public class ServiceProviderController {
                 mavenBundle(ODL, "yang-jmx-generator").versionAsInProject(),
                 mavenBundle(ODL, "logback-config").versionAsInProject(),
                 mavenBundle(ODL, "config-persister-api").versionAsInProject(),
-                // mavenBundle(ODL,"config-persister-file-adapter").versionAsInProject(),
+                // mavenBundle(ODL,"config-persister-file-xml-adapter").versionAsInProject(),
                 mavenBundle(ODL, "protocol-framework").versionAsInProject(),
                 mavenBundle(ODL, "netconf-api").versionAsInProject(),
                 mavenBundle(ODL, "netconf-impl").versionAsInProject(),
index c1cad4a8ddaba3750b70c3530d7f8324afde8a95..31a4f080368515c075872173e9ba066c830f5e0e 100644 (file)
@@ -37,12 +37,12 @@ import java.util.ListIterator;
  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
+ netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
  netconf.config.persister.2.readonly=true
- netconf.config.persister.2.properties.fileStorage=configuration/current/controller.config.1.txt
+ netconf.config.persister.2.properties.fileStorage=configuration/current/controller.config.1.xml
 
- netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
- netconf.config.persister.3.properties.fileStorage=configuration/current/controller.config.2.txt
+ netconf.config.persister.3.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.xml.XmlFileStorageAdapter
+ netconf.config.persister.3.properties.fileStorage=configuration/current/controller.config.2.xml
  netconf.config.persister.3.properties.numberOfBackups=3
 
  </pre>
index 586366f41a63659bc8b75fd8ccbf12df97ae34bd..2be64a8a9873f138ae29876a2ac1c1d1998213e4 100644 (file)
                 <artifactId>config-persister-api</artifactId>
                 <version>${config.version}</version>
             </dependency>
-            <dependency>
-                <groupId>org.opendaylight.controller</groupId>
-                <artifactId>config-persister-file-adapter</artifactId>
-                <version>${config.version}</version>
-            </dependency>
             <dependency>
                 <groupId>${project.groupId}</groupId>
                 <artifactId>netconf-client</artifactId>
index 6582d8c021d5f61de10ae6b221f1217fdd1d668f..ae84a72bbac84ddda56c102972c894e21873a603 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corporation, 2013.  All rights reserved.
+ * Copyright IBM Corporation and others, 2013.  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,
@@ -64,6 +64,12 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable {
     @XmlElement (name="tenant_id")
     String tenantID;
 
+    @XmlElement (name="ipv6_address_mode", nillable=true)
+    String ipV6AddressMode;
+
+    @XmlElement (name="ipv6_ra_mode", nillable=true)
+    String ipV6RaMode;
+
     /* stores the OpenStackPorts associated with an instance
      * used to determine if that instance can be deleted.
      */
@@ -170,6 +176,14 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable {
         this.tenantID = tenantID;
     }
 
+    public String getIpV6AddressMode() { return ipV6AddressMode; }
+
+    public void setIpV6AddressMode(String ipV6AddressMode) { this.ipV6AddressMode = ipV6AddressMode; }
+
+    public String getIpV6RaMode() { return ipV6RaMode; }
+
+    public void setIpV6RaMode(String ipV6RaMode) { this.ipV6RaMode = ipV6RaMode; }
+
     /**
      * This method copies selected fields from the object and returns them
      * as a new object, suitable for marshaling.
@@ -224,6 +238,12 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable {
             if (s.equals("tenant_id")) {
                 ans.setTenantID(this.getTenantID());
             }
+            if (s.equals("ipv6_address_mode")) {
+                ans.setIpV6AddressMode(this.getIpV6AddressMode());
+            }
+            if (s.equals("ipv6_ra_mode")) {
+                ans.setIpV6RaMode(this.getIpV6RaMode());
+            }
         }
         return ans;
     }
@@ -444,6 +464,7 @@ public class NeutronSubnet extends ConfigurationObject implements Serializable {
                 + ", ipVersion=" + ipVersion + ", cidr=" + cidr + ", gatewayIP=" + gatewayIP + ", dnsNameservers="
                 + dnsNameservers + ", allocationPools=" + allocationPools + ", hostRoutes=" + hostRoutes
                 + ", enableDHCP=" + enableDHCP + ", tenantID=" + tenantID + ", myPorts=" + myPorts
-                + ", gatewayIPAssigned=" + gatewayIPAssigned + "]";
+                + ", gatewayIPAssigned=" + gatewayIPAssigned + ", ipv6AddressMode=" + ipV6AddressMode
+                + ", ipv6RaMode=" + ipV6RaMode + "]";
     }
 }
index 224fcb5f01ceaaaa662d2c9bbe0655892da463a2..f397eb3a97b0630002b3fc1b70901a1a25cf0609 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright IBM Corporation, 2013.  All rights reserved.
+ * Copyright IBM Corporation and others, 2013.  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,
@@ -87,6 +87,8 @@ public class NeutronSubnetsNorthbound {
             @QueryParam("gateway_ip") String queryGatewayIP,
             @QueryParam("enable_dhcp") String queryEnableDHCP,
             @QueryParam("tenant_id") String queryTenantID,
+            @QueryParam("ipv6_address_mode") String queryIpV6AddressMode,
+            @QueryParam("ipv6_ra_mode") String queryIpV6RaMode,
             // pagination
             @QueryParam("limit") String limit,
             @QueryParam("marker") String marker,
@@ -110,7 +112,9 @@ public class NeutronSubnetsNorthbound {
                     (queryCIDR == null || queryCIDR.equals(oSS.getCidr())) &&
                     (queryGatewayIP == null || queryGatewayIP.equals(oSS.getGatewayIP())) &&
                     (queryEnableDHCP == null || queryEnableDHCP.equals(oSS.getEnableDHCP())) &&
-                    (queryTenantID == null || queryTenantID.equals(oSS.getTenantID()))) {
+                    (queryTenantID == null || queryTenantID.equals(oSS.getTenantID())) &&
+                    (queryIpV6AddressMode == null || queryIpV6AddressMode.equals(oSS.getIpV6AddressMode())) &&
+                    (queryIpV6RaMode == null || queryIpV6RaMode.equals(oSS.getIpV6RaMode()))){
                 if (fields.size() > 0) {
                     ans.add(extractFields(oSS,fields));
                 } else {
index 548bfb1f9fb26eb93ab4ca5bcd456d9bdc4082c3..fc668b3f4d0f1a1f01bb3a9b096b6bc7440515c0 100644 (file)
@@ -945,7 +945,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
         if (!src.getType().equals(NodeConnector.NodeConnectorIDType.PRODUCTION)) {
             if (type == UpdateType.ADDED) {
                 edgeMap.put(dst, edge);
-            } else {
+            } else if (type == UpdateType.REMOVED) {
                 edgeMap.remove(dst);
             }
         } else {
@@ -954,7 +954,7 @@ public class DiscoveryService implements IInventoryShimExternalListener, IDataPa
              */
             if (type == UpdateType.ADDED) {
                 prodMap.put(dst, edge);
-            } else {
+            } else if (type == UpdateType.REMOVED) {
                 prodMap.remove(dst);
             }
         }