-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
</dependency>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
- <artifactId>concepts</artifactId>
- <version>${opendaylight.yangtools.version}</version>
+ <artifactId>yang-binding</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
</dependency>
</dependencies>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- javax.management,
- org.opendaylight.yangtools.concepts,
- org.osgi.framework,
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.api,
org.opendaylight.controller.config.api.annotations,
org.opendaylight.controller.config.api.jmx,
org.opendaylight.controller.config.api.jmx.constants,
org.opendaylight.controller.config.api.runtime,
+ org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.rpc.context.rev130617.*,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.config.rev130405.*,
</Export-Package>
</instructions>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ </plugin>
</plugins>
</build>
</project>
org.opendaylight.controller.config.manager.*,
javax.annotation.*,
</Private-Package>
- <Import-Package>
- org.opendaylight.controller.config.api.*,
- org.opendaylight.controller.config.spi.*,
- org.slf4j,
- javax.management,
- org.osgi.framework,
- org.opendaylight.yangtools.concepts.*,
- org.apache.commons.io,
- org.osgi.util.tracker,
- </Import-Package>
<Export-Package>
</Export-Package>
</instructions>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- com.google.common.base,
- org.w3c.dom,
- org.osgi.framework,
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.persist.api,
org.opendaylight.controller.config.persist.api.storage,
</Fragment-Host>
<Provide-Capability>org.opendaylight.controller.config.persister.storage.adapter
</Provide-Capability>
- <Import-Package>
- org.osgi.framework,
- com.google.common.base,
- com.google.common.collect,
- com.google.common.io,
- javax.xml.parsers,
- javax.xml.transform,
- javax.xml.transform.dom,
- javax.xml.transform.stream,
- org.apache.commons.lang3,
- org.opendaylight.controller.config.persist.api,
- org.slf4j,
- org.w3c.dom,
- org.xml.sax,
- </Import-Package>
</instructions>
</configuration>
</plugin>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<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">
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-subsystem</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>config-plugin-parent</artifactId>
+ <name>${project.artifactId}</name>
+ <packaging>pom</packaging>
+ <prerequisites>
+ <maven>3.0.4</maven>
+ </prerequisites>
+
+ <properties>
+ <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
+ </properties>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>config</id>
+ <goals>
+ <goal>generate-sources</goal>
+ </goals>
+ <configuration>
+ <codeGenerators>
+ <generator>
+ <codeGeneratorClass>
+ org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ </codeGeneratorClass>
+ <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+ <additionalConfiguration>
+ <namespaceToPackage1>
+ urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+ </namespaceToPackage1>
+ </additionalConfiguration>
+ </generator>
+ </codeGenerators>
+ <inspectDependencies>true</inspectDependencies>
+ </configuration>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>yang-jmx-generator-plugin</artifactId>
+ <version>${config.version}</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+ <!-- tell eclipse about generated source folders -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <version>1.8</version>
+ <executions>
+ <execution>
+ <id>add-source</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>add-source</goal>
+ </goals>
+ <configuration>
+ <sources>
+ <source>${jmxGeneratorPath}</source>
+ </sources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+</project>
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
+ <artifactId>config-plugin-parent</artifactId>
<version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<artifactId>logback-config</artifactId>
<name>${project.artifactId}</name>
<instructions>
<Private-Package>
</Private-Package>
- <Import-Package>
- ch.qos.logback.classic,
- ch.qos.logback.classic.encoder,
- ch.qos.logback.classic.filter,
- ch.qos.logback.classic.spi,
- ch.qos.logback.core,
- ch.qos.logback.core.status,
- ch.qos.logback.core.encoder,
- ch.qos.logback.core.rolling,
- org.opendaylight.controller.config.api,
- org.opendaylight.controller.config.api.runtime,
- org.opendaylight.controller.config.api.annotations,
- org.opendaylight.controller.config.spi,
- com.google.common.base,
- com.google.common.collect,
- org.apache.commons.lang3,
- org.slf4j,
- org.osgi.framework
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.yang.logback.config,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.logback.config.rev130716.*,
</Export-Package>
</instructions>
</configuration>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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">
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
- <version>0.2.3-SNAPSHOT</version>
+ <artifactId>config-plugin-parent</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-config-api</artifactId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- org.opendaylight.controller.config.api.*,
- io.netty.channel,
- io.netty.util,
- io.netty.util.concurrent
- </Import-Package>
<Export-Package>
- org.opendaylight.controller.config.yang.netty
+ org.opendaylight.controller.config.yang.netty,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.netty.rev131119.*,
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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">
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
- <version>0.2.3-SNAPSHOT</version>
+ <artifactId>config-plugin-parent</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-event-executor-config</artifactId>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Export-Package>
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.netty.eventexecutor.rev131112.*,
</Export-Package>
- <Import-Package>
- com.google.common.base,
- org.opendaylight.controller.config.yang.netty,
- io.netty.util.concurrent,
- org.opendaylight.controller.config.api,
- org.opendaylight.controller.config.api.annotations,
- org.opendaylight.controller.config.api.runtime,
- org.opendaylight.controller.config.spi,
- org.slf4j,
- org.osgi.framework
- </Import-Package>
</instructions>
</configuration>
</plugin>
</site>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
+ <artifactId>config-plugin-parent</artifactId>
<version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Export-Package>
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.netty.threadgroup.rev131107.*,
</Export-Package>
- <Import-Package>
- com.google.common.base,
- io.netty.channel.nio,
- org.opendaylight.controller.config.yang.netty,
- io.netty.util.concurrent,
- org.opendaylight.controller.config.api,
- org.opendaylight.controller.config.api.annotations,
- org.opendaylight.controller.config.api.runtime,
- org.opendaylight.controller.config.spi,
- org.slf4j,
- org.osgi.framework
- </Import-Package>
</instructions>
</configuration>
</plugin>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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">
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
- <version>0.2.3-SNAPSHOT</version>
+ <artifactId>config-plugin-parent</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>netty-timer-config</artifactId>
<instructions>
<Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
<Export-Package>
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.netty.timer.rev131119.*,
</Export-Package>
- <Import-Package>
- javax.management,
- com.google.common.base,
- org.opendaylight.controller.config.yang.netty,
- org.opendaylight.controller.config.yang.threadpool,
- io.netty.util,
- org.opendaylight.controller.config.api,
- org.opendaylight.controller.config.api.annotations,
- org.opendaylight.controller.config.api.runtime,
- org.opendaylight.controller.config.spi,
- org.slf4j,
- org.osgi.framework
- </Import-Package>
</instructions>
</configuration>
</plugin>
<url>${basedir}/target/site/${project.artifactId}</url>
</site>
</distributionManagement>
-</project>
\ No newline at end of file
+</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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>
<modules>
<module>config-api</module>
<module>config-manager</module>
+ <module>config-plugin-parent</module>
<module>config-util</module>
<module>config-persister-api</module>
<module>config-persister-file-adapter</module>
<opendaylight.yang.version>0.5.9-SNAPSHOT</opendaylight.yang.version>
<opendaylight.binding.version>0.6.0-SNAPSHOT</opendaylight.binding.version>
<opendaylight.yangtools.version>0.1.1-SNAPSHOT</opendaylight.yangtools.version>
- <jmxGeneratorPath>${project.build.directory}/generated-sources/config</jmxGeneratorPath>
</properties>
<dependencies>
<artifactId>yang-store-api</artifactId>
<version>${config.version}</version>
</dependency>
+
+ <!-- MD-SAL -->
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-binding</artifactId>
+ <version>${opendaylight.binding.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>yang-common</artifactId>
+ <version>${opendaylight.yang.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>concepts</artifactId>
+ <version>${opendaylight.yangtools.version}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
</plugin>
</plugins>
-
-
<pluginManagement>
<plugins>
<plugin>
<version>${opendaylight.yang.version}</version>
<executions>
<execution>
+ <id>sal</id>
<goals>
<goal>generate-sources</goal>
</goals>
<configuration>
+ <yangFilesRootDir>src/main/yang</yangFilesRootDir>
<codeGenerators>
<generator>
<codeGeneratorClass>
- org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+ org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl
</codeGeneratorClass>
- <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
- <additionalConfiguration>
- <namespaceToPackage1>
- urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
- </namespaceToPackage1>
- </additionalConfiguration>
+ <outputBaseDir>
+ target/generated-sources/sal
+ </outputBaseDir>
+ </generator>
+ <generator>
+ <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+ <outputBaseDir>target/site</outputBaseDir>
</generator>
</codeGenerators>
<inspectDependencies>true</inspectDependencies>
</executions>
<dependencies>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>yang-jmx-generator-plugin</artifactId>
- <version>${config.version}</version>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>maven-sal-api-gen-plugin</artifactId>
+ <version>${opendaylight.binding.version}</version>
+ <type>jar</type>
</dependency>
</dependencies>
</plugin>
- <!-- tell eclipse about generated source folders -->
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <version>1.8</version>
- <executions>
- <execution>
- <id>add-source</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>add-source</goal>
- </goals>
- <configuration>
- <sources>
- <source>${jmxGeneratorPath}</source>
- </sources>
- </configuration>
- </execution>
- </executions>
- </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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">
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
- <version>0.2.3-SNAPSHOT</version>
+ <artifactId>config-plugin-parent</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>threadpool-config-api</artifactId>
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- org.opendaylight.controller.config.api.*,
- com.google.common.eventbus,
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.threadpool,
- org.opendaylight.controller.config.yang.threadpool
+ org.opendaylight.controller.config.yang.threadpool,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.rev130409.*,
</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<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">
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
- <version>0.2.3-SNAPSHOT</version>
+ <artifactId>config-plugin-parent</artifactId>
+ <version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>threadpool-config-impl</artifactId>
javax.annotation.*,
org.opendaylight.controller.config.yang.threadpool.impl,
</Private-Package>
- <Import-Package>
- org.opendaylight.controller.config.api.*,
- org.opendaylight.controller.config.spi.*,
- org.opendaylight.controller.config.threadpool,
- org.opendaylight.controller.config.yang.threadpool,
- javax.management,
- org.osgi.framework,
- org.slf4j,
- com.google.common.*
- </Import-Package>
<Export-Package>
- org.opendaylight.controller.config.threadpool.util
+ org.opendaylight.controller.config.threadpool.util,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.threadpool.impl.rev130405.*,
</Export-Package>
</instructions>
</configuration>
public String getDefinition() {
return definition;
}
+
+ public boolean isArray() {
+ return type.endsWith("[]");
+ }
}
dependencyResolver.validateDependency(${field.dependency.sie.fullyQualifiedName}.class, ${field.name}, ${field.name}JmxAttribute);
</#if>
</#list>
+ customValidation();
+ }
+
+ protected void customValidation(){
+
}
// caches of resolved dependencies
public boolean canReuseInstance(${typeDeclaration.name} oldModule){
// allow reusing of old instance if no parameters was changed
- return equals(oldModule);
+ return isSame(oldModule);
}
public ${instanceType} reuseInstance(${instanceType} oldInstance){
public abstract ${instanceType} createInstance();
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ${typeDeclaration.name} other = (${typeDeclaration.name}) obj;
-
-
+ public boolean isSame(${typeDeclaration.name} other) {
+ if (other == null) {
+ throw new IllegalArgumentException("Parameter 'other' is null");
+ }
<#list moduleFields as field>
<#if field.dependent==true>
if (${field.name}Dependency == null) {
if (other.${field.name}Dependency != null)
return false;
- } else if (!${field.name}Dependency.equals(other.${field.name}Dependency))
+ } else if (!${field.name}Dependency.equals(other.${field.name}Dependency)) {
return false;
+ }
<#else>
if (${field.name} == null) {
- if (other.${field.name} != null)
+ if (other.${field.name} != null) {
return false;
- } else if (!${field.name}.equals(other.${field.name}))
+ }
+ } else if
+ <#if field.array == false>
+ (${field.name}.equals(other.${field.name}) == false)
+ <#else>
+ (java.util.Arrays.equals(${field.name},other.${field.name}) == false)
+ </#if>
+ {
return false;
+ }
</#if>
</#list>
return true;
}
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ ${typeDeclaration.name} that = (${typeDeclaration.name}) o;
+
+ return identifier.equals(that.identifier);
+ }
+
+ @Override
+ public int hashCode() {
+ return identifier.hashCode();
+ }
}
package ${packageName};
<@javadocD object=javadoc/>
-<@typeDeclarationD object=typeDeclaration/>
-{
+<@typeDeclarationD object=typeDeclaration/> {
public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver) {
super(identifier, dependencyResolver);
}
- public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver, ${typeDeclaration.name} oldModule, ${instanceType} oldInstance) {
+ public ${typeDeclaration.name}(${moduleNameType} identifier, ${dependencyResolverType} dependencyResolver,
+ ${typeDeclaration.name} oldModule, ${instanceType} oldInstance) {
+
super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate(){
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
assertContains(reqIfc, PackageTranslatorTest.EXPECTED_PACKAGE_PREFIX
+ ".threads.ThreadFactoryServiceInterface");
- assertEquals("Incorrenct number of generated methods", 24,
+ assertEquals("Incorrenct number of generated methods", 27,
visitor.methods.size());
assertEquals("Incorrenct number of generated method descriptions", 3,
visitor.methodDescriptions.size());
<Private-Package>
org.opendaylight.controller.config.yangjmxgenerator.plugin.util,
</Private-Package>
- <Import-Package>
- org.slf4j,
- com.google.common.base,
- com.google.common.collect,
- javax.management.*,
- <!-- YANGTOOLS -->
- org.opendaylight.yangtools.binding.generator.util,
- org.opendaylight.yangtools.sal.binding.generator.spi,
- org.opendaylight.yangtools.sal.binding.model.api,
- org.opendaylight.yangtools.yang.common,
- org.opendaylight.yangtools.yang.model.api
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.yangjmxgenerator,
org.opendaylight.controller.config.yangjmxgenerator.attribute,
<artifactId>maven-bundle-plugin</artifactId>
<configuration>
<instructions>
- <Import-Package>
- org.opendaylight.controller.config.yangjmxgenerator,
- org.opendaylight.yangtools.yang.model.api
- </Import-Package>
<Export-Package>
org.opendaylight.controller.config.yang.store.api,
</Export-Package>
<configuration>
<instructions>
<Bundle-Activator>org.opendaylight.controller.config.yang.store.impl.YangStoreActivator</Bundle-Activator>
- <Import-Package>
- org.opendaylight.controller.config.yang.store.api,
- org.opendaylight.controller.config.yangjmxgenerator,
- com.google.common.base,
- com.google.common.collect,
- com.google.common.primitives,
- org.apache.commons.io,
- org.osgi.framework,
- org.osgi.util.tracker,
- org.slf4j,
- <!-- YANGTOOLS -->
- org.opendaylight.yangtools.sal.binding.yang.types,
- org.opendaylight.yangtools.yang.common,
- org.opendaylight.yangtools.yang.model.api,
- org.opendaylight.yangtools.sal.binding.generator.spi,
- org.opendaylight.yangtools.yang.parser.impl,
- </Import-Package>
<Export-Package>
</Export-Package>
</instructions>
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>config-subsystem</artifactId>
+ <artifactId>config-plugin-parent</artifactId>
<version>0.2.3-SNAPSHOT</version>
+ <relativePath>../config-plugin-parent</relativePath>
</parent>
<artifactId>yang-test</artifactId>
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-dep
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
/**
*
*/
-public final class DepTestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModule {
+public final class DepTestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModule
+ {
- public DepTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public DepTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public DepTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public DepTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
DepTestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
}
};
}
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-dep
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class DepTestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModuleFactory {
+public class DepTestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractDepTestImplModuleFactory
+{
+
}
--- /dev/null
+ return new AutoCloseable() {
+ @Override
+ public void close() throws Exception {
+ }
+ };
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-netconf
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
-import com.google.common.collect.Lists;
-
-import java.util.List;
-
/**
*
*/
-public final class NetconfTestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModule {
+public final class NetconfTestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModule
+ {
- public NetconfTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public NetconfTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public NetconfTestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public NetconfTestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
NetconfTestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
@Override
public java.lang.AutoCloseable createInstance() {
- return registerRuntimeBeans();
+ return NetconfTestImplModuleUtil.registerRuntimeBeans(this);
}
-
- private NetconfTestImplRuntimeRegistration registerRuntimeBeans() {
- NetconfTestImplRuntimeRegistration reg = getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
-
- @Override
- public Long getCreatedSessions() {
- return getSimpleLong();
- }
-
- @Override
- public Asdf getAsdf() {
- final Asdf asdf = new Asdf();
- asdf.setSimpleString("asdf");
- return asdf;
- }
-
- @Override
- public String noArg(final String arg1) {
- return arg1.toUpperCase();
- }
-
- });
-
- for (int i = 0; i < getSimpleShort(); i++) {
- final int finalI = i;
-
- reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return getSimpleTest();
- }
-
- @Override
- public Deep4 getDeep4() {
- final Deep4 d = new Deep4();
- d.setBoool(false);
- return d;
- }
-
- @Override
- public String getSimpleString() {
- return Integer.toString(finalI);
- }
-
- @Override
- public void noArgInner() {
- }
- });
-
- InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
- @Override
- public Integer getSimpleInt3() {
- return finalI;
- }
-
- @Override
- public Deep2 getDeep2() {
- return new Deep2();
- }
- });
-
- for (int j = 0; j < getSimpleShort(); j++) {
- final int finalJ = j;
- innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
- @Override
- public List<NotStateBean> getNotStateBean() {
- NotStateBean b1 = new NotStateBean();
- b1.setElement("not state");
- return Lists.newArrayList(b1);
- }
-
- @Override
- public Integer getSimpleInt3() {
- return finalJ;
- }
-
- @Override
- public Deep3 getDeep3() {
- return new Deep3();
- }
-
- @Override
- public List<String> getListOfStrings() {
- return Lists.newArrayList("l1", "l2");
- }
-
- @Override
- public List<RetValList> listOutput() {
- return Lists.newArrayList(new RetValList());
- }
-
- @Override
- public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
- return aBoolean;
- }
-
- @Override
- public RetValContainer containerOutput() {
- return new RetValContainer();
- }
-
- @Override
- public List<String> leafListOutput() {
- return Lists.newArrayList("1", "2");
- }
- });
- }
- }
-
- return reg;
- }
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl-netconf
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class NetconfTestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModuleFactory {
+public class NetconfTestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractNetconfTestImplModuleFactory
+{
+
}
--- /dev/null
+return NetconfTestImplModuleUtil.registerRuntimeBeans(this);
--- /dev/null
+/**
+ * @author Tomas Olvecky
+ *
+ * 11 2013
+ *
+ * Copyright (c) 2013 by Cisco Systems, Inc.
+ * All rights reserved.
+ */
+package org.opendaylight.controller.config.yang.test.impl;
+
+import com.google.common.collect.Lists;
+
+import java.util.List;
+
+public class NetconfTestImplModuleUtil {
+ static NetconfTestImplRuntimeRegistration registerRuntimeBeans(final NetconfTestImplModule module) {
+ NetconfTestImplRuntimeRegistration reg = module.getRootRuntimeBeanRegistratorWrapper().register(new NetconfTestImplRuntimeMXBean() {
+
+ @Override
+ public Long getCreatedSessions() {
+ return module.getSimpleLong();
+ }
+
+ @Override
+ public Asdf getAsdf() {
+ final Asdf asdf = new Asdf();
+ asdf.setSimpleString("asdf");
+ return asdf;
+ }
+
+ @Override
+ public String noArg(final String arg1) {
+ return arg1.toUpperCase();
+ }
+
+ });
+
+ for (int i = 0; i < module.getSimpleShort(); i++) {
+ final int finalI = i;
+
+ reg.register(new InnerRunningDataAdditionalRuntimeMXBean() {
+ @Override
+ public Integer getSimpleInt3() {
+ return module.getSimpleTest();
+ }
+
+ @Override
+ public Deep4 getDeep4() {
+ final Deep4 d = new Deep4();
+ d.setBoool(false);
+ return d;
+ }
+
+ @Override
+ public String getSimpleString() {
+ return Integer.toString(finalI);
+ }
+
+ @Override
+ public void noArgInner() {
+ }
+ });
+
+ InnerRunningDataRuntimeRegistration innerReg = reg.register(new InnerRunningDataRuntimeMXBean() {
+ @Override
+ public Integer getSimpleInt3() {
+ return finalI;
+ }
+
+ @Override
+ public Deep2 getDeep2() {
+ return new Deep2();
+ }
+ });
+
+ for (int j = 0; j < module.getSimpleShort(); j++) {
+ final int finalJ = j;
+ innerReg.register(new InnerInnerRunningDataRuntimeMXBean() {
+ @Override
+ public List<NotStateBean> getNotStateBean() {
+ NotStateBean b1 = new NotStateBean();
+ b1.setElement("not state");
+ return Lists.newArrayList(b1);
+ }
+
+ @Override
+ public Integer getSimpleInt3() {
+ return finalJ;
+ }
+
+ @Override
+ public Deep3 getDeep3() {
+ return new Deep3();
+ }
+
+ @Override
+ public List<String> getListOfStrings() {
+ return Lists.newArrayList("l1", "l2");
+ }
+
+ @Override
+ public List<RetValList> listOutput() {
+ return Lists.newArrayList(new RetValList());
+ }
+
+ @Override
+ public Boolean noArgInnerInner(Integer integer, Boolean aBoolean) {
+ return aBoolean;
+ }
+
+ @Override
+ public RetValContainer containerOutput() {
+ return new RetValContainer();
+ }
+
+ @Override
+ public List<String> leafListOutput() {
+ return Lists.newArrayList("1", "2");
+ }
+ });
+ }
+ }
+
+ return reg;
+ }
+}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
-
/**
*
*/
-public final class TestImplModule
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModule {
+public final class TestImplModule extends org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModule
+ {
- public TestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
- super(name, dependencyResolver);
+ public TestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+ super(identifier, dependencyResolver);
}
- public TestImplModule(
- org.opendaylight.controller.config.api.ModuleIdentifier name,
- org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+ public TestImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
TestImplModule oldModule, java.lang.AutoCloseable oldInstance) {
- super(name, dependencyResolver, oldModule, oldInstance);
+
+ super(identifier, dependencyResolver, oldModule, oldInstance);
}
@Override
- public void validate() {
- super.validate();
+ protected void customValidation(){
// Add custom validation for module attributes here.
}
}
};
}
-
}
-/**
- * Generated file
-
- * Generated from: yang module name: config-test-impl yang module local name: impl
- * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
- * Generated at: Fri Sep 27 13:02:28 CEST 2013
- *
- * Do not modify this file unless it is present under src/main directory
- */
package org.opendaylight.controller.config.yang.test.impl;
/**
*
*/
-public class TestImplModuleFactory
- extends
- org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModuleFactory {
+public class TestImplModuleFactory extends org.opendaylight.controller.config.yang.test.impl.AbstractTestImplModuleFactory
+{
+
}
--- /dev/null
+ return new AutoCloseable() {
+ @Override
+ public void close() throws Exception {
+ }
+ };
private void addFlow(InstanceIdentifier<?> path, Flow dataObject) {
AddFlowInputBuilder input = new AddFlowInputBuilder();
+
List<Instruction> inst = (dataObject).getInstructions().getInstruction();
input.setNode((dataObject).getNode());
input.setPriority((dataObject).getPriority());
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupRemoved;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.GroupUpdated;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.RemoveGroupInputBuilder;
-
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupListener;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.SalGroupService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.UpdateGroupInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.service.rev130918.group.update.UpdatedGroupBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes.GroupType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.config.rev131024.meters.Meter;
import org.opendaylight.yangtools.concepts.Registration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
return new Status(StatusCode.BADREQUEST, "Group record does not exist");
}*/
- if (!(group.getGroupType().getIntValue() >= GroupType.GroupAll.getIntValue() && group.getGroupType()
- .getIntValue() <= GroupType.GroupFf.getIntValue())) {
+ if (!(group.getGroupType().getIntValue() >= GroupTypes.GroupAll.getIntValue() && group.getGroupType()
+ .getIntValue() <= GroupTypes.GroupFf.getIntValue())) {
logger.error("Invalid Group type %d" + group.getGroupType().getIntValue());
return new Status(StatusCode.BADREQUEST, "Invalid Group type");
}
type uint32;
}
- grouping group-types {
- leaf group-type {
- type enumeration {
- enum group-all;
- enum group-select;
- enum group-indirect;
- enum group-ff;
- }
- }
+ typedef group-types {
+ type enumeration {
+ enum group-all;
+ enum group-select;
+ enum group-indirect;
+ enum group-ff;
+ }
}
typedef group-capabilities {
- type enumeration {
- enum select-weight;
- enum select-liveness;
- enum chaining;
- enum chaining-checks;
- }
- }
+ type enumeration {
+ enum select-weight;
+ enum select-liveness;
+ enum chaining;
+ enum chaining-checks;
+ }
+ }
grouping group {
- uses group-types;
+ leaf group-type {
+ type group-types;
+ }
leaf group-id {
type group-id;
type uint32;
}
- grouping meter-flags {
- leaf flags {
- type bits {
- bit meter-kbps;
- bit meter-pktps;
- bit meter-burst;
- bit meter-stats;
- }
- }
+ // field types
+ identity meter-flags {
+ description "Base identity for match Fields";
}
- grouping meter-band-type {
- leaf flags {
- type bits {
- bit ofpmbt-drop;
- bit ofpmbt-dscp-remark;
- bit ofpmbt-experimenter;
- }
+ typedef meter-flags {
+ type bits {
+ bit meter-kbps;
+ bit meter-pktps;
+ bit meter-burst;
+ bit meter-stats;
+ }
+ }
+
+ typedef meter-band-type {
+ type bits {
+ bit ofpmbt-drop;
+ bit ofpmbt-dscp-remark;
+ bit ofpmbt-experimenter;
}
}
grouping meter {
- uses meter-flags;
+ leaf flags {
+ type meter-flags;
+ }
leaf meter-id {
type meter-id;
}
container meter-band-types {
- uses meter-band-type;
+ leaf flags {
+ type meter-band-type;
+ }
}
leaf rate {
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-directory-adapter</artifactId>
+ <version>${parent.version}</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
if (maybeConfig.isPresent()) {
logger.debug("Last config found {}", persister);
ConflictingVersionException lastException = null;
- int maxAttempts = 30;
- for(int i = 0 ; i < maxAttempts; i++) {
- registerToNetconf(maybeConfig.get().getCapabilities());
-
- final String configSnapshot = maybeConfig.get().getConfigSnapshot();
- logger.trace("Pushing following xml to netconf {}", configSnapshot);
- try {
- pushLastConfig(XmlUtil.readXmlToElement(configSnapshot));
- return;
- } catch(ConflictingVersionException e) {
- closeClientAndDispatcher(netconfClient, netconfClientDispatcher);
- lastException = e;
- Thread.sleep(1000);
- } catch (SAXException | IOException e) {
- throw new IllegalStateException("Unable to load last config", e);
- }
- }
- throw new IllegalStateException("Failed to push configuration, maximum attempt count has been reached: "
- + maxAttempts, lastException);
+ pushLastConfigWithRetries(maybeConfig, lastException);
} else {
// this ensures that netconf is initialized, this is first
registerAsJMXListener();
}
+ private void pushLastConfigWithRetries(Optional<ConfigSnapshotHolder> maybeConfig, ConflictingVersionException lastException) throws InterruptedException {
+ int maxAttempts = 30;
+ for(int i = 0 ; i < maxAttempts; i++) {
+ registerToNetconf(maybeConfig.get().getCapabilities());
+
+ final String configSnapshot = maybeConfig.get().getConfigSnapshot();
+ logger.trace("Pushing following xml to netconf {}", configSnapshot);
+ try {
+ pushLastConfig(XmlUtil.readXmlToElement(configSnapshot));
+ return;
+ } catch(ConflictingVersionException e) {
+ closeClientAndDispatcher(netconfClient, netconfClientDispatcher);
+ lastException = e;
+ Thread.sleep(1000);
+ } catch (SAXException | IOException e) {
+ throw new IllegalStateException("Unable to load last config", e);
+ }
+ }
+ throw new IllegalStateException("Failed to push configuration, maximum attempt count has been reached: "
+ + maxAttempts, lastException);
+ }
+
private synchronized long registerToNetconf(Set<String> expectedCaps) throws InterruptedException {
Set<String> currentCapabilities = Sets.newHashSet();
}
private void registerAsJMXListener() {
+ logger.trace("Called registerAsJMXListener");
try {
mbeanServer.addNotificationListener(on, this, null, null);
} catch (InstanceNotFoundException | IOException e) {
public static class PersisterWithConfiguration {
- public final Persister storage;
+ private final Persister storage;
private final boolean readOnly;
public PersisterWithConfiguration(Persister storage, boolean readOnly) {
this.readOnly = readOnly;
}
+ @VisibleForTesting
+ public Persister getStorage() {
+ return storage;
+ }
+
+ @VisibleForTesting
+ public boolean isReadOnly() {
+ return readOnly;
+ }
+
@Override
public String toString() {
return "PersisterWithConfiguration{" +
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.netconf.persist.impl;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
+import org.opendaylight.controller.config.persist.api.Persister;
+import org.opendaylight.controller.config.persist.api.PropertiesProvider;
+import org.opendaylight.controller.config.persist.api.StorageAdapter;
+
+import java.io.IOException;
+
+public class DummyAdapter implements StorageAdapter, Persister {
+
+ static int persist = 0;
+
+ @Override
+ public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
+ persist++;
+ }
+
+ static int load = 0;
+
+ @Override
+ public Optional<ConfigSnapshotHolder> loadLastConfig() throws IOException {
+ load++;
+ return Optional.absent();
+ }
+
+ static int props = 0;
+
+ @Override
+ public Persister instantiate(PropertiesProvider propertiesProvider) {
+ props++;
+ return this;
+ }
+
+ @Override
+ public void close() {
+ }
+
+}
package org.opendaylight.controller.netconf.persist.impl;
import com.google.common.base.Optional;
-import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.config.persist.api.ConfigSnapshotHolder;
import org.opendaylight.controller.config.persist.api.Persister;
-import org.opendaylight.controller.config.persist.api.PropertiesProvider;
-import org.opendaylight.controller.config.persist.api.StorageAdapter;
import org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter;
import org.opendaylight.controller.netconf.persist.impl.osgi.ConfigPersisterActivator;
import org.opendaylight.controller.netconf.persist.impl.osgi.PropertiesProviderBaseImpl;
-import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.Properties;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertEquals;
import static org.junit.matchers.JUnitMatchers.containsString;
-import static org.mockito.Matchers.anyString;
-import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
+import static org.opendaylight.controller.netconf.persist.impl.PersisterAggregator.PersisterWithConfiguration;
+import static org.opendaylight.controller.netconf.persist.impl.PersisterAggregatorTest.TestingPropertiesProvider.loadFile;
public class PersisterAggregatorTest {
- @Mock
- TestingPropertiesProvider propertiesProvider;
- class TestingPropertiesProvider extends PropertiesProviderBaseImpl {
- TestingPropertiesProvider() {
+ static class TestingPropertiesProvider extends PropertiesProviderBaseImpl {
+
+ private static Properties prop = new Properties();
+
+ public TestingPropertiesProvider() {
super(null);
}
+ public static TestingPropertiesProvider loadFile(String fileName) {
+ try {
+ prop.load(TestingPropertiesProvider.class.getClassLoader().getResourceAsStream(fileName));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ return new TestingPropertiesProvider();
+ }
+
@Override
public String getFullKeyForReporting(String key) {
- return "prefix." + key;
+ return ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER + "." + key;
}
@Override
public String getProperty(String key) {
- throw new UnsupportedOperationException("should be mocked");
+ return prop.getProperty(getFullKeyForReporting(key));
}
- }
- @Before
- public void setUpMocks() {
- MockitoAnnotations.initMocks(this);
- doCallRealMethod().when(propertiesProvider).getFullKeyForReporting(anyString());
+ @Override
+ public String getPropertyWithoutPrefix(String fullKey){
+ return prop.getProperty(fullKey);
+ }
}
- @Ignore
@Test
- public void testFromProperties() throws Exception {
- doReturn("").when(propertiesProvider).getProperty(ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER);
- doReturn(MockAdapter.class.getName()).when(propertiesProvider).getProperty(
- ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX);
- doReturn("false").when(propertiesProvider).getProperty("readOnly");
+ public void testDummyAdapter() throws Exception {
+ PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(loadFile("test1.properties"));
+ List<PersisterWithConfiguration> persisters = persisterAggregator.getPersisterWithConfigurations();
+ assertEquals(1, persisters.size());
+ PersisterWithConfiguration persister = persisters.get(0);
+ assertEquals(DummyAdapter.class.getName() ,persister.getStorage().getClass().getName());
+ assertFalse(persister.isReadOnly());
- PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(propertiesProvider);
persisterAggregator.persistConfig(null);
persisterAggregator.loadLastConfig();
persisterAggregator.persistConfig(null);
persisterAggregator.loadLastConfig();
- assertEquals(2, MockAdapter.persist);
- assertEquals(2, MockAdapter.load);
- assertEquals(1, MockAdapter.props);
+ assertEquals(2, DummyAdapter.persist);
+ assertEquals(2, DummyAdapter.load);
+ assertEquals(1, DummyAdapter.props);
}
-
- @Ignore
@Test
- public void testFromProperties2() throws Exception {
- String prefix = "";
- doReturn(prefix).when(propertiesProvider).getProperty(ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER);
- doReturn(FileStorageAdapter.class.getName()).when(propertiesProvider).getProperty(
- ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX);
-
- doReturn("target" + File.separator + "generated-test-sources" + File.separator + "testFile").when(
- propertiesProvider).getProperty("prefix.properties.fileStorage");
- doReturn("propertiesProvider").when(propertiesProvider).toString();
- doReturn(null).when(propertiesProvider).getProperty("prefix.properties.numberOfBackups");
-
- PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(propertiesProvider);
+ public void testLoadFromPropertyFile() throws Exception {
+ PersisterAggregator persisterAggregator = PersisterAggregator.createFromProperties(loadFile("test2.properties"));
+ List<PersisterWithConfiguration> persisters = persisterAggregator.getPersisterWithConfigurations();
+ assertEquals(1, persisters.size());
+ PersisterWithConfiguration persister = persisters.get(0);
+ assertEquals(FileStorageAdapter.class.getName() ,persister.getStorage().getClass().getName());
+ assertFalse(persister.isReadOnly());
}
- @Ignore
@Test
- public void testFromProperties3() throws Exception {
- doReturn("").when(propertiesProvider).getProperty(ConfigPersisterActivator.NETCONF_CONFIG_PERSISTER);
- doReturn(FileStorageAdapter.class.getName()).when(propertiesProvider).getProperty(
- ConfigPersisterActivator.STORAGE_ADAPTER_CLASS_PROP_SUFFIX);
- doReturn("target" + File.separator + "generated-test-sources" + File.separator + "testFile").when(
- propertiesProvider).getProperty("prefix.properties.fileStorage");
- doReturn("false").when(propertiesProvider).getProperty("readOnly");
- doReturn("propertiesProvider").when(propertiesProvider).toString();
- doReturn("0").when(propertiesProvider).getProperty("prefix.properties.numberOfBackups");
+ public void testFileStorageNumberOfBackups() throws Exception {
try {
- PersisterAggregator.createFromProperties(propertiesProvider);
+ PersisterAggregator.createFromProperties(loadFile("test3.properties"));
fail();
} catch (RuntimeException e) {
assertThat(
@Test
public void loadLastConfig() throws Exception {
- List<PersisterAggregator.PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
- PersisterAggregator.PersisterWithConfiguration first = new PersisterAggregator.PersisterWithConfiguration(mock(Persister.class), false);
+ List<PersisterWithConfiguration> persisterWithConfigurations = new ArrayList<>();
+ PersisterWithConfiguration first = new PersisterWithConfiguration(mock(Persister.class), false);
ConfigSnapshotHolder ignored = mock(ConfigSnapshotHolder.class);
- doReturn(Optional.of(ignored)).when(first.storage).loadLastConfig(); // should be ignored
+ doReturn(Optional.of(ignored)).when(first.getStorage()).loadLastConfig(); // should be ignored
ConfigSnapshotHolder used = mock(ConfigSnapshotHolder.class);
- PersisterAggregator.PersisterWithConfiguration second = new PersisterAggregator.PersisterWithConfiguration(mock(Persister.class), false);
- doReturn(Optional.of(used)).when(second.storage).loadLastConfig(); // should be used
+ PersisterWithConfiguration second = new PersisterWithConfiguration(mock(Persister.class), false);
+ doReturn(Optional.of(used)).when(second.getStorage()).loadLastConfig(); // should be used
- PersisterAggregator.PersisterWithConfiguration third = new PersisterAggregator.PersisterWithConfiguration(mock(Persister.class), false);
- doReturn(Optional.absent()).when(third.storage).loadLastConfig();
+ PersisterWithConfiguration third = new PersisterWithConfiguration(mock(Persister.class), false);
+ doReturn(Optional.absent()).when(third.getStorage()).loadLastConfig();
persisterWithConfigurations.add(first);
persisterWithConfigurations.add(second);
assertEquals(used, configSnapshotHolderOptional.get());
}
- @Ignore
- @Test
- public void test() throws Exception {
-// Persister storage = mock(Persister.class);
-// doReturn(null).when(storage).loadLastConfig();
-// doNothing().when(storage).persistConfig(any(ConfigSnapshotHolder.class));
-//
-// PersisterAggregator persister = new PersisterAggregator(storage);
-// persister.loadLastConfig();
-// persister.persistConfig(null);
-//
-// verify(storage).loadLastConfig();
-// verify(storage).persistConfig(any(ConfigSnapshotHolder.class));
- }
-
- public static class MockAdapter implements StorageAdapter, Persister {
-
- static int persist = 0;
-
- @Override
- public void persistConfig(ConfigSnapshotHolder holder) throws IOException {
- persist++;
- }
-
- static int load = 0;
-
- @Override
- public Optional<ConfigSnapshotHolder> loadLastConfig() throws IOException {
- load++;
- return Optional.absent();
- }
-
- static int props = 0;
-
- @Override
- public Persister instantiate(PropertiesProvider propertiesProvider) {
- props++;
- return this;
- }
-
- @Override
- public void close() {
- }
-
- }
-
}
--- /dev/null
+netconf.config.persister.active=1
+netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.netconf.persist.impl.DummyAdapter
+netconf.config.persister.1.properties.fileStorage=configuration/initial/
\ No newline at end of file
--- /dev/null
+netconf.config.persister.active=2
+# read startup configuration
+netconf.config.persister.1.storageAdapterClass=org.opendaylight.controller.config.persist.storage.directory.DirectoryStorageAdapter
+netconf.config.persister.1.properties.directoryStorage=configuration/initial/
+netconf.config.persister.1.readonly=true
+
+netconf.config.persister.2.storageAdapterClass=org.opendaylight.controller.config.persist.storage.file.FileStorageAdapter
+netconf.config.persister.2.properties.fileStorage=configuration/current/controller.config.2.txt
+netconf.config.persister.2.properties.numberOfBackups=3
\ No newline at end of file
--- /dev/null
+netconf.config.persister.active=3
+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.properties.numberOfBackups=0
\ No newline at end of file