From 0e4624c8b041722680ca406f65ee070aab7baa70 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Mon, 7 Apr 2014 13:04:39 +0200 Subject: [PATCH] BUG-672 Remove deprecated plaintext/autodetect persister adapters. Xml adapters are the default adapters now for configuration persister. Change-Id: Ie8eb41520671bb00503a340f6b4b55ebe1ef7bf1 Signed-off-by: Maros Marsalek --- opendaylight/commons/opendaylight/pom.xml | 15 - .../pom.xml | 93 ------- .../storage/directory/DirectoryPersister.java | 177 ------------ .../directory/DirectoryStorageAdapter.java | 39 --- .../src/main/resources/footer.txt | 2 - .../src/main/resources/header.txt | 2 - .../src/main/resources/middle.txt | 2 - .../DirectoryStorageAdapterTest.java | 101 ------- .../resources/oneFile/controller.config.txt | 120 -------- .../oneFileExpected/expectedCapabilities.txt | 20 -- .../oneFileExpected/expectedSnapshot.xml | 103 ------- .../resources/twoFiles/controller.config1.txt | 82 ------ .../resources/twoFiles/controller.config2.txt | 41 --- .../expectedCapabilities.txt | 1 - .../twoFilesExpected1/expectedSnapshot.xml | 84 ------ .../expectedCapabilities.txt | 19 -- .../twoFilesExpected2/expectedSnapshot.xml | 25 -- .../pom.xml | 114 -------- .../AutodetectDirectoryPersister.java | 97 ------- .../AutodetectDirectoryStorageAdapter.java | 39 --- .../directory/autodetect/FileType.java | 83 ------ .../AutodetectDirectoryPersisterTest.java | 91 ------- .../directory/autodetect/FileTypeTest.java | 52 ---- .../test/resources/bad_controller.xml.config | 10 - .../resources/combined/1controller.txt.config | 8 - .../resources/combined/2controller.xml.config | 10 - .../src/test/resources/test.txt.config | 2 - .../src/test/resources/test.xml.config | 2 - .../src/test/resources/unknown.config | 2 - .../config-persister-file-adapter/pom.xml | 81 ------ .../storage/file/FileStorageAdapter.java | 252 ----------------- .../storage/file/FileStorageAdapterTest.java | 256 ------------------ opendaylight/config/pom.xml | 3 - .../distribution/opendaylight/pom.xml | 12 - .../main/resources/configuration/config.ini | 14 +- .../integrationtest/pom.xml | 7 +- .../integrationtest/test-it/pom.xml | 10 +- .../md-sal/test/sal-rest-connector-it/pom.xml | 6 +- .../it/ServiceProviderController.java | 6 +- .../persist/impl/PersisterAggregator.java | 8 +- opendaylight/netconf/pom.xml | 5 - 41 files changed, 17 insertions(+), 2079 deletions(-) delete mode 100644 opendaylight/config/config-persister-directory-adapter/pom.xml delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryPersister.java delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapter.java delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/main/resources/footer.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/main/resources/header.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/main/resources/middle.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapterTest.java delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFile/controller.config.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedCapabilities.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedSnapshot.xml delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config1.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config2.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedCapabilities.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedSnapshot.xml delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedCapabilities.txt delete mode 100644 opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedSnapshot.xml delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/pom.xml delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersister.java delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryStorageAdapter.java delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileType.java delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileTypeTest.java delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/bad_controller.xml.config delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/1controller.txt.config delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/2controller.xml.config delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.txt.config delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.xml.config delete mode 100644 opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/unknown.config delete mode 100644 opendaylight/config/config-persister-file-adapter/pom.xml delete mode 100644 opendaylight/config/config-persister-file-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapter.java delete mode 100644 opendaylight/config/config-persister-file-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapterTest.java diff --git a/opendaylight/commons/opendaylight/pom.xml b/opendaylight/commons/opendaylight/pom.xml index e7c7bbe637..1e06679a3b 100644 --- a/opendaylight/commons/opendaylight/pom.xml +++ b/opendaylight/commons/opendaylight/pom.xml @@ -1351,31 +1351,16 @@ config-persister-api ${config.version} - - org.opendaylight.controller - config-persister-file-adapter - ${config.version} - org.opendaylight.controller config-persister-file-xml-adapter ${config.version} - - org.opendaylight.controller - config-persister-directory-adapter - ${config.version} - org.opendaylight.controller config-persister-directory-xml-adapter ${config.version} - - org.opendaylight.controller - config-persister-directory-autodetect-adapter - ${config.version} - org.opendaylight.controller diff --git a/opendaylight/config/config-persister-directory-adapter/pom.xml b/opendaylight/config/config-persister-directory-adapter/pom.xml deleted file mode 100644 index 86b8c4d947..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - - config-subsystem - org.opendaylight.controller - 0.2.5-SNAPSHOT - .. - - config-persister-directory-adapter - ${project.artifactId} - bundle - - - - - ${project.groupId} - config-persister-api - - - org.apache.commons - commons-lang3 - - - com.google.guava - guava - - - org.slf4j - slf4j-api - - - commons-io - commons-io - - - - - org.opendaylight.yangtools - mockito-configuration - - - ${project.groupId} - config-persister-api - test-jar - test - - - - - - - - - org.codehaus.groovy.maven - gmaven-plugin - - - generate-sources - - execute - - - - System.setProperty("osgiversion", "${project.version}".replace('-', '.')) - - - - - - - org.apache.felix - maven-bundle-plugin - - - ${project.groupId}.config-persister-impl;bundle-version=${osgiversion} - - org.opendaylight.controller.config.persister.storage.adapter - - - com.google.common.base, - com.google.common.io, - org.apache.commons.io, - org.opendaylight.controller.config.persist.api, - org.slf4j - - - - - - - - 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 index eb8ef8cddf..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryPersister.java +++ /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 loadLastConfigs() throws IOException { - File[] filesArray = storage.listFiles(); - if (filesArray == null || filesArray.length == 0) { - return Collections.emptyList(); - } - List sortedFiles = new ArrayList<>(Arrays.asList(filesArray)); - Collections.sort(sortedFiles); - // combine all found files - logger.debug("Reading files in following order: {}", sortedFiles); - - List 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 { - private final String fileNameForReporting; - - private boolean inModules, inServices, inCapabilities; - private final StringBuffer modulesBuffer = new StringBuffer(), servicesBuilder = new StringBuffer(); - private final SortedSet 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 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 index 69c8fba9da..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapter.java +++ /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 index d4dcc62822..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/main/resources/footer.txt +++ /dev/null @@ -1,2 +0,0 @@ - - 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 index 90ed41c3da..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/main/resources/header.txt +++ /dev/null @@ -1,2 +0,0 @@ - - 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 index f728cfdd95..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/main/resources/middle.txt +++ /dev/null @@ -1,2 +0,0 @@ - - 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 index 278d0d2456..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/DirectoryStorageAdapterTest.java +++ /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.emptyList(), tested.loadLastConfigs()); - - try { - tested.persistConfig(new ConfigSnapshotHolder() { - @Override - public String getConfigSnapshot() { - throw new RuntimeException(); - } - - @Override - public SortedSet 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 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 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 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 index 99b4cb9891..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFile/controller.config.txt +++ /dev/null @@ -1,120 +0,0 @@ -//MODULES START - - prefix:schema-service-singleton - yang-schema-service - - - prefix:hash-map-data-store - hash-map-data-store - - - prefix:dom-broker-impl - dom-broker - - dom:dom-data-store - ref_hash-map-data-store - - - - prefix:binding-broker-impl - binding-broker-impl - - binding:binding-notification-service - ref_binding-notification-broker - - - binding:binding-data-broker - ref_binding-data-broker - - - - prefix:runtime-generated-mapping - runtime-mapping-singleton - - - prefix:binding-notification-broker - binding-notification-broker - - - prefix:binding-data-broker - binding-data-broker - - dom:dom-broker-osgi-registry - ref_dom-broker - - - binding:binding-dom-mapping-service - ref_runtime-mapping-singleton - - -//SERVICES START - - dom:schema-service - - ref_yang-schema-service - /config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service'] - - - - binding:binding-notification-service - - ref_binding-notification-broker - /config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker'] - - - - dom:dom-data-store - - ref_hash-map-data-store - /config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store'] - - - - binding:binding-broker-osgi-registry - - ref_binding-broker-impl - /config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl'] - - - - binding-impl:binding-dom-mapping-service - - ref_runtime-mapping-singleton - /config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton'] - - - - dom:dom-broker-osgi-registry - - ref_dom-broker - /config/modules/module[name='dom-broker-impl']/instance[name='dom-broker'] - - - - binding:binding-data-broker - - ref_binding-data-broker - /config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker'] - - -//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 index 84c85b740c..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedCapabilities.txt +++ /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 index a6a57d704a..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/oneFileExpected/expectedSnapshot.xml +++ /dev/null @@ -1,103 +0,0 @@ - - - - prefix:schema-service-singleton - yang-schema-service - - - prefix:hash-map-data-store - hash-map-data-store - - - prefix:dom-broker-impl - dom-broker - - dom:dom-data-store - ref_hash-map-data-store - - - - prefix:binding-broker-impl - binding-broker-impl - - binding:binding-notification-service - ref_binding-notification-broker - - - binding:binding-data-broker - ref_binding-data-broker - - - - prefix:runtime-generated-mapping - runtime-mapping-singleton - - - prefix:binding-notification-broker - binding-notification-broker - - - prefix:binding-data-broker - binding-data-broker - - dom:dom-broker-osgi-registry - ref_dom-broker - - - binding:binding-dom-mapping-service - ref_runtime-mapping-singleton - - - - - - dom:schema-service - - ref_yang-schema-service - /config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service'] - - - - binding:binding-notification-service - - ref_binding-notification-broker - /config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker'] - - - - dom:dom-data-store - - ref_hash-map-data-store - /config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store'] - - - - binding:binding-broker-osgi-registry - - ref_binding-broker-impl - /config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl'] - - - - binding-impl:binding-dom-mapping-service - - ref_runtime-mapping-singleton - /config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton'] - - - - dom:dom-broker-osgi-registry - - ref_dom-broker - /config/modules/module[name='dom-broker-impl']/instance[name='dom-broker'] - - - - binding:binding-data-broker - - ref_binding-data-broker - /config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker'] - - - - 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 index 6ae48fb84b..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config1.txt +++ /dev/null @@ -1,82 +0,0 @@ -//MODULES START - - prefix:schema-service-singleton - yang-schema-service - - - prefix:hash-map-data-store - hash-map-data-store - - - prefix:dom-broker-impl - dom-broker - - dom:dom-data-store - ref_hash-map-data-store - - - - prefix:binding-broker-impl - binding-broker-impl - - binding:binding-notification-service - ref_binding-notification-broker - - - binding:binding-data-broker - ref_binding-data-broker - - - - prefix:runtime-generated-mapping - runtime-mapping-singleton - - - prefix:binding-notification-broker - binding-notification-broker - -//SERVICES START - - dom:schema-service - - ref_yang-schema-service - /config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service'] - - - - binding:binding-notification-service - - ref_binding-notification-broker - /config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker'] - - - - dom:dom-data-store - - ref_hash-map-data-store - /config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store'] - - - - binding:binding-broker-osgi-registry - - ref_binding-broker-impl - /config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl'] - - - - binding-impl:binding-dom-mapping-service - - ref_runtime-mapping-singleton - /config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton'] - - - - dom:dom-broker-osgi-registry - - ref_dom-broker - /config/modules/module[name='dom-broker-impl']/instance[name='dom-broker'] - - -//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 index ad9138f5d2..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFiles/controller.config2.txt +++ /dev/null @@ -1,41 +0,0 @@ -//MODULES START - - prefix:binding-data-broker - binding-data-broker - - dom:dom-broker-osgi-registry - ref_dom-broker - - - binding:binding-dom-mapping-service - ref_runtime-mapping-singleton - - -//SERVICES START - - binding:binding-data-broker - - ref_binding-data-broker - /config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker'] - - -//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 index ef35fddbce..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedCapabilities.txt +++ /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 index 2b1d06ecc0..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected1/expectedSnapshot.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - prefix:schema-service-singleton - yang-schema-service - - - prefix:hash-map-data-store - hash-map-data-store - - - prefix:dom-broker-impl - dom-broker - - dom:dom-data-store - ref_hash-map-data-store - - - - prefix:binding-broker-impl - binding-broker-impl - - binding:binding-notification-service - ref_binding-notification-broker - - - binding:binding-data-broker - ref_binding-data-broker - - - - prefix:runtime-generated-mapping - runtime-mapping-singleton - - - prefix:binding-notification-broker - binding-notification-broker - - - - - dom:schema-service - - ref_yang-schema-service - /config/modules/module[name='schema-service-singleton']/instance[name='yang-schema-service'] - - - - binding:binding-notification-service - - ref_binding-notification-broker - /config/modules/module[name='binding-notification-broker']/instance[name='binding-notification-broker'] - - - - dom:dom-data-store - - ref_hash-map-data-store - /config/modules/module[name='hash-map-data-store']/instance[name='hash-map-data-store'] - - - - binding:binding-broker-osgi-registry - - ref_binding-broker-impl - /config/modules/module[name='binding-broker-impl']/instance[name='binding-broker-impl'] - - - - binding-impl:binding-dom-mapping-service - - ref_runtime-mapping-singleton - /config/modules/module[name='runtime-generated-mapping']/instance[name='runtime-mapping-singleton'] - - - - dom:dom-broker-osgi-registry - - ref_dom-broker - /config/modules/module[name='dom-broker-impl']/instance[name='dom-broker'] - - - - 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 index 9924111627..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedCapabilities.txt +++ /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 index 887cb2c1d4..0000000000 --- a/opendaylight/config/config-persister-directory-adapter/src/test/resources/twoFilesExpected2/expectedSnapshot.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - prefix:binding-data-broker - binding-data-broker - - dom:dom-broker-osgi-registry - ref_dom-broker - - - binding:binding-dom-mapping-service - ref_runtime-mapping-singleton - - - - - - binding:binding-data-broker - - ref_binding-data-broker - /config/modules/module[name='binding-data-broker']/instance[name='binding-data-broker'] - - - - 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 index 5e556c07a9..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/pom.xml +++ /dev/null @@ -1,114 +0,0 @@ - - - 4.0.0 - - config-subsystem - org.opendaylight.controller - 0.2.5-SNAPSHOT - .. - - config-persister-directory-autodetect-adapter - ${project.artifactId} - bundle - - - - - ${project.groupId} - config-persister-api - - - org.apache.commons - commons-lang3 - - - com.google.guava - guava - - - org.opendaylight.controller - config-persister-directory-adapter - - - org.opendaylight.controller - config-persister-directory-xml-adapter - - - - org.slf4j - slf4j-api - - - commons-io - commons-io - - - - - org.opendaylight.yangtools - mockito-configuration - - - ${project.groupId} - config-persister-api - test-jar - test - - - - - - - - - org.codehaus.groovy.maven - gmaven-plugin - - - generate-sources - - execute - - - - System.setProperty("osgiversion", "${project.version}".replace('-', '.')) - - - - - - - org.apache.felix - maven-bundle-plugin - - - ${project.groupId}.config-persister-impl;bundle-version=${osgiversion} - - org.opendaylight.controller.config.persister.storage.adapter - - - 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 - - - org.opendaylight.controller.config.persist.storage.file.xml.model, - org.opendaylight.controller.config.persist.storage.directory, - org.opendaylight.controller.config.persist.storage.directory.xml, - - - - - - - - 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 index 2028d62bd0..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersister.java +++ /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 loadLastConfigs() throws IOException { - File[] filesArray = storage.listFiles(); - if (filesArray == null || filesArray.length == 0) { - return Collections.emptyList(); - } - List sortedFiles = new ArrayList<>(Arrays.asList(filesArray)); - Collections.sort(sortedFiles); - - // combine all found files - logger.debug("Reading files in following order: {}", sortedFiles); - - List 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 index f856ddd6cb..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryStorageAdapter.java +++ /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 index 779a887924..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileType.java +++ /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 = " { - 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 index bcade93352..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/AutodetectDirectoryPersisterTest.java +++ /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 configs = persister.loadLastConfigs(); - - Assert.assertEquals(2, configs.size()); - String snapFromTxt = configs.get(0).getConfigSnapshot(); - org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("txt")); - org.junit.Assert.assertThat(snapFromTxt, JUnitMatchers.containsString("txt")); - - String snapFromXml = configs.get(1).getConfigSnapshot(); - org.junit.Assert.assertThat(snapFromXml, JUnitMatchers.containsString("xml")); - - 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 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 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 index bbc272d388..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/directory/autodetect/FileTypeTest.java +++ /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 index 3f6a3375d0..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/bad_controller.xml.config +++ /dev/null @@ -1,10 +0,0 @@ - - - cap2 - capa a - - - xml - - \ 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 index f72cd1c080..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/1controller.txt.config +++ /dev/null @@ -1,8 +0,0 @@ -//MODULES START - txt -//SERVICES START - txt -//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 index 988f86675d..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/combined/2controller.xml.config +++ /dev/null @@ -1,10 +0,0 @@ - - - cap1&rev - cap2 - capa a - - - xml - - \ 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 index edf37caf0e..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.txt.config +++ /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 index fe94299adb..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/test.xml.config +++ /dev/null @@ -1,2 +0,0 @@ - - \ 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 index c4218c8d64..0000000000 --- a/opendaylight/config/config-persister-directory-autodetect-adapter/src/test/resources/unknown.config +++ /dev/null @@ -1,2 +0,0 @@ -unknown -file type \ 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 index a8ea93e71b..0000000000 --- a/opendaylight/config/config-persister-file-adapter/pom.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - 4.0.0 - - config-subsystem - org.opendaylight.controller - 0.2.5-SNAPSHOT - .. - - config-persister-file-adapter - ${project.artifactId} - bundle - - - - - ${project.groupId} - config-persister-api - - - org.apache.commons - commons-lang3 - - - com.google.guava - guava - - - org.slf4j - slf4j-api - - - - - org.opendaylight.yangtools - mockito-configuration - - - ${project.groupId} - config-persister-api - test-jar - test - - - - - - - - org.codehaus.groovy.maven - gmaven-plugin - - - generate-sources - - execute - - - - System.setProperty("osgiversion", "${project.version}".replace('-', '.')) - - - - - - - org.apache.felix - maven-bundle-plugin - - - ${project.groupId}.config-persister-impl;bundle-version=${osgiversion} - - org.opendaylight.controller.config.persister.storage.adapter - - - - - - - - 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 index 1b9948bf39..0000000000 --- a/opendaylight/config/config-persister-file-adapter/src/main/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapter.java +++ /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 capabilities) { - StringBuilder b = new StringBuilder(); - for (String capability : capabilities) { - b.append(newLine(capability)); - } - return b.toString(); - } - - @Override - public List 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.asList(new ConfigSnapshotHolderImpl(lineProcessor.getConfigSnapshot().get(), - lineProcessor.getCapabilities(), storage.getAbsolutePath())); - } - - } - - private static final class LineProcessor implements com.google.common.io.LineProcessor { - - private boolean inLastConfig, inLastSnapshot; - private final StringBuffer snapshotBuffer = new StringBuffer(); - private final SortedSet 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 getConfigSnapshot() { - final String xmlContent = snapshotBuffer.toString(); - if (xmlContent.equals("")) { - return Optional.absent(); - } else { - return Optional.of(xmlContent); - } - } - - SortedSet 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 index 0366dbcaed..0000000000 --- a/opendaylight/config/config-persister-file-adapter/src/test/java/org/opendaylight/controller/config/persist/storage/file/FileStorageAdapterTest.java +++ /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 getCapabilities() { - return createCaps(); - } - }; - configPersister.persistConfig(holder); - - configPersister.persistConfig(holder); - - Collection readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8), - new Predicate() { - - @Override - public boolean apply(String input) { - if (input.equals("")) - return false; - return true; - } - }); - assertEquals(14, readLines.size()); - - List lastConf = storage.loadLastConfigs(); - assertEquals(1, lastConf.size()); - ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0); - assertEquals("2", - 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 getCapabilities() { - return createCaps(); - } - }; - storage.persistConfig(holder); - - storage.persistConfig(holder); - - Collection readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8), - new Predicate() { - - @Override - public boolean apply(String input) { - if (input.equals("")) - return false; - return true; - } - }); - assertEquals(14, readLines.size()); - - List lastConf = storage.loadLastConfigs(); - assertEquals(1, lastConf.size()); - ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0); - assertEquals("2", - configSnapshotHolder.getConfigSnapshot().replaceAll("\\s", "")); - assertEquals(createCaps(), configSnapshotHolder.getCapabilities()); - } - - private SortedSet createCaps() { - SortedSet 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 getCapabilities() { - return createCaps(); - } - }; - storage.persistConfig(holder); - - storage.persistConfig(holder); - - Collection readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8), - new Predicate() { - - @Override - public boolean apply(String input) { - if (input.equals("")) - return false; - return true; - } - }); - assertEquals(7, readLines.size()); - - List lastConf = storage.loadLastConfigs(); - assertEquals(1, lastConf.size()); - ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0); - assertEquals("2", - 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 getCapabilities() { - return createCaps(); - } - }; - storage.persistConfig(holder); - - storage.persistConfig(holder); - storage.persistConfig(holder); - - Collection readLines = Collections2.filter(com.google.common.io.Files.readLines(file, Charsets.UTF_8), - new Predicate() { - - @Override - public boolean apply(String input) { - if (input.equals("")) - return false; - return true; - } - }); - - assertEquals(14, readLines.size()); - - List lastConf = storage.loadLastConfigs(); - assertEquals(1, lastConf.size()); - ConfigSnapshotHolder configSnapshotHolder = lastConf.get(0); - assertEquals("3", - 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 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 getCapabilities() { - return new TreeSet<>(); - } - } ); - } - - static String createConfig() { - return "" + i++ + ""; - } - -} diff --git a/opendaylight/config/pom.xml b/opendaylight/config/pom.xml index 6b55b6ad16..d700075e95 100644 --- a/opendaylight/config/pom.xml +++ b/opendaylight/config/pom.xml @@ -23,7 +23,6 @@ config-plugin-parent config-util config-persister-api - config-persister-file-adapter config-persister-file-xml-adapter yang-jmx-generator yang-jmx-generator-plugin @@ -35,9 +34,7 @@ netty-threadgroup-config netty-event-executor-config netty-timer-config - config-persister-directory-adapter config-persister-directory-xml-adapter - config-persister-directory-autodetect-adapter yang-test-plugin shutdown-api shutdown-impl diff --git a/opendaylight/distribution/opendaylight/pom.xml b/opendaylight/distribution/opendaylight/pom.xml index a38a9b4f93..a6d1019c42 100644 --- a/opendaylight/distribution/opendaylight/pom.xml +++ b/opendaylight/distribution/opendaylight/pom.xml @@ -202,26 +202,14 @@ org.opendaylight.controller config-persister-api - - org.opendaylight.controller - config-persister-file-adapter - org.opendaylight.controller config-persister-file-xml-adapter - - org.opendaylight.controller - config-persister-directory-adapter - org.opendaylight.controller config-persister-directory-xml-adapter - - org.opendaylight.controller - config-persister-directory-autodetect-adapter - org.opendaylight.controller diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini index 4598bac593..ea2955e34e 100644 --- a/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini +++ b/opendaylight/distribution/opendaylight/src/main/resources/configuration/config.ini @@ -26,22 +26,10 @@ 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/ 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 diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml index 74e7d1afe7..01e5ae0372 100644 --- a/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml +++ b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml @@ -165,7 +165,7 @@ org.opendaylight.controller - config-persister-file-adapter + config-persister-file-xml-adapter ${config.version} @@ -269,11 +269,6 @@ config-persister-impl ${config.version} - - org.opendaylight.controller - config-persister-file-adapter - ${config.version} - org.opendaylight.controller netconf-impl diff --git a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml index 3e73f161c2..ffdcda31eb 100644 --- a/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml +++ b/opendaylight/md-sal/sal-remoterpc-connector/integrationtest/test-it/pom.xml @@ -50,7 +50,7 @@ - org.eclipse.m2e @@ -203,7 +203,7 @@ org.opendaylight.yangtools yang-data-api - org.opendaylight.yangtools @@ -455,7 +455,7 @@ org.opendaylight.controller - config-persister-file-adapter + config-persister-file-xml-adapter ${config.version} @@ -472,8 +472,8 @@ org.ops4j.pax.exam pax-exam ${exam.version} - compile diff --git a/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml b/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml index a9fc739456..f0a8584730 100644 --- a/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml +++ b/opendaylight/md-sal/test/sal-rest-connector-it/pom.xml @@ -43,7 +43,7 @@ - org.eclipse.m2e @@ -605,7 +605,7 @@ jersey-core ${jersey.version} - com.sun.jersey @@ -667,7 +667,7 @@ org.opendaylight.controller - config-persister-file-adapter + config-persister-file-xml-adapter ${config.version} diff --git a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java index 8400bc1835..4a43e0cf82 100644 --- a/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java +++ b/opendaylight/md-sal/test/sal-rest-connector-it/src/test/java/org/opendaylight/controller/test/restconf/it/ServiceProviderController.java @@ -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(), diff --git a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java index c1cad4a8dd..31a4f08036 100644 --- a/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java +++ b/opendaylight/netconf/config-persister-impl/src/main/java/org/opendaylight/controller/netconf/persist/impl/PersisterAggregator.java @@ -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 diff --git a/opendaylight/netconf/pom.xml b/opendaylight/netconf/pom.xml index 586366f41a..2be64a8a98 100644 --- a/opendaylight/netconf/pom.xml +++ b/opendaylight/netconf/pom.xml @@ -153,11 +153,6 @@ config-persister-api ${config.version} - - org.opendaylight.controller - config-persister-file-adapter - ${config.version} - ${project.groupId} netconf-client -- 2.36.6